From ceb601d74ac3692b324a6e66d5268b909551f1bd Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 16 Sep 2025 18:24:40 +0800 Subject: [PATCH] feat: add login settings management and captcha display logic --- ui/src/api/system-settings/auth-setting.ts | 24 +- ui/src/api/user/login.ts | 4 +- ui/src/locales/lang/en-US/views/system.ts | 5 + ui/src/locales/lang/zh-CN/views/system.ts | 5 + ui/src/locales/lang/zh-Hant/views/system.ts | 5 + .../xpack-component/XPackLimitDrawer.vue | 56 +++-- ui/src/views/chat/user-login/index.vue | 6 +- ui/src/views/login/index.vue | 235 ++++++++++++------ .../views/login/scanCompinents/QrCodeTab.vue | 16 +- .../authentication/component/OAuth2.vue | 18 +- .../authentication/component/Setting.vue | 136 ++++++++++ .../system-setting/authentication/index.vue | 8 +- 12 files changed, 409 insertions(+), 109 deletions(-) create mode 100644 ui/src/views/system-setting/authentication/component/Setting.vue diff --git a/ui/src/api/system-settings/auth-setting.ts b/ui/src/api/system-settings/auth-setting.ts index 552f82e12..5f71b1b37 100644 --- a/ui/src/api/system-settings/auth-setting.ts +++ b/ui/src/api/system-settings/auth-setting.ts @@ -30,9 +30,31 @@ const putAuthSetting: (auth_type: string, data: any, loading?: Ref) => ) => { return put(`${prefix}/${auth_type}/info`, data, undefined, loading) } +/** + * 登录设置 + */ +const putLoginSetting: (data: any, loading?: Ref) => Promise> = ( + data, + loading +) => { + return put(`${prefix}/setting`, data, undefined, loading) +} +/** + * 获取登录设置 + */ +const getLoginSetting: (loading?: Ref) => Promise> = (loading) => { + return get(`${prefix}/setting`, undefined, loading) +} + +const getLoginAuthSetting: (loading?: Ref) => Promise> = (loading) => { + return get(`login/auth/setting`, undefined, loading) +} export default { getAuthSetting, postAuthSetting, - putAuthSetting + putAuthSetting, + putLoginSetting, + getLoginSetting, + getLoginAuthSetting } diff --git a/ui/src/api/user/login.ts b/ui/src/api/user/login.ts index b224a0314..a97ee097d 100644 --- a/ui/src/api/user/login.ts +++ b/ui/src/api/user/login.ts @@ -38,8 +38,8 @@ const logout: (loading?: Ref) => Promise> = (loading) = * 获取验证码 * @param loading 接口加载器 */ -const getCaptcha: (loading?: Ref) => Promise> = (loading) => { - return get('/user/captcha', undefined, loading) +const getCaptcha: (username?: string, loading?: Ref) => Promise> = (username, loading) => { + return get('/user/captcha', {username}, loading) } /** diff --git a/ui/src/locales/lang/en-US/views/system.ts b/ui/src/locales/lang/en-US/views/system.ts index 045d7a59d..33e78ea3b 100644 --- a/ui/src/locales/lang/en-US/views/system.ts +++ b/ui/src/locales/lang/en-US/views/system.ts @@ -130,4 +130,9 @@ export default { type: 'Type', management: 'management', }, + default_login: 'Default Login Method', + display_code: 'Display verification code when login fails', + display_codeTip: 'When the value is -1, the verification code is not displayed', + time: 'Times', + setting: 'Login Setting', } diff --git a/ui/src/locales/lang/zh-CN/views/system.ts b/ui/src/locales/lang/zh-CN/views/system.ts index 4bf583d1e..0158dfdf1 100644 --- a/ui/src/locales/lang/zh-CN/views/system.ts +++ b/ui/src/locales/lang/zh-CN/views/system.ts @@ -131,4 +131,9 @@ export default { type: '类型', management: '管理', }, + default_login: '默认登录方式', + display_code: '登录失败显示验证码', + display_codeTip: '值为-1时,不显示验证码', + time: '次', + setting: '登录设置', } diff --git a/ui/src/locales/lang/zh-Hant/views/system.ts b/ui/src/locales/lang/zh-Hant/views/system.ts index 4fb0c9323..aa034ca6e 100644 --- a/ui/src/locales/lang/zh-Hant/views/system.ts +++ b/ui/src/locales/lang/zh-Hant/views/system.ts @@ -130,4 +130,9 @@ export default { type: '類型', management: '管理', }, + default_login: '預設登入方式', + display_code: '登入失敗顯示驗證碼', + display_codeTip: '值為-1時,不顯示驗證碼', + time: '次', + setting: '登录設置', } diff --git a/ui/src/views/application-overview/xpack-component/XPackLimitDrawer.vue b/ui/src/views/application-overview/xpack-component/XPackLimitDrawer.vue index 18a5faabe..84c05110f 100644 --- a/ui/src/views/application-overview/xpack-component/XPackLimitDrawer.vue +++ b/ui/src/views/application-overview/xpack-component/XPackLimitDrawer.vue @@ -23,8 +23,8 @@ step-strictly /> {{ - $t('views.applicationOverview.appInfo.LimitDialog.timesDays') - }} + $t('views.applicationOverview.appInfo.LimitDialog.timesDays') + }} - + @@ -111,10 +111,32 @@ > + + + + {{ $t('views.system.display_codeTip') }} + + @@ -144,18 +166,18 @@ diff --git a/ui/src/views/system-setting/authentication/index.vue b/ui/src/views/system-setting/authentication/index.vue index f3bf3ec34..14cb050e1 100644 --- a/ui/src/views/system-setting/authentication/index.vue +++ b/ui/src/views/system-setting/authentication/index.vue @@ -23,14 +23,20 @@ import CAS from './component/CAS.vue' import OIDC from './component/OIDC.vue' import SCAN from './component/SCAN.vue' import OAuth2 from './component/OAuth2.vue' +import Setting from './component/Setting.vue' import { t } from '@/locales' import useStore from '@/stores' const { user } = useStore() const router = useRouter() -const activeName = ref('LDAP') +const activeName = ref('SETTING') const tabList = [ + { + label: t('views.system.setting'), + name: "SETTING", + component: Setting, + }, { label: t('views.system.authentication.ldap.title'), name: 'LDAP',