-
-
-
{{ user.token ? '已登录' : '登录/注册' }}
-
-
{{ setting.title }}
-
-
-
- 知识点学习
-
-
学习
-
仿真实验
-
+
+
+
+
{{ user.token ? "已登录" : "登录/注册" }}
+
+
+
{{ setting.title }}
+
+
+ 知识点学习
+
+
+ 学习
+
+
+ 仿真实验
+
+
+
\ No newline at end of file
+
diff --git a/src/permissions.ts b/src/permissions.ts
index fa9a430..a7a06f1 100644
--- a/src/permissions.ts
+++ b/src/permissions.ts
@@ -6,7 +6,7 @@ const store = userStore(pinia);
router.beforeEach((to: any, from: any, next: any) => {
if (to.path === "/login") {
if (store.token) {
- next("/");
+ next("/studyPage");
} else {
next();
}
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 691d243..031139b 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -2,8 +2,9 @@
import axios from "axios";
import pinia from "@/store";
import { ElMessage } from "element-plus";
-
+import {removeToken} from '@/utils/auth'
import userStore from "@/store/modules/user";
+import router from '@/router'
// 创建axios实例
const server = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_API,
@@ -26,8 +27,14 @@ server.interceptors.response.use((response) => {
// useuserStore.clearStatus();
// return Promise.reject(response);
}
+ if(response.data.code=== 401){
+ ElMessage.error(response.data.message);
+ return Promise.reject(response);
+ }
if (response.data.code === 412) {
ElMessage.error(response.data.message);
+ removeToken()
+ router.push('/login')
return Promise.reject(response);
}
return response.data;
diff --git a/src/views/program/index.vue b/src/views/program/index.vue
index fdfbaaf..c13a319 100644
--- a/src/views/program/index.vue
+++ b/src/views/program/index.vue
@@ -1391,7 +1391,7 @@ const onSave = async () => {
// console.log(graph.toJSON());
// return;
- clearLocalStorage();
+ clearLocalStorage(false);
const data = graph.toJSON().cells.map((item: any) => {
return {
node: item,
@@ -1474,10 +1474,13 @@ function loadFromLocalStorage() {
return JSON.parse(localStorage.getItem(SESSION_KEY) as string) || [];
}
-function clearLocalStorage() {
+function clearLocalStorage(falg=true) {
localStorage.removeItem(SESSION_KEY);
+ if(falg){
window.location.reload();
+ }
+
}
// 恢复画布状态
function restoreGraph() {
diff --git a/src/views/subjectTest/index.vue b/src/views/subjectTest/index.vue
index 1bb6f37..b8df040 100644
--- a/src/views/subjectTest/index.vue
+++ b/src/views/subjectTest/index.vue
@@ -157,7 +157,7 @@ import { useRouter } from 'vue-router';
// 退出答题
const router = useRouter()
const resetAnswers = () => {
- router.push('/spacePage')
+ router.push('/studyPage')
};
// 计时器相关变量
const timer = ref
(null); // 用于存储 setInterval 的返回值