fix: 🐛 request 清空缓存 uuid丢失判断优化

master
Yer 2023-05-09 18:12:52 +08:00
parent b4f46ded2b
commit 7b8e954555
1 changed files with 11 additions and 3 deletions

View File

@ -53,12 +53,19 @@ function cleanStorage() {
let http = new Request(); let http = new Request();
http.setConfig((config) => { /**
// 没有uuid创建 * 创建uuid方法
*/
const createUuid = () => {
if (!storage.getUuid()) { if (!storage.getUuid()) {
storage.setUuid(uuid.v1()); storage.setUuid(uuid.v1());
console.log("uuid", storage.getUuid());
}
} }
http.setConfig((config) => {
createUuid();
/* 设置全局配置 */ /* 设置全局配置 */
config.baseURL = api.buyer; config.baseURL = api.buyer;
config.header = { config.header = {
@ -105,9 +112,10 @@ http.interceptors.request.use(
} }
createUuid();
config.header = { config.header = {
...config.header, ...config.header,
uuid: storage.getUuid() || uuid.v1(), uuid: storage.getUuid()
}; };
return config; return config;
}, },