Procházet zdrojové kódy

fix: 修改token字段

carver před 2 roky
rodič
revize
88af08e3a4

+ 3 - 4
antbuilder/core/utils/request.js

@@ -35,7 +35,6 @@ export function _request({
 		}
 		// eslint-disable-next-line no-undef
 		const app = getApp();
-		const token = my.getStorageSync({ key: "YWT_TOKEN" });
 		my.request({
 			url: url.startsWith("http") ? url : joinUrl(host, url),
 			method,
@@ -44,7 +43,7 @@ export function _request({
 				"content-type": "application/x-www-form-urlencoded",
 				ticket: app.globalData.ticketData.ticket, // todo test
 				appId: app.globalData.appId, // todo test
-				ywtToken: token.data || "",
+				Authorization: app.globalData.ywtToken || "",
 				...headers,
 			},
 			dataType: "json",
@@ -103,13 +102,13 @@ export function _ywtRequest({
 		if (isShowLoadig) {
 			my.showLoading();
 		}
-		const token = my.getStorageSync({ key: "YWT_TOKEN" });
+		const app = getApp();
 		my.request({
 			url: url.startsWith("http") ? url : joinUrl(ywtRequestUrl, url),
 			method,
 			data,
 			headers: {
-				ywtToken: token.data || "",
+				Authorization: app.globalData.ywtToken || "",
 				...headers,
 			},
 			dataType: "json",

+ 2 - 1
antbuilder/core/utils/service.js

@@ -82,8 +82,9 @@ export async function checkUserInfo() {
 		if (!ywtErr && ywtResult && ywtResult.token) {
 			my.setStorageSync({
 				key: "YWT_TOKEN",
-				data: ywtResult.token,
+				data: "Bearer " + ywtResult.token,
 			});
+			app.globalData.ywtToken = "Bearer " + ywtResult.token;
 		}
 	}
 	return [null, res];