Browse Source

chore: 优化客户端登陆

master
wangxiang 2 years ago
parent
commit
fff8542395
No known key found for this signature in database
GPG Key ID: 1BA7946AB6B232E4
  1. 4
      src/store/modules/lock.ts
  2. 13
      src/store/modules/user.ts

4
src/store/modules/lock.ts

@ -37,7 +37,7 @@ export const useLockStore = defineStore({ @@ -37,7 +37,7 @@ export const useLockStore = defineStore({
this.lockInfo = null;
},
/** 解锁锁屏 */
async unLock(password?: string) {
async unLock(password: string) {
const userStore = useUserStore();
// 浏览器存在当前锁屏信息缓存,直接比对当前用户密码
if (this.lockInfo?.pwd === password) {
@ -52,7 +52,7 @@ export const useLockStore = defineStore({ @@ -52,7 +52,7 @@ export const useLockStore = defineStore({
userStore.setRefreshToken('');
const res = await userStore.login({
username,
password: password!,
password: password,
goHome: false,
clientId: 'kicc_lock'
});

13
src/store/modules/user.ts

@ -23,6 +23,7 @@ import { useGlobSetting } from '/@/hooks/setting'; @@ -23,6 +23,7 @@ import { useGlobSetting } from '/@/hooks/setting';
import { isUrl, isEmpty } from '/@/utils/is';
import { h } from 'vue';
import { getAuthClient } from '/@/utils';
import { merge } from 'lodash-es';
interface UserState {
userInfo: Nullable<User>;
@ -114,11 +115,13 @@ export const useUserStore = defineStore({ @@ -114,11 +115,13 @@ export const useUserStore = defineStore({
const { goHome = true, clientId = '', ...loginParams } = params;
// 处理自定义授权客户端
if (clientId) {
const client = getAuthClient(clientId);
!isEmpty(client) && Object.assign({}, loginParams.options, {
clientId: client[0],
clientSecret: client[1]
});
const client = getAuthClient(clientId);
!isEmpty(client) && merge(loginParams, {
options: {
clientId: client[0],
clientSecret: client[1]
}
});
}
const data = await login(loginParams);
const { access_token, refresh_token } = data;

Loading…
Cancel
Save