完善系统设置密钥保护确认
This commit is contained in:
@@ -108,7 +108,7 @@
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>地图服务</strong><span>安全接入</span><a-button size="small" type="primary" :loading="savingMap" @click="saveMapConfig">保存地图设置</a-button></div>
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>地图服务</strong><span>安全接入</span><a-button size="small" type="primary" :loading="savingMap || confirmingMap" @click="saveMapConfig">保存地图设置</a-button></div>
|
||||
<div class="setting-row">
|
||||
<div class="setting-copy"><strong>默认地图渠道</strong><span>店铺选点和后台地图展示使用的默认渠道。</span></div>
|
||||
<div class="setting-control"><a-select v-model:value="mapProvider" :options="mapProviderOptions" /></div>
|
||||
@@ -132,8 +132,8 @@
|
||||
<span>{{ item.description }}</span>
|
||||
</div>
|
||||
<div class="setting-control setting-control--password">
|
||||
<a-input-password v-model:value="mapSecrets[item.key]" :placeholder="item.placeholder" autocomplete="new-password" />
|
||||
<a-button v-if="mapConfigured(item.key)" size="small" type="text" danger @click="toggleMapSecretClear(item.key)">{{ clearMapSecrets[item.key] ? '撤销清除' : '清除' }}</a-button>
|
||||
<a-input-password v-model:value="mapSecrets[item.key]" :placeholder="mapKeyPlaceholder(item.key, item.placeholder)" autocomplete="new-password" @update:value="clearMapSecrets[item.key] = false" />
|
||||
<a-button v-if="mapKeyStoredConfigured(item.key)" size="small" type="text" danger @click="toggleMapSecretClear(item.key)">{{ clearMapSecrets[item.key] ? '撤销清除' : '清除' }}</a-button>
|
||||
</div>
|
||||
<span class="status-pill" :class="{ 'is-muted': !mapConfigured(item.key) || clearMapSecrets[item.key] }">{{ clearMapSecrets[item.key] ? '保存后清除' : mapConfigured(item.key) ? '已配置' : '待配置' }}</span>
|
||||
</div>
|
||||
@@ -146,7 +146,7 @@
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>微信内容审核</strong><span>安全回调</span><a-button size="small" type="primary" :loading="savingModeration" @click="saveModerationConfig">保存审核设置</a-button></div>
|
||||
<div class="setting-group__head setting-group__head--with-action"><strong>微信内容审核</strong><span>安全回调</span><a-button size="small" type="primary" :loading="savingModeration || confirmingModeration" @click="saveModerationConfig">保存审核设置</a-button></div>
|
||||
<div class="setting-row">
|
||||
<div class="setting-copy"><strong>审核渠道</strong><span>未启用或配置不完整时,内容保持隔离,不会自动放行。</span></div>
|
||||
<div class="setting-control"><a-select v-model:value="moderationProvider" :options="moderationProviderOptions" /></div>
|
||||
@@ -168,7 +168,7 @@
|
||||
<div class="setting-row">
|
||||
<div class="setting-copy"><strong>回调 Token</strong><span>3-32 位英文字母或数字;留空表示不修改已保存值。</span></div>
|
||||
<div class="setting-control setting-control--password">
|
||||
<a-input-password v-model:value="moderationSecrets.callbackToken" autocomplete="new-password" :placeholder="secureStatus?.moderationCallbackTokenConfigured && !clearModerationSecrets.callbackToken ? '••••••••' : '填写新的 Token,留空保持原值'" />
|
||||
<a-input-password v-model:value="moderationSecrets.callbackToken" autocomplete="new-password" :placeholder="secureStatus?.moderationCallbackTokenConfigured && !clearModerationSecrets.callbackToken ? '••••••••' : '填写新的 Token,留空保持原值'" @update:value="clearModerationSecrets.callbackToken = false" />
|
||||
<a-button v-if="secureStatus?.moderationCallbackTokenConfigured" size="small" type="text" danger @click="toggleModerationSecretClear('callbackToken')">{{ clearModerationSecrets.callbackToken ? '撤销清除' : '清除' }}</a-button>
|
||||
</div>
|
||||
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationCallbackTokenConfigured || clearModerationSecrets.callbackToken }">{{ clearModerationSecrets.callbackToken ? '保存后清除' : secureStatus?.moderationCallbackTokenConfigured ? '已配置' : '待配置' }}</span>
|
||||
@@ -176,7 +176,7 @@
|
||||
<div class="setting-row setting-row--last">
|
||||
<div class="setting-copy"><strong>EncodingAESKey</strong><span>微信平台生成的 43 位密钥;消息加密方式必须选择「安全模式」。</span></div>
|
||||
<div class="setting-control setting-control--password">
|
||||
<a-input-password v-model:value="moderationSecrets.encodingAesKey" autocomplete="new-password" :placeholder="secureStatus?.moderationEncodingAesKeyConfigured && !clearModerationSecrets.encodingAesKey ? '••••••••' : '填写 43 位 EncodingAESKey,留空保持原值'" />
|
||||
<a-input-password v-model:value="moderationSecrets.encodingAesKey" autocomplete="new-password" :placeholder="secureStatus?.moderationEncodingAesKeyConfigured && !clearModerationSecrets.encodingAesKey ? '••••••••' : '填写 43 位 EncodingAESKey,留空保持原值'" @update:value="clearModerationSecrets.encodingAesKey = false" />
|
||||
<a-button v-if="secureStatus?.moderationEncodingAesKeyConfigured" size="small" type="text" danger @click="toggleModerationSecretClear('encodingAesKey')">{{ clearModerationSecrets.encodingAesKey ? '撤销清除' : '清除' }}</a-button>
|
||||
</div>
|
||||
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationEncodingAesKeyConfigured || clearModerationSecrets.encodingAesKey }">{{ clearModerationSecrets.encodingAesKey ? '保存后清除' : secureStatus?.moderationEncodingAesKeyConfigured ? '已配置' : '待配置' }}</span>
|
||||
@@ -245,7 +245,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ApiOutlined, CopyOutlined, ExportOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
import { adminSecureIntegrationConfigApi, adminSystemParameterConfigApi, type SecureIntegrationConfigVO, type SystemParameterConfigVO } from '@/api/admin'
|
||||
import { ADMIN_API_BASE_URL } from '@/config/api'
|
||||
@@ -263,6 +263,8 @@ const savingManagerReviewMode = ref(false)
|
||||
const savingShopValidity = ref(false)
|
||||
const savingMap = ref(false)
|
||||
const savingModeration = ref(false)
|
||||
const confirmingMap = ref(false)
|
||||
const confirmingModeration = ref(false)
|
||||
const savingSmsProvider = ref(false)
|
||||
const defaultPasswordEnabled = ref(true)
|
||||
const reviewNoticeEnabled = ref(true)
|
||||
@@ -356,11 +358,26 @@ const defaultCallbackUrl = () => {
|
||||
const mapConfigured = (key: MapKey) => {
|
||||
if (clearMapSecrets[key]) return false
|
||||
if (mapSecrets[key]) return true
|
||||
return mapKeyStoredConfigured(key)
|
||||
}
|
||||
const mapKeyStoredConfigured = (key: MapKey) => {
|
||||
if (!secureStatus.value) return false
|
||||
return key === 'tencentWeb' ? secureStatus.value.tencentWebKeyConfigured
|
||||
: key === 'amapWeb' ? secureStatus.value.amapWebKeyConfigured
|
||||
: secureStatus.value.amapMiniKeyConfigured
|
||||
}
|
||||
const mapKeyPlaceholder = (key: MapKey, fallback: string) =>
|
||||
mapKeyStoredConfigured(key) && !clearMapSecrets[key] ? '••••••••' : fallback
|
||||
const confirmSecureKeyChanges = (title: string, changes: string[]) => new Promise<boolean>(resolve => {
|
||||
Modal.confirm({
|
||||
title,
|
||||
content: `${changes.join(';')}。确认后将立即应用到当前环境。`,
|
||||
okText: '确认保存',
|
||||
cancelText: '取消',
|
||||
onOk: () => resolve(true),
|
||||
onCancel: () => resolve(false)
|
||||
})
|
||||
})
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
@@ -490,6 +507,21 @@ const saveMapConfig = async () => {
|
||||
message.warning('当前默认渠道的 Key 已标记清除,请同时停用地图服务后再保存')
|
||||
return
|
||||
}
|
||||
const secretChanges = mapKeyRows.flatMap(item => {
|
||||
if (clearMapSecrets[item.key]) return [`${item.label}将被清除`]
|
||||
if (!mapSecrets[item.key].trim()) return []
|
||||
return [`${item.label}将${mapKeyStoredConfigured(item.key) ? '替换当前配置' : '保存新配置'}`]
|
||||
})
|
||||
if (secretChanges.length) {
|
||||
confirmingMap.value = true
|
||||
let confirmed = false
|
||||
try {
|
||||
confirmed = await confirmSecureKeyChanges('确认保存地图 Key', secretChanges)
|
||||
} finally {
|
||||
confirmingMap.value = false
|
||||
}
|
||||
if (!confirmed) return
|
||||
}
|
||||
savingMap.value = true
|
||||
try {
|
||||
const result = await adminSecureIntegrationConfigApi.saveMapConfig({
|
||||
@@ -534,6 +566,20 @@ const saveModerationConfig = async () => {
|
||||
message.warning('EncodingAESKey 需要为 43 位字符')
|
||||
return
|
||||
}
|
||||
const moderationSecretChanges = [
|
||||
clearModerationSecrets.callbackToken ? '回调 Token 将被清除' : moderationSecrets.callbackToken.trim() ? `回调 Token 将${secureStatus.value?.moderationCallbackTokenConfigured ? '替换当前配置' : '保存新配置'}` : '',
|
||||
clearModerationSecrets.encodingAesKey ? 'EncodingAESKey 将被清除' : moderationSecrets.encodingAesKey.trim() ? `EncodingAESKey 将${secureStatus.value?.moderationEncodingAesKeyConfigured ? '替换当前配置' : '保存新配置'}` : ''
|
||||
].filter(Boolean)
|
||||
if (moderationSecretChanges.length) {
|
||||
confirmingModeration.value = true
|
||||
let confirmed = false
|
||||
try {
|
||||
confirmed = await confirmSecureKeyChanges('确认保存微信审核密钥', moderationSecretChanges)
|
||||
} finally {
|
||||
confirmingModeration.value = false
|
||||
}
|
||||
if (!confirmed) return
|
||||
}
|
||||
savingModeration.value = true
|
||||
try {
|
||||
secureStatus.value = await adminSecureIntegrationConfigApi.saveModerationConfig({
|
||||
|
||||
Reference in New Issue
Block a user