From 9f16b5c553b479ea12fe368a7ecc748872ea8b98 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期四, 12 六月 2025 11:11:27 +0800
Subject: [PATCH] 修改配置文件

---
 web_src/src/main.js |   70 ++++++++++++++++++++++++++---------
 1 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/web_src/src/main.js b/web_src/src/main.js
old mode 100644
new mode 100755
index 03bb4a4..328bb25
--- a/web_src/src/main.js
+++ b/web_src/src/main.js
@@ -1,46 +1,80 @@
 import Vue from 'vue';
 import App from './App.vue';
-Vue.config.productionTip = false;
-import ElementUI from 'element-ui';
+import ElementUI, {Notification} from 'element-ui';
 import 'element-ui/lib/theme-chalk/index.css';
 import router from './router/index.js';
 import axios from 'axios';
 import VueCookies from 'vue-cookies';
-import echarts from 'echarts';
+import VCharts from 'v-charts';
 
 import VueClipboard from 'vue-clipboard2';
-import { Notification } from 'element-ui';
 import Fingerprint2 from 'fingerprintjs2';
+import VueClipboards from 'vue-clipboards';
+import Contextmenu from "vue-contextmenujs"
+import userService from "./components/service/UserService"
 
-// 生成唯一ID
-Fingerprint2.get(function(components) {
-  const values = components.map(function(component,index) {
-    if (index === 0) { //把微信浏览器里UA的wifi或4G等网络替换成空,不然切换网络会ID不一样
+Vue.config.productionTip = false;
+
+
+// 鐢熸垚鍞竴ID
+Fingerprint2.get(function (components) {
+  const values = components.map(function (component, index) {
+    if (index === 0) { //鎶婂井淇℃祻瑙堝櫒閲孶A鐨剋ifi鎴�4G绛夌綉缁滄浛鎹㈡垚绌�,涓嶇劧鍒囨崲缃戠粶浼欼D涓嶄竴鏍�
       return component.value.replace(/\bNetType\/\w+\b/, '');
     }
     return component.value;
   })
-  //console.log(values)  //使用的浏览器信息npm 
-  // 生成最终id
+  //console.log(values)  //浣跨敤鐨勬祻瑙堝櫒淇℃伅npm
+  // 鐢熸垚鏈�缁坕d
   let port = window.location.port;
-  console.log(port);
   const fingerPrint = Fingerprint2.x64hash128(values.join(port), 31)
   Vue.prototype.$browserId = fingerPrint;
-  console.log("唯一标识码:" + fingerPrint);
+  console.log("娴忚鍣� ID: " + fingerPrint);
 });
 
 Vue.use(VueClipboard);
 Vue.use(ElementUI);
 Vue.use(VueCookies);
-Vue.prototype.$axios = axios;
+Vue.use(VueClipboards);
+
 Vue.prototype.$notify = Notification;
+Vue.use(Contextmenu);
+Vue.use(VCharts);
 
-axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : "";
+axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : (window.baseUrl ? window.baseUrl : "");
+axios.defaults.withCredentials = true;
+// api 杩斿洖401鑷姩鍥炵櫥闄嗛〉闈�
+axios.interceptors.response.use((response) => {
+  // 瀵瑰搷搴旀暟鎹仛鐐逛粈涔�
+  let token = response.headers["access-token"];
+  if (token) {
+    userService.setToken(token)
+  }
+  return response;
+}, (error) => {
+  // 瀵瑰搷搴旈敊璇仛鐐逛粈涔�
+  if (error.response.status === 401) {
+    console.log("Received 401 Response")
+    router.push('/login');
+  }
+  return Promise.reject(error);
+});
+axios.interceptors.request.use(
+  config => {
+    if (userService.getToken() != null && config.url !== "/api/user/login") {
+      config.headers['access-token'] = `${userService.getToken()}`;
+    }
+    return config;
+  },
+  error => {
+    return Promise.reject(error);
+  }
+);
 
-Vue.prototype.$cookies.config(60*30);
-
+Vue.prototype.$axios = axios;
+Vue.prototype.$cookies.config(60 * 30);
 
 new Vue({
-	router: router,
-	render: h => h(App),
+  router: router,
+  render: h => h(App),
 }).$mount('#app')

--
Gitblit v1.8.0