|
@ -2,8 +2,8 @@ import { defineStore } from "pinia"; |
|
|
import { store } from "/@/store"; |
|
|
import { store } from "/@/store"; |
|
|
import { userType } from "./types"; |
|
|
import { userType } from "./types"; |
|
|
import { router } from "/@/router"; |
|
|
import { router } from "/@/router"; |
|
|
|
|
|
import { storageSession } from "/@/utils/storage"; |
|
|
import { getLogin, refreshToken } from "/@/api/user"; |
|
|
import { getLogin, refreshToken } from "/@/api/user"; |
|
|
import { storageLocal, storageSession } from "/@/utils/storage"; |
|
|
|
|
|
import { getToken, setToken, removeToken } from "/@/utils/auth"; |
|
|
import { getToken, setToken, removeToken } from "/@/utils/auth"; |
|
|
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; |
|
|
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; |
|
|
|
|
|
|
|
@ -33,12 +33,12 @@ export const useUserStore = defineStore({ |
|
|
}, |
|
|
}, |
|
|
// 登入
|
|
|
// 登入
|
|
|
async loginByUsername(data) { |
|
|
async loginByUsername(data) { |
|
|
return new Promise<void>((resolve, reject) => { |
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
getLogin(data) |
|
|
getLogin(data) |
|
|
.then(data => { |
|
|
|
|
|
if (data) { |
|
|
|
|
|
setToken(data); |
|
|
|
|
|
resolve(); |
|
|
|
|
|
|
|
|
.then(res => { |
|
|
|
|
|
if (res) { |
|
|
|
|
|
setToken(res); |
|
|
|
|
|
resolve(res); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
.catch(error => { |
|
|
.catch(error => { |
|
@ -51,7 +51,6 @@ export const useUserStore = defineStore({ |
|
|
this.token = ""; |
|
|
this.token = ""; |
|
|
this.name = ""; |
|
|
this.name = ""; |
|
|
removeToken(); |
|
|
removeToken(); |
|
|
storageLocal.clear(); |
|
|
|
|
|
storageSession.clear(); |
|
|
storageSession.clear(); |
|
|
useMultiTagsStoreHook().handleTags("equal", [ |
|
|
useMultiTagsStoreHook().handleTags("equal", [ |
|
|
{ |
|
|
{ |
|
|