|
@@ -1,11 +1,12 @@
|
|
import Vue from "vue";
|
|
import Vue from "vue";
|
|
-import Store from "@/store";
|
|
|
|
|
|
+// import Store from "@/store";
|
|
import axios from "axios";
|
|
import axios from "axios";
|
|
import { loadProgressBar } from "axios-progress-bar";
|
|
import { loadProgressBar } from "axios-progress-bar";
|
|
import cachingGet from "./axiosCache";
|
|
import cachingGet from "./axiosCache";
|
|
import { notifyInvalidTokenThrottled } from "./axiosNotice";
|
|
import { notifyInvalidTokenThrottled } from "./axiosNotice";
|
|
import { getToken, removeToken } from "../auth/auth";
|
|
import { getToken, removeToken } from "../auth/auth";
|
|
import axiosRetry from "axios-retry";
|
|
import axiosRetry from "axios-retry";
|
|
|
|
+import { DEVICE_ID } from "@/constant/constants";
|
|
|
|
|
|
const PLATFORM = "web";
|
|
const PLATFORM = "web";
|
|
|
|
|
|
@@ -23,33 +24,33 @@ const cacheGetUrls = [];
|
|
const _axiosApp = axios.create(config);
|
|
const _axiosApp = axios.create(config);
|
|
axiosRetry(_axiosApp);
|
|
axiosRetry(_axiosApp);
|
|
|
|
|
|
-function gToken(uri, token) {
|
|
|
|
- const now = Date.now();
|
|
|
|
- // console.log(`${uri}&${now}&${token}`);
|
|
|
|
- const a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
- let randomStr = "";
|
|
|
|
- for (let i = 0; i < 6; i++) {
|
|
|
|
- const idx = Math.round(Math.random() * 100) % a.length;
|
|
|
|
- randomStr += a[idx];
|
|
|
|
- }
|
|
|
|
|
|
+// function gToken(uri, token) {
|
|
|
|
+// const now = Date.now();
|
|
|
|
+// // console.log(`${uri}&${now}&${token}`);
|
|
|
|
+// const a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
+// let randomStr = "";
|
|
|
|
+// for (let i = 0; i < 6; i++) {
|
|
|
|
+// const idx = Math.round(Math.random() * 100) % a.length;
|
|
|
|
+// randomStr += a[idx];
|
|
|
|
+// }
|
|
|
|
|
|
- const Authorization = `Token ${randomStr}${btoa(
|
|
|
|
- uri + "&" + now + "&" + token
|
|
|
|
- )}`;
|
|
|
|
|
|
+// const Authorization = `Token ${randomStr}${btoa(
|
|
|
|
+// uri + "&" + now + "&" + token
|
|
|
|
+// )}`;
|
|
|
|
|
|
- return Authorization;
|
|
|
|
-}
|
|
|
|
|
|
+// return Authorization;
|
|
|
|
+// }
|
|
|
|
|
|
_axiosApp.interceptors.request.use(
|
|
_axiosApp.interceptors.request.use(
|
|
function (config) {
|
|
function (config) {
|
|
const wk_token = getToken();
|
|
const wk_token = getToken();
|
|
if (wk_token) {
|
|
if (wk_token) {
|
|
- config.headers.common["Authorization"] = gToken(config.url, wk_token);
|
|
|
|
- config.headers.common["deviceId"] = Store.state.user.deviceId;
|
|
|
|
- config.headers.common["domain"] = Store.state.user.domain;
|
|
|
|
|
|
+ // config.headers.common["Authorization"] = gToken(config.url, wk_token);
|
|
|
|
+ config.headers.common["Authorization"] = wk_token;
|
|
}
|
|
}
|
|
config.headers.common["platform"] = PLATFORM;
|
|
config.headers.common["platform"] = PLATFORM;
|
|
- config.headers.common["deviceId"] = Store.state.user.deviceId;
|
|
|
|
|
|
+ config.headers.common["deviceId"] = DEVICE_ID;
|
|
|
|
+ config.headers.common["time"] = Date.now();
|
|
return config;
|
|
return config;
|
|
},
|
|
},
|
|
function (error) {
|
|
function (error) {
|
|
@@ -105,10 +106,10 @@ _axiosApp.interceptors.response.use(
|
|
|
|
|
|
if (status != 200) {
|
|
if (status != 200) {
|
|
const data = error.response.data;
|
|
const data = error.response.data;
|
|
- if (data && data.desc) {
|
|
|
|
|
|
+ if (data && data.message) {
|
|
Vue.prototype.$notify({
|
|
Vue.prototype.$notify({
|
|
showClose: true,
|
|
showClose: true,
|
|
- message: data.desc,
|
|
|
|
|
|
+ message: data.message,
|
|
type: "error",
|
|
type: "error",
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|