bug: 退出登录
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* @desc 当前用户
|
* @desc 当前用户
|
||||||
*/
|
*/
|
||||||
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
|
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
|
||||||
import type { AxiosResponse } from 'axios';
|
import type { AxiosResponse } from 'axios'
|
||||||
export default async function (
|
export default async function (
|
||||||
success: (data: auth.AuthUser) => void = defaultSuccess,
|
success: (data: auth.AuthUser) => void = defaultSuccess,
|
||||||
fail: (error: { code: string; error?: string }) => void = defaultError,
|
fail: (error: { code: string; error?: string }) => void = defaultError,
|
||||||
@@ -12,7 +12,7 @@ export default async function (
|
|||||||
url: `/auth/current-user`,
|
url: `/auth/current-user`,
|
||||||
})
|
})
|
||||||
.then((data: AxiosResponse<auth.AuthUser, unknown>) => {
|
.then((data: AxiosResponse<auth.AuthUser, unknown>) => {
|
||||||
success(data.data);
|
success(data.data)
|
||||||
})
|
})
|
||||||
.catch((error: { code: string; error?: string }) => fail(error));
|
.catch((error: { code: string; error?: string }) => fail(error))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
import { config } from '@/settings/application'
|
import { config } from '@/settings/application'
|
||||||
import { MenuInfo } from 'ant-design-vue/es/menu/src/interface'
|
import { MenuInfo } from 'ant-design-vue/es/menu/src/interface'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import api from '@/api'
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const user = useUserStore()
|
const user = useUserStore()
|
||||||
|
|
||||||
@@ -85,7 +86,9 @@
|
|||||||
icon: createVNode(ExclamationCircleOutlined),
|
icon: createVNode(ExclamationCircleOutlined),
|
||||||
content: createVNode('div', { style: 'color:red;' }, '确定退出系统吗?'),
|
content: createVNode('div', { style: 'color:red;' }, '确定退出系统吗?'),
|
||||||
onOk() {
|
onOk() {
|
||||||
|
api.authApi.auth.logout(() => {
|
||||||
user.logout()
|
user.logout()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ export const routes: Array<RouteRecordRaw> = [
|
|||||||
|
|
||||||
const getNewRouter = () => {
|
const getNewRouter = () => {
|
||||||
// TODO 用户store判断是否登录,登录就返回过滤的,没有登录就返回全量
|
// TODO 用户store判断是否登录,登录就返回过滤的,没有登录就返回全量
|
||||||
|
|
||||||
return createRouter({
|
return createRouter({
|
||||||
history: createWebHashHistory(),
|
history: createWebHashHistory(),
|
||||||
routes: [
|
routes: [
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ export const useUserStore = defineStore('user', {
|
|||||||
isAdmin(state) {
|
isAdmin(state) {
|
||||||
return state.roles.includes('admin')
|
return state.roles.includes('admin')
|
||||||
},
|
},
|
||||||
|
isLogin(state) {
|
||||||
|
return state.token && state.refreshToken
|
||||||
|
},
|
||||||
|
getPermission(state) {
|
||||||
|
return state.permissions
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
refreshUserInfo(user: auth.AuthUser) {
|
refreshUserInfo(user: auth.AuthUser) {
|
||||||
|
|||||||
Reference in New Issue
Block a user