mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-11 19:53:50 +08:00
opt: 抽离 session 验证函数,修正前端路由覆盖 bug
This commit is contained in:
@@ -82,6 +82,7 @@ import {useRouter} from 'vue-router';
|
||||
import {ArrowDown, Expand, Fold} from "@element-plus/icons-vue";
|
||||
import {httpGet} from "@/utils/http";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {checkAdminSession} from "@/action/session";
|
||||
|
||||
const message = ref(5);
|
||||
const username = ref('极客学长')
|
||||
@@ -93,7 +94,7 @@ const title = ref('Chat-Plus 控制台')
|
||||
const logo = ref('/images/logo.png')
|
||||
|
||||
// 获取会话信息
|
||||
httpGet("/api/admin/session").then(() => {
|
||||
checkAdminSession().then(() => {
|
||||
// 加载系统配置
|
||||
httpGet('/api/admin/config/get?key=system').then(res => {
|
||||
title.value = res.data['admin_title'];
|
||||
|
||||
@@ -36,14 +36,24 @@
|
||||
import {useTagsStore} from '@/store/tags';
|
||||
import {onBeforeRouteUpdate, useRoute, useRouter} from 'vue-router';
|
||||
import {ArrowDown, Close} from "@element-plus/icons-vue";
|
||||
import {checkAdminSession} from "@/action/session";
|
||||
import {ElMessageBox} from "element-plus";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
checkAdminSession().catch(() => {
|
||||
ElMessageBox({
|
||||
title: '提示',
|
||||
message: "当前会话已经失效,请重新登录",
|
||||
confirmButtonText: 'OK',
|
||||
callback: () => router.replace('/admin/login')
|
||||
});
|
||||
})
|
||||
const isActive = (path) => {
|
||||
return path === route.fullPath;
|
||||
};
|
||||
|
||||
const tags = useTagsStore();
|
||||
const route = useRoute();
|
||||
// 关闭单个标签
|
||||
const closeTags = (index) => {
|
||||
const delItem = tags.list[index];
|
||||
|
||||
Reference in New Issue
Block a user