diff --git a/.env.development b/.env.development
index 7b55620..0e5f525 100644
--- a/.env.development
+++ b/.env.development
@@ -1,4 +1,4 @@
# 变量必须以 VITE_ 为前缀才能暴露给外部读取
NODE_ENV = 'development'
-VITE_APP_TITLE = '大屏数据'
-VITE_APP_BASE_API = 'http://10.115.6.28:18083/'
\ No newline at end of file
+VITE_APP_TITLE = '实验仿真'
+VITE_APP_BASE_API = '//localhost:16066/jeecg-boot'
\ No newline at end of file
diff --git a/package.json b/package.json
index 080e8f6..c7275f2 100644
--- a/package.json
+++ b/package.json
@@ -18,6 +18,7 @@
"@antv/x6-plugin-stencil": "^2.1.5",
"@antv/x6-plugin-transform": "^2.1.8",
"@antv/x6-vue-shape": "^2.1.2",
+ "@element-plus/icons-vue": "^2.3.1",
"@kjgl77/datav-vue3": "^1.7.3",
"axios": "^1.7.2",
"echarts": "^5.6.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e83cfbb..11ad3e4 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -35,6 +35,9 @@ importers:
'@antv/x6-vue-shape':
specifier: ^2.1.2
version: 2.1.2(@antv/x6@2.18.1)(vue@3.4.29(typescript@5.2.2))
+ '@element-plus/icons-vue':
+ specifier: ^2.3.1
+ version: 2.3.1(vue@3.4.29(typescript@5.2.2))
'@kjgl77/datav-vue3':
specifier: ^1.7.3
version: 1.7.3(vue@3.4.29(typescript@5.2.2))
diff --git a/src/api/index.ts b/src/api/index.ts
index d95ed38..3879b01 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,2 +1,14 @@
import request from '@/utils/request'
+export const login = (data: any) => {
+ return request({
+ url: '/sys/login',
+ method: 'post',
+ data
+ })
+}
+export const getCode = (time: any) => {
+ return request({
+ url: '/sys/randomImage/' + time,
+ })
+ }
\ No newline at end of file
diff --git a/src/layout/index.vue b/src/layout/index.vue
index 60e7e7b..bcfdaff 100644
--- a/src/layout/index.vue
+++ b/src/layout/index.vue
@@ -2,7 +2,7 @@
-
登录/注册
+
{{user.token?'已登录':'登录/注册'}}
{{ setting.title }}
@@ -18,10 +18,13 @@
\ No newline at end of file
+
diff --git a/src/main.ts b/src/main.ts
index a16be23..e979875 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,6 +1,6 @@
import { createApp } from 'vue'
import App from './App.vue'
-import router from '@/router'
+import router from './permissions'
import '@/styles/index.scss'
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css'; // 引入 Element Plus 的样式文件
diff --git a/src/permissions.ts b/src/permissions.ts
new file mode 100644
index 0000000..3bc2aa0
--- /dev/null
+++ b/src/permissions.ts
@@ -0,0 +1,23 @@
+import router from "./router";
+import userStore from "./store/modules/user";
+import { getToken } from "./utils/auth";
+import pinia from "./store";
+const store = userStore(pinia);
+router.beforeEach((to: any, from: any, next: any) => {
+ if (to.path === "/login") {
+ if (store.token) {
+ next("/");
+ } else {
+ next();
+ }
+ // next();
+ } else {
+ const token = getToken();
+ if (token) {
+ next();
+ } else {
+ next("/login");
+ }
+ }
+});
+export default router;
\ No newline at end of file
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index b1e6a68..a2c0c45 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -1,14 +1,31 @@
import { defineStore } from "pinia";
-import { getToken } from "@/utils/auth";
+import { getToken,setToken } from "@/utils/auth";
+import { login } from "@/api";
+import { ElMessage } from "element-plus";
const userStore = defineStore("userStore", {
state: () => ({
token: getToken(),
userInfo: {},
}),
actions: {
- async logIn(){
-
- }
+ async logIn(form: any) {
+ console.log(form);
+ const res: any = await login(form);
+ // if(res.code === 500) return ElMessage.error(res.msg)
+ if(res.code !== 200) {
+ ElMessage.error(res.msg)
+ return false
+ }
+ this.token = res.result.token;
+ this.userInfo = res.result.userInfo;
+ setToken(this.token);
+ console.log(res);
+ return true
+ },
+ clearStatus() {
+ this.token = "";
+ this.userInfo = {};
+ },
},
});
export default userStore;
diff --git a/src/utils/setToken.ts b/src/utils/auth.ts
similarity index 94%
rename from src/utils/setToken.ts
rename to src/utils/auth.ts
index 569c0a5..11e86ff 100644
--- a/src/utils/setToken.ts
+++ b/src/utils/auth.ts
@@ -4,7 +4,7 @@ const setToken = (token: string): void => {
};
const getToken = () => localStorage.getItem(TOKEN_KEY) || "";
const removeToken = () => localStorage.removeItem(TOKEN_KEY);
-export default {
+export {
setToken,
getToken,
removeToken,
diff --git a/src/utils/request.ts b/src/utils/request.ts
index e335ec8..691d243 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -1,23 +1,38 @@
// 引入第三方请求库axios
-import axios from 'axios'
+import axios from "axios";
+import pinia from "@/store";
+import { ElMessage } from "element-plus";
+
+import userStore from "@/store/modules/user";
// 创建axios实例
const server = axios.create({
- baseURL:import.meta.env.VITE_APP_BASE_API,
- timeout:10000,
-})
+ baseURL: import.meta.env.VITE_APP_BASE_API,
+ timeout: 30000,
+});
// 创建请求拦截器
+
server.interceptors.request.use((config) => {
- return config
-
-})
+ const useuserStore = userStore(pinia);
+
+ config.headers.Authorization = useuserStore.token;
+ config.headers["x-access-token"] = useuserStore.token;
+ return config;
+});
// 创建相应拦截器
-server.interceptors.response.use((response:any) => {
- if(response.status === 200){
- return response.data
- }
- // return response
-})
+server.interceptors.response.use((response) => {
+ if (response.data.code === 401) {
+ const useuserStore = userStore(pinia);
+
+// useuserStore.clearStatus();
+ // return Promise.reject(response);
+ }
+ if (response.data.code === 412) {
+ ElMessage.error(response.data.message);
+ return Promise.reject(response);
+ }
+ return response.data;
+});
// 暴露axios实例
-export default server
\ No newline at end of file
+export default server;
diff --git a/src/views/largeDataScreen/home.vue b/src/views/largeDataScreen/home.vue
index 3a2eba9..4e7b75f 100644
--- a/src/views/largeDataScreen/home.vue
+++ b/src/views/largeDataScreen/home.vue
@@ -291,7 +291,7 @@ const step = ref
(0);
const popover1 = ref(null);
const popover2 = ref(null);
const dialogVisible = ref(false);
-const Installation = ref(true);
+const Installation = ref(false);
const installationStep = ref(1);
const checkList = ref([1, 2]);
const unpack = (): void => {
diff --git a/src/views/program/components/yibiao.vue b/src/views/program/components/yibiao.vue
index b0bd9a4..76b8700 100644
--- a/src/views/program/components/yibiao.vue
+++ b/src/views/program/components/yibiao.vue
@@ -4,7 +4,7 @@
-