eprolo-cli 1.0.67 → 1.0.69

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 +18 -6
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -96,23 +96,35 @@ async function postJsonWithRetry(url, body, config) {
96
96
  refreshToken: config.refreshToken
97
97
  });
98
98
 
99
- if (refreshRes.data.code == 0 && refreshRes.data.accessToken) {
99
+ if (refreshRes.data.code == 0 && refreshRes.data.data.accessToken) {
100
100
  // 更新凭据文件
101
- config.accessToken = refreshRes.data.accessToken;
102
- if (refreshRes.data.account) config.account = refreshRes.data.account;
101
+ config.accessToken = refreshRes.data.data.accessToken;
102
+ if (refreshRes.data.data.account) config.account = refreshRes.data.data.account;
103
103
  writeConfig(config);
104
104
 
105
105
  // 用新 token 重试
106
106
  headers["accessToken"] = `${config.accessToken}`;
107
107
  result = await postJson(url, body, headers);
108
- } else {
108
+ }else if (refreshRes.data.code == 400) {
109
+ const res = await postJson(LOGIN_API, { openApiKey: config.openApiKey });
110
+ if (res.data.code != 0) {
111
+ const err = new Error(`HTTP ${res.statusCode}`);
112
+ err.response = res.data.data.msg;
113
+ throw err;
114
+ }
115
+ res.data.data.openApiKey = config.openApiKey;
116
+ writeConfig(res.data.data);
117
+ headers["accessToken"] = `${res.data.data.accessToken}`;
118
+ result = await postJson(url, body, headers);
119
+ }
120
+ else {
109
121
  const err = new Error("Token 刷新失败,请重新登录授权");
110
122
  err.response = refreshRes.data;
111
123
  throw err;
112
124
  }
113
125
  }else if (result.data.code != 0) {
114
126
  const err = new Error(`HTTP ${result.statusCode}`);
115
- err.response = 6666;
127
+ err.response = result.data.data.msg;
116
128
  throw err;
117
129
  }
118
130
 
@@ -138,7 +150,7 @@ async function login(argv) {
138
150
  }));
139
151
  process.exit(1);
140
152
  }
141
-
153
+ res.data.data.openApiKey = userCode;
142
154
  // const { account, accessToken, accountId, shopId } = res.data;
143
155
  // const config = { account, accessToken, defaultShop, accountId, shopId, version: 1 };
144
156
  writeConfig(res.data.data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
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"