@cpzxrobot/sdk 1.0.34 → 1.0.35
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.
- package/dist/index.js +32 -3
- package/index.ts +32 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -222,12 +222,41 @@ class Cpzxrobot {
|
|
|
222
222
|
if (token) {
|
|
223
223
|
this.token = token;
|
|
224
224
|
this.initAxios("https://www.cpzxrobot.com/");
|
|
225
|
-
this.
|
|
225
|
+
this.axios.get("/api/v1/user/auth").then((res) => {
|
|
226
|
+
if (res.data.Error) {
|
|
227
|
+
window.location.href = "/login.html?error=" + res.data.Error;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.resolveReady(this.axios);
|
|
231
|
+
});
|
|
226
232
|
return;
|
|
227
233
|
}
|
|
228
234
|
else {
|
|
229
|
-
//
|
|
230
|
-
window.location.href
|
|
235
|
+
//if url has access_token and app_code, use it
|
|
236
|
+
const url = new URL(window.location.href);
|
|
237
|
+
const access_token = url.searchParams.get("access_token");
|
|
238
|
+
const app_code = url.searchParams.get("app_code");
|
|
239
|
+
if (access_token && app_code) {
|
|
240
|
+
this.initAxios("https://www.cpzxrobot.com/");
|
|
241
|
+
this.axios
|
|
242
|
+
.post("/api/v1/user/auth", {
|
|
243
|
+
appCode: app_code,
|
|
244
|
+
auth: access_token,
|
|
245
|
+
})
|
|
246
|
+
.then((res) => {
|
|
247
|
+
if (res.data.Error) {
|
|
248
|
+
window.location.href = "/login.html?error=" + res.data.Error;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this.token = "Bearer " + res.data.token;
|
|
252
|
+
this.resolveReady(this.axios);
|
|
253
|
+
});
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
//jump to miniapp login page
|
|
258
|
+
window.location.href = "/login.html";
|
|
259
|
+
}
|
|
231
260
|
}
|
|
232
261
|
}
|
|
233
262
|
else {
|
package/index.ts
CHANGED
|
@@ -257,11 +257,40 @@ export class Cpzxrobot {
|
|
|
257
257
|
if (token) {
|
|
258
258
|
this.token = token;
|
|
259
259
|
this.initAxios("https://www.cpzxrobot.com/");
|
|
260
|
-
this.
|
|
260
|
+
this.axios.get("/api/v1/user/auth").then((res) => {
|
|
261
|
+
if (res.data.Error) {
|
|
262
|
+
window.location.href = "/login.html?error=" + res.data.Error;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.resolveReady(this.axios);
|
|
266
|
+
});
|
|
261
267
|
return;
|
|
262
268
|
} else {
|
|
263
|
-
//
|
|
264
|
-
window.location.href
|
|
269
|
+
//if url has access_token and app_code, use it
|
|
270
|
+
const url = new URL(window.location.href);
|
|
271
|
+
const access_token = url.searchParams.get("access_token");
|
|
272
|
+
const app_code = url.searchParams.get("app_code");
|
|
273
|
+
if (access_token && app_code) {
|
|
274
|
+
this.initAxios("https://www.cpzxrobot.com/");
|
|
275
|
+
this.axios
|
|
276
|
+
.post("/api/v1/user/auth", {
|
|
277
|
+
appCode: app_code,
|
|
278
|
+
auth: access_token,
|
|
279
|
+
})
|
|
280
|
+
.then((res) => {
|
|
281
|
+
if (res.data.Error) {
|
|
282
|
+
window.location.href = "/login.html?error=" + res.data.Error;
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this.token = "Bearer " + res.data.token;
|
|
286
|
+
this.resolveReady(this.axios);
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}else{
|
|
290
|
+
//jump to miniapp login page
|
|
291
|
+
window.location.href = "/login.html";
|
|
292
|
+
}
|
|
293
|
+
|
|
265
294
|
}
|
|
266
295
|
} else {
|
|
267
296
|
this.initAxios(baseURL);
|