增加后台默认密码管理入口
This commit is contained in:
@@ -26,6 +26,7 @@ export const adminNavigationItems: AdminNavigationItem[] = [
|
|||||||
{ path: ADMIN_HOME_PATH, iconKey: 'home', label: '首页', permissionCode: '' },
|
{ path: ADMIN_HOME_PATH, iconKey: 'home', label: '首页', permissionCode: '' },
|
||||||
{ path: '/admin/users', iconKey: 'user', label: '店长账号', permissionCode: 'user:view' },
|
{ path: '/admin/users', iconKey: 'user', label: '店长账号', permissionCode: 'user:view' },
|
||||||
{ path: '/admin/shops', iconKey: 'home', label: '店铺管理', permissionCode: 'shop:view' },
|
{ path: '/admin/shops', iconKey: 'home', label: '店铺管理', permissionCode: 'shop:view' },
|
||||||
|
{ path: '/admin/settings', iconKey: 'tool', label: '系统设置', permissionCode: 'messagehub:config:manage' },
|
||||||
{ path: '/admin/profile', iconKey: 'user', label: '个人设置', permissionCode: '' }
|
{ path: '/admin/profile', iconKey: 'user', label: '个人设置', permissionCode: '' }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
const pageNames = [
|
const pageNames = [
|
||||||
['', 'HomeView', 'admin', undefined],
|
['', 'HomeView', 'admin', undefined],
|
||||||
['users', 'UsersView', 'admin-users', 'user:view'], ['shops', 'ShopsView', 'admin-shops', 'shop:view'],
|
['users', 'UsersView', 'admin-users', 'user:view'], ['shops', 'ShopsView', 'admin-shops', 'shop:view'],
|
||||||
['profile', 'ProfileView', 'admin-profile', undefined]
|
['profile', 'ProfileView', 'admin-profile', undefined], ['settings', 'SystemSettingsView', 'admin-settings', 'messagehub:config:manage']
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<template>
|
||||||
|
<div class="system-settings">
|
||||||
|
<a-page-header title="系统设置" sub-title="管理店长账号默认密码" />
|
||||||
|
<a-card title="店长默认密码" :loading="loading">
|
||||||
|
<a-alert
|
||||||
|
message="用于新增或重置店长账号"
|
||||||
|
description="店长未设置密码时,以及管理员执行重置密码时,系统会使用这里配置的默认密码。修改后只对后续新增或重置生效。"
|
||||||
|
show-icon
|
||||||
|
type="info"
|
||||||
|
/>
|
||||||
|
<a-form class="settings-form" layout="vertical" @submit.prevent="save">
|
||||||
|
<a-form-item label="默认密码">
|
||||||
|
<a-input-password v-model:value="form.configValue" autocomplete="new-password" placeholder="请输入默认密码" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="状态">
|
||||||
|
<a-switch v-model:checked="enabled" checked-children="启用" un-checked-children="停用" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-button type="primary" :loading="saving" @click="save">保存默认密码</a-button>
|
||||||
|
</a-form>
|
||||||
|
</a-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { adminSystemParameterConfigApi, type SystemParameterConfigVO } from '@/api/admin'
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const saving = ref(false)
|
||||||
|
const enabled = ref(true)
|
||||||
|
const form = reactive<SystemParameterConfigVO>({
|
||||||
|
configGroup: 'USER',
|
||||||
|
configKey: 'DEFAULT_PASSWORD',
|
||||||
|
configName: '店长默认密码',
|
||||||
|
configValue: 'Fingertip@123',
|
||||||
|
enabled: 1,
|
||||||
|
remark: '新增或重置店长账号时使用的默认密码'
|
||||||
|
})
|
||||||
|
|
||||||
|
const load = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const configs = await adminSystemParameterConfigApi.listConfigs('USER')
|
||||||
|
const config = configs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
||||||
|
if (config) {
|
||||||
|
Object.assign(form, config)
|
||||||
|
enabled.value = config.enabled === 1
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error instanceof Error ? error.message : '默认密码加载失败')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const save = async () => {
|
||||||
|
const password = form.configValue.trim()
|
||||||
|
if (password.length < 8 || password.length > 32) {
|
||||||
|
message.warning('默认密码长度需为 8-32 位')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const categoryCount = [/[0-9]/.test(password), /[a-z]/.test(password), /[A-Z]/.test(password), /[^A-Za-z0-9]/.test(password)].filter(Boolean).length
|
||||||
|
if (categoryCount < 3) {
|
||||||
|
message.warning('默认密码需至少包含数字、小写字母、大写字母、特殊符号中的 3 类')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
saving.value = true
|
||||||
|
try {
|
||||||
|
await adminSystemParameterConfigApi.saveConfig({ ...form, configValue: password, enabled: enabled.value ? 1 : 0 })
|
||||||
|
message.success('默认密码已保存')
|
||||||
|
await load()
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error instanceof Error ? error.message : '默认密码保存失败')
|
||||||
|
} finally {
|
||||||
|
saving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void load()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.system-settings {
|
||||||
|
display: grid;
|
||||||
|
gap: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-form {
|
||||||
|
max-width: 560px;
|
||||||
|
margin-top: 24px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user