flat: 优化
This commit is contained in:
@@ -26,6 +26,10 @@ const needToEncrypt = [
|
||||
*/
|
||||
export async function createRequestWithCache(url, data = {}, method = 'GET', loading = false, headers = {},
|
||||
onCacheLoad = null) {
|
||||
// 是分页接口的话, 只缓存第一页的数据
|
||||
if (data.current && data.current > 1) {
|
||||
return createRequest(url, data, method, loading, headers);
|
||||
}
|
||||
const cacheKey = `${method.toUpperCase()}:${url}:${JSON.stringify(data)}`;
|
||||
|
||||
baseDB.getDB().then(async (dbHelper) => {
|
||||
@@ -77,13 +81,16 @@ export function createRequest(url, data = {}, method = 'GET', loading = false, h
|
||||
mask: true
|
||||
})
|
||||
}
|
||||
let Authorization = ''
|
||||
if (useUserStore().token) {
|
||||
Authorization = `${useUserStore().token}`
|
||||
}
|
||||
let header = {
|
||||
...headers
|
||||
};
|
||||
const userStore = useUserStore();
|
||||
const token = userStore.token;
|
||||
|
||||
const header = headers || {};
|
||||
header["Authorization"] = encodeURIComponent(Authorization);
|
||||
if (token) {
|
||||
// 确保 Authorization 不会被覆盖,且进行编码
|
||||
header["Authorization"] = encodeURIComponent(token);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// 检查当前请求是否需要加密
|
||||
|
||||
Reference in New Issue
Block a user