eprolo-cli 1.0.81 → 1.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/eprolo-cli.js +9 -20
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -100,7 +100,7 @@ async function postJsonWithRetry(url, body, config, method = "POST") {
100
100
  body.sign = config.accessToken;
101
101
  }
102
102
  let result = await postJson(url, body, headers, method);
103
- if (result.data.code == 400) {
103
+ if (result.data.code == '-1') {
104
104
  // 刷新 token
105
105
  const refreshRes = await postJson(REFRESH_API, {},{
106
106
  refreshToken: config.refreshToken
@@ -108,25 +108,14 @@ async function postJsonWithRetry(url, body, config, method = "POST") {
108
108
 
109
109
  if (refreshRes.data.code == 0 && refreshRes.data.data.accessToken) {
110
110
  // 更新凭据文件
111
- config.accessToken = refreshRes.data.data.accessToken;
112
- if (refreshRes.data.data.account) config.account = refreshRes.data.data.account;
113
- writeConfig(config);
111
+ body.timestamp = data.data.timestamp;
112
+ body.sign = data.data.accessToken;
113
+ writeConfig(data.data);
114
114
 
115
115
  // 用新 token 重试
116
- headers["accessToken"] = `${config.accessToken}`;
117
- result = await postJson(url, body, headers);
118
- }else if (refreshRes.data.code == 400) {
119
- const res = await postJson(LOGIN_API, { openApiKey: config.openApiKey });
120
- if (res.data.code != 0) {
121
- const err = new Error(`HTTP ${res.statusCode}`);
122
- err.response = res.data.data.msg;
123
- throw err;
124
- }
125
- res.data.data.openApiKey = config.openApiKey;
126
- writeConfig(res.data.data);
127
- headers["accessToken"] = `${res.data.data.accessToken}`;
128
- result = await postJson(url, body, headers);
129
- }
116
+ headers["apiKey"] = `${config.apiKey}`;
117
+ result = await postJson(url, body, headers,method);
118
+ }
130
119
  else {
131
120
  const err = new Error("Token 刷新失败,请重新登录授权");
132
121
  err.response = refreshRes.data;
@@ -242,7 +231,7 @@ async function insertProduct(argv) {
242
231
  process.exit(0);
243
232
  }
244
233
  async function addOrder(argv) {
245
- console.log('addOrder', JSON.stringify(argv, null, 2));
234
+ console.log('addOrder', argv);
246
235
  const config = readConfig();
247
236
  if (!argv) {
248
237
  console.error(JSON.stringify({ success: false, errorMessage: "缺少订单 JSON 字符串" }));
@@ -331,7 +320,7 @@ async function main() {
331
320
  return;
332
321
  }
333
322
  if (argv[0] === "add-order") {
334
- await addOrder(argv.slice(1));
323
+ await addOrder(argv[1]);
335
324
  return;
336
325
  }
337
326
  printHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "description": "CLI for Dianxiaobao ICBU AI publishing, authorization profile management, task submission, and task status checks.",
5
5
  "bin": {
6
6
  "eprolo": "bin/eprolo-cli.js"