From fa8bd09374041c473618696a13bbf98186627351 Mon Sep 17 00:00:00 2001 From: shizhongming Date: Fri, 8 Mar 2024 10:46:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E6=9E=B6=E6=9E=84):=20?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=99=BB=E5=BD=95=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 8 ++++ src/api/sys/app.ts | 15 ++++++ src/api/sys/model/userModel.ts | 2 +- src/components/Verify/index.ts | 3 ++ src/components/Verify/src/TextCaptcha.vue | 55 ++++++++++++++++++++++ src/components/registerGlobComp.ts | 8 ++++ src/locales/lang/zh-CN/component.json | 3 +- src/store/modules/app.ts | 18 +++++++- src/views/sys/login/LoginForm.vue | 56 ++++++++++++++--------- types/store.d.ts | 20 ++++++++ 10 files changed, 163 insertions(+), 25 deletions(-) create mode 100644 src/api/sys/app.ts create mode 100644 src/components/Verify/src/TextCaptcha.vue diff --git a/src/App.vue b/src/App.vue index 97600d8e3..77abb458e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,6 +18,8 @@ import { computed } from 'vue'; import { ExceptionModal } from '@/views/sys/exception'; + import { useAppStore } from '@/store/modules/app'; + // support Multi-language const { getAntdLocale } = useLocale(); @@ -39,4 +41,10 @@ ); // Listening to page changes and dynamically changing site titles useTitle(); + + /** + * 初始化系统参数 + */ + const appStore = useAppStore(); + appStore.initSystemProperties(); diff --git a/src/api/sys/app.ts b/src/api/sys/app.ts new file mode 100644 index 000000000..9bce92085 --- /dev/null +++ b/src/api/sys/app.ts @@ -0,0 +1,15 @@ +import { ApiServiceEnum, defHttp } from '@/utils/http/axios'; + +enum Api { + getAuthProperties = 'public/auth/getAuthProperties', +} + +/** + * 获取认证参数 + */ +export const getAuthPropertiesApi = () => { + return defHttp.post({ + service: ApiServiceEnum.SMART_AUTH, + url: Api.getAuthProperties, + }); +}; diff --git a/src/api/sys/model/userModel.ts b/src/api/sys/model/userModel.ts index c459cee6e..301825a50 100644 --- a/src/api/sys/model/userModel.ts +++ b/src/api/sys/model/userModel.ts @@ -4,7 +4,7 @@ export interface LoginParams { username: string; password: string; - codeKey: string; + key: string; code: string; } diff --git a/src/components/Verify/index.ts b/src/components/Verify/index.ts index 13df25e02..0322981f8 100644 --- a/src/components/Verify/index.ts +++ b/src/components/Verify/index.ts @@ -1,7 +1,10 @@ import { withInstall } from '@/utils'; import basicDragVerify from './src/DragVerify.vue'; import rotateDragVerify from './src/ImgRotate.vue'; +import textCaptcha from './src/TextCaptcha.vue'; export const BasicDragVerify = withInstall(basicDragVerify); export const RotateDragVerify = withInstall(rotateDragVerify); export * from './src/typing'; + +export const TextCaptcha = withInstall(textCaptcha); diff --git a/src/components/Verify/src/TextCaptcha.vue b/src/components/Verify/src/TextCaptcha.vue new file mode 100644 index 000000000..a0787a273 --- /dev/null +++ b/src/components/Verify/src/TextCaptcha.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/src/components/registerGlobComp.ts b/src/components/registerGlobComp.ts index f7c396eeb..94dd6a0e4 100644 --- a/src/components/registerGlobComp.ts +++ b/src/components/registerGlobComp.ts @@ -16,6 +16,10 @@ import { } from 'ant-design-vue'; import VXETable from 'vxe-table'; +import ExcelJS from 'exceljs'; +import VXETablePluginExportXLSX from 'vxe-table-plugin-export-xlsx'; +import { VXETablePluginAntd } from '@/components/SmartTable/VXETablePluginAntd'; + import { i18n } from '@/locales/setupI18n'; export function registerGlobComp(app: App) { @@ -34,6 +38,10 @@ export function registerGlobComp(app: App) { return key; }, }); + VXETable.use(VXETablePluginAntd); + VXETable.use(VXETablePluginExportXLSX, { + ExcelJS, + }); app .use(Input) .use(Button) diff --git a/src/locales/lang/zh-CN/component.json b/src/locales/lang/zh-CN/component.json index 952d99ddc..3599fd68d 100644 --- a/src/locales/lang/zh-CN/component.json +++ b/src/locales/lang/zh-CN/component.json @@ -123,6 +123,7 @@ "time": "验证校验成功,耗时{time}秒!", "redoTip": "点击图片可刷新", "dragText": "请按住滑块拖动", - "successText": "验证通过" + "successText": "验证通过", + "refresh": "点击刷新验证码" } } diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 6660d2b8b..bbc44e3d1 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -6,7 +6,7 @@ import type { MultiTabsSetting, SizeConfig, } from '#/config'; -import type { BeforeMiniState, ApiAddress } from '#/store'; +import type { BeforeMiniState, ApiAddress, SystemProperties } from '#/store'; import { defineStore } from 'pinia'; import { store } from '@/store'; @@ -18,6 +18,8 @@ import { darkMode } from '@/settings/designSetting'; import { resetRouter } from '@/router'; import { deepMerge } from '@/utils'; +import { getAuthPropertiesApi } from '@/api/sys/app'; + interface AppState { darkMode?: ThemeEnum; // Page loading status @@ -26,6 +28,7 @@ interface AppState { projectConfig: ProjectConfig | null; // When the window shrinks, remember some states, and restore these states when the window is restored beforeMiniInfo: BeforeMiniState; + systemProperties: SystemProperties; } let timeId: TimeoutHandle; export const useAppStore = defineStore({ @@ -35,6 +38,7 @@ export const useAppStore = defineStore({ pageLoading: false, projectConfig: Persistent.getLocal(PROJ_CFG_KEY), beforeMiniInfo: {}, + systemProperties: {}, }), getters: { getPageLoading(state): boolean { @@ -70,6 +74,9 @@ export const useAppStore = defineStore({ getSizeSetting(): SizeConfig { return this.getProjectConfig.sizeConfig; }, + getSystemProperties(state): SystemProperties { + return state.systemProperties; + }, }, actions: { setPageLoading(loading: boolean): void { @@ -113,6 +120,15 @@ export const useAppStore = defineStore({ setApiAddress(config: ApiAddress): void { localStorage.setItem(API_ADDRESS, JSON.stringify(config)); }, + /** + * 初始化系统参数 + */ + async initSystemProperties() { + const authProperties = await getAuthPropertiesApi(); + this.systemProperties = { + ...authProperties, + }; + }, }, }); diff --git a/src/views/sys/login/LoginForm.vue b/src/views/sys/login/LoginForm.vue index 8e0731b56..d6df20bc2 100644 --- a/src/views/sys/login/LoginForm.vue +++ b/src/views/sys/login/LoginForm.vue @@ -25,7 +25,8 @@ /> - + + - - - - + @@ -101,15 +104,15 @@ diff --git a/types/store.d.ts b/types/store.d.ts index fdca922cd..ef2591e17 100644 --- a/types/store.d.ts +++ b/types/store.d.ts @@ -56,3 +56,23 @@ export interface TableSetting { columns: Recordable>>; showRowSelection: Recordable>; } + +/** + * 后台的系统参数 + */ +export interface SystemProperties { + /** + * 是否启用验证码 + */ + captchaEnabled?: boolean; + + /** + * 验证码类型 + */ + captchaType?: string; + + /** + * 验证码标记 + */ + captchaIdent?: string; +}