|
@@ -5,8 +5,7 @@ import { useRoute } from 'vue-router';
|
|
import { SetupStoreId } from '@/enum';
|
|
import { SetupStoreId } from '@/enum';
|
|
import { useRouterPush } from '@/hooks/common/router';
|
|
import { useRouterPush } from '@/hooks/common/router';
|
|
import { $t } from '@/locales';
|
|
import { $t } from '@/locales';
|
|
-import { fetchGetUserInfoDemo, fetchLoginDemo } from '@/service/api';
|
|
|
|
-// import { fetchLogin, fetchGetUserInfo } from '@/service/api';
|
|
|
|
|
|
+import { fetchGetUserInfo, fetchLogin } from '@/service/api';
|
|
import { localStg } from '@/utils/storage';
|
|
import { localStg } from '@/utils/storage';
|
|
import { useRouteStore } from '../route';
|
|
import { useRouteStore } from '../route';
|
|
import { useTabStore } from '../tab';
|
|
import { useTabStore } from '../tab';
|
|
@@ -65,13 +64,15 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
|
*/
|
|
*/
|
|
async function login(params: object, redirect = true) {
|
|
async function login(params: object, redirect = true) {
|
|
startLoading();
|
|
startLoading();
|
|
- // 待完善 此处和目前业务逻辑不同,关于refreshToken需后续处理
|
|
|
|
- const { token: currentToken, currentAuthority: refreshToken, error } = await fetchLoginDemo(params);
|
|
|
|
- // const { data: loginToken, error } = await fetchLogin('Soybean', '123456');
|
|
|
|
- console.log('error-----', error);
|
|
|
|
|
|
+ const { data, error } = await fetchLogin(params);
|
|
if (!error) {
|
|
if (!error) {
|
|
- const pass = await loginByToken({ token: currentToken, refreshToken, data: null, code: 200 });
|
|
|
|
- // const pass = await loginByToken(loginToken);
|
|
|
|
|
|
+ const loginToken = {
|
|
|
|
+ token: data.token,
|
|
|
|
+ refreshToken: '',
|
|
|
|
+ data: null,
|
|
|
|
+ code: 200
|
|
|
|
+ };
|
|
|
|
+ const pass = await loginByToken(loginToken);
|
|
|
|
|
|
if (pass) {
|
|
if (pass) {
|
|
await routeStore.initAuthRoute();
|
|
await routeStore.initAuthRoute();
|
|
@@ -112,13 +113,10 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
|
}
|
|
}
|
|
|
|
|
|
async function getUserInfo() {
|
|
async function getUserInfo() {
|
|
- const { data: info, error } = await fetchGetUserInfoDemo();
|
|
|
|
- // const { data: info, error } = await fetchGetUserInfo();
|
|
|
|
|
|
+ const { data: info, error } = await fetchGetUserInfo();
|
|
|
|
|
|
if (!error) {
|
|
if (!error) {
|
|
// update store
|
|
// update store
|
|
- // 此处为权限测试方式
|
|
|
|
- // const testInfo = { roles: ['R_SUPER'] };
|
|
|
|
Object.assign(userInfo, info);
|
|
Object.assign(userInfo, info);
|
|
|
|
|
|
return true;
|
|
return true;
|