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

13
src/store/modules/user.ts

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

Loading…
Cancel
Save