重构Salon后台系统设置并整合个人账号信息

This commit is contained in:
2026-10-25 20:34:15 +08:00
parent c1b282d465
commit 76917d92ad
7 changed files with 443 additions and 529 deletions
@@ -3,75 +3,11 @@
<div class="page-head">
<div>
<h2>参数管理</h2>
<p>统一维护地图 Key、短信 MessageHub 对接参数等平台级配置,仅平台管理员可修改。</p>
<p>维护短信验证码场景的 MessageHub 模板、队列和通道配置,仅平台管理员可修改。</p>
</div>
<a-button type="primary" @click="openCreate">新增配置</a-button>
</div>
<a-card title="地图服务配置" :bordered="false">
<a-form layout="vertical">
<a-form-item label="当前地图渠道">
<a-radio-group v-model:value="mapProvider">
<a-radio-button value="TENCENT">腾讯地图</a-radio-button>
<a-radio-button value="AMAP">高德地图</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item label="腾讯 Web Key">
<a-input-password v-model:value="mapForms.tencentWeb.configValue" placeholder="用于后台腾讯地图选点和 Web 展示" />
</a-form-item>
<a-form-item label="高德 Web Key">
<a-input-password v-model:value="mapForms.amapWeb.configValue" placeholder="用于后台高德地图选点和 Web 展示" />
</a-form-item>
<a-form-item label="高德小程序 Key">
<a-input-password v-model:value="mapForms.amapMini.configValue" placeholder="用于后续小程序端高德 SDK / API 调用" />
</a-form-item>
<a-form-item label="备注">
<a-textarea v-model:value="mapRemark" :rows="2" placeholder="例如:默认使用腾讯地图,高德小程序 Key 单独申请填写" />
</a-form-item>
<a-form-item>
<a-space>
<a-switch v-model:checked="mapEnabled" checked-children="启用" un-checked-children="停用" />
<a-button type="primary" :loading="savingMap" @click="saveMapConfig">保存地图配置</a-button>
</a-space>
</a-form-item>
</a-form>
</a-card>
<a-card title="用户默认密码" :bordered="false">
<a-form layout="vertical">
<a-alert
type="info"
show-icon
message="后台新增用户时,密码留空会自动使用这里配置的默认密码。"
class="inline-alert"
/>
<a-form-item label="后台新增用户默认密码">
<a-input-password
v-model:value="defaultPasswordForm.configValue"
placeholder="请输入 8-32 位强密码"
autocomplete="new-password"
/>
</a-form-item>
<a-form-item label="备注">
<a-textarea v-model:value="defaultPasswordForm.remark" :rows="2" />
</a-form-item>
<a-form-item>
<a-space>
<a-switch v-model:checked="defaultPasswordEnabled" checked-children="启用" un-checked-children="停用" />
<a-button type="primary" :loading="savingDefaultPassword" @click="saveDefaultPasswordConfig">
保存默认密码
</a-button>
</a-space>
</a-form-item>
</a-form>
</a-card>
<a-alert
type="info"
show-icon
message="这里不配置 Spug、阿里云等供应商密钥;真实短信通道仍在 MessageHub 中独立管理。"
/>
<a-table :columns="columns" :data-source="configs" :loading="loading" row-key="id" :scroll="{ x: 'max-content' }">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'scene'">
@@ -150,9 +86,7 @@ import { message } from 'ant-design-vue'
*/
import {
adminMessageHubPushConfigApi,
adminSystemParameterConfigApi,
type MessageHubPushConfigVO,
type SystemParameterConfigVO
type MessageHubPushConfigVO
} from '@/api/admin'
/** loading is a reactive state variable used by the template and event handlers. */
@@ -182,59 +116,6 @@ const testPhone = ref('')
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const configs = ref<MessageHubPushConfigVO[]>([])
/**
* Purpose: savingMap supports MessageHubPushConfigsView.vue by holding or executing the saving map page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const savingMap = ref(false)
const savingDefaultPassword = ref(false)
/**
* Purpose: mapEnabled supports MessageHubPushConfigsView.vue by holding or executing the map enabled page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const mapEnabled = ref(true)
const defaultPasswordEnabled = ref(true)
/**
* Purpose: mapProvider supports MessageHubPushConfigsView.vue by holding or executing the map provider page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const mapProvider = ref<'TENCENT' | 'AMAP'>('TENCENT')
/**
* Purpose: mapRemark supports MessageHubPushConfigsView.vue by holding or executing the map remark page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const mapRemark = ref('地图渠道由平台管理员选择;高德 Web Key 与高德小程序 Key 分开填写。')
/**
* Purpose: createMapForm supports MessageHubPushConfigsView.vue by holding or executing the create map form page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const createMapForm = (configKey: string, configName: string, remark: string) => ({
configGroup: 'MAP',
configKey,
configName,
configValue: '',
enabled: 1,
remark
})
/**
* Purpose: mapForms supports MessageHubPushConfigsView.vue by holding or executing the map forms page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const mapForms = reactive({
provider: createMapForm('MAP_PROVIDER', '当前地图渠道', 'TENCENT 或 AMAP;决定后台店铺选点默认使用哪个地图渠道'),
tencentWeb: createMapForm('TENCENT_MAP_KEY', '腾讯 Web Key', '用于后台腾讯地图选点和 Web 展示'),
amapWeb: createMapForm('AMAP_WEB_KEY', '高德 Web Key', '用于后台高德地图选点和 Web 展示'),
amapMini: createMapForm('AMAP_MINI_KEY', '高德小程序 Key', '用于后续小程序端高德 SDK / API 调用')
})
const defaultPasswordForm = reactive<SystemParameterConfigVO>({
configGroup: 'USER',
configKey: 'DEFAULT_PASSWORD',
configName: '后台新增用户默认密码',
configValue: 'Fingertip@123',
enabled: 1,
remark: '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类'
})
/**
* Purpose: sceneOptions supports MessageHubPushConfigsView.vue by holding or executing the scene options page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -292,102 +173,12 @@ const columns = [
const load = async () => {
loading.value = true
try {
const [messageConfigs, mapConfigs, userConfigs] = await Promise.all([
adminMessageHubPushConfigApi.listConfigs(),
adminSystemParameterConfigApi.listConfigs('MAP'),
adminSystemParameterConfigApi.listConfigs('USER')
])
configs.value = messageConfigs
const providerConfig = mapConfigs.find(item => item.configKey === 'MAP_PROVIDER')
const tencentMapConfig = mapConfigs.find(item => item.configKey === 'TENCENT_MAP_KEY')
const amapWebConfig = mapConfigs.find(item => item.configKey === 'AMAP_WEB_KEY')
const amapMiniConfig = mapConfigs.find(item => item.configKey === 'AMAP_MINI_KEY')
if (providerConfig?.configValue) {
mapProvider.value = providerConfig.configValue === 'AMAP' ? 'AMAP' : 'TENCENT'
mapEnabled.value = providerConfig.enabled === 1
Object.assign(mapForms.provider, providerConfig)
}
if (tencentMapConfig) Object.assign(mapForms.tencentWeb, tencentMapConfig)
if (amapWebConfig) Object.assign(mapForms.amapWeb, amapWebConfig)
if (amapMiniConfig) Object.assign(mapForms.amapMini, amapMiniConfig)
const defaultPasswordConfig = userConfigs.find(item => item.configKey === 'DEFAULT_PASSWORD')
if (defaultPasswordConfig) {
Object.assign(defaultPasswordForm, defaultPasswordConfig)
defaultPasswordEnabled.value = defaultPasswordConfig.enabled === 1
}
configs.value = await adminMessageHubPushConfigApi.listConfigs()
} finally {
loading.value = false
}
}
/**
* Purpose: saveMapConfig supports MessageHubPushConfigsView.vue by holding or executing the save map config page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const saveMapConfig = async () => {
savingMap.value = true
try {
await adminSystemParameterConfigApi.saveConfig({
...mapForms.provider,
configValue: mapProvider.value,
enabled: mapEnabled.value ? 1 : 0
})
await adminSystemParameterConfigApi.saveConfig({
...mapForms.tencentWeb,
enabled: mapEnabled.value ? 1 : 0
})
await adminSystemParameterConfigApi.saveConfig({
...mapForms.amapWeb,
enabled: mapEnabled.value ? 1 : 0
})
await adminSystemParameterConfigApi.saveConfig({
...mapForms.amapMini,
enabled: mapEnabled.value ? 1 : 0
})
message.success('地图配置已保存')
await load()
} finally {
savingMap.value = false
}
}
const validateDefaultPasswordInput = () => {
const password = defaultPasswordForm.configValue.trim()
if (password.length < 8 || password.length > 32) {
message.warning('默认密码长度需为 8-32 位')
return false
}
const categoryCount = [
/\d/.test(password),
/[a-z]/.test(password),
/[A-Z]/.test(password),
/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password)
].filter(Boolean).length
if (categoryCount < 3) {
message.warning('默认密码需至少包含数字、小写字母、大写字母、特殊符号中的 3 类')
return false
}
return true
}
const saveDefaultPasswordConfig = async () => {
if (!validateDefaultPasswordInput()) {
return
}
savingDefaultPassword.value = true
try {
await adminSystemParameterConfigApi.saveConfig({
...defaultPasswordForm,
configValue: defaultPasswordForm.configValue.trim(),
enabled: defaultPasswordEnabled.value ? 1 : 0
})
message.success('默认密码已保存')
await load()
} finally {
savingDefaultPassword.value = false
}
}
/** resetForm is a local helper used by this page script. */
const resetForm = () => Object.assign(form, {
sceneCode: 'USER_LOGIN_SMS_CODE',