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 { defineStore } from 'pinia'
import type { UserState } from './types' import type { UserState } from './types'
import { resetRouter } from '@/router'
import api from '@/api'
const { apiGetUserRoleInfo, apiLogout } = api.login
import menuList from '@/config/menuList.ts' import menuList from '@/config/menuList.ts'
const useUserStore = defineStore('user', { const useUserStore = defineStore('user', {
@ -52,9 +49,9 @@ const useUserStore = defineStore('user', {
// 退出登录 // 退出登录
onLogout() { onLogout() {
return new Promise((resolve) => { return new Promise((resolve) => {
apiLogout.get!().then(() => { api.login.apiLogout.get!().then(() => {
this.RESET_STATE() this.RESET_STATE()
resetRouter() window.location.href = '/login'
resolve(null) resolve(null)
}) })
}) })

View File

@ -4,7 +4,7 @@ import axios, {
type AxiosResponse type AxiosResponse
} from 'axios' } from 'axios'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import useStore from '@/stores' import useUserStore from '@/stores/modules/user'
// 创建 axios 实例 // 创建 axios 实例
const service = axios.create({ const service = axios.create({
@ -43,8 +43,8 @@ service.interceptors.request.use(
config.params = {} config.params = {}
config.url = url config.url = url
} }
const { user } = useStore() const userStore = useUserStore()
user.tokenValue && (config.headers[user.tokenName] = user.tokenValue) userStore.tokenValue && (config.headers[userStore.tokenName] = userStore.tokenValue)
return config return config
}, },
(error: any) => { (error: any) => {