Skip to content

Commit 6ade283

Browse files
authored
获取价格接口添加token (#160)
* 获取价格接口添加token * 修改version
1 parent 413764e commit 6ade283

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

bizyui/js/model_price.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getCookie, getIsServerMode } from "./subassembly/tools.js";
12
/**
23
* 货币类型枚举,包含徽章配置信息
34
*/
@@ -219,14 +220,30 @@ export async function fetchNodePrice(model, nodeInputs) {
219220
if (!nodeInputs) {
220221
throw new Error("节点输入信息为空,无法获取价格");
221222
}
222-
223+
const isServerMode = await getIsServerMode();
224+
let token = null;
225+
if (isServerMode) {
226+
// 服务器模式,需要token
227+
token = await new Promise((resolve) => {
228+
const checkToken = () => {
229+
const token = getCookie("bizy_token");
230+
if (token) {
231+
clearInterval(timer);
232+
resolve(token);
233+
}
234+
};
235+
const timer = setInterval(checkToken, 300);
236+
checkToken(); // 立即执行一次检查
237+
});
238+
}
223239
// 调用bizyengine价格查询接口
224240
const response = await fetch(
225241
`/bizyair/trd_api_pricing?model=${encodeURIComponent(model)}`,
226242
{
227243
method: "POST",
228244
headers: {
229-
"Content-Type": "application/json"
245+
"Content-Type": "application/json",
246+
"Authorization": token
230247
},
231248
body: JSON.stringify(nodeInputs),
232249
}

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.87
1+
1.2.88

0 commit comments

Comments
 (0)