|
@@ -7,6 +7,7 @@ import store from "./store";
|
|
|
import globalVuePlugins from "./plugins/globalVuePlugins";
|
|
|
import GLOBAL from "./config";
|
|
|
import { jsonBigNumberToString } from "./plugins/utils";
|
|
|
+// import { getAuthorisation } from "./plugins/crypto";
|
|
|
|
|
|
// https://github.com/RobinCK/vue-ls
|
|
|
import VueLocalStorage from "vue-ls";
|
|
@@ -26,17 +27,6 @@ router.beforeEach((to, from, next) => {
|
|
|
const token = Vue.ls.get("token");
|
|
|
if (to.meta.noRequire) {
|
|
|
next();
|
|
|
- // 不需要登录的页面
|
|
|
- // if (token) {
|
|
|
- // // 当前状态是已登录
|
|
|
- // ElementUI.Notice.info({
|
|
|
- // title: "您已经登录,已自动跳转到主页",
|
|
|
- // duration: 5
|
|
|
- // });
|
|
|
- // next({ name: "Home" });
|
|
|
- // } else {
|
|
|
-
|
|
|
- // }
|
|
|
} else {
|
|
|
// 需要登录的路由
|
|
|
if (token) {
|
|
@@ -60,6 +50,8 @@ axios.defaults.transformResponse = [
|
|
|
return JSON.parse(jsonBigNumberToString(data));
|
|
|
}
|
|
|
];
|
|
|
+// 设置延迟时效
|
|
|
+axios.defaults.timeout = GLOBAL.timeout;
|
|
|
axios.interceptors.request.use(
|
|
|
config => {
|
|
|
// 显示loading提示
|
|
@@ -72,19 +64,27 @@ axios.interceptors.request.use(
|
|
|
}
|
|
|
queue.push(1);
|
|
|
|
|
|
- // 为请求地址添加全局domain
|
|
|
- if (config.url.indexOf("http://") < 0) {
|
|
|
- config.url = GLOBAL.domain + config.url;
|
|
|
- }
|
|
|
-
|
|
|
- // 为请求头添加token信息
|
|
|
+ // 为请求头添加鉴权信息
|
|
|
let token = Vue.ls.get("token");
|
|
|
if (token) {
|
|
|
+ // 新版鉴权 to open
|
|
|
+ // const userId = Vue.ls.get("user").id;
|
|
|
+ // const { Authorization, timestamp } = getAuthorisation(
|
|
|
+ // {
|
|
|
+ // token: token,
|
|
|
+ // account: userId,
|
|
|
+ // uri: config.url,
|
|
|
+ // method: config.method
|
|
|
+ // },
|
|
|
+ // "token"
|
|
|
+ // );
|
|
|
+ // config.headers["Authorization"] = Authorization;
|
|
|
+ // config.headers["time"] = timestamp;
|
|
|
+ // config.headers["deviceId"] = userId;
|
|
|
+ // config.headers["domain"] = window.location.origin;
|
|
|
+ // config.headers["platform"] = "print-web";
|
|
|
config.headers["token"] = token;
|
|
|
}
|
|
|
-
|
|
|
- // 设置延迟时效
|
|
|
- config.timeout = GLOBAL.timeout;
|
|
|
return config;
|
|
|
},
|
|
|
error => {
|