2020-10-10 17:33:29 +08:00
|
|
|
import Vue from 'vue';
|
|
|
|
import App from './App.vue';
|
2023-03-15 19:05:56 +08:00
|
|
|
|
2020-10-10 17:33:29 +08:00
|
|
|
Vue.config.productionTip = false;
|
|
|
|
import ElementUI 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';
|
2022-10-20 18:03:40 +08:00
|
|
|
import VCharts from 'v-charts';
|
2020-10-26 11:40:46 +08:00
|
|
|
|
2021-01-21 20:58:11 +08:00
|
|
|
import VueClipboard from 'vue-clipboard2';
|
2023-03-15 19:05:56 +08:00
|
|
|
import {Notification} from 'element-ui';
|
2021-01-21 20:58:11 +08:00
|
|
|
import Fingerprint2 from 'fingerprintjs2';
|
2021-03-30 18:46:34 +08:00
|
|
|
import VueClipboards from 'vue-clipboards';
|
2022-01-05 15:23:14 +08:00
|
|
|
import Contextmenu from "vue-contextmenujs"
|
2023-03-15 19:05:56 +08:00
|
|
|
import userService from "./components/service/UserService"
|
2021-03-30 18:46:34 +08:00
|
|
|
|
2021-01-20 20:27:25 +08:00
|
|
|
|
2021-01-27 15:24:28 +08:00
|
|
|
// 生成唯一ID
|
2023-03-15 19:05:56 +08:00
|
|
|
Fingerprint2.get(function (components) {
|
|
|
|
const values = components.map(function (component, index) {
|
2021-01-27 15:24:28 +08:00
|
|
|
if (index === 0) { //把微信浏览器里UA的wifi或4G等网络替换成空,不然切换网络会ID不一样
|
2021-01-21 20:58:11 +08:00
|
|
|
return component.value.replace(/\bNetType\/\w+\b/, '');
|
|
|
|
}
|
|
|
|
return component.value;
|
|
|
|
})
|
2021-02-25 18:10:02 +08:00
|
|
|
//console.log(values) //使用的浏览器信息npm
|
2021-01-27 15:24:28 +08:00
|
|
|
// 生成最终id
|
2021-01-21 20:58:11 +08:00
|
|
|
let port = window.location.port;
|
|
|
|
console.log(port);
|
|
|
|
const fingerPrint = Fingerprint2.x64hash128(values.join(port), 31)
|
|
|
|
Vue.prototype.$browserId = fingerPrint;
|
2021-01-27 15:24:28 +08:00
|
|
|
console.log("唯一标识码:" + fingerPrint);
|
2021-01-21 20:58:11 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
Vue.use(VueClipboard);
|
2020-10-10 17:33:29 +08:00
|
|
|
Vue.use(ElementUI);
|
|
|
|
Vue.use(VueCookies);
|
2021-03-30 18:46:34 +08:00
|
|
|
Vue.use(VueClipboards);
|
2023-03-05 09:53:26 +08:00
|
|
|
|
2021-01-20 20:27:25 +08:00
|
|
|
Vue.prototype.$notify = Notification;
|
2022-01-05 15:23:14 +08:00
|
|
|
Vue.use(Contextmenu);
|
2022-10-20 18:03:40 +08:00
|
|
|
Vue.use(VCharts);
|
2020-10-10 17:33:29 +08:00
|
|
|
|
2023-03-15 19:05:56 +08:00
|
|
|
axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : (window.baseUrl ? window.baseUrl : "");
|
2023-03-05 09:53:26 +08:00
|
|
|
axios.defaults.withCredentials = true;
|
2021-04-14 16:33:10 +08:00
|
|
|
// api 返回401自动回登陆页面
|
2023-03-15 19:05:56 +08:00
|
|
|
axios.interceptors.response.use((response) => {
|
2021-04-19 11:24:03 +08:00
|
|
|
// 对响应数据做点什么
|
2023-03-15 19:05:56 +08:00
|
|
|
let token = response.headers["access-token"];
|
|
|
|
if (token) {
|
|
|
|
userService.setToken(token)
|
|
|
|
}
|
2021-04-19 11:24:03 +08:00
|
|
|
return response;
|
2023-03-15 19:05:56 +08:00
|
|
|
}, (error) => {
|
2021-04-19 11:24:03 +08:00
|
|
|
// 对响应错误做点什么
|
|
|
|
if (error.response.status === 401) {
|
2021-06-22 11:32:30 +08:00
|
|
|
console.log("Received 401 Response")
|
2021-04-19 11:24:03 +08:00
|
|
|
router.push('/login');
|
|
|
|
}
|
|
|
|
return Promise.reject(error);
|
|
|
|
});
|
2023-03-15 19:05:56 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-03-05 09:53:26 +08:00
|
|
|
Vue.prototype.$axios = axios;
|
2020-10-10 17:33:29 +08:00
|
|
|
Vue.prototype.$cookies.config(60*30);
|
|
|
|
|
|
|
|
new Vue({
|
2023-03-15 19:05:56 +08:00
|
|
|
router: router,
|
|
|
|
render: h => h(App),
|
2020-10-10 17:33:29 +08:00
|
|
|
}).$mount('#app')
|