diff --git a/mini-program/src/pages/login/index.vue b/mini-program/src/pages/login/index.vue index 7827fef..ddd7baf 100644 --- a/mini-program/src/pages/login/index.vue +++ b/mini-program/src/pages/login/index.vue @@ -30,13 +30,13 @@ 微信一键登录 - + 或使用手机号登录 - + 手机号码 import { ref, computed, onMounted } from 'vue' import { useAppStore } from '../../stores/app.js' -import { getSmsCode } from '../../services/auth.js' +import { getSmsCode, getLoginConfig } from '../../services/auth.js' const store = useAppStore() @@ -100,11 +101,21 @@ const statusBarHeight = ref(uni.getStorageSync('statusBarHeight') || 20) const safeAreaTop = ref(uni.getStorageSync('safeAreaTop') || 20) const safeAreaBottom = ref(uni.getStorageSync('safeAreaBottom') || 0) -onMounted(() => { +onMounted(async () => { const windowInfo = uni.getWindowInfo() statusBarHeight.value = windowInfo.statusBarHeight || 20 safeAreaTop.value = windowInfo.safeAreaInsets?.top || windowInfo.statusBarHeight || 20 safeAreaBottom.value = windowInfo.safeAreaInsets?.bottom || 0 + + try { + const res = await getLoginConfig() + if (res.data) { + loginConfig.value = res.data + } + } catch (e) { + // 接口失败时默认只显示微信登录 + loginConfig.value = { wechatLoginEnabled: true, smsLoginEnabled: false } + } }) const phone = ref('') @@ -114,6 +125,8 @@ const activeMethod = ref('') const countdown = ref(60) const isCountingDown = ref(false) +const loginConfig = ref({ wechatLoginEnabled: true, smsLoginEnabled: false }) + const canSubmit = computed(() => { return phone.value.length === 11 && code.value.length === 6 }) diff --git a/mini-program/src/services/auth.js b/mini-program/src/services/auth.js index b015fa6..d65e641 100644 --- a/mini-program/src/services/auth.js +++ b/mini-program/src/services/auth.js @@ -16,6 +16,15 @@ export const getSmsCode = async (phone) => { return response } +/** + * 获取登录方式配置 + * @returns {Promise} 登录方式配置 + */ +export const getLoginConfig = async () => { + const response = await get('/auth/loginConfig') + return response +} + /** * 用户登录(手机号 + 验证码) * @param {Object} params - 登录参数 @@ -134,6 +143,7 @@ export const checkPhone = async (phone) => { } export default { + getLoginConfig, getSmsCode, login, wechatLogin, diff --git a/web-admin/src/api/systemConfig.ts b/web-admin/src/api/systemConfig.ts new file mode 100644 index 0000000..3df737a --- /dev/null +++ b/web-admin/src/api/systemConfig.ts @@ -0,0 +1,18 @@ +import request from '@/utils/request' + +// 获取所有可见配置列表 +export function getSystemConfigList() { + return request({ + url: '/admin/systemConfig/list', + method: 'get' + }) +} + +// 批量更新配置 +export function updateSystemConfig(data: { configKey: string; configValue: string }[]) { + return request({ + url: '/admin/systemConfig/update', + method: 'put', + data + }) +} \ No newline at end of file diff --git a/web-admin/src/config/menu.ts b/web-admin/src/config/menu.ts index dbfadc9..2cdd014 100644 --- a/web-admin/src/config/menu.ts +++ b/web-admin/src/config/menu.ts @@ -27,6 +27,11 @@ export const menuConfig: MenuItem[] = [ title: '用户管理', icon: 'UserFilled' }, + { + path: '/system', + title: '系统设置', + icon: 'Setting' + }, { path: '/aiconfig', title: 'AI配置管理', diff --git a/web-admin/src/router/index.ts b/web-admin/src/router/index.ts index 1eed311..2a008b9 100644 --- a/web-admin/src/router/index.ts +++ b/web-admin/src/router/index.ts @@ -55,6 +55,20 @@ const routes: RouteRecordRaw[] = [ } ] }, + { + path: '/system', + component: Layout, + redirect: '/system/settings', + meta: { title: '系统设置', icon: 'Setting' }, + children: [ + { + path: 'settings', + name: 'SystemSettings', + component: () => import('@/views/system/SystemSettings.vue'), + meta: { title: '基础设置' } + } + ] + }, { path: '/aiconfig', component: Layout, diff --git a/web-admin/src/views/system/SystemSettings.vue b/web-admin/src/views/system/SystemSettings.vue new file mode 100644 index 0000000..7af34eb --- /dev/null +++ b/web-admin/src/views/system/SystemSettings.vue @@ -0,0 +1,183 @@ + + + + 基础设置 + 保存 + + + + + + + + {{ groupLabels[group] || group }} + + + + + {{ item.configName }} + {{ item.description }} + + + + + + {{ editValues[item.configKey] }} + + + + + + + + + + + + \ No newline at end of file