diff --git a/mayfly_go_web/package.json b/mayfly_go_web/package.json index cb695586..718a8f7c 100644 --- a/mayfly_go_web/package.json +++ b/mayfly_go_web/package.json @@ -24,6 +24,7 @@ "monaco-themes": "^0.4.4", "nprogress": "^0.2.0", "pinia": "^2.1.3", + "qrcode.vue": "^3.4.0", "screenfull": "^6.0.2", "sortablejs": "^1.13.0", "sql-formatter": "^12.1.2", diff --git a/mayfly_go_web/src/common/openApi.ts b/mayfly_go_web/src/common/openApi.ts index c5cf61ef..44694164 100644 --- a/mayfly_go_web/src/common/openApi.ts +++ b/mayfly_go_web/src/common/openApi.ts @@ -2,6 +2,7 @@ import Api from './Api' export default { login: Api.newPost("/sys/accounts/login"), + otpVerify: Api.newPost("/sys/accounts/otp-verify"), changePwd: Api.newPost("/sys/accounts/change-pwd"), getPublicKey: Api.newGet("/common/public-key"), getConfigValue: Api.newGet("/sys/configs/value"), diff --git a/mayfly_go_web/src/common/sysconfig.ts b/mayfly_go_web/src/common/sysconfig.ts index 60e25058..1891b352 100644 --- a/mayfly_go_web/src/common/sysconfig.ts +++ b/mayfly_go_web/src/common/sysconfig.ts @@ -1,6 +1,7 @@ import openApi from './openApi'; // 登录是否使用验证码配置key +const AccountLoginSecurity = "AccountLoginSecurity" const UseLoginCaptchaConfigKey = "UseLoginCaptcha" const UseWartermarkConfigKey = "UseWartermark" @@ -22,11 +23,24 @@ export async function getConfigValue(key: string) : Promise { * @returns 是否为ture,1: true;其他: false */ export async function getBoolConfigValue(key :string, defaultValue :boolean) : Promise { - const value = await getConfigValue(key) + const value = await getConfigValue(key); + return convertBool(value, defaultValue); +} + +/** + * 获取账号登录安全配置 + * + * @returns + */ +export async function getAccountLoginSecurity() : Promise { + const value = await getConfigValue(AccountLoginSecurity); if (!value) { - return defaultValue; + return null; } - return value == "1"; + const jsonValue = JSON.parse(value); + jsonValue.useCaptcha = convertBool(jsonValue.useCaptcha, true); + jsonValue.useOtp = convertBool(jsonValue.useOtp, true); + return jsonValue; } /** @@ -45,4 +59,11 @@ export async function useLoginCaptcha() : Promise { */ export async function useWartermark() : Promise { return await getBoolConfigValue(UseWartermarkConfigKey, true) +} + +function convertBool(value: string, defaultValue: boolean) { + if (!value) { + return defaultValue; + } + return value == "1" || value == "true"; } \ No newline at end of file diff --git a/mayfly_go_web/src/views/login/component/AccountLogin.vue b/mayfly_go_web/src/views/login/component/AccountLogin.vue index a7440bd7..e7f8da2c 100644 --- a/mayfly_go_web/src/views/login/component/AccountLogin.vue +++ b/mayfly_go_web/src/views/login/component/AccountLogin.vue @@ -11,7 +11,7 @@ autocomplete="off" @keyup.enter="login" show-password> - + + + 提示:登录失败超过{{ accountLoginSecurity.loginFailCount }}次后将被限制{{ accountLoginSecurity.loginFailMin }}分钟内不可再次登录 +