|
@@ -10,10 +10,16 @@ import router from '@/router';
|
|
|
import { initSyncTime, fetchTime } from './syncServerTime';
|
|
|
import { cookie } from '@/utils/tool';
|
|
|
|
|
|
-if (!cookie.get('deviceId')) {
|
|
|
- cookie.set('deviceId', MD5(Math.random() + '-' + Date.now()));
|
|
|
+function getDeviceId() {
|
|
|
+ let deviceId = cookie.get('deviceId');
|
|
|
+ if (deviceId) return deviceId;
|
|
|
+
|
|
|
+ if (!deviceId) {
|
|
|
+ deviceId = MD5(Math.random() + '-' + Date.now());
|
|
|
+ cookie.set('deviceId', deviceId);
|
|
|
+ return deviceId;
|
|
|
+ }
|
|
|
}
|
|
|
-const DEVICE_ID = cookie.get('deviceId');
|
|
|
|
|
|
function setAuth(config) {
|
|
|
let userSession = sessionStorage.getItem('user');
|
|
@@ -144,7 +150,7 @@ function createRequest(service) {
|
|
|
const env = import.meta.env;
|
|
|
let headers = {
|
|
|
'platform': 'WEB',
|
|
|
- 'deviceId': DEVICE_ID,
|
|
|
+ 'deviceId': getDeviceId(),
|
|
|
...(config.headers || {}),
|
|
|
'Content-Type': get(
|
|
|
config,
|