build: hmr热更新修改
This commit is contained in:
parent
5561b8d4bb
commit
263fbb3633
@ -1,8 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { UserState } from './types'
|
||||
import { resetRouter } from '@/router'
|
||||
import api from '@/api'
|
||||
const { apiGetUserRoleInfo, apiLogout } = api.login
|
||||
import menuList from '@/config/menuList.ts'
|
||||
|
||||
const useUserStore = defineStore('user', {
|
||||
@ -52,9 +49,9 @@ const useUserStore = defineStore('user', {
|
||||
// 退出登录
|
||||
onLogout() {
|
||||
return new Promise((resolve) => {
|
||||
apiLogout.get!().then(() => {
|
||||
api.login.apiLogout.get!().then(() => {
|
||||
this.RESET_STATE()
|
||||
resetRouter()
|
||||
window.location.href = '/login'
|
||||
resolve(null)
|
||||
})
|
||||
})
|
||||
|
||||
@ -4,7 +4,7 @@ import axios, {
|
||||
type AxiosResponse
|
||||
} from 'axios'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import useStore from '@/stores'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
|
||||
// 创建 axios 实例
|
||||
const service = axios.create({
|
||||
@ -43,8 +43,8 @@ service.interceptors.request.use(
|
||||
config.params = {}
|
||||
config.url = url
|
||||
}
|
||||
const { user } = useStore()
|
||||
user.tokenValue && (config.headers[user.tokenName] = user.tokenValue)
|
||||
const userStore = useUserStore()
|
||||
userStore.tokenValue && (config.headers[userStore.tokenName] = userStore.tokenValue)
|
||||
return config
|
||||
},
|
||||
(error: any) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user