提交 35669278 authored 作者: 钟是志's avatar 钟是志

修改鉴权代码, 让时间戳不再使用定时器获取

上级 6c05fb2d
......@@ -9,9 +9,8 @@ const isTest = getUrlInfo().test;
export function getHeaders(url = '') {
const token = getToken();
const currentInfo = getCurrentUser();
const timestamp = window.serviceCurrentDate || new Date().getTime();
const timestamp = new Date().getTime() + window.differenceBetweenServerAndClientTime;
const secretString = token + currentInfo.xgUserId + timestamp;
// const secretString = token + '112233' + timestamp;
const res = {
headers: {
......@@ -29,6 +28,7 @@ export function getHeaders(url = '') {
timestamp,
xgUserId: currentInfo.xgUserId,
typeString: currentInfo.typeString,
differenceBetweenServerAndClientTime: window.differenceBetweenServerAndClientTime,
},
);
}
......
import request from '@/webPublic/zyd_public/request/request';
import config from '@/config/config';
window.differenceBetweenServerAndClientTime = 0;
const getTime = () => {
return request(`${config.mockServer}/${config.gateWayUrl.zydxg}/InstructorConfigApi/getCurrentDate`, {
method: 'POST',
......@@ -11,10 +11,7 @@ const getTime = () => {
export async function queryCurrent() {
let t = await getTime();
if (t) {
window.serviceCurrentDate = t; // 服务器时间
setInterval(() => {
window.serviceCurrentDate += 1000;
}, 1000);
window.differenceBetweenServerAndClientTime = t - new Date().getTime(); // 服务器时间 与 客户端时间的差值
}
return request(`${config.mockServer}/${config.gateWayUrl.zydxg}/UserApi/queryCurrent`, {
method: 'POST',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论