@@ -1,6 +1,15 @@
|
||||
<template>
|
||||
<div class="system-settings">
|
||||
<a-page-header title="系统设置" sub-title="管理店长账号默认密码" />
|
||||
<a-card title="短信供应商" :loading="loading">
|
||||
<a-alert message="全局统一切换短信发送渠道" description="保存后会同步所有短信验证码场景的 MessageHub 模板、通道和发送方式。" show-icon type="info" />
|
||||
<a-form class="settings-form" layout="vertical">
|
||||
<a-form-item label="当前供应商">
|
||||
<a-select v-model:value="smsProviderForm.configValue" :options="smsProviderOptions" />
|
||||
</a-form-item>
|
||||
<a-button type="primary" :loading="savingSmsProvider" @click="saveSmsProvider">保存短信供应商</a-button>
|
||||
</a-form>
|
||||
</a-card>
|
||||
<a-card title="店长默认密码" :loading="loading">
|
||||
<a-alert
|
||||
message="用于新增或重置店长账号"
|
||||
@@ -28,6 +37,7 @@ import { adminSystemParameterConfigApi, type SystemParameterConfigVO } from '@/a
|
||||
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const savingSmsProvider = ref(false)
|
||||
const enabled = ref(true)
|
||||
const form = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'USER',
|
||||
@@ -37,16 +47,29 @@ const form = reactive<SystemParameterConfigVO>({
|
||||
enabled: 1,
|
||||
remark: '新增或重置店长账号时使用的默认密码'
|
||||
})
|
||||
const smsProviderOptions = [
|
||||
{ label: 'Spug 短信', value: 'SPUG' },
|
||||
{ label: '阿里云短信认证服务', value: 'ALIYUN_SMS_VERIFY' }
|
||||
]
|
||||
const smsProviderForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'SMS', configKey: 'SMS_PROVIDER', configName: '短信供应商', configValue: 'SPUG', enabled: 1,
|
||||
remark: '全局切换短信供应商时同步验证码模板和 MessageHub 通道'
|
||||
})
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const configs = await adminSystemParameterConfigApi.listConfigs('USER')
|
||||
const [configs, smsConfigs] = await Promise.all([
|
||||
adminSystemParameterConfigApi.listConfigs('USER'),
|
||||
adminSystemParameterConfigApi.listConfigs('SMS')
|
||||
])
|
||||
const config = configs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
||||
if (config) {
|
||||
Object.assign(form, config)
|
||||
enabled.value = config.enabled === 1
|
||||
}
|
||||
const smsProvider = smsConfigs.find(item => item.configKey === 'SMS_PROVIDER')
|
||||
if (smsProvider) Object.assign(smsProviderForm, smsProvider)
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '默认密码加载失败')
|
||||
} finally {
|
||||
@@ -54,6 +77,19 @@ const load = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const saveSmsProvider = async () => {
|
||||
const confirmed = window.confirm('保存后会同步全部短信验证码场景的模板、通道和发送方式,确认切换吗?')
|
||||
if (!confirmed) return
|
||||
savingSmsProvider.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({ ...smsProviderForm, configValue: smsProviderForm.configValue.toUpperCase(), enabled: 1 })
|
||||
message.success('短信供应商已切换')
|
||||
await load()
|
||||
} finally {
|
||||
savingSmsProvider.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
const password = form.configValue.trim()
|
||||
if (password.length < 8 || password.length > 32) {
|
||||
|
||||
Reference in New Issue
Block a user