build: hmr热更新修改

This commit is contained in:
zc 2025-10-23 23:08:37 +08:00
parent 5561b8d4bb
commit 263fbb3633
2 changed files with 5 additions and 8 deletions

View File

@ -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)
})
})

View File

@ -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) => {