增加系统接入诊断基础能力
This commit is contained in:
@@ -36,6 +36,27 @@
|
||||
<span />
|
||||
</div>
|
||||
|
||||
<div class="setting-group probe-group">
|
||||
<div class="setting-group__head"><strong>接入诊断</strong><span>TEST</span></div>
|
||||
<div class="probe-list">
|
||||
<div v-for="card in probeCards" :key="card.service" class="probe-row">
|
||||
<div class="probe-row__copy">
|
||||
<strong>{{ card.label }}</strong>
|
||||
<span>{{ card.description }}</span>
|
||||
<small v-if="probeFor(card.service)">最近:{{ probeFor(card.service)?.summary }} · {{ formatProbeTime(probeFor(card.service)?.checkedAt) }}</small>
|
||||
</div>
|
||||
<div class="probe-row__actions">
|
||||
<a-button size="small" :loading="testingProbe === `${card.service}:${card.operation}`" @click="runProbe(card.service, card.operation)">{{ card.action }}</a-button>
|
||||
<a-button v-if="card.service === 'CONTENT_MODERATION'" size="small" type="link" :loading="testingProbe === 'CONTENT_MODERATION:IMAGE_CALLBACK'" @click="runProbe('CONTENT_MODERATION', 'IMAGE_CALLBACK')">图片回调</a-button>
|
||||
<a-button v-if="card.service === 'SMS' || card.service === 'SUBSCRIBE_MESSAGE'" size="small" type="link" @click="openRealProbe(card.service)">真实发送</a-button>
|
||||
</div>
|
||||
<span v-if="probeFor(card.service)" :class="['status-pill', `probe-status--${probeFor(card.service)?.status.toLowerCase()}`]">{{ probeStatusLabel(probeFor(card.service)?.status) }}</span>
|
||||
<span v-else class="status-pill is-muted">未测试</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="secure-note">配置保存后再测试。短信和订阅消息默认只诊断,真实发送会产生外部副作用并要求二次确认;对象存储测试文件会自动清理。</p>
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>账号默认值</strong><span>USER</span><a-button size="small" type="primary" :loading="savingDefaultPassword" @click="saveDefaultPassword">保存密码设置</a-button></div>
|
||||
<div class="setting-row setting-row--last">
|
||||
@@ -257,6 +278,17 @@
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<a-modal v-model:open="realProbeOpen" title="确认真实接入测试" :confirm-loading="realProbeLoading" ok-text="确认发送" cancel-text="取消" @ok="submitRealProbe">
|
||||
<template v-if="realProbeService === 'SMS'">
|
||||
<p>将向指定手机号发送一条真实测试短信,可能产生费用。</p>
|
||||
<a-input v-model:value="realProbePhone" placeholder="请输入接收手机号" maxlength="11" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<p>将向当前环境已有微信绑定账号发送一条真实订阅消息,可能消耗订阅额度。</p>
|
||||
<a-checkbox v-model:checked="realProbeConfirmed">我确认发送真实测试消息</a-checkbox>
|
||||
</template>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -265,7 +297,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ApiOutlined, ArrowDownOutlined, ArrowUpOutlined, CopyOutlined, ExportOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
import { adminSecureIntegrationConfigApi, adminSystemParameterConfigApi, type SecureIntegrationConfigVO, type SystemParameterConfigVO } from '@/api/admin'
|
||||
import { adminSecureIntegrationConfigApi, adminSystemParameterConfigApi, type IntegrationProbeResultVO, type SecureIntegrationConfigVO, type SystemParameterConfigVO } from '@/api/admin'
|
||||
import { ADMIN_API_BASE_URL } from '@/config/api'
|
||||
import { loadCachedAdminUserInfo } from '@/utils/admin-session'
|
||||
|
||||
@@ -275,6 +307,13 @@ type MapKey = 'tencentWeb' | 'amapWeb' | 'amapMini'
|
||||
const route = useRoute()
|
||||
const activeSection = ref<SettingsSection>(route.query.section === 'account' ? 'account' : 'runtime')
|
||||
const loading = ref(false)
|
||||
const testingProbe = ref('')
|
||||
const probeResults = ref<IntegrationProbeResultVO[]>([])
|
||||
const realProbeOpen = ref(false)
|
||||
const realProbeLoading = ref(false)
|
||||
const realProbeService = ref<'SMS' | 'SUBSCRIBE_MESSAGE'>('SMS')
|
||||
const realProbePhone = ref('')
|
||||
const realProbeConfirmed = ref(false)
|
||||
const savingDefaultPassword = ref(false)
|
||||
const savingReviewNotice = ref(false)
|
||||
const savingManagerReviewMode = ref(false)
|
||||
@@ -342,6 +381,13 @@ const sections = [
|
||||
{ key: 'services' as const, label: '服务接入', icon: ApiOutlined },
|
||||
{ key: 'account' as const, label: '当前账号', icon: UserOutlined }
|
||||
]
|
||||
const probeCards = [
|
||||
{ service: 'CONTENT_MODERATION', label: '微信内容审核', description: '先诊断配置,再调用无害文本;图片测试会等待微信回调。', operation: 'TEXT', action: '文本探测' },
|
||||
{ service: 'MAP', label: '地图服务', description: '调用当前渠道固定地址,验证 Web Key 是否真正可用。', operation: 'REQUEST', action: '测试请求' },
|
||||
{ service: 'OBJECT_STORAGE', label: '对象存储三副本', description: '临时上传、读取、签名访问并自动清理。', operation: 'ROUND_TRIP', action: '往返测试' },
|
||||
{ service: 'SMS', label: '短信服务', description: '默认只检查六个验证码场景和 MessageHub 配置。', operation: 'CONFIG', action: '配置诊断' },
|
||||
{ service: 'SUBSCRIBE_MESSAGE', label: '微信订阅消息', description: '默认检查凭据和固定模板,不发送真实消息。', operation: 'CONFIG', action: '配置诊断' }
|
||||
]
|
||||
const mapKeyRows: Array<{ key: MapKey; label: string; description: string; placeholder: string; url: string }> = [
|
||||
{ key: 'tencentWeb', label: '腾讯 Web Key', description: '用于后台腾讯地图选点。', placeholder: '填写腾讯 Web Key;留空保持原值', url: 'https://lbs.qq.com/dev/console/key/manage' },
|
||||
{ key: 'amapWeb', label: '高德 Web Key', description: '用于后台高德地图选点。', placeholder: '填写高德 Web Key;留空保持原值', url: 'https://console.amap.com/dev/key/app' },
|
||||
@@ -406,13 +452,14 @@ const confirmSecureKeyChanges = (title: string, changes: string[]) => new Promis
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const [userConfigs, smsConfigs, workbenchConfigs, shopConfigs, fileConfigs, secureConfig] = await Promise.all([
|
||||
const [userConfigs, smsConfigs, workbenchConfigs, shopConfigs, fileConfigs, secureConfig, latestProbeResults] = await Promise.all([
|
||||
adminSystemParameterConfigApi.listConfigs('USER'),
|
||||
adminSystemParameterConfigApi.listConfigs('SMS'),
|
||||
adminSystemParameterConfigApi.listConfigs('WORKBENCH'),
|
||||
adminSystemParameterConfigApi.listConfigs('SHOP'),
|
||||
adminSystemParameterConfigApi.listConfigs('FILE'),
|
||||
adminSecureIntegrationConfigApi.getConfig()
|
||||
adminSecureIntegrationConfigApi.getConfig(),
|
||||
adminSecureIntegrationConfigApi.listProbeResults()
|
||||
])
|
||||
const defaultPassword = userConfigs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
||||
if (defaultPassword) {
|
||||
@@ -448,6 +495,7 @@ const load = async () => {
|
||||
}
|
||||
}
|
||||
secureStatus.value = secureConfig
|
||||
probeResults.value = latestProbeResults || []
|
||||
mapProvider.value = secureConfig.mapProvider === 'AMAP' ? 'AMAP' : 'TENCENT'
|
||||
mapEnabled.value = Boolean(secureConfig.mapEnabled)
|
||||
moderationProvider.value = secureConfig.moderationProvider || 'DISABLED'
|
||||
@@ -465,6 +513,44 @@ const load = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const probeFor = (service: string) => probeResults.value.filter(item => item.service === service).sort((a, b) => String(b.checkedAt || '').localeCompare(String(a.checkedAt || '')))[0]
|
||||
const formatProbeTime = (time?: string) => time ? new Date(time).toLocaleString('zh-CN', { hour12: false }) : '暂无时间'
|
||||
const probeStatusLabel = (status?: string) => ({ PASS: '通过', WARN: '需关注', FAIL: '失败', PENDING: '等待回调' } as Record<string, string>)[status || ''] || '未知'
|
||||
const runProbe = async (service: string, operation: string) => {
|
||||
const key = `${service}:${operation}`
|
||||
testingProbe.value = key
|
||||
try {
|
||||
const result = await adminSecureIntegrationConfigApi.probe({ service, operation, mode: 'DIAGNOSTIC' })
|
||||
probeResults.value = [...probeResults.value.filter(item => !(item.service === result.service && item.operation === result.operation)), result]
|
||||
message[result.status === 'PASS' ? 'success' : result.status === 'WARN' ? 'warning' : 'error'](result.summary)
|
||||
} catch (error) { message.error(error instanceof Error ? error.message : '接入测试失败') }
|
||||
finally { testingProbe.value = '' }
|
||||
}
|
||||
const openRealProbe = (service: 'SMS' | 'SUBSCRIBE_MESSAGE') => {
|
||||
realProbeService.value = service
|
||||
realProbePhone.value = ''
|
||||
realProbeConfirmed.value = false
|
||||
realProbeOpen.value = true
|
||||
}
|
||||
const submitRealProbe = async () => {
|
||||
if (realProbeService.value === 'SMS' && !/^1[3-9]\d{9}$/.test(realProbePhone.value.trim())) { message.warning('请输入有效的接收手机号'); return }
|
||||
if (realProbeService.value === 'SUBSCRIBE_MESSAGE' && !realProbeConfirmed.value) { message.warning('请确认发送真实订阅消息'); return }
|
||||
realProbeLoading.value = true
|
||||
try {
|
||||
const result = await adminSecureIntegrationConfigApi.probe({
|
||||
service: realProbeService.value,
|
||||
operation: 'SEND',
|
||||
mode: 'REAL',
|
||||
targetPhone: realProbeService.value === 'SMS' ? realProbePhone.value.trim() : undefined,
|
||||
confirmed: true
|
||||
})
|
||||
probeResults.value = [...probeResults.value.filter(item => !(item.service === result.service && item.operation === result.operation)), result]
|
||||
message[result.status === 'PASS' ? 'success' : result.status === 'WARN' ? 'warning' : 'error'](result.summary)
|
||||
realProbeOpen.value = false
|
||||
} catch (error) { message.error(error instanceof Error ? error.message : '真实接入测试失败') }
|
||||
finally { realProbeLoading.value = false }
|
||||
}
|
||||
|
||||
const validateDefaultPassword = () => {
|
||||
const password = defaultPasswordForm.configValue.trim()
|
||||
if (password.length < 8 || password.length > 32) {
|
||||
|
||||
Reference in New Issue
Block a user