From 7b8e954555be83b4d4d1342be6c2a258cbe1c262 Mon Sep 17 00:00:00 2001 From: Yer <17633066053@163.com> Date: Tue, 9 May 2023 18:12:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20request=20=E6=B8=85=E7=A9=BA?= =?UTF-8?q?=E7=BC=93=E5=AD=98=20uuid=E4=B8=A2=E5=A4=B1=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/request.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/utils/request.js b/utils/request.js index 65393ae..60e6767 100644 --- a/utils/request.js +++ b/utils/request.js @@ -53,12 +53,19 @@ function cleanStorage() { let http = new Request(); -http.setConfig((config) => { - // 没有uuid创建 +/** + * 创建uuid方法 + */ +const createUuid = () => { if (!storage.getUuid()) { storage.setUuid(uuid.v1()); + console.log("uuid", storage.getUuid()); } +} + +http.setConfig((config) => { + createUuid(); /* 设置全局配置 */ config.baseURL = api.buyer; config.header = { @@ -105,9 +112,10 @@ http.interceptors.request.use( } + createUuid(); config.header = { ...config.header, - uuid: storage.getUuid() || uuid.v1(), + uuid: storage.getUuid() }; return config; },