|
|
@@ -6,7 +6,6 @@ import { Local, Session } from '@/utils/storage';
|
|
|
import { useLoginApi } from '@/api/system/login';
|
|
|
import { useSystemApi } from '@/api/system/index';
|
|
|
import { useUserApi } from '@/api/user/index';
|
|
|
-import { useAchievementApi } from '@/api/achievement/index';
|
|
|
import type { LoginParams, UserInfo } from '@/types/user';
|
|
|
import { sm3 } from 'sm-crypto';
|
|
|
import to from 'await-to-js';
|
|
|
@@ -51,6 +50,13 @@ export const useUserStore = defineStore('user', () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function saveSciTokenFromLoginResponse(res: { data?: { sciToken?: string } } | null | undefined) {
|
|
|
+ const sciToken = res?.data?.sciToken
|
|
|
+ if (sciToken) {
|
|
|
+ Local.set(CACHE_KEY.SCITOKEN, sciToken)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 清理用户状态和本地缓存
|
|
|
*/
|
|
|
@@ -97,6 +103,7 @@ export const useUserStore = defineStore('user', () => {
|
|
|
if (resToken) {
|
|
|
token.value = resToken;
|
|
|
Local.set(CACHE_KEY.TOKEN, resToken);
|
|
|
+ saveSciTokenFromLoginResponse(res);
|
|
|
// 登录成功后主动获取用户信息
|
|
|
await fetchUserInfo();
|
|
|
}
|
|
|
@@ -122,6 +129,7 @@ export const useUserStore = defineStore('user', () => {
|
|
|
if (resToken) {
|
|
|
token.value = resToken;
|
|
|
Local.set(CACHE_KEY.TOKEN, resToken);
|
|
|
+ saveSciTokenFromLoginResponse(res);
|
|
|
// 登录成功后主动获取用户信息
|
|
|
await fetchUserInfo();
|
|
|
}
|
|
|
@@ -157,17 +165,6 @@ export const useUserStore = defineStore('user', () => {
|
|
|
Local.set(CACHE_KEY.USER_INFO, userInfo.value);
|
|
|
Local.set(CACHE_KEY.PERMS, perms.value);
|
|
|
Local.set(CACHE_KEY.ROLES, roles.value);
|
|
|
-
|
|
|
- // 获取科技专项活动 TOKEN
|
|
|
- if (userInfo.value.id) {
|
|
|
- const achievementApi = useAchievementApi();
|
|
|
- const [sciErr, sciRes] = await to(achievementApi.getSciToken(userInfo.value.id));
|
|
|
- console.log(sciRes)
|
|
|
- const sciToken = sciRes?.token;
|
|
|
- if (!sciErr && sciToken) {
|
|
|
- Local.set(CACHE_KEY.SCITOKEN, sciToken);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|