@cpzxrobot/sdk 1.3.34 → 1.3.36

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/device_filter.ts CHANGED
@@ -370,8 +370,9 @@ export abstract class DeviceFilter<T extends { id: number }> {
370
370
  return p
371
371
  .then((farm) => {
372
372
  console.log("type", type);
373
- return this.context.axios.get("/api/v1/device/list?rand=" + rand, {
373
+ return this.context.axios.get("/api/v1/device/list", {
374
374
  params: {
375
+ rand: rand,
375
376
  location: farm,
376
377
  type: options?.type || this.deviceType,
377
378
  unit: options?.unit,
@@ -314,8 +314,9 @@ class DeviceFilter {
314
314
  return p
315
315
  .then((farm) => {
316
316
  console.log("type", type);
317
- return this.context.axios.get("/api/v1/device/list?rand=" + rand, {
317
+ return this.context.axios.get("/api/v1/device/list", {
318
318
  params: {
319
+ rand: rand,
319
320
  location: farm,
320
321
  type: (options === null || options === void 0 ? void 0 : options.type) || this.deviceType,
321
322
  unit: options === null || options === void 0 ? void 0 : options.unit,
package/dist/index.js CHANGED
@@ -162,6 +162,9 @@ class Cpzxrobot {
162
162
  openMiniApp(url) {
163
163
  this.platform.jumpToMiniApp(url);
164
164
  }
165
+ scanQrcode() {
166
+ return this.platform.scanQrcode();
167
+ }
165
168
  setAuth(auth, args) {
166
169
  var logger = (msg, level) => {
167
170
  switch (level) {
@@ -88,6 +88,8 @@ class WebPlatform {
88
88
  ;
89
89
  processQueryParams(url, config) {
90
90
  if (config && config.params) {
91
+ // 检查URL是否已包含查询参数
92
+ const hasExistingParams = url.includes('?');
91
93
  const flattenParams = (params, prefix = '') => {
92
94
  const result = {};
93
95
  Object.keys(params).forEach(key => {
@@ -103,7 +105,9 @@ class WebPlatform {
103
105
  return result;
104
106
  };
105
107
  const flattened = flattenParams(config.params);
106
- url += "?" + new URLSearchParams(flattened).toString();
108
+ const newParams = new URLSearchParams(flattened).toString();
109
+ // 根据是否已有参数决定使用?还是&连接
110
+ url += (hasExistingParams ? '&' : '?') + newParams;
107
111
  delete config.params;
108
112
  }
109
113
  return url;
package/index.ts CHANGED
@@ -175,6 +175,10 @@ export class Cpzxrobot {
175
175
  this.platform.jumpToMiniApp(url);
176
176
  }
177
177
 
178
+ scanQrcode() {
179
+ return this.platform.scanQrcode();
180
+ }
181
+
178
182
  setAuth(auth: string, args: {
179
183
  baseURL: string;
180
184
  verbose: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.34",
3
+ "version": "1.3.36",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -428,7 +428,7 @@ class Cpzxrobot {
428
428
  // setTitle: (title: string) => void;
429
429
  // saveBase64: (base64: string, filename: string) => void;
430
430
  // saveBlob: (blob: Blob, filename: string) => void;
431
- // scanQrcode: () => Promise<string>;
431
+ scanQrcode: () => Promise<string>;
432
432
  // vibrate: (time?: number) => void;
433
433
  // reloadGroup: (key: string) => void;
434
434
  // getGeo: () => Promise<{ lat: number; lng: number }>;
package/web_platform.ts CHANGED
@@ -96,6 +96,9 @@ export class WebPlatform implements PlatformInterface {
96
96
 
97
97
  processQueryParams(url: string, config?: any) {
98
98
  if (config && config.params) {
99
+ // 检查URL是否已包含查询参数
100
+ const hasExistingParams = url.includes('?');
101
+
99
102
  const flattenParams = (params: any, prefix = '') => {
100
103
  const result: Record<string, string> = {};
101
104
  Object.keys(params).forEach(key => {
@@ -109,8 +112,12 @@ export class WebPlatform implements PlatformInterface {
109
112
  });
110
113
  return result;
111
114
  };
115
+
112
116
  const flattened = flattenParams(config.params);
113
- url += "?" + new URLSearchParams(flattened).toString();
117
+ const newParams = new URLSearchParams(flattened).toString();
118
+
119
+ // 根据是否已有参数决定使用?还是&连接
120
+ url += (hasExistingParams ? '&' : '?') + newParams;
114
121
  delete config.params;
115
122
  }
116
123
  return url;