@cpzxrobot/sdk 1.0.0

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/index.ts ADDED
@@ -0,0 +1,283 @@
1
+ import { DeviceGateway } from "./device_gateway";
2
+ import { UserGateway } from "./user_gateway";
3
+ import { FactoryGateway } from "./factory_gateway";
4
+ import { TransportGateway } from "./transport_gateway";
5
+ import axios from "axios";
6
+ import { AssistantGateway } from "./assistant_gateway";
7
+ import { EnergyGateway } from "./energy_gateway";
8
+ import { CameraGateway } from "./camera_gateway";
9
+ import { type ElectricMeterRate } from "./energy_types/electric_meter_gateway";
10
+ import { PigfarmGateway } from "./pigfarm_gateway";
11
+
12
+ class shzx {
13
+ device: DeviceGateway;
14
+ pigfarm: PigfarmGateway = new PigfarmGateway(this);
15
+ public hash = "shzx";
16
+ mode: string = "dev";
17
+ auth: string = "";
18
+ axios!: MyAxiosInstance;
19
+ appCode: string;
20
+ user: UserGateway;
21
+ token: string = "";
22
+ factory: FactoryGateway;
23
+ ready: Promise<MyAxiosInstance>;
24
+ resolveReady!: (
25
+ value: MyAxiosInstance | PromiseLike<MyAxiosInstance>
26
+ ) => void;
27
+ rejectReady!: (reason?: any) => void;
28
+ transport: TransportGateway;
29
+ platformReady!: Promise<boolean>;
30
+ _getSelectedFarmFromMiniApp!: () => any;
31
+ _getSelectedUnitFromMiniApp!: () => any;
32
+ _jumpToMiniApp!: (url: string) => any;
33
+ setTitle: Function = () => {};
34
+ assistant: AssistantGateway;
35
+ energy: EnergyGateway;
36
+ camera: CameraGateway;
37
+
38
+ constructor(appCode: string) {
39
+ //获取当前浏览器的域名
40
+ this.ready = new Promise<MyAxiosInstance>((resolve, reject) => {
41
+ this.resolveReady = resolve;
42
+ this.rejectReady = reject;
43
+ });
44
+ this.getDomain();
45
+ this.appCode = appCode;
46
+ this.user = new UserGateway(this);
47
+ this.factory = new FactoryGateway(this);
48
+ this.device = new DeviceGateway(this);
49
+ this.transport = new TransportGateway(this);
50
+ this.assistant = new AssistantGateway(this);
51
+ this.energy = new EnergyGateway(this);
52
+ this.camera = new CameraGateway(this);
53
+ }
54
+
55
+ exit() {
56
+ if (this.mode === "miniapp_in_app") {
57
+ // @ts-ignore
58
+ window.exitMiniapp();
59
+ } else {
60
+ window.close();
61
+ }
62
+ }
63
+
64
+ inApp() {
65
+ return this.mode === "miniapp_in_app";
66
+ }
67
+
68
+ initAxios() {
69
+ if (this.mode !== "miniapp_in_app") {
70
+ const instance = axios.create({
71
+ baseURL: "/",
72
+ });
73
+ instance.interceptors.request.use(
74
+ (config) => {
75
+ // 在发送请求之前在头部添加token
76
+ config.headers.Authorization = this.token;
77
+ // 解析和验证Token
78
+
79
+ return config;
80
+ },
81
+ function (error) {
82
+ // 对请求错误做些什么
83
+ return Promise.reject(error);
84
+ }
85
+ );
86
+ this.axios = instance;
87
+ }
88
+ }
89
+
90
+ //获取当前浏览器的域名
91
+ getDomain() {
92
+ const domain = window.location.hostname;
93
+ console.log("load domain ", domain);
94
+ if (domain == "miniapp") {
95
+ this.mode = "miniapp_in_app";
96
+ // @ts-ignore
97
+ this.axios = getAxiosFromMiniApp();
98
+ this.platformReady = Promise.resolve(true);
99
+ // @ts-ignore
100
+ this._getSelectedFarmFromMiniApp = window.getSelectedFarmFromMiniApp;
101
+ // @ts-ignore
102
+ this._getSelectedUnitFromMiniApp = window.getSelectedUnitFromMiniApp;
103
+ // @ts-ignore
104
+ this._jumpToMiniApp = window.miniapp.open;
105
+ // @ts-ignore
106
+ this.setTitle = window.miniapp.setTitle;
107
+ } else if (
108
+ domain == "appassets.androidplatform.net" ||
109
+ this.isIosMiniApp(window.location)
110
+ ) {
111
+ this.mode = "miniapp_in_app";
112
+ const platform: {
113
+ callHandler: Function;
114
+ } =
115
+ // @ts-ignore
116
+ window.flutter_inappwebview;
117
+ this._getSelectedFarmFromMiniApp = function () {
118
+ return platform.callHandler("getSelectedFarmFromMiniApp");
119
+ };
120
+ this._getSelectedUnitFromMiniApp = function () {
121
+ return platform.callHandler("getSelectedUnitFromMiniApp");
122
+ };
123
+ this._jumpToMiniApp = function (url: string) {
124
+ return platform.callHandler("app.openMiniapp", url);
125
+ };
126
+ this.setTitle = function (title: string) {
127
+ return platform.callHandler("app.setTitle", title);
128
+ }
129
+ this.axios = {
130
+ get: function (url, data) {
131
+ console.log(url, data);
132
+ return platform.callHandler("axios_get", url, data);
133
+ },
134
+ post: function (url, data) {
135
+ console.log(url, data);
136
+ return platform.callHandler("axios_post", url, data);
137
+ },
138
+ };
139
+ this.platformReady = new Promise<boolean>((resolve, reject) => {
140
+ window.addEventListener(
141
+ "flutterInAppWebViewPlatformReady",
142
+ function () {
143
+ console.log("flutter android/ios platform is ready");
144
+ resolve(true);
145
+ }
146
+ );
147
+ setTimeout(() => {
148
+ reject("timeout");
149
+ }, 1500);
150
+ });
151
+ } else if (this.isLocalDomain(domain)) {
152
+ this.mode = "dev";
153
+ this.setTitle = function (title: string) {
154
+ document.title = title;
155
+ }
156
+ console.log(
157
+ "欢迎使用上海正诚物联网IOT系统,您当前是开发环境,请在平台获取开发用jwt key,并传入devAuth设置"
158
+ );
159
+ } else {
160
+ this.mode = "miniapp_in_web";
161
+ }
162
+ }
163
+ isIosMiniApp(location: Location): boolean {
164
+ //hostname is 'localhost' and has search params starting with 'mode=ios'
165
+ return (
166
+ location.hostname === "localhost" &&
167
+ location.search.startsWith("?mode=ios")
168
+ );
169
+ }
170
+ on(event: string, cb: Function) {
171
+ switch (event) {
172
+ case "unitChanged":
173
+ // @ts-ignore
174
+ window._notifyUnitChanged = cb;
175
+ break;
176
+ }
177
+ }
178
+
179
+ //打开其他小程序
180
+ openMiniApp(url: string) {
181
+ this._jumpToMiniApp(url);
182
+ }
183
+
184
+ setAuth(auth: string) {
185
+ if (this.mode === "miniapp_in_app") {
186
+ this.platformReady.then(() => {
187
+ this.initAxios();
188
+ console.log("shzx is ready");
189
+ this.resolveReady(this.axios);
190
+ });
191
+ return;
192
+ }
193
+ this.initAxios();
194
+ this.auth = auth;
195
+ this.axios
196
+ .post("/api/v1/user/auth", {
197
+ appCode: this.appCode,
198
+ auth: auth,
199
+ })
200
+ .then((res) => {
201
+ if (res.data.Error) {
202
+ throw res.data.Error;
203
+ } else {
204
+ this.token = "Bearer " + res.data.token;
205
+ }
206
+ this.resolveReady(this.axios);
207
+ })
208
+ .catch((err) => {
209
+ console.log("shzx ready caller reject", err);
210
+ this.rejectReady(err);
211
+ });
212
+ }
213
+
214
+ isLocalDomain(domain: string): boolean {
215
+ // 列出所有的本地开发域名
216
+ const localDomains = ["localhost", "127.0.0.1", "0.0.0.0"];
217
+
218
+ // 检查当前域名是否在本地开发域名列表中
219
+ return localDomains.includes(domain);
220
+ }
221
+ }
222
+
223
+ let _instance!: shzx;
224
+
225
+ export default function (
226
+ args: {
227
+ devAuth: string;
228
+ appCode: string;
229
+ selectedFarm: Factory;
230
+ selectedUnit: Unit;
231
+ } = {
232
+ devAuth: "",
233
+ appCode: "",
234
+ selectedFarm: {
235
+ id: 0,
236
+ code: "",
237
+ name: "",
238
+ company_code: "",
239
+ },
240
+ selectedUnit: {
241
+ id: 0,
242
+ name: "",
243
+ },
244
+ }
245
+ ): shzx {
246
+ if (!_instance) {
247
+ _instance = new shzx(args.appCode);
248
+ _instance.setAuth(args.devAuth);
249
+ if (args.selectedFarm) {
250
+ _instance.user.selectedFarm = args.selectedFarm;
251
+ }
252
+ if (args.selectedUnit) {
253
+ _instance.user.selectedUnit = args.selectedUnit;
254
+ }
255
+ }
256
+ return _instance;
257
+ }
258
+ export interface FeedTower {
259
+ id: number;
260
+ name: string;
261
+ currentAmount: number;
262
+ lastZeroTime: string;
263
+ cycle?: number;
264
+ "pg.feedtower.status"?: string;
265
+ "pg.feedtower.near-zero"?: string;
266
+ deviation: number;
267
+ towerVolume: number;
268
+ unit: string;
269
+ deviceId: number;
270
+ fodderUnit: string;
271
+ fodderCode: string;
272
+ }
273
+ export interface Assistant {
274
+ info: String;
275
+ status: Number;
276
+ name: String;
277
+ id: Number;
278
+ }
279
+ export interface ElectricMeter extends Device {
280
+ coefficient: number;
281
+ status: string;
282
+ }
283
+ export { type ElectricMeterRate };
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@cpzxrobot/sdk",
3
+ "version": "1.0.0",
4
+ "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "tsc"
9
+ },
10
+ "author": "上海正芯科融机器人科技有限公司",
11
+ "license": "MIT",
12
+ "devDependencies": {
13
+ "typescript": "^5.5.3"
14
+ },
15
+ "dependencies": {
16
+ "axios": "^1.7.2"
17
+ }
18
+ }
@@ -0,0 +1,13 @@
1
+ export class PigfarmGateway extends Object {
2
+ context: Shzx
3
+ constructor(context: Shzx) {
4
+ super()
5
+ this.context = context
6
+ }
7
+ //获得日龄
8
+ dayageForUnit(unit: Unit) {
9
+ return this.context.ready.then((axios) => {
10
+ return axios.get(`/api/v1/pigfarm/${unit.id}/dayage`);
11
+ });
12
+ }
13
+ }
package/readme.md ADDED
@@ -0,0 +1,6 @@
1
+ # 正芯数智SDK
2
+
3
+ 这是提供给上海正芯数智APP第三方H5应用使用的SDK模块,包含相关物联网设备的获取方式和接口功能
4
+
5
+ ## 使用方式
6
+
@@ -0,0 +1,67 @@
1
+ export class TransportGateway extends Object {
2
+ _selectedFarm: string = ''
3
+ context: Shzx
4
+
5
+ constructor(context: Shzx) {
6
+ super()
7
+ this.context = context
8
+ }
9
+
10
+ get fodder() {
11
+ return {
12
+ //获得打料列表
13
+ getData: (
14
+ id: number | undefined = undefined,
15
+ page: {
16
+ current: number
17
+ pageSize: number
18
+ deviceId: number | undefined
19
+ } = {
20
+ current: 1,
21
+ pageSize: 10,
22
+ deviceId: id
23
+ }
24
+ ): Promise<FodderOrder[]> => {
25
+ return this.context.ready.then(() => {
26
+ return this.context.axios
27
+ .get('/api/v1/pigfarm/device/fodder', {
28
+ params: page
29
+ })
30
+ .then((res) => {
31
+ if (res.data.code != 200) {
32
+ throw res.data.message
33
+ }
34
+ return res.data.data.list
35
+ })
36
+ })
37
+ },
38
+ create: (data: FodderOrder) => {
39
+ return this.context.ready.then(() => {
40
+ return this.context.axios.post('/api/v1/pigfarm/device/fodder/add', data).then((res) => {
41
+ if (res.data.code != 200) {
42
+ throw res.data.message
43
+ }
44
+ return res.data.data
45
+ })
46
+ })
47
+ },
48
+ bind: (data: {
49
+ deviceIds: number[]
50
+ fodderType: string //料塔类型
51
+ fodderAmount: number //料塔容量
52
+ fodderId: number //料塔id,类 ZC2023 用于绑定料塔
53
+ }) => {
54
+ return this.context.ready.then(() => {
55
+ return this.context.axios
56
+ .post('/api/v1/pigfarm/device/fodderTower/addList', data)
57
+ .then((res) => {
58
+ if (res.data.code != 200) {
59
+ throw res.data.message
60
+ }
61
+ return res.data.data
62
+ })
63
+ })
64
+ }
65
+ }
66
+ }
67
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,108 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "es2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ "lib": ["es2017","dom"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "commonjs", /* Specify what module code is generated. */
29
+ // "rootDir": "./", /* Specify the root folder within your source files. */
30
+ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
40
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
41
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
42
+ // "resolveJsonModule": true, /* Enable importing .json files. */
43
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
44
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
45
+
46
+ /* JavaScript Support */
47
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
48
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
49
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
50
+
51
+ /* Emit */
52
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
53
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
54
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
55
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
56
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
58
+ "outDir": "./dist/", /* Specify an output folder for all emitted files. */
59
+ // "removeComments": true, /* Disable emitting comments. */
60
+ // "noEmit": true, /* Disable emitting files from a compilation. */
61
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
62
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
63
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
64
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
65
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
66
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
67
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
68
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
69
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
70
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
71
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
72
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
73
+
74
+ /* Interop Constraints */
75
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
76
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
77
+ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
78
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
79
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
80
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
81
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
82
+
83
+ /* Type Checking */
84
+ "strict": true, /* Enable all strict type-checking options. */
85
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
86
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
87
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
88
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
89
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
90
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
91
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
92
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
93
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
94
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
95
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
96
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
97
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
98
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
99
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
100
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
101
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
102
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
103
+
104
+ /* Completeness */
105
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
106
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
107
+ }
108
+ }
package/types.d.ts ADDED
@@ -0,0 +1,102 @@
1
+
2
+
3
+ type Device = {
4
+ id: number
5
+ deviceId: string
6
+ name: string
7
+ type: number
8
+ typeCode:string
9
+ currentAmount: number
10
+ location: string
11
+ supplier?: string
12
+ data?: number[]
13
+ typeCode: string
14
+ }
15
+
16
+ type FeedTowerExtraInfo = {
17
+ currentAmount: number
18
+ loadAmount: number
19
+ feedTowerAmount: number
20
+ feedTowerCode: string
21
+ id: number
22
+ surplus_amount: number
23
+ }
24
+
25
+ type FodderOrder = {
26
+ id?: number
27
+ fodderId?: string
28
+ fodderAmount: number
29
+ fodderCode: string
30
+ createTime: string
31
+ status: string
32
+ fodderUnit: string
33
+ truckCode?: string
34
+ date?: string
35
+ type?: string
36
+ }
37
+ //录入
38
+ type FodderAdd = {
39
+ car: string //车牌号
40
+ date: string //日期
41
+ source: string //来源
42
+ factoryCode: string //当前工厂编号
43
+ results: FodderUpdate[]
44
+ }
45
+ type FodderUpdate = {
46
+ farm: string //工厂名称
47
+ fodderCode: string //料号
48
+ towers: Fodder[]
49
+ }
50
+
51
+ type Fodder = {
52
+ name: string //料塔名称
53
+ unit: string //单位
54
+ weight: number //重量
55
+ }
56
+
57
+ type Shzx = {
58
+ user: UserGateway
59
+ ready: Promise<MyAxiosInstance>
60
+ axios: MyAxiosInstance
61
+ _getSelectedFarmFromMiniApp: () => Promise<Factory>
62
+ _getSelectedUnitFromMiniApp: () => Promise<Unit>
63
+ mode: string
64
+ }
65
+ type Assistant = {
66
+ info: String
67
+ status: String
68
+ name: String
69
+ id: Number
70
+ }
71
+ type Factory = {
72
+ code: string
73
+ name?: string
74
+ company_code: string
75
+ id?: number
76
+ }
77
+ type Unit = {
78
+ name?: string
79
+ id?: number
80
+ type?: string
81
+ workshopName?:string
82
+ }
83
+
84
+ type Electricity = {
85
+ deviceId: string
86
+ nextDeviceList: number[] | []
87
+ power: number
88
+ }
89
+
90
+ type Camera = {
91
+ id: number
92
+ name: string
93
+ }
94
+
95
+ interface MyAxiosInstance {
96
+ get: (url: string, config?: any) => Promise<any>
97
+ post: (url: string, data?: any, config?: any) => Promise<any>
98
+ }
99
+
100
+ declare global {
101
+ let getAuth: () => string
102
+ }