@cpzxrobot/sdk 1.1.96 → 1.1.97

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_gateway.ts CHANGED
@@ -55,10 +55,23 @@ export class DeviceGateway extends Object {
55
55
  workshopId?: number;
56
56
  factoryId?: number;
57
57
  companyId?: number;
58
- }) => {
58
+ },params:any= undefined) => {
59
59
  let axios = await this.context.ready;
60
-
61
- return axios.post(`/api/v2/device/list`, condition).then((res) => {
60
+ var url = `/api/v2/device/list`;
61
+ if (params) {
62
+ //if params is string
63
+ if (typeof params === "string") {
64
+ url = `/api/v2/device/list?${params}`;
65
+ }
66
+ // if params is object
67
+ else {
68
+ url = `/api/v2/device/list?${Object.keys(params)
69
+ .map((key) => `${key}=${params[key]}`)
70
+ .join("&")}`;
71
+ }
72
+ }
73
+
74
+ return axios.post(url, condition).then((res) => {
62
75
  return res.data;
63
76
  });
64
77
  },
@@ -30,9 +30,22 @@ class DeviceGateway extends Object {
30
30
  return res.data;
31
31
  });
32
32
  },
33
- list: async (condition) => {
33
+ list: async (condition, params = undefined) => {
34
34
  let axios = await this.context.ready;
35
- return axios.post(`/api/v2/device/list`, condition).then((res) => {
35
+ var url = `/api/v2/device/list`;
36
+ if (params) {
37
+ //if params is string
38
+ if (typeof params === "string") {
39
+ url = `/api/v2/device/list?${params}`;
40
+ }
41
+ // if params is object
42
+ else {
43
+ url = `/api/v2/device/list?${Object.keys(params)
44
+ .map((key) => `${key}=${params[key]}`)
45
+ .join("&")}`;
46
+ }
47
+ }
48
+ return axios.post(url, condition).then((res) => {
36
49
  return res.data;
37
50
  });
38
51
  },
package/dist/index.js CHANGED
@@ -338,7 +338,7 @@ class Cpzxrobot {
338
338
  const token = localStorage.getItem("token");
339
339
  if (token) {
340
340
  this.token = token;
341
- this.initAxios("https://www.cpzxrobot.com/");
341
+ this.initAxios(baseURL);
342
342
  this.axios.get("/api/v1/user/auth").then((res) => {
343
343
  if (res.data.Error) {
344
344
  window.location.href = "/login.html?error=" + res.data.Error;
@@ -370,7 +370,7 @@ class Cpzxrobot {
370
370
  const access_token = url.searchParams.get("access_token");
371
371
  const app_code = url.searchParams.get("app_code");
372
372
  if (access_token && app_code) {
373
- this.initAxios("https://www.cpzxrobot.com/");
373
+ this.initAxios(baseURL);
374
374
  this.axios
375
375
  .post("/api/v1/user/auth", {
376
376
  appCode: app_code,
@@ -123,9 +123,11 @@ class UserGateway extends Object {
123
123
  //当前如果打开的是公司,则说明该应用支持在公司级别打开,则要求该应用应该有对应的公司级别的角色配置,所以并不需要查找公司下属工厂或工厂的对应公司,再去查找用户
124
124
  return axios.get(`/api/v2/company/${factory.id}/users?roleCode=${role}`);
125
125
  }
126
- async mypermission() {
126
+ async mypermission(params = undefined) {
127
127
  var axios = await this.context.ready;
128
- return axios.get("/api/v2/user/role/mypermission");
128
+ return axios.get("/api/v2/user/role/mypermission", {
129
+ params
130
+ });
129
131
  }
130
132
  async delete(id) {
131
133
  var axios = await this.context.ready;
package/index.ts CHANGED
@@ -386,7 +386,7 @@ export class Cpzxrobot {
386
386
  const token = localStorage.getItem("token");
387
387
  if (token) {
388
388
  this.token = token;
389
- this.initAxios("https://www.cpzxrobot.com/");
389
+ this.initAxios(baseURL);
390
390
  this.axios.get("/api/v1/user/auth").then((res) => {
391
391
  if (res.data.Error) {
392
392
  window.location.href = "/login.html?error=" + res.data.Error;
@@ -417,7 +417,7 @@ export class Cpzxrobot {
417
417
  const access_token = url.searchParams.get("access_token");
418
418
  const app_code = url.searchParams.get("app_code");
419
419
  if (access_token && app_code) {
420
- this.initAxios("https://www.cpzxrobot.com/");
420
+ this.initAxios(baseURL);
421
421
  this.axios
422
422
  .post("/api/v1/user/auth", {
423
423
  appCode: app_code,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.1.96",
3
+ "version": "1.1.97",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/user_gateway.ts CHANGED
@@ -136,9 +136,11 @@ export class UserGateway extends Object {
136
136
  return axios.get(`/api/v2/company/${factory.id}/users?roleCode=${role}`);
137
137
  }
138
138
 
139
- async mypermission() {
139
+ async mypermission(params: any = undefined) {
140
140
  var axios = await this.context.ready;
141
- return axios.get("/api/v2/user/role/mypermission");
141
+ return axios.get("/api/v2/user/role/mypermission",{
142
+ params
143
+ });
142
144
  }
143
145
 
144
146
  async delete(id: number) {