@cpzxrobot/sdk 1.2.93 → 1.2.95

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 CHANGED
@@ -101,12 +101,6 @@ class Cpzxrobot {
101
101
  inApp() {
102
102
  return this.mode === "miniapp_in_app";
103
103
  }
104
- initAxios(baseURL) {
105
- if (this.mode !== "miniapp_in_app") {
106
- // @ts-ignore
107
- this.axios = instance;
108
- }
109
- }
110
104
  _saveBlobAsBase64(blob, filename) {
111
105
  return this.platform.saveBlob(blob, filename);
112
106
  }
@@ -130,6 +124,7 @@ class Cpzxrobot {
130
124
  }
131
125
  else {
132
126
  this.mode = "miniapp_in_web";
127
+ baseURL = "https://www.cpzxrobot.com";
133
128
  }
134
129
  this.platform = new web_platform_1.WebPlatform(this.token, this.appCode, baseURL, initSelectedFactory, initSelectedUnit);
135
130
  }
@@ -181,7 +176,6 @@ class Cpzxrobot {
181
176
  };
182
177
  if (this.mode === "miniapp_in_app") {
183
178
  this.platformReady.then(() => {
184
- this.initAxios(args.baseURL);
185
179
  logger("shzx is ready", "info");
186
180
  this.resolveReady(this.axios);
187
181
  });
@@ -194,7 +188,6 @@ class Cpzxrobot {
194
188
  if (token) {
195
189
  logger(`found token(${token}) in localstorage`, "debug");
196
190
  this.token = token;
197
- this.initAxios("https://www.cpzxrobot.com");
198
191
  this.axios.get("/api/v1/user/auth").then((res) => {
199
192
  if (res.data.Error) {
200
193
  window.location.href = "/login.html?error=" + res.data.Error;
@@ -248,7 +241,6 @@ class Cpzxrobot {
248
241
  const app_code = url.searchParams.get("app_code");
249
242
  if (access_token && app_code) {
250
243
  logger(`found access_token(${access_token}) and app_code(${app_code}) in url`, "debug");
251
- this.initAxios(args.baseURL);
252
244
  this.axios
253
245
  .post("/api/v1/user/auth", {
254
246
  appCode: app_code,
@@ -278,7 +270,6 @@ class Cpzxrobot {
278
270
  }
279
271
  else {
280
272
  logger(`sdk under ${this.mode} mode`, "debug");
281
- this.initAxios(args.baseURL);
282
273
  this.auth = auth;
283
274
  if (this.auth.startsWith("Bearer ")) {
284
275
  this.token = auth;
@@ -197,13 +197,13 @@ class WebPlatform {
197
197
  };
198
198
  }
199
199
  ready() {
200
- throw new Error("Method not implemented.");
200
+ return Promise.resolve(true);
201
201
  }
202
202
  getSelectedFarmFromMiniApp() {
203
- throw new Error("Method not available in web platform");
203
+ return Promise.resolve(this._selectedFarm);
204
204
  }
205
205
  getSelectedUnitFromMiniApp() {
206
- throw new Error("Method not available in web platform");
206
+ return Promise.resolve(this._selectedUnit);
207
207
  }
208
208
  jumpToMiniApp(url) {
209
209
  window.location.href = url;
package/index.ts CHANGED
@@ -102,14 +102,6 @@ export class Cpzxrobot {
102
102
  return this.mode === "miniapp_in_app";
103
103
  }
104
104
 
105
- initAxios(baseURL: string) {
106
- if (this.mode !== "miniapp_in_app") {
107
-
108
- // @ts-ignore
109
- this.axios = instance;
110
- }
111
- }
112
-
113
105
  _saveBlobAsBase64(blob: Blob, filename: string): Promise<void> {
114
106
  return this.platform.saveBlob(blob, filename);
115
107
  }
@@ -135,6 +127,7 @@ export class Cpzxrobot {
135
127
  );
136
128
  } else {
137
129
  this.mode = "miniapp_in_web";
130
+ baseURL = "https://www.cpzxrobot.com"
138
131
  }
139
132
  this.platform = new WebPlatform(this.token, this.appCode, baseURL, initSelectedFactory, initSelectedUnit);
140
133
  }
@@ -196,7 +189,6 @@ export class Cpzxrobot {
196
189
  };
197
190
  if (this.mode === "miniapp_in_app") {
198
191
  this.platformReady.then(() => {
199
- this.initAxios(args.baseURL);
200
192
  logger("shzx is ready", "info");
201
193
  this.resolveReady(this.axios);
202
194
  });
@@ -208,7 +200,6 @@ export class Cpzxrobot {
208
200
  if (token) {
209
201
  logger(`found token(${token}) in localstorage`, "debug");
210
202
  this.token = token;
211
- this.initAxios("https://www.cpzxrobot.com");
212
203
  this.axios.get("/api/v1/user/auth").then((res) => {
213
204
  if (res.data.Error) {
214
205
  window.location.href = "/login.html?error=" + res.data.Error;
@@ -260,7 +251,6 @@ export class Cpzxrobot {
260
251
  const app_code = url.searchParams.get("app_code");
261
252
  if (access_token && app_code) {
262
253
  logger(`found access_token(${access_token}) and app_code(${app_code}) in url`, "debug");
263
- this.initAxios(args.baseURL);
264
254
  this.axios
265
255
  .post("/api/v1/user/auth", {
266
256
  appCode: app_code,
@@ -288,7 +278,6 @@ export class Cpzxrobot {
288
278
  }
289
279
  } else {
290
280
  logger(`sdk under ${this.mode} mode`, "debug");
291
- this.initAxios(args.baseURL);
292
281
  this.auth = auth;
293
282
  if (this.auth.startsWith("Bearer ")) {
294
283
  this.token = auth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.93",
3
+ "version": "1.2.95",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/web_platform.ts CHANGED
@@ -214,14 +214,14 @@ export class WebPlatform implements PlatformInterface {
214
214
  };
215
215
  }
216
216
  ready(): Promise<boolean> {
217
- throw new Error("Method not implemented.");
217
+ return Promise.resolve(true);
218
218
  }
219
219
  getSelectedFarmFromMiniApp(): Promise<any> {
220
- throw new Error("Method not available in web platform");
220
+ return Promise.resolve(this._selectedFarm);
221
221
  }
222
222
 
223
223
  getSelectedUnitFromMiniApp(): Promise<any> {
224
- throw new Error("Method not available in web platform");
224
+ return Promise.resolve(this._selectedUnit);
225
225
  }
226
226
 
227
227
  jumpToMiniApp(url: string): Promise<void> {