From d3c107f2ff824785f1e944f3434f69d6abd4f784 Mon Sep 17 00:00:00 2001 From: louis <869322496@qq.com> Date: Fri, 1 Mar 2024 16:00:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=88=E5=90=8C=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/backend/api/auth.ts | 11 ++++++ src/api/backend/api/typings.d.ts | 4 +-- .../basic/lockscreen/lockscreen-page.vue | 34 +++++-------------- src/layout/header/index.vue | 17 +--------- src/router/routes/modules/index.ts | 2 +- src/store/modules/user.ts | 30 ++++++++++++++-- src/views/contract/index.vue | 7 ++-- src/views/contract/upload-contract.vue | 4 +-- 8 files changed, 58 insertions(+), 51 deletions(-) diff --git a/src/api/backend/api/auth.ts b/src/api/backend/api/auth.ts index 8dafcbf..31ffc6d 100644 --- a/src/api/backend/api/auth.ts +++ b/src/api/backend/api/auth.ts @@ -14,6 +14,17 @@ export async function authLogin(body: API.LoginDto, options?: RequestOptions) { }); } +/** 解锁屏幕 POST /api/auth/unlock */ +export async function unlock(body: API.LoginDto, options?: RequestOptions) { + return request('/api/auth/unlock', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} /** 注册 POST /api/auth/register */ export async function authRegister(body: API.RegisterDto, options?: RequestOptions) { return request('/api/auth/register', { diff --git a/src/api/backend/api/typings.d.ts b/src/api/backend/api/typings.d.ts index 7665655..33e7ec2 100644 --- a/src/api/backend/api/typings.d.ts +++ b/src/api/backend/api/typings.d.ts @@ -352,9 +352,9 @@ declare namespace API { /** 密码 */ password: string; /** 验证码标识 */ - captchaId: string; + captchaId?: string; /** 用户输入的验证码 */ - verifyCode: string; + verifyCode?: string; }; type LoginLogInfo = { diff --git a/src/components/basic/lockscreen/lockscreen-page.vue b/src/components/basic/lockscreen/lockscreen-page.vue index e72f815..66d528d 100644 --- a/src/components/basic/lockscreen/lockscreen-page.vue +++ b/src/components/basic/lockscreen/lockscreen-page.vue @@ -75,7 +75,6 @@ WifiOutlined, } from '@ant-design/icons-vue'; - import { useRouter, useRoute } from 'vue-router'; import { Avatar, message } from 'ant-design-vue'; import HuaweiCharge from './huawei-charge.vue'; import XiaomiCharge from './xiaomi-charge.vue'; @@ -85,7 +84,6 @@ import { useBattery } from '@/hooks/useBattery'; import { useLockscreenStore } from '@/store/modules/lockscreen'; import { useUserStore } from '@/store/modules/user'; - import { LOGIN_NAME } from '@/router/constant'; const lockscreenStore = useLockscreenStore(); const userStore = useUserStore(); @@ -94,9 +92,6 @@ const { month, day, hour, minute, week } = useTime(); const { online } = useOnline(); - const router = useRouter(); - const route = useRoute(); - const { battery, batteryStatus, calcDischargingTime } = useBattery(); const randomCompName = Math.random() > 0.48 ? XiaomiCharge : HuaweiCharge; @@ -116,33 +111,20 @@ // 登录 const onLogin = async () => { if (state.loginForm.password.trim() == '') return message.warn('请填写密码'); - // const params = { ...state.loginForm }; + const params = { ...state.loginForm }; state.loginLoading = true; - // params.password = md5(params.password) - // const { code, message: msg } = await userStore.login(params).finally(() => { - // state.loginLoading = false; - // message.destroy(); - // }); - // if (code == 0) { - // Modal.destroyAll(); - // message.success('登录成功!'); - // unLockLogin(false); - // lockscreenStore.setLock(false); - // } else { - // message.info(msg || '登录失败'); - // } - state.loginLoading = false; + await userStore.unlock(params).finally(() => { + state.loginLoading = false; + }); + message.destroy(); + unLockLogin(false); + lockscreenStore.setLock(false); }; const nav2login = () => { unLockLogin(false); lockscreenStore.setLock(false); - router.replace({ - name: LOGIN_NAME, - query: { - redirect: route.fullPath, - }, - }); + userStore.logout(); }; diff --git a/src/layout/header/index.vue b/src/layout/header/index.vue index 4584ab3..b47a830 100644 --- a/src/layout/header/index.vue +++ b/src/layout/header/index.vue @@ -61,7 +61,7 @@