fofstudio-aimcpztdata 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/build/MCPMain.js +2577 -0
- package/build/modules/BufferClass.js +6 -0
- package/build/modules/DataPackaging.js +57 -0
- package/build/modules/DecoderAPI.js +30 -0
- package/build/modules/DialogAPI.js +48 -0
- package/build/modules/EXEAPI.js +64 -0
- package/build/modules/FOFTcp.js +309 -0
- package/build/modules/FOFUDP.js +78 -0
- package/build/modules/File.js +525 -0
- package/build/modules/IP.js +54 -0
- package/build/modules/NoSqlFOFStudio.js +63 -0
- package/build/modules/PlatAPI.js +115 -0
- package/build/modules/ProcessAPI.js +36 -0
- package/build/modules/ReadAPI.js +67 -0
- package/build/modules/SendHttp.js +484 -0
- package/build/modules/dns.js +36 -0
- package/build/modules/mysql.js +0 -0
- package/build/modules/sqlServer.js +0 -0
- package/build/modules/trayApi.js +34 -0
- package/package.json +37 -0
package/build/MCPMain.js
ADDED
|
@@ -0,0 +1,2577 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
3
|
+
const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
4
|
+
const { z } = require("zod");
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 自定义单击事件
|
|
10
|
+
* @id 选择器
|
|
11
|
+
* @fun 点击事件
|
|
12
|
+
* */
|
|
13
|
+
function baseClick(id, fun) {
|
|
14
|
+
document.querySelectorAll(id).forEach(function (v) {
|
|
15
|
+
v.addEventListener('click', fun);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 自定义双击事件
|
|
21
|
+
* @id 选择器
|
|
22
|
+
* @fun 点击事件
|
|
23
|
+
* */
|
|
24
|
+
function baseDblclick(id, fun) {
|
|
25
|
+
document.querySelectorAll(id).forEach(function (v) {
|
|
26
|
+
v.addEventListener('dblclick', fun);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 自定义鼠标按键按下事件
|
|
32
|
+
* @id 选择器
|
|
33
|
+
* @fun 点击事件
|
|
34
|
+
* */
|
|
35
|
+
function baseMousedown(id, fun) {
|
|
36
|
+
document.querySelectorAll(id).forEach(function (v) {
|
|
37
|
+
v.addEventListener('mousedown', fun);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 自定义鼠标按键松开事件
|
|
43
|
+
* @id 选择器
|
|
44
|
+
* @fun 点击事件
|
|
45
|
+
* */
|
|
46
|
+
function baseMouseup(id, fun) {
|
|
47
|
+
document.querySelectorAll(id).forEach(function (v) {
|
|
48
|
+
v.addEventListener('mouseup', fun);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 自定义鼠标移入事件
|
|
54
|
+
* @id 选择器
|
|
55
|
+
* @fun 点击事件
|
|
56
|
+
* */
|
|
57
|
+
function baseMouseenter(id, fun) {
|
|
58
|
+
document.querySelectorAll(id).forEach(function (v) {
|
|
59
|
+
v.addEventListener('mouseenter', fun);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 自定义鼠标移出事件
|
|
65
|
+
* @id 选择器
|
|
66
|
+
* @fun 点击事件
|
|
67
|
+
* */
|
|
68
|
+
function baseMouseleave(id, fun) {
|
|
69
|
+
document.querySelectorAll(id).forEach(function (v) {
|
|
70
|
+
v.addEventListener('mouseleave', fun);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 自定义鼠标移动事件
|
|
76
|
+
* @id 选择器
|
|
77
|
+
* @fun 点击事件
|
|
78
|
+
* */
|
|
79
|
+
function baseMousemove(id, fun) {
|
|
80
|
+
document.querySelectorAll(id).forEach(function (v) {
|
|
81
|
+
v.addEventListener('mousemove', fun);
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Utf8Array转字符串
|
|
86
|
+
* @array Utf8Array数据
|
|
87
|
+
* */
|
|
88
|
+
function Utf8ArrayToStr(array) {
|
|
89
|
+
var out, i, len, c;
|
|
90
|
+
var char2, char3;
|
|
91
|
+
out = "";
|
|
92
|
+
len = array.length;
|
|
93
|
+
i = 0;
|
|
94
|
+
while (i < len) {
|
|
95
|
+
c = array[i++];
|
|
96
|
+
switch (c >> 4) {
|
|
97
|
+
case 0:
|
|
98
|
+
case 1:
|
|
99
|
+
case 2:
|
|
100
|
+
case 3:
|
|
101
|
+
case 4:
|
|
102
|
+
case 5:
|
|
103
|
+
case 6:
|
|
104
|
+
case 7:
|
|
105
|
+
// 0xxxxxxx
|
|
106
|
+
out += String.fromCharCode(c);
|
|
107
|
+
break;
|
|
108
|
+
case 12:
|
|
109
|
+
case 13:
|
|
110
|
+
// 110x xxxx 10xx xxxx
|
|
111
|
+
char2 = array[i++];
|
|
112
|
+
out += String.fromCharCode((c & 0x1f) << 6 | char2 & 0x3f);
|
|
113
|
+
break;
|
|
114
|
+
case 14:
|
|
115
|
+
// 1110 xxxx 10xx xxxx 10xx xxxx
|
|
116
|
+
char2 = array[i++];
|
|
117
|
+
char3 = array[i++];
|
|
118
|
+
out += String.fromCharCode((c & 0x0f) << 12 | (char2 & 0x3f) << 6 | (char3 & 0x3f) << 0);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let LetData = {
|
|
126
|
+
sqlServer: null,
|
|
127
|
+
fofsqlite3: null,
|
|
128
|
+
fofmysql: null,
|
|
129
|
+
crypto: null,
|
|
130
|
+
sharp: null,
|
|
131
|
+
email: null,
|
|
132
|
+
compress: null,
|
|
133
|
+
ftp: null,
|
|
134
|
+
fileFOF: null,
|
|
135
|
+
DecoderAPI: null,
|
|
136
|
+
SendHttp: null,
|
|
137
|
+
dnsFOF: null,
|
|
138
|
+
EXEAPI: null,
|
|
139
|
+
PlatAPI: null,
|
|
140
|
+
ReadAPI: null,
|
|
141
|
+
ProcessAPI: null,
|
|
142
|
+
HttpServer: null,
|
|
143
|
+
TcpServer: null,
|
|
144
|
+
UdpServer: null,
|
|
145
|
+
IPData: null,
|
|
146
|
+
BufferClass: null,
|
|
147
|
+
DataPackaging: null,
|
|
148
|
+
websocket: null,
|
|
149
|
+
sms: null,
|
|
150
|
+
excel: null,
|
|
151
|
+
word: null,
|
|
152
|
+
docxObj: null,
|
|
153
|
+
wordPath: null,
|
|
154
|
+
nodeRsa: null,
|
|
155
|
+
ffiNapi: null,
|
|
156
|
+
HttpProxy: null,
|
|
157
|
+
TxCdn: null,
|
|
158
|
+
SerialPortNode: null,
|
|
159
|
+
mqttServer: null,
|
|
160
|
+
modbus: null,
|
|
161
|
+
printWindows: null,
|
|
162
|
+
postgres: null,
|
|
163
|
+
BaiDuOpencv: null,
|
|
164
|
+
Alioss: null
|
|
165
|
+
}
|
|
166
|
+
let fofletData = LetData;
|
|
167
|
+
|
|
168
|
+
let electronProcessAPI = {
|
|
169
|
+
runExec: (Path, cmdCode, SetProcessYesMsg = undefined, SetProcessNoMsg = undefined, SetProcessEndMsg = undefined, encoding_ = "GBK", env = undefined, ifArr = false) => {
|
|
170
|
+
if (LetData.ProcessAPI == null) {
|
|
171
|
+
LetData.ProcessAPI = require('./modules/ProcessAPI.js');
|
|
172
|
+
}
|
|
173
|
+
LetData.ProcessAPI.runExec({ "路径": Path, "code": cmdCode }, SetProcessYesMsg, SetProcessNoMsg, SetProcessEndMsg, encoding_, env, ifArr)
|
|
174
|
+
},
|
|
175
|
+
runExeckill: () => {
|
|
176
|
+
if (LetData.ProcessAPI == null) {
|
|
177
|
+
LetData.ProcessAPI = require('./modules/ProcessAPI.js');
|
|
178
|
+
}
|
|
179
|
+
LetData.ProcessAPI.runExeckill()
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
let electronReadAPI = {
|
|
184
|
+
readText: () => {
|
|
185
|
+
if (LetData.ReadAPI == null) {
|
|
186
|
+
LetData.ReadAPI = require('./modules/ReadAPI.js');
|
|
187
|
+
}
|
|
188
|
+
return LetData.ReadAPI.readText();
|
|
189
|
+
},
|
|
190
|
+
writeText: (text) => {
|
|
191
|
+
if (LetData.ReadAPI == null) {
|
|
192
|
+
LetData.ReadAPI = require('./modules/ReadAPI.js');
|
|
193
|
+
}
|
|
194
|
+
return LetData.ReadAPI.writeText(text);
|
|
195
|
+
},
|
|
196
|
+
readHTML: () => {
|
|
197
|
+
if (LetData.ReadAPI == null) {
|
|
198
|
+
LetData.ReadAPI = require('./modules/ReadAPI.js');
|
|
199
|
+
}
|
|
200
|
+
return LetData.ReadAPI.readHTML();
|
|
201
|
+
},
|
|
202
|
+
writeHTML: (text) => {
|
|
203
|
+
if (LetData.ReadAPI == null) {
|
|
204
|
+
LetData.ReadAPI = require('./modules/ReadAPI.js');
|
|
205
|
+
}
|
|
206
|
+
return LetData.ReadAPI.writeHTML(text);
|
|
207
|
+
},
|
|
208
|
+
readRTF: () => {
|
|
209
|
+
if (LetData.ReadAPI == null) {
|
|
210
|
+
LetData.ReadAPI = require('./modules/ReadAPI.js');
|
|
211
|
+
}
|
|
212
|
+
return LetData.ReadAPI.readRTF();
|
|
213
|
+
},
|
|
214
|
+
writeRTF: (text) => {
|
|
215
|
+
if (LetData.ReadAPI == null) {
|
|
216
|
+
LetData.ReadAPI = require('./modules/ReadAPI.js');
|
|
217
|
+
}
|
|
218
|
+
return LetData.ReadAPI.writeRTF(text);
|
|
219
|
+
},
|
|
220
|
+
}
|
|
221
|
+
let electronPlatAPI = {
|
|
222
|
+
getPlatform: () => {
|
|
223
|
+
if (LetData.PlatAPI == null) {
|
|
224
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
225
|
+
}
|
|
226
|
+
return LetData.PlatAPI.getPlatform();
|
|
227
|
+
},
|
|
228
|
+
globalShortcut: (key) => {
|
|
229
|
+
//全局快捷键绑定
|
|
230
|
+
try {
|
|
231
|
+
//只在electron中生效
|
|
232
|
+
ipcRenderer.invoke('globalShortcut', key)
|
|
233
|
+
} catch (error) {
|
|
234
|
+
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
Notification: (data) => {
|
|
238
|
+
try {
|
|
239
|
+
//只在electron中生效
|
|
240
|
+
ipcRenderer.invoke('Notification', data)
|
|
241
|
+
} catch (error) {
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
openAtLogin: (true_) => {
|
|
246
|
+
try {
|
|
247
|
+
//只在electron中生效
|
|
248
|
+
ipcRenderer.invoke('openAtLogin', true_)
|
|
249
|
+
} catch (error) {
|
|
250
|
+
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
powerSaveBlocker: () => {
|
|
254
|
+
try {
|
|
255
|
+
//只在electron中生效
|
|
256
|
+
ipcRenderer.invoke('powerSaveBlocker')
|
|
257
|
+
} catch (error) {
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
processArgv: () => {
|
|
262
|
+
return process.argv;
|
|
263
|
+
},
|
|
264
|
+
getCursorScreenPoint: () => {
|
|
265
|
+
if (LetData.PlatAPI == null) {
|
|
266
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
267
|
+
}
|
|
268
|
+
return LetData.PlatAPI.getCursorScreenPoint()
|
|
269
|
+
},
|
|
270
|
+
dipToScreenPoint: (data) => {
|
|
271
|
+
if (LetData.PlatAPI == null) {
|
|
272
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
273
|
+
}
|
|
274
|
+
return LetData.PlatAPI.dipToScreenPoint(data)
|
|
275
|
+
},
|
|
276
|
+
networkInterfaces: () => {
|
|
277
|
+
if (LetData.PlatAPI == null) {
|
|
278
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
279
|
+
}
|
|
280
|
+
return LetData.PlatAPI.networkInterfaces()
|
|
281
|
+
},
|
|
282
|
+
getLocalIP: () => {
|
|
283
|
+
if (LetData.IPData == null) {
|
|
284
|
+
LetData.IPData = require('./modules/IP.js');
|
|
285
|
+
}
|
|
286
|
+
return LetData.IPData.getLocalIP()
|
|
287
|
+
},
|
|
288
|
+
cpus: () => {
|
|
289
|
+
if (LetData.PlatAPI == null) {
|
|
290
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
291
|
+
}
|
|
292
|
+
return LetData.PlatAPI.cpus()
|
|
293
|
+
},
|
|
294
|
+
tmpDir: () => {
|
|
295
|
+
if (LetData.PlatAPI == null) {
|
|
296
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
297
|
+
}
|
|
298
|
+
return LetData.PlatAPI.tmpDir()
|
|
299
|
+
},
|
|
300
|
+
arch: () => {
|
|
301
|
+
if (LetData.PlatAPI == null) {
|
|
302
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
303
|
+
}
|
|
304
|
+
return LetData.PlatAPI.arch()
|
|
305
|
+
},
|
|
306
|
+
totalmem: () => {
|
|
307
|
+
if (LetData.PlatAPI == null) {
|
|
308
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
309
|
+
}
|
|
310
|
+
return LetData.PlatAPI.totalmem()
|
|
311
|
+
},
|
|
312
|
+
freemem: () => {
|
|
313
|
+
if (LetData.PlatAPI == null) {
|
|
314
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
315
|
+
}
|
|
316
|
+
return LetData.PlatAPI.freemem()
|
|
317
|
+
},
|
|
318
|
+
OStype: () => {
|
|
319
|
+
if (LetData.PlatAPI == null) {
|
|
320
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
321
|
+
}
|
|
322
|
+
return LetData.PlatAPI.OStype()
|
|
323
|
+
},
|
|
324
|
+
hostname: () => {
|
|
325
|
+
if (LetData.PlatAPI == null) {
|
|
326
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
327
|
+
}
|
|
328
|
+
return LetData.PlatAPI.hostname()
|
|
329
|
+
},
|
|
330
|
+
release: () => {
|
|
331
|
+
if (LetData.PlatAPI == null) {
|
|
332
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
333
|
+
}
|
|
334
|
+
return LetData.PlatAPI.release()
|
|
335
|
+
},
|
|
336
|
+
uptime: () => {
|
|
337
|
+
if (LetData.PlatAPI == null) {
|
|
338
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
339
|
+
}
|
|
340
|
+
return LetData.PlatAPI.uptime()
|
|
341
|
+
},
|
|
342
|
+
loadavg: () => {
|
|
343
|
+
if (LetData.PlatAPI == null) {
|
|
344
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
345
|
+
}
|
|
346
|
+
return LetData.PlatAPI.loadavg()
|
|
347
|
+
},
|
|
348
|
+
showItemInFolder: (fullPath) => {
|
|
349
|
+
if (LetData.PlatAPI == null) {
|
|
350
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
351
|
+
}
|
|
352
|
+
LetData.PlatAPI.showItemInFolder(fullPath)
|
|
353
|
+
},
|
|
354
|
+
openPath: (fullPath) => {
|
|
355
|
+
if (LetData.PlatAPI == null) {
|
|
356
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
357
|
+
}
|
|
358
|
+
LetData.PlatAPI.openPath(fullPath)
|
|
359
|
+
},
|
|
360
|
+
openExternal: (url) => {
|
|
361
|
+
if (LetData.PlatAPI == null) {
|
|
362
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
363
|
+
}
|
|
364
|
+
LetData.PlatAPI.openExternal(url)
|
|
365
|
+
},
|
|
366
|
+
trashItem: (fullPath) => {
|
|
367
|
+
if (LetData.PlatAPI == null) {
|
|
368
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
369
|
+
}
|
|
370
|
+
LetData.PlatAPI.trashItem(fullPath)
|
|
371
|
+
},
|
|
372
|
+
openItem: (fullPath) => {
|
|
373
|
+
if (LetData.PlatAPI == null) {
|
|
374
|
+
LetData.PlatAPI = require('./modules/PlatAPI.js');
|
|
375
|
+
}
|
|
376
|
+
LetData.PlatAPI.openItem(fullPath)
|
|
377
|
+
},
|
|
378
|
+
}
|
|
379
|
+
let electronEXEAPI = {
|
|
380
|
+
OpenEXE: (path) => {
|
|
381
|
+
if (LetData.EXEAPI == null) {
|
|
382
|
+
LetData.EXEAPI = require('./modules/EXEAPI.js');
|
|
383
|
+
}
|
|
384
|
+
return LetData.EXEAPI.OpenEXE(path)
|
|
385
|
+
},
|
|
386
|
+
KillEXE: (pid) => {
|
|
387
|
+
if (LetData.EXEAPI == null) {
|
|
388
|
+
LetData.EXEAPI = require('./modules/EXEAPI.js');
|
|
389
|
+
}
|
|
390
|
+
return LetData.EXEAPI.KillEXE(pid)
|
|
391
|
+
},
|
|
392
|
+
DoesTheProcessExist: (query, cb, encoding = "GBK") => {
|
|
393
|
+
if (LetData.EXEAPI == null) {
|
|
394
|
+
LetData.EXEAPI = require('./modules/EXEAPI.js');
|
|
395
|
+
}
|
|
396
|
+
return LetData.EXEAPI.DoesTheProcessExist(query, cb, encoding)
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
let electronDnsAPI = {
|
|
401
|
+
lookup: (url, funStr = undefined) => {
|
|
402
|
+
if (LetData.dnsFOF == null) {
|
|
403
|
+
LetData.dnsFOF = require('./modules/dns.js');
|
|
404
|
+
}
|
|
405
|
+
LetData.dnsFOF.lookup(url, funStr)
|
|
406
|
+
},
|
|
407
|
+
lookupService: (address, family, funStr = undefined) => {
|
|
408
|
+
if (LetData.dnsFOF == null) {
|
|
409
|
+
LetData.dnsFOF = require('./modules/dns.js');
|
|
410
|
+
}
|
|
411
|
+
LetData.dnsFOF.lookupService(address, family, funStr)
|
|
412
|
+
},
|
|
413
|
+
resolve4: (url, funStr = undefined) => {
|
|
414
|
+
if (LetData.dnsFOF == null) {
|
|
415
|
+
LetData.dnsFOF = require('./modules/dns.js');
|
|
416
|
+
}
|
|
417
|
+
LetData.dnsFOF.resolve4(url, funStr)
|
|
418
|
+
},
|
|
419
|
+
resolve6: (url, funStr) => {
|
|
420
|
+
if (LetData.dnsFOF == null) {
|
|
421
|
+
LetData.dnsFOF = require('./modules/dns.js');
|
|
422
|
+
}
|
|
423
|
+
LetData.dnsFOF.resolve6(url, funStr)
|
|
424
|
+
},
|
|
425
|
+
reverse: (ip, funStr) => {
|
|
426
|
+
if (LetData.dnsFOF == null) {
|
|
427
|
+
LetData.dnsFOF = require('./modules/dns.js');
|
|
428
|
+
}
|
|
429
|
+
LetData.dnsFOF.reverse(ip, funStr)
|
|
430
|
+
},
|
|
431
|
+
}
|
|
432
|
+
let electronFileAPI = {
|
|
433
|
+
getAppPath: () => {
|
|
434
|
+
if (LetData.fileFOF == null) {
|
|
435
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
436
|
+
}
|
|
437
|
+
if (__filename.indexOf("MCPMain.js") != -1) {
|
|
438
|
+
return LetData.fileFOF.getAppPath(true);
|
|
439
|
+
} else {
|
|
440
|
+
return LetData.fileFOF.getAppPath();
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
getDesktop: () => {
|
|
444
|
+
if (LetData.fileFOF == null) {
|
|
445
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
446
|
+
}
|
|
447
|
+
return LetData.fileFOF.getDesktop();
|
|
448
|
+
},
|
|
449
|
+
getPathAll: () => {
|
|
450
|
+
if (LetData.fileFOF == null) {
|
|
451
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
452
|
+
}
|
|
453
|
+
return LetData.fileFOF.getPathAll();
|
|
454
|
+
},
|
|
455
|
+
|
|
456
|
+
listFile: (path, funEv = undefined) => {
|
|
457
|
+
if (LetData.fileFOF == null) {
|
|
458
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
459
|
+
}
|
|
460
|
+
LetData.fileFOF.listFile(path, funEv);
|
|
461
|
+
},
|
|
462
|
+
watch: (path, funEv = undefined) => {
|
|
463
|
+
if (LetData.fileFOF == null) {
|
|
464
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
465
|
+
}
|
|
466
|
+
LetData.fileFOF.watch(path, funEv);
|
|
467
|
+
},
|
|
468
|
+
getExe: () => {
|
|
469
|
+
if (LetData.fileFOF == null) {
|
|
470
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
471
|
+
}
|
|
472
|
+
return LetData.fileFOF.getExe();
|
|
473
|
+
},
|
|
474
|
+
existsSync: (path) => {
|
|
475
|
+
if (LetData.fileFOF == null) {
|
|
476
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
477
|
+
}
|
|
478
|
+
return LetData.fileFOF.existsSync(path);
|
|
479
|
+
},
|
|
480
|
+
writeFileSync: (path, data) => {
|
|
481
|
+
if (LetData.fileFOF == null) {
|
|
482
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
483
|
+
}
|
|
484
|
+
return LetData.fileFOF.writeFileSync({ "路径": path, "数据": data });
|
|
485
|
+
},
|
|
486
|
+
writeFileBase64Sync: (path, data) => {
|
|
487
|
+
if (LetData.fileFOF == null) {
|
|
488
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
489
|
+
}
|
|
490
|
+
return LetData.fileFOF.writeFileBase64Sync({ "路径": path, "数据": data });
|
|
491
|
+
},
|
|
492
|
+
writeFileHexSync: (path, data) => {
|
|
493
|
+
if (LetData.fileFOF == null) {
|
|
494
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
495
|
+
}
|
|
496
|
+
return LetData.fileFOF.writeFileHexSync({ "路径": path, "数据": data });
|
|
497
|
+
},
|
|
498
|
+
readFileSync: (path, unicode = "utf8") => {
|
|
499
|
+
if (LetData.fileFOF == null) {
|
|
500
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
501
|
+
}
|
|
502
|
+
return LetData.fileFOF.readFileSync({ "路径": path, "编码": unicode });
|
|
503
|
+
},
|
|
504
|
+
readFileBase64Sync: (path) => {
|
|
505
|
+
if (LetData.fileFOF == null) {
|
|
506
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
507
|
+
}
|
|
508
|
+
return LetData.fileFOF.readFileBase64Sync({ "路径": path });
|
|
509
|
+
},
|
|
510
|
+
readFileHexSync: (path) => {
|
|
511
|
+
if (LetData.fileFOF == null) {
|
|
512
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
513
|
+
}
|
|
514
|
+
return LetData.fileFOF.readFileHexSync({ "路径": path });
|
|
515
|
+
},
|
|
516
|
+
mkdirSync: (path) => {
|
|
517
|
+
if (LetData.fileFOF == null) {
|
|
518
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
519
|
+
}
|
|
520
|
+
return LetData.fileFOF.mkdirSync(path);
|
|
521
|
+
},
|
|
522
|
+
cp: (path, path2, funEv = undefined) => {
|
|
523
|
+
if (LetData.fileFOF == null) {
|
|
524
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
525
|
+
}
|
|
526
|
+
return LetData.fileFOF.cp(path, path2, funEv);
|
|
527
|
+
},
|
|
528
|
+
renameSync: (path, newPath) => {
|
|
529
|
+
if (LetData.fileFOF == null) {
|
|
530
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
531
|
+
}
|
|
532
|
+
return LetData.fileFOF.renameSync({ "路径": path, "路径2": newPath });
|
|
533
|
+
},
|
|
534
|
+
unlink: (path, funEv = undefined) => {
|
|
535
|
+
if (LetData.fileFOF == null) {
|
|
536
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
537
|
+
}
|
|
538
|
+
return LetData.fileFOF.unlink(path, funEv);
|
|
539
|
+
},
|
|
540
|
+
appendFile: (path, data) => {
|
|
541
|
+
if (LetData.fileFOF == null) {
|
|
542
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
543
|
+
}
|
|
544
|
+
return LetData.fileFOF.appendFile({ "路径": path, "数据": data });
|
|
545
|
+
},
|
|
546
|
+
basename: (path) => {
|
|
547
|
+
if (LetData.fileFOF == null) {
|
|
548
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
549
|
+
}
|
|
550
|
+
return LetData.fileFOF.basename(path);
|
|
551
|
+
},
|
|
552
|
+
dirname: (path) => {
|
|
553
|
+
if (LetData.fileFOF == null) {
|
|
554
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
555
|
+
}
|
|
556
|
+
return LetData.fileFOF.dirname(path);
|
|
557
|
+
},
|
|
558
|
+
extname: (path) => {
|
|
559
|
+
if (LetData.fileFOF == null) {
|
|
560
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
561
|
+
}
|
|
562
|
+
return LetData.fileFOF.extname(path);
|
|
563
|
+
},
|
|
564
|
+
isAbsolute: (path) => {
|
|
565
|
+
if (LetData.fileFOF == null) {
|
|
566
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
567
|
+
}
|
|
568
|
+
return LetData.fileFOF.isAbsolute(path);
|
|
569
|
+
},
|
|
570
|
+
normalize: (path) => {
|
|
571
|
+
if (LetData.fileFOF == null) {
|
|
572
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
573
|
+
}
|
|
574
|
+
return LetData.fileFOF.normalize(path);
|
|
575
|
+
},
|
|
576
|
+
FileMsg: (path, EVFun) => {
|
|
577
|
+
if (LetData.fileFOF == null) {
|
|
578
|
+
LetData.fileFOF = require('./modules/File.js');
|
|
579
|
+
}
|
|
580
|
+
return LetData.fileFOF.FileMsg(path, EVFun);
|
|
581
|
+
},
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
electronFileAPI.getAppPath = function () {
|
|
585
|
+
let path = __dirname.replace("/MCPMain.js", "")
|
|
586
|
+
path = path.replaceAll("\\", "/")
|
|
587
|
+
return path;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
let electronDecoderAPI = {
|
|
591
|
+
TextDecoder: (Decoder, Code, hexTrue = false, hexCode = "hex") => {
|
|
592
|
+
if (LetData.DecoderAPI == null) {
|
|
593
|
+
LetData.DecoderAPI = require('./modules/DecoderAPI.js');
|
|
594
|
+
}
|
|
595
|
+
return LetData.DecoderAPI.TextDecoder(Decoder, Code, hexTrue, hexCode);
|
|
596
|
+
},
|
|
597
|
+
TextDecoderBase64: (Decoder, Code) => {
|
|
598
|
+
if (LetData.DecoderAPI == null) {
|
|
599
|
+
LetData.DecoderAPI = require('./modules/DecoderAPI.js');
|
|
600
|
+
}
|
|
601
|
+
return LetData.DecoderAPI.TextDecoderBase64(Decoder, Code);
|
|
602
|
+
},
|
|
603
|
+
TextToBase64: (Code) => {
|
|
604
|
+
if (LetData.DecoderAPI == null) {
|
|
605
|
+
LetData.DecoderAPI = require('./modules/DecoderAPI.js');
|
|
606
|
+
}
|
|
607
|
+
return LetData.DecoderAPI.TextToBase64(Code);
|
|
608
|
+
},
|
|
609
|
+
Base64ToText: (Code) => {
|
|
610
|
+
if (LetData.DecoderAPI == null) {
|
|
611
|
+
LetData.DecoderAPI = require('./modules/DecoderAPI.js');
|
|
612
|
+
}
|
|
613
|
+
return LetData.DecoderAPI.Base64ToText(Code);
|
|
614
|
+
},
|
|
615
|
+
TextTo16: (Code) => {
|
|
616
|
+
if (LetData.DecoderAPI == null) {
|
|
617
|
+
LetData.DecoderAPI = require('./modules/DecoderAPI.js');
|
|
618
|
+
}
|
|
619
|
+
return LetData.DecoderAPI.TextTo16(Code);
|
|
620
|
+
},
|
|
621
|
+
HexToText: (Code) => {
|
|
622
|
+
if (LetData.DecoderAPI == null) {
|
|
623
|
+
LetData.DecoderAPI = require('./modules/DecoderAPI.js');
|
|
624
|
+
}
|
|
625
|
+
return LetData.DecoderAPI.HexToText(Code);
|
|
626
|
+
},
|
|
627
|
+
}
|
|
628
|
+
let electronHTTPAPI = {
|
|
629
|
+
httpSend: (url, RetFun = undefined, method_ = "GET", POSTDATA = "", headers_ = {}) => {
|
|
630
|
+
if (LetData.SendHttp == null) {
|
|
631
|
+
LetData.SendHttp = require('./modules/SendHttp.js');
|
|
632
|
+
}
|
|
633
|
+
LetData.SendHttp.httpSend(url, RetFun, method_, POSTDATA, headers_);
|
|
634
|
+
},
|
|
635
|
+
httpsSend: (url, RetFun = undefined, method_ = "GET", POSTDATA = "", headers_ = {}) => {
|
|
636
|
+
if (LetData.SendHttp == null) {
|
|
637
|
+
LetData.SendHttp = require('./modules/SendHttp.js');
|
|
638
|
+
}
|
|
639
|
+
LetData.SendHttp.httpsSend(url, RetFun, method_, POSTDATA, headers_);
|
|
640
|
+
},
|
|
641
|
+
}
|
|
642
|
+
let electronSqlServer = {
|
|
643
|
+
sendsqlserver: (funStr, host, user, password, database, port = 1433, max = 20, if2000 = false, obj = undefined) => {
|
|
644
|
+
if (LetData.sqlServer == null) {
|
|
645
|
+
LetData.sqlServer = require('./modules/sqlServer.js');
|
|
646
|
+
}
|
|
647
|
+
return LetData.sqlServer.sendsqlserver(funStr, host, user, password, database, port, max, if2000, obj);
|
|
648
|
+
},
|
|
649
|
+
exec: (funStr, sqltXet, values, poolID = 0) => {
|
|
650
|
+
if (LetData.sqlServer == null) {
|
|
651
|
+
LetData.sqlServer = require('./modules/sqlServer.js');
|
|
652
|
+
}
|
|
653
|
+
LetData.sqlServer.exec(sqltXet, values, poolID, funStr)
|
|
654
|
+
},
|
|
655
|
+
exec2: async (sqltXet, values, poolID = 0) => {
|
|
656
|
+
if (LetData.sqlServer == null) {
|
|
657
|
+
LetData.sqlServer = require('./modules/sqlServer.js');
|
|
658
|
+
}
|
|
659
|
+
let RetExec = await LetData.sqlServer.exec(sqltXet, values, poolID, undefined)
|
|
660
|
+
return RetExec;
|
|
661
|
+
},
|
|
662
|
+
execTransaction: (funStr, sqltXet, poolID = 0, TransactionType = {}) => {
|
|
663
|
+
if (LetData.sqlServer == null) {
|
|
664
|
+
LetData.sqlServer = require('./modules/sqlServer.js');
|
|
665
|
+
}
|
|
666
|
+
LetData.sqlServer.execTransaction(sqltXet, poolID, funStr, TransactionType);
|
|
667
|
+
},
|
|
668
|
+
execTransaction2: async (sqltXet, poolID = 0, TransactionType = {}) => {
|
|
669
|
+
if (LetData.sqlServer == null) {
|
|
670
|
+
LetData.sqlServer = require('./modules/sqlServer.js');
|
|
671
|
+
}
|
|
672
|
+
let RetData = {};
|
|
673
|
+
await LetData.sqlServer.execTransaction(sqltXet, poolID, undefined, TransactionType)
|
|
674
|
+
.then(res => {
|
|
675
|
+
RetData = res;
|
|
676
|
+
})
|
|
677
|
+
.catch(err => RetData = { "状态": "失败", "数据": err });
|
|
678
|
+
return RetData;
|
|
679
|
+
},
|
|
680
|
+
endPool: (poolID = 0) => {
|
|
681
|
+
if (LetData.sqlServer == null) {
|
|
682
|
+
LetData.sqlServer = require('./modules/sqlServer.js');
|
|
683
|
+
}
|
|
684
|
+
LetData.sqlServer.endPool(poolID);
|
|
685
|
+
},
|
|
686
|
+
}
|
|
687
|
+
let electronMysql = {
|
|
688
|
+
sendmysql: (funStr, host, user, password, database, port = 3306, connectionLimit = 20, Obj = {}) => {
|
|
689
|
+
if (LetData.fofmysql == null) {
|
|
690
|
+
LetData.fofmysql = require('./modules/mysql.js');
|
|
691
|
+
}
|
|
692
|
+
return LetData.fofmysql.sendmysql(funStr, host, user, password, database, port, connectionLimit, Obj)
|
|
693
|
+
},
|
|
694
|
+
query: (funStr, sqltXet, params = [], poolID = 0) => {
|
|
695
|
+
if (LetData.fofmysql == null) {
|
|
696
|
+
LetData.fofmysql = require('./modules/mysql.js');
|
|
697
|
+
}
|
|
698
|
+
LetData.fofmysql.query(sqltXet, params, poolID, funStr)
|
|
699
|
+
},
|
|
700
|
+
query2: async (sqltXet, params = [], poolID = 0) => {
|
|
701
|
+
if (LetData.fofmysql == null) {
|
|
702
|
+
LetData.fofmysql = require('./modules/mysql.js');
|
|
703
|
+
}
|
|
704
|
+
let RetData = {};
|
|
705
|
+
await LetData.fofmysql.query(sqltXet, params, poolID).then(res => {
|
|
706
|
+
RetData = { "状态": "成功", "数据": res }
|
|
707
|
+
}).catch(err => RetData = { "状态": "失败", "数据": err })
|
|
708
|
+
try {
|
|
709
|
+
if (RetData["数据"] == false) {
|
|
710
|
+
if (Array.isArray(RetData["数据"]) == false) {
|
|
711
|
+
RetData["数据"] = [];
|
|
712
|
+
RetData["状态"] == "失败"
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
} catch (error) {
|
|
716
|
+
|
|
717
|
+
}
|
|
718
|
+
return RetData;
|
|
719
|
+
},
|
|
720
|
+
exec: (funStr, sqltXet, values = [], poolID = 0) => {
|
|
721
|
+
if (LetData.fofmysql == null) {
|
|
722
|
+
LetData.fofmysql = require('./modules/mysql.js');
|
|
723
|
+
}
|
|
724
|
+
LetData.fofmysql.exec(sqltXet, values, poolID, funStr)
|
|
725
|
+
},
|
|
726
|
+
exec2: async (sqltXet, values = [], poolID = 0) => {
|
|
727
|
+
if (LetData.fofmysql == null) {
|
|
728
|
+
LetData.fofmysql = require('./modules/mysql.js');
|
|
729
|
+
}
|
|
730
|
+
let RetData = {};
|
|
731
|
+
await LetData.fofmysql.exec(sqltXet, values, poolID).then(res => {
|
|
732
|
+
RetData = { "状态": "成功", "数据": res && res.affectedRows > 0, "数据2": res }
|
|
733
|
+
}).catch(err => RetData = { "状态": "失败", "数据": err, "数据2": {} });
|
|
734
|
+
return RetData;
|
|
735
|
+
|
|
736
|
+
},
|
|
737
|
+
execTransaction: (funStr, sqlArr, poolID = 0, TransactionType = {}) => {
|
|
738
|
+
if (LetData.fofmysql == null) {
|
|
739
|
+
LetData.fofmysql = require('./modules/mysql.js');
|
|
740
|
+
}
|
|
741
|
+
if (sqlArr.length <= 0) {
|
|
742
|
+
LetData.fofmysql.execTransaction(sqlArr, poolID, funStr, TransactionType);
|
|
743
|
+
} else {
|
|
744
|
+
LetData.fofmysql.execTransaction(sqlArr, poolID)
|
|
745
|
+
.then(res => funStr({ "状态": "成功", "事务状态": "成功", "数据": res }))
|
|
746
|
+
.catch(err => funStr({ "状态": "失败", "事务状态": "无状态", "数据": err }));
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
execTransaction2: async (sqlArr, poolID = 0, TransactionType = {}) => {
|
|
750
|
+
if (LetData.fofmysql == null) {
|
|
751
|
+
LetData.fofmysql = require('./modules/mysql.js');
|
|
752
|
+
}
|
|
753
|
+
let RetData = {};
|
|
754
|
+
if (sqlArr.length <= 0) {
|
|
755
|
+
RetData = await LetData.fofmysql.execTransaction(sqlArr, poolID, undefined, TransactionType);
|
|
756
|
+
return RetData;
|
|
757
|
+
} else {
|
|
758
|
+
await LetData.fofmysql.execTransaction(sqlArr, poolID)
|
|
759
|
+
.then(res => RetData = { "状态": "成功", "事务状态": "成功", "数据": res })
|
|
760
|
+
.catch(err => RetData = { "状态": "失败", "事务状态": "无状态", "数据": err });
|
|
761
|
+
return RetData;
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
endPool: (poolID = 0) => {
|
|
765
|
+
if (LetData.fofmysql == null) {
|
|
766
|
+
LetData.fofmysql = require('./modules/mysql.js');
|
|
767
|
+
}
|
|
768
|
+
LetData.fofmysql.endPool(poolID);
|
|
769
|
+
},
|
|
770
|
+
}
|
|
771
|
+
let electronCrypto = {
|
|
772
|
+
md5: (data) => {
|
|
773
|
+
if (LetData.crypto == null) {
|
|
774
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
775
|
+
}
|
|
776
|
+
return LetData.crypto.md5(data);
|
|
777
|
+
},
|
|
778
|
+
sha1: (data) => {
|
|
779
|
+
if (LetData.crypto == null) {
|
|
780
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
781
|
+
}
|
|
782
|
+
return LetData.crypto.sha1(data);
|
|
783
|
+
},
|
|
784
|
+
md5hmac: (data, password) => {
|
|
785
|
+
if (LetData.crypto == null) {
|
|
786
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
787
|
+
}
|
|
788
|
+
return LetData.crypto.md5hmac(data, password);
|
|
789
|
+
},
|
|
790
|
+
sha256: (data) => {
|
|
791
|
+
if (LetData.crypto == null) {
|
|
792
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
793
|
+
}
|
|
794
|
+
return LetData.crypto.sha256(data);
|
|
795
|
+
},
|
|
796
|
+
sha256hmac: (data, password) => {
|
|
797
|
+
if (LetData.crypto == null) {
|
|
798
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
799
|
+
}
|
|
800
|
+
return LetData.crypto.sha256hmac(data, password);
|
|
801
|
+
},
|
|
802
|
+
shaSet: (type, data) => {
|
|
803
|
+
if (LetData.crypto == null) {
|
|
804
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
805
|
+
}
|
|
806
|
+
return LetData.crypto.shaSet(type, data);
|
|
807
|
+
},
|
|
808
|
+
shaSethmac: (type, data, password) => {
|
|
809
|
+
if (LetData.crypto == null) {
|
|
810
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
811
|
+
}
|
|
812
|
+
return LetData.crypto.shaSethmac(type, data, password);
|
|
813
|
+
},
|
|
814
|
+
encryptBase64: (data) => {
|
|
815
|
+
if (LetData.crypto == null) {
|
|
816
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
817
|
+
}
|
|
818
|
+
return LetData.crypto.encryptBase64(data);
|
|
819
|
+
},
|
|
820
|
+
decryptBase64: (data) => {
|
|
821
|
+
if (LetData.crypto == null) {
|
|
822
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
823
|
+
}
|
|
824
|
+
return LetData.crypto.decryptBase64(data);
|
|
825
|
+
},
|
|
826
|
+
encryptDes: (str, key, iv = null, destype = 'des-ecb') => {
|
|
827
|
+
if (LetData.crypto == null) {
|
|
828
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
829
|
+
}
|
|
830
|
+
return LetData.crypto.encryptDes(str, key, iv, destype);
|
|
831
|
+
},
|
|
832
|
+
decryptDes: (str, key, iv = null, destype = 'des-ecb') => {
|
|
833
|
+
if (LetData.crypto == null) {
|
|
834
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
835
|
+
}
|
|
836
|
+
return LetData.crypto.decryptDes(str, key, iv, destype);
|
|
837
|
+
},
|
|
838
|
+
encryptAes: (str, key, iv = null, destype = 'aes-128-ecb') => {
|
|
839
|
+
if (LetData.crypto == null) {
|
|
840
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
841
|
+
}
|
|
842
|
+
return LetData.crypto.encryptAes(str, key, iv, destype);
|
|
843
|
+
},
|
|
844
|
+
decryptAes: (str, key, iv = null, destype = 'aes-128-ecb') => {
|
|
845
|
+
if (LetData.crypto == null) {
|
|
846
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
847
|
+
}
|
|
848
|
+
return LetData.crypto.decryptAes(str, key, iv, destype);
|
|
849
|
+
},
|
|
850
|
+
generateRSAKey: (size = 1024) => {
|
|
851
|
+
if (LetData.crypto == null) {
|
|
852
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
853
|
+
}
|
|
854
|
+
return LetData.crypto.generateRSAKey(size);
|
|
855
|
+
},
|
|
856
|
+
encryptRSAByPrivateKey: (str, privateKey) => {
|
|
857
|
+
if (LetData.crypto == null) {
|
|
858
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
859
|
+
}
|
|
860
|
+
return LetData.crypto.encryptRSAByPrivateKey(str, privateKey);
|
|
861
|
+
},
|
|
862
|
+
decryptRSAByPublicKey: (str, privateKey) => {
|
|
863
|
+
if (LetData.crypto == null) {
|
|
864
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
865
|
+
}
|
|
866
|
+
return LetData.crypto.decryptRSAByPublicKey(str, privateKey);
|
|
867
|
+
},
|
|
868
|
+
encryptRSAByPublicKey: (str, privateKey) => {
|
|
869
|
+
if (LetData.crypto == null) {
|
|
870
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
871
|
+
}
|
|
872
|
+
return LetData.crypto.encryptRSAByPublicKey(str, privateKey);
|
|
873
|
+
},
|
|
874
|
+
decryptRSAByPrivateKey: (str, privateKey) => {
|
|
875
|
+
if (LetData.crypto == null) {
|
|
876
|
+
LetData.crypto = require('./modules/crypto.js');
|
|
877
|
+
}
|
|
878
|
+
return LetData.crypto.decryptRSAByPrivateKey(str, privateKey);
|
|
879
|
+
},
|
|
880
|
+
}
|
|
881
|
+
let electronSharp = {
|
|
882
|
+
metadata: (img, funStr) => {
|
|
883
|
+
if (LetData.sharp == null) {
|
|
884
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
885
|
+
}
|
|
886
|
+
LetData.sharp.metadata(img).then(res => funStr({ "宽度": res.width, "高度": res.height, "格式": res.format }))
|
|
887
|
+
},
|
|
888
|
+
resize: (img, options, savePath, funStr = undefined) => {
|
|
889
|
+
if (LetData.sharp == null) {
|
|
890
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
891
|
+
}
|
|
892
|
+
LetData.sharp.resize(img, options, savePath, funStr);
|
|
893
|
+
},
|
|
894
|
+
border: (img, options, savePath, funStr = undefined) => {
|
|
895
|
+
if (LetData.sharp == null) {
|
|
896
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
897
|
+
}
|
|
898
|
+
LetData.sharp.border(img, options, savePath, funStr);
|
|
899
|
+
},
|
|
900
|
+
crop: (img, options, savePath, funStr = undefined) => {
|
|
901
|
+
if (LetData.sharp == null) {
|
|
902
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
903
|
+
}
|
|
904
|
+
LetData.sharp.crop(img, options, savePath, funStr);
|
|
905
|
+
},
|
|
906
|
+
format: (img, type, quality = 80, savePath, funStr = undefined) => {
|
|
907
|
+
if (LetData.sharp == null) {
|
|
908
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
909
|
+
}
|
|
910
|
+
LetData.sharp.format(img, type, quality, savePath, funStr);
|
|
911
|
+
},
|
|
912
|
+
rotate: (img, angle, savePath, funStr = undefined) => {
|
|
913
|
+
if (LetData.sharp == null) {
|
|
914
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
915
|
+
}
|
|
916
|
+
LetData.sharp.rotate(img, angle, savePath, funStr);
|
|
917
|
+
},
|
|
918
|
+
rotateBlur: (img, sigma, savePath, funStr = undefined) => {
|
|
919
|
+
if (LetData.sharp == null) {
|
|
920
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
921
|
+
}
|
|
922
|
+
LetData.sharp.rotateBlur(img, sigma, savePath, funStr);
|
|
923
|
+
},
|
|
924
|
+
greyscale: (img, savePath, funStr = undefined) => {
|
|
925
|
+
if (LetData.sharp == null) {
|
|
926
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
927
|
+
}
|
|
928
|
+
LetData.sharp.greyscale(img, savePath, funStr);
|
|
929
|
+
},
|
|
930
|
+
watermark: (img, text, options = {}, savePath, funStr = undefined) => {
|
|
931
|
+
if (LetData.sharp == null) {
|
|
932
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
933
|
+
}
|
|
934
|
+
LetData.sharp.watermark(img, text, options, savePath, funStr);
|
|
935
|
+
},
|
|
936
|
+
watermarkFun: (img, text, options = {}, savePath, funStr = undefined) => {
|
|
937
|
+
if (LetData.sharp == null) {
|
|
938
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
939
|
+
}
|
|
940
|
+
LetData.sharp.watermarkFun(img, text, options, savePath, funStr);
|
|
941
|
+
},
|
|
942
|
+
tint: (img, rgb, savePath, funStr = undefined) => {
|
|
943
|
+
if (LetData.sharp == null) {
|
|
944
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
945
|
+
}
|
|
946
|
+
LetData.sharp.tint(img, rgb, savePath, funStr);
|
|
947
|
+
},
|
|
948
|
+
compose: (img, options, savePath, funStr = undefined) => {
|
|
949
|
+
if (LetData.sharp == null) {
|
|
950
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
951
|
+
}
|
|
952
|
+
LetData.sharp.compose(img, options, savePath, funStr);
|
|
953
|
+
},
|
|
954
|
+
sharpen: (img, options, savePath, funStr = undefined) => {
|
|
955
|
+
if (LetData.sharp == null) {
|
|
956
|
+
LetData.sharp = require('./modules/sharp.js');
|
|
957
|
+
}
|
|
958
|
+
LetData.sharp.sharpen(img, options, savePath, funStr);
|
|
959
|
+
},
|
|
960
|
+
}
|
|
961
|
+
let electronEmailAPI = {
|
|
962
|
+
sendMail: (host, port, name, user, pass, sendto, title, contents, attachments_ = [], funStr = undefined) => {
|
|
963
|
+
if (LetData.email == null) {
|
|
964
|
+
LetData.email = require('./modules/email.js');
|
|
965
|
+
}
|
|
966
|
+
LetData.email.sendMail(host, port, name, user, pass, sendto, title, contents, attachments_, funStr);
|
|
967
|
+
},
|
|
968
|
+
}
|
|
969
|
+
let electronCompressAPI = {
|
|
970
|
+
compressDir: (dirPath, output, format, funStr = undefined) => {
|
|
971
|
+
if (LetData.compress == null) {
|
|
972
|
+
LetData.compress = require('./modules/compress.js');
|
|
973
|
+
}
|
|
974
|
+
LetData.compress.compressDir(dirPath, output, format, funStr);
|
|
975
|
+
},
|
|
976
|
+
compressFile: (filePath, output, format, funStr = undefined) => {
|
|
977
|
+
if (LetData.compress == null) {
|
|
978
|
+
LetData.compress = require('./modules/compress.js');
|
|
979
|
+
}
|
|
980
|
+
LetData.compress.compressFile(filePath, output, format, funStr);
|
|
981
|
+
},
|
|
982
|
+
compressFileBatch: (filePathArr, output, format, funStr = undefined) => {
|
|
983
|
+
if (LetData.compress == null) {
|
|
984
|
+
LetData.compress = require('./modules/compress.js');
|
|
985
|
+
}
|
|
986
|
+
LetData.compress.compressFileBatch(filePathArr, output, format, funStr);
|
|
987
|
+
},
|
|
988
|
+
unCompress: (filePath, output, funStr = undefined) => {
|
|
989
|
+
if (LetData.compress == null) {
|
|
990
|
+
LetData.compress = require('./modules/compress.js');
|
|
991
|
+
}
|
|
992
|
+
LetData.compress.unCompress(filePath, output, funStr);
|
|
993
|
+
},
|
|
994
|
+
}
|
|
995
|
+
let electronFtpAPI = {
|
|
996
|
+
config: (host_, port_, user_, password_) => {
|
|
997
|
+
if (LetData.ftp == null) {
|
|
998
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
999
|
+
}
|
|
1000
|
+
LetData.ftp.config(host_, port_ + "", user_, password_);
|
|
1001
|
+
},
|
|
1002
|
+
list: (funStr = undefined, path = "") => {
|
|
1003
|
+
if (LetData.ftp == null) {
|
|
1004
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
1005
|
+
}
|
|
1006
|
+
LetData.ftp.list(funStr, path);
|
|
1007
|
+
},
|
|
1008
|
+
download: (targetPath, savePath, funStr = undefined) => {
|
|
1009
|
+
if (LetData.ftp == null) {
|
|
1010
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
1011
|
+
}
|
|
1012
|
+
LetData.ftp.download(targetPath, savePath, funStr);
|
|
1013
|
+
},
|
|
1014
|
+
upload: (filePath, savePath, funStr = undefined) => {
|
|
1015
|
+
if (LetData.ftp == null) {
|
|
1016
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
1017
|
+
}
|
|
1018
|
+
LetData.ftp.upload(savePath, filePath, funStr);
|
|
1019
|
+
},
|
|
1020
|
+
delete: (filePath, funStr = undefined) => {
|
|
1021
|
+
if (LetData.ftp == null) {
|
|
1022
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
1023
|
+
}
|
|
1024
|
+
LetData.ftp.delete(filePath, funStr);
|
|
1025
|
+
},
|
|
1026
|
+
rename: (oldPath, newPath, funStr = undefined) => {
|
|
1027
|
+
if (LetData.ftp == null) {
|
|
1028
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
1029
|
+
}
|
|
1030
|
+
LetData.ftp.rename(oldPath, newPath, funStr);
|
|
1031
|
+
},
|
|
1032
|
+
mkDir: (dirPath, funStr = undefined) => {
|
|
1033
|
+
if (LetData.ftp == null) {
|
|
1034
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
1035
|
+
}
|
|
1036
|
+
LetData.ftp.mkDir(dirPath, funStr);
|
|
1037
|
+
},
|
|
1038
|
+
rmDir: (dirPath, funStr = undefined) => {
|
|
1039
|
+
if (LetData.ftp == null) {
|
|
1040
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
1041
|
+
}
|
|
1042
|
+
LetData.ftp.rmDir(dirPath, funStr);
|
|
1043
|
+
},
|
|
1044
|
+
size: (filePath, funStr = undefined) => {
|
|
1045
|
+
if (LetData.ftp == null) {
|
|
1046
|
+
LetData.ftp = require('./modules/ftp.js');
|
|
1047
|
+
}
|
|
1048
|
+
LetData.ftp.size(filePath, funStr);
|
|
1049
|
+
},
|
|
1050
|
+
|
|
1051
|
+
}
|
|
1052
|
+
let electronHttpServerAPI = {
|
|
1053
|
+
initServer: (Data, MsgFun = undefined, funGet = undefined, funPost = undefined, funPut = undefined) => {
|
|
1054
|
+
if (LetData.HttpServer == null) {
|
|
1055
|
+
LetData.HttpServer = require('./modules/HttpServer.js');
|
|
1056
|
+
}
|
|
1057
|
+
return LetData.HttpServer.initServer(Data, MsgFun, funGet, funPost, funPut);
|
|
1058
|
+
},
|
|
1059
|
+
getTypeMime: (extname) => {
|
|
1060
|
+
if (LetData.HttpServer == null) {
|
|
1061
|
+
LetData.HttpServer = require('./modules/HttpServer.js');
|
|
1062
|
+
}
|
|
1063
|
+
return LetData.HttpServer.getTypeMime(extname);
|
|
1064
|
+
},
|
|
1065
|
+
serverClose: (IntID) => {
|
|
1066
|
+
if (LetData.HttpServer == null) {
|
|
1067
|
+
LetData.HttpServer = require('./modules/HttpServer.js');
|
|
1068
|
+
}
|
|
1069
|
+
LetData.HttpServer.serverClose(IntID);
|
|
1070
|
+
},
|
|
1071
|
+
|
|
1072
|
+
}
|
|
1073
|
+
let electronTcpServerAPI = {
|
|
1074
|
+
NewServer: (ServerData, MsgFun = undefined) => {
|
|
1075
|
+
if (LetData.TcpServer == null) {
|
|
1076
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1077
|
+
}
|
|
1078
|
+
return LetData.TcpServer.NewServer(ServerData, MsgFun);
|
|
1079
|
+
},
|
|
1080
|
+
InsertIPBlacklist: (ip) => {
|
|
1081
|
+
if (LetData.TcpServer == null) {
|
|
1082
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1083
|
+
}
|
|
1084
|
+
return LetData.TcpServer.InsertIPBlacklist(ip);
|
|
1085
|
+
},
|
|
1086
|
+
ServerClose: (server) => {
|
|
1087
|
+
if (LetData.TcpServer == null) {
|
|
1088
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1089
|
+
}
|
|
1090
|
+
return LetData.TcpServer.ServerClose(server);
|
|
1091
|
+
},
|
|
1092
|
+
send: (ServerIDInt, id, data) => {
|
|
1093
|
+
if (LetData.TcpServer == null) {
|
|
1094
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1095
|
+
}
|
|
1096
|
+
LetData.TcpServer.send(ServerIDInt, id, data);
|
|
1097
|
+
},
|
|
1098
|
+
Disconnect: (ServerIDInt, id) => {
|
|
1099
|
+
if (LetData.TcpServer == null) {
|
|
1100
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1101
|
+
}
|
|
1102
|
+
LetData.TcpServer.Disconnect(ServerIDInt, id);
|
|
1103
|
+
},
|
|
1104
|
+
socketList: (ServerIDInt) => {
|
|
1105
|
+
if (LetData.TcpServer == null) {
|
|
1106
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1107
|
+
}
|
|
1108
|
+
return LetData.TcpServer.socketList(ServerIDInt);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
let electronTcpSocketAPI = {
|
|
1112
|
+
NewSocket: (ServerData, MsgFun = undefined) => {
|
|
1113
|
+
if (LetData.TcpServer == null) {
|
|
1114
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1115
|
+
}
|
|
1116
|
+
return LetData.TcpServer.NewSocket(ServerData, MsgFun);
|
|
1117
|
+
},
|
|
1118
|
+
SocketWrite: (IntServer, Data) => {
|
|
1119
|
+
if (LetData.TcpServer == null) {
|
|
1120
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1121
|
+
}
|
|
1122
|
+
return LetData.TcpServer.SocketWrite(IntServer, Data);
|
|
1123
|
+
},
|
|
1124
|
+
SocketReadyState: (IntServer) => {
|
|
1125
|
+
if (LetData.TcpServer == null) {
|
|
1126
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1127
|
+
}
|
|
1128
|
+
return LetData.TcpServer.SocketReadyState(IntServer);
|
|
1129
|
+
},
|
|
1130
|
+
SocketDestroy: (IntServer) => {
|
|
1131
|
+
if (LetData.TcpServer == null) {
|
|
1132
|
+
LetData.TcpServer = require('./modules/FOFTcp.js');
|
|
1133
|
+
}
|
|
1134
|
+
return LetData.TcpServer.SocketDestroy(IntServer);
|
|
1135
|
+
},
|
|
1136
|
+
|
|
1137
|
+
}
|
|
1138
|
+
let electronUdpServerAPI = {
|
|
1139
|
+
NewServer: (port = 22333, MsgFun = undefined) => {
|
|
1140
|
+
if (LetData.UdpServer == null) {
|
|
1141
|
+
LetData.UdpServer = require('./modules/FOFUDP.js');
|
|
1142
|
+
}
|
|
1143
|
+
return LetData.UdpServer.NewServer(port, MsgFun);
|
|
1144
|
+
},
|
|
1145
|
+
ServerClose: (IntServer) => {
|
|
1146
|
+
if (LetData.UdpServer == null) {
|
|
1147
|
+
LetData.UdpServer = require('./modules/FOFUDP.js');
|
|
1148
|
+
}
|
|
1149
|
+
return LetData.UdpServer.ServerClose(IntServer);
|
|
1150
|
+
},
|
|
1151
|
+
ServerSend: (IntServer, data, address, port) => {
|
|
1152
|
+
if (LetData.UdpServer == null) {
|
|
1153
|
+
LetData.UdpServer = require('./modules/FOFUDP.js');
|
|
1154
|
+
}
|
|
1155
|
+
return LetData.UdpServer.ServerSend(IntServer, data, address, port);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
let electronUdpClientAPI = {
|
|
1159
|
+
NewClient: (MsgFun = undefined) => {
|
|
1160
|
+
if (LetData.UdpServer == null) {
|
|
1161
|
+
LetData.UdpServer = require('./modules/FOFUDP.js');
|
|
1162
|
+
}
|
|
1163
|
+
return LetData.UdpServer.NewClient(MsgFun);
|
|
1164
|
+
},
|
|
1165
|
+
ClientClose: (IntServer) => {
|
|
1166
|
+
if (LetData.UdpServer == null) {
|
|
1167
|
+
LetData.UdpServer = require('./modules/FOFUDP.js');
|
|
1168
|
+
}
|
|
1169
|
+
return LetData.UdpServer.ClientClose(IntServer);
|
|
1170
|
+
},
|
|
1171
|
+
ClientSend: (IntServer, message, address, port) => {
|
|
1172
|
+
if (LetData.UdpServer == null) {
|
|
1173
|
+
LetData.UdpServer = require('./modules/FOFUDP.js');
|
|
1174
|
+
}
|
|
1175
|
+
return LetData.UdpServer.ClientSend(IntServer, message, address, port);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
let BufferClass = {
|
|
1179
|
+
BufferClassToArrar: (data) => {
|
|
1180
|
+
if (LetData.BufferClass == null) {
|
|
1181
|
+
LetData.BufferClass = require('./modules/BufferClass.js');
|
|
1182
|
+
}
|
|
1183
|
+
return LetData.BufferClass.BufferClassToArrar(data);
|
|
1184
|
+
},
|
|
1185
|
+
ArrarToBufferClass: (data) => {
|
|
1186
|
+
if (LetData.BufferClass == null) {
|
|
1187
|
+
LetData.BufferClass = require('./modules/BufferClass.js');
|
|
1188
|
+
}
|
|
1189
|
+
return LetData.BufferClass.ArrarToBufferClass(data);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
let DataPackaging = {
|
|
1193
|
+
NewID: (ID, dataHead, dataEnd) => {
|
|
1194
|
+
if (LetData.DataPackaging == null) {
|
|
1195
|
+
LetData.DataPackaging = require('./modules/DataPackaging.js');
|
|
1196
|
+
}
|
|
1197
|
+
return LetData.DataPackaging.NewID(ID, dataHead, dataEnd);
|
|
1198
|
+
},
|
|
1199
|
+
InsertData: (ID, Data) => {
|
|
1200
|
+
if (LetData.DataPackaging == null) {
|
|
1201
|
+
LetData.DataPackaging = require('./modules/DataPackaging.js');
|
|
1202
|
+
}
|
|
1203
|
+
return LetData.DataPackaging.InsertData(ID, Data);
|
|
1204
|
+
},
|
|
1205
|
+
SelectData: (ID) => {
|
|
1206
|
+
if (LetData.DataPackaging == null) {
|
|
1207
|
+
LetData.DataPackaging = require('./modules/DataPackaging.js');
|
|
1208
|
+
}
|
|
1209
|
+
return LetData.DataPackaging.SelectData(ID);
|
|
1210
|
+
},
|
|
1211
|
+
IFDataLength: (ID) => {
|
|
1212
|
+
if (LetData.DataPackaging == null) {
|
|
1213
|
+
LetData.DataPackaging = require('./modules/DataPackaging.js');
|
|
1214
|
+
}
|
|
1215
|
+
return LetData.DataPackaging.IFDataLength(ID);
|
|
1216
|
+
},
|
|
1217
|
+
DeleteData: (ID) => {
|
|
1218
|
+
if (LetData.DataPackaging == null) {
|
|
1219
|
+
LetData.DataPackaging = require('./modules/DataPackaging.js');
|
|
1220
|
+
}
|
|
1221
|
+
return LetData.DataPackaging.DeleteData(ID);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
let websocketServer = {
|
|
1225
|
+
initWebSocketServer: (port_ = 8080, fun = undefined) => {
|
|
1226
|
+
if (LetData.websocket == null) {
|
|
1227
|
+
LetData.websocket = require('./modules/WebSocKet.js');
|
|
1228
|
+
}
|
|
1229
|
+
return LetData.websocket.initWebSocketServer(port_, fun);
|
|
1230
|
+
},
|
|
1231
|
+
send: (ServerIDInt, id, data) => {
|
|
1232
|
+
if (LetData.websocket == null) {
|
|
1233
|
+
LetData.websocket = require('./modules/WebSocKet.js');
|
|
1234
|
+
}
|
|
1235
|
+
LetData.websocket.send(ServerIDInt, id, data);
|
|
1236
|
+
},
|
|
1237
|
+
Disconnect: (ServerIDInt, id) => {
|
|
1238
|
+
if (LetData.websocket == null) {
|
|
1239
|
+
LetData.websocket = require('./modules/WebSocKet.js');
|
|
1240
|
+
}
|
|
1241
|
+
LetData.websocket.Disconnect(ServerIDInt, id);
|
|
1242
|
+
},
|
|
1243
|
+
socketList: (ServerIDInt) => {
|
|
1244
|
+
if (LetData.websocket == null) {
|
|
1245
|
+
LetData.websocket = require('./modules/WebSocKet.js');
|
|
1246
|
+
}
|
|
1247
|
+
return LetData.websocket.socketList(ServerIDInt);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
}
|
|
1251
|
+
let electronSqlite3 = {
|
|
1252
|
+
SetDatabase: (dbpath, password) => {
|
|
1253
|
+
if (LetData.fofsqlite3 == null) {
|
|
1254
|
+
LetData.fofsqlite3 = require('./modules/sqlite3.js');
|
|
1255
|
+
}
|
|
1256
|
+
return LetData.fofsqlite3.SetDatabase(dbpath, password)
|
|
1257
|
+
},
|
|
1258
|
+
query: (funStr, sqltXet, params, DBID = null) => {
|
|
1259
|
+
if (LetData.fofsqlite3 == null) {
|
|
1260
|
+
LetData.fofsqlite3 = require('./modules/sqlite3.js');
|
|
1261
|
+
}
|
|
1262
|
+
LetData.fofsqlite3.query(sqltXet, params, DBID).then(res => {
|
|
1263
|
+
funStr({ "状态": "成功", "数据": res })
|
|
1264
|
+
}).catch(err => funStr({ "状态": "失败", "数据": err }))
|
|
1265
|
+
},
|
|
1266
|
+
query2: async (sqltXet, params, DBID = null) => {
|
|
1267
|
+
if (LetData.fofsqlite3 == null) {
|
|
1268
|
+
LetData.fofsqlite3 = require('./modules/sqlite3.js');
|
|
1269
|
+
}
|
|
1270
|
+
let RetData = {};
|
|
1271
|
+
await LetData.fofsqlite3.query(sqltXet, params, DBID).then(res => {
|
|
1272
|
+
RetData = { "状态": "成功", "数据": res }
|
|
1273
|
+
}).catch(err => RetData = { "状态": "失败", "数据": err })
|
|
1274
|
+
return RetData;
|
|
1275
|
+
},
|
|
1276
|
+
exec: (funStr, sqltXet, values = [], DBID = null) => {
|
|
1277
|
+
if (LetData.fofsqlite3 == null) {
|
|
1278
|
+
LetData.fofsqlite3 = require('./modules/sqlite3.js');
|
|
1279
|
+
}
|
|
1280
|
+
LetData.fofsqlite3.exec(sqltXet, values, DBID).then(res => res ? funStr({ "状态": "成功", "数据": res }) : funStr({ "状态": "失败", "数据": res })).catch(err => funStr({ "状态": "失败", "数据": err }));
|
|
1281
|
+
},
|
|
1282
|
+
exec2: async (sqltXet, values = [], DBID = null) => {
|
|
1283
|
+
if (LetData.fofsqlite3 == null) {
|
|
1284
|
+
LetData.fofsqlite3 = require('./modules/sqlite3.js');
|
|
1285
|
+
}
|
|
1286
|
+
let RetData = {};
|
|
1287
|
+
await LetData.fofsqlite3.exec(sqltXet, values, DBID).then(res => res ? RetData = { "状态": "成功", "数据": res } : RetData = { "状态": "失败", "数据": res }).catch(err => RetData = { "状态": "失败", "数据": err });
|
|
1288
|
+
return RetData;
|
|
1289
|
+
},
|
|
1290
|
+
execTransaction: (funStr, sqlArr) => {
|
|
1291
|
+
if (LetData.fofsqlite3 == null) {
|
|
1292
|
+
LetData.fofsqlite3 = require('./modules/sqlite3.js');
|
|
1293
|
+
}
|
|
1294
|
+
LetData.fofsqlite3.execTransaction(sqlArr)
|
|
1295
|
+
.then(res => res ? funStr({ "状态": "成功", "事务状态": "成功", "数据": res }) : funStr({ "状态": "失败", "事务状态": "失败并回滚", "数据": res }))
|
|
1296
|
+
.catch(err => funStr({ "状态": "失败", "事务状态": "无状态", "数据": err }));
|
|
1297
|
+
},
|
|
1298
|
+
execTransaction2: async (sqlArr) => {
|
|
1299
|
+
if (LetData.fofsqlite3 == null) {
|
|
1300
|
+
LetData.fofsqlite3 = require('./modules/sqlite3.js');
|
|
1301
|
+
}
|
|
1302
|
+
let RetData = {};
|
|
1303
|
+
await LetData.fofsqlite3.execTransaction(sqlArr)
|
|
1304
|
+
.then(res => res ? RetData = { "状态": "成功", "事务状态": "成功", "数据": res } : RetData = { "状态": "失败", "事务状态": "失败并回滚", "数据": res })
|
|
1305
|
+
.catch(err => RetData = { "状态": "失败", "事务状态": "无状态", "数据": err });
|
|
1306
|
+
return RetData;
|
|
1307
|
+
},
|
|
1308
|
+
}
|
|
1309
|
+
let electronSms = {
|
|
1310
|
+
generateCode: (bit = 6, onlyNumber = true) => {
|
|
1311
|
+
if (LetData.sms == null) {
|
|
1312
|
+
LetData.sms = require('./modules/sms.js');
|
|
1313
|
+
}
|
|
1314
|
+
return LetData.sms.generateCode(bit, onlyNumber)
|
|
1315
|
+
},
|
|
1316
|
+
sendAliSMS: (fun = undefined, config = {}, phone, params = {}) => {
|
|
1317
|
+
if (LetData.sms == null) {
|
|
1318
|
+
LetData.sms = require('./modules/sms.js');
|
|
1319
|
+
}
|
|
1320
|
+
LetData.sms.sendAliSMS(config, phone, params).then(res => res ? fun({ "状态": "成功" }) : fun({ "状态": "失败", "数据": res })).catch(err => fun({ "状态": "失败", "数据": err }));
|
|
1321
|
+
},
|
|
1322
|
+
sendTencentSMS: (fun = undefined, config = {}, phone, params = []) => {
|
|
1323
|
+
if (LetData.sms == null) {
|
|
1324
|
+
LetData.sms = require('./modules/sms.js');
|
|
1325
|
+
}
|
|
1326
|
+
LetData.sms.sendTencentSMS(config, phone, params).then(res => res ? fun({ "状态": "成功" }) : fun({ "状态": "失败", "数据": res })).catch(err => fun({ "状态": "失败", "数据": err }));
|
|
1327
|
+
},
|
|
1328
|
+
sendAliSMS2: async (config = {}, phone, params = {}) => {
|
|
1329
|
+
if (LetData.sms == null) {
|
|
1330
|
+
LetData.sms = require('./modules/sms.js');
|
|
1331
|
+
}
|
|
1332
|
+
let RetData = {};
|
|
1333
|
+
await LetData.sms.sendAliSMS(config, phone, params).then(res => RetData = { "状态": "成功", "数据": res }).catch(err => RetData = { "状态": "失败", "数据": err });
|
|
1334
|
+
return RetData;
|
|
1335
|
+
},
|
|
1336
|
+
sendTencentSMS2: async (config = {}, phone, params = []) => {
|
|
1337
|
+
if (LetData.sms == null) {
|
|
1338
|
+
LetData.sms = require('./modules/sms.js');
|
|
1339
|
+
}
|
|
1340
|
+
let RetData = {};
|
|
1341
|
+
await LetData.sms.sendTencentSMS(config, phone, params).then(res => RetData = { "状态": "成功", "数据": res }).catch(err => RetData = { "状态": "失败", "数据": err });
|
|
1342
|
+
return RetData;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
let electronExcel = {
|
|
1346
|
+
readFileSheet: (filePath, sheetName) => {
|
|
1347
|
+
if (LetData.excel == null) {
|
|
1348
|
+
LetData.excel = require('./modules/excel.js');
|
|
1349
|
+
}
|
|
1350
|
+
return LetData.excel.readFileSheet(filePath, sheetName)
|
|
1351
|
+
},
|
|
1352
|
+
readFileToJson: (filePath, sheetName) => {
|
|
1353
|
+
if (LetData.excel == null) {
|
|
1354
|
+
LetData.excel = require('./modules/excel.js');
|
|
1355
|
+
}
|
|
1356
|
+
return LetData.excel.readFileToJson(filePath, sheetName)
|
|
1357
|
+
},
|
|
1358
|
+
readFileToHtml: (filePath, sheetName) => {
|
|
1359
|
+
if (LetData.excel == null) {
|
|
1360
|
+
LetData.excel = require('./modules/excel.js');
|
|
1361
|
+
}
|
|
1362
|
+
return LetData.excel.readFileToHtml(filePath, sheetName)
|
|
1363
|
+
},
|
|
1364
|
+
readFileToCsv: (filePath, sheetName) => {
|
|
1365
|
+
if (LetData.excel == null) {
|
|
1366
|
+
LetData.excel = require('./modules/excel.js');
|
|
1367
|
+
}
|
|
1368
|
+
return LetData.excel.readFileToCsv(filePath, sheetName)
|
|
1369
|
+
},
|
|
1370
|
+
createFileFrom: (data, savePath = "", sheetName = 'sheet1') => {
|
|
1371
|
+
if (LetData.excel == null) {
|
|
1372
|
+
LetData.excel = require('./modules/excel.js');
|
|
1373
|
+
}
|
|
1374
|
+
LetData.excel.createFileFrom(data, savePath, sheetName)
|
|
1375
|
+
},
|
|
1376
|
+
createFileFromArray: (data, savePath = "", sheetName = 'sheet1') => {
|
|
1377
|
+
if (LetData.excel == null) {
|
|
1378
|
+
LetData.excel = require('./modules/excel.js');
|
|
1379
|
+
}
|
|
1380
|
+
LetData.excel.createFileFromArray(data, savePath, sheetName)
|
|
1381
|
+
},
|
|
1382
|
+
createFileFromJsonArray: (data, savePath = "", sheetName = 'sheet1') => {
|
|
1383
|
+
if (LetData.excel == null) {
|
|
1384
|
+
LetData.excel = require('./modules/excel.js');
|
|
1385
|
+
}
|
|
1386
|
+
LetData.excel.createFileFromJsonArray(data, savePath, sheetName)
|
|
1387
|
+
},
|
|
1388
|
+
}
|
|
1389
|
+
let electronWrod = {
|
|
1390
|
+
insertWordText: (content, paragraphStyle = 0, textStyle) => {
|
|
1391
|
+
LetData.docxObj.insertWordText(content, paragraphStyle, textStyle)
|
|
1392
|
+
},
|
|
1393
|
+
insertWordImage: (imagePath, paragraphStyle = 0, imageStyle) => {
|
|
1394
|
+
LetData.docxObj.insertWordImage(imagePath, paragraphStyle, imageStyle)
|
|
1395
|
+
},
|
|
1396
|
+
insertWordTable: (tableArray, tableStyle) => {
|
|
1397
|
+
LetData.docxObj.insertWordTable(tableArray, tableStyle)
|
|
1398
|
+
},
|
|
1399
|
+
insertWordHeader: (content, paragraphStyle, textStyle) => {
|
|
1400
|
+
LetData.docxObj.insertWordHeader(content, paragraphStyle, textStyle)
|
|
1401
|
+
},
|
|
1402
|
+
insertWordFooter: (content, paragraphStyle, textStyle) => {
|
|
1403
|
+
LetData.docxObj.insertWordFooter(content, paragraphStyle, textStyle)
|
|
1404
|
+
},
|
|
1405
|
+
insertHorizontalLine: () => {
|
|
1406
|
+
LetData.docxObj.insertHorizontalLine()
|
|
1407
|
+
},
|
|
1408
|
+
insertSoftEnter: () => {
|
|
1409
|
+
LetData.docxObj.insertSoftEnter()
|
|
1410
|
+
},
|
|
1411
|
+
insertPageBreak: () => {
|
|
1412
|
+
LetData.docxObj.insertPageBreak()
|
|
1413
|
+
},
|
|
1414
|
+
insertListItem: (content, style, dots = true, level) => {
|
|
1415
|
+
LetData.docxObj.insertListItem(content, style, dots, level)
|
|
1416
|
+
},
|
|
1417
|
+
output: (fun = undefined) => {
|
|
1418
|
+
LetData.docxObj.output(LetData.wordPath, fun)
|
|
1419
|
+
},
|
|
1420
|
+
NewWord: (filePath) => {
|
|
1421
|
+
if (LetData.word == null) {
|
|
1422
|
+
LetData.word = require('./modules/word.js');
|
|
1423
|
+
}
|
|
1424
|
+
LetData.docxObj = LetData.word.createWord({
|
|
1425
|
+
creator: 'MrJiang',
|
|
1426
|
+
description: 'This is Through NodeJS Operate Microsoft Office Word Library Demo.',
|
|
1427
|
+
title: 'Microsoft Office Word Demo For NodeJS',
|
|
1428
|
+
subject: 'Microsoft Office Word Library',
|
|
1429
|
+
})
|
|
1430
|
+
LetData.wordPath = filePath;
|
|
1431
|
+
},
|
|
1432
|
+
}
|
|
1433
|
+
let FOFnodeRsa = {
|
|
1434
|
+
RsaSign: (Str, RsaKey, KeyLengTh = 1024, signingScheme = "sha256", userPrivateKey = 'pkcs8-private') => {
|
|
1435
|
+
if (LetData.nodeRsa == null) {
|
|
1436
|
+
LetData.nodeRsa = require('./modules/NodeRsa.js');
|
|
1437
|
+
}
|
|
1438
|
+
return LetData.nodeRsa.RsaSign(Str, RsaKey, KeyLengTh, signingScheme, userPrivateKey)
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
let FOFffiNapi = {
|
|
1442
|
+
insertCode: (file, code) => {
|
|
1443
|
+
if (LetData.ffiNapi == null) {
|
|
1444
|
+
LetData.ffiNapi = require('./modules/ffiNapi.js');
|
|
1445
|
+
}
|
|
1446
|
+
return LetData.ffiNapi.insertCode(file, code)
|
|
1447
|
+
},
|
|
1448
|
+
GetCallback: (name, int_ = 0) => {
|
|
1449
|
+
if (LetData.ffiNapi == null) {
|
|
1450
|
+
LetData.ffiNapi = require('./modules/ffiNapi.js');
|
|
1451
|
+
}
|
|
1452
|
+
return LetData.ffiNapi.GetCallback(name, int_)
|
|
1453
|
+
},
|
|
1454
|
+
RetCodeList: (name, int_ = 0) => {
|
|
1455
|
+
if (LetData.ffiNapi == null) {
|
|
1456
|
+
LetData.ffiNapi = require('./modules/ffiNapi.js');
|
|
1457
|
+
}
|
|
1458
|
+
return LetData.ffiNapi.RetCodeList(name, int_)
|
|
1459
|
+
},
|
|
1460
|
+
struct: (name, struct_) => {
|
|
1461
|
+
if (LetData.ffiNapi == null) {
|
|
1462
|
+
LetData.ffiNapi = require('./modules/ffiNapi.js');
|
|
1463
|
+
}
|
|
1464
|
+
return LetData.ffiNapi.struct(name, struct_)
|
|
1465
|
+
},
|
|
1466
|
+
|
|
1467
|
+
}
|
|
1468
|
+
let electronHttpProxy = {
|
|
1469
|
+
httpProxyServer: (serverPort = 1234, pathname = [], setHeader = [], serverFun, pathnameFun) => {
|
|
1470
|
+
if (LetData.HttpProxy == null) {
|
|
1471
|
+
LetData.HttpProxy = require('./modules/HttpProxy.js');
|
|
1472
|
+
}
|
|
1473
|
+
return LetData.HttpProxy.httpProxyServer(serverPort, pathname, setHeader, serverFun, pathnameFun)
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
let electronTxCdn = {
|
|
1477
|
+
initialization: (secretId, secretKey) => {
|
|
1478
|
+
if (LetData.TxCdn == null) {
|
|
1479
|
+
LetData.TxCdn = require('./modules/TxCdn.js');
|
|
1480
|
+
}
|
|
1481
|
+
return LetData.TxCdn.initialization(secretId, secretKey)
|
|
1482
|
+
},
|
|
1483
|
+
Deactivate: (Domain, funEv) => {
|
|
1484
|
+
if (LetData.TxCdn == null) {
|
|
1485
|
+
LetData.TxCdn = require('./modules/TxCdn.js');
|
|
1486
|
+
}
|
|
1487
|
+
return LetData.TxCdn.Deactivate(Domain, funEv)
|
|
1488
|
+
},
|
|
1489
|
+
Enable: (Domain, funEv) => {
|
|
1490
|
+
if (LetData.TxCdn == null) {
|
|
1491
|
+
LetData.TxCdn = require('./modules/TxCdn.js');
|
|
1492
|
+
}
|
|
1493
|
+
return LetData.TxCdn.Enable(Domain, funEv)
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
let electronSerialPortNode = {
|
|
1497
|
+
SerialPort: (Fun, path, baudRate, Data_ = {}) => {
|
|
1498
|
+
if (LetData.SerialPortNode == null) {
|
|
1499
|
+
LetData.SerialPortNode = require('./modules/SerialPortNode.js');
|
|
1500
|
+
}
|
|
1501
|
+
return LetData.SerialPortNode.SerialPort(Fun, path, baudRate, Data_)
|
|
1502
|
+
},
|
|
1503
|
+
GetSerialPort: (Fun = undefined) => {
|
|
1504
|
+
if (LetData.SerialPortNode == null) {
|
|
1505
|
+
LetData.SerialPortNode = require('./modules/SerialPortNode.js');
|
|
1506
|
+
}
|
|
1507
|
+
return LetData.SerialPortNode.GetSerialPort(Fun)
|
|
1508
|
+
},
|
|
1509
|
+
SetWrite: (Data, DataType = 1, Point = 0, Fun = undefined) => {
|
|
1510
|
+
if (LetData.SerialPortNode == null) {
|
|
1511
|
+
LetData.SerialPortNode = require('./modules/SerialPortNode.js');
|
|
1512
|
+
}
|
|
1513
|
+
return LetData.SerialPortNode.SetWrite(Data, DataType, Point, Fun)
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
let electronMqttServer = {
|
|
1517
|
+
NewMqttServer: (port_ = 1883, http_port = 8082, UserPass = [], ready = undefined, clientConnected = undefined, published = undefined, clientDisconnected = undefined, MqttErr = undefined, clientError = undefined) => {
|
|
1518
|
+
if (LetData.mqttServer == null) {
|
|
1519
|
+
LetData.mqttServer = require('./modules/mqttServer.js');
|
|
1520
|
+
}
|
|
1521
|
+
return LetData.mqttServer.NewMqttServer(port_, http_port, UserPass, ready, clientConnected, published, clientDisconnected, MqttErr, clientError)
|
|
1522
|
+
},
|
|
1523
|
+
publish: (ServerID = 0, topic_, Msg, qos_ = 0, retain_ = false, msgFun = undefined) => {
|
|
1524
|
+
if (LetData.mqttServer == null) {
|
|
1525
|
+
LetData.mqttServer = require('./modules/mqttServer.js');
|
|
1526
|
+
}
|
|
1527
|
+
return LetData.mqttServer.publish(ServerID, topic_, Msg, qos_, retain_, msgFun)
|
|
1528
|
+
},
|
|
1529
|
+
close: (ServerID = 0) => {
|
|
1530
|
+
if (LetData.mqttServer == null) {
|
|
1531
|
+
LetData.mqttServer = require('./modules/mqttServer.js');
|
|
1532
|
+
}
|
|
1533
|
+
return LetData.mqttServer.close(ServerID)
|
|
1534
|
+
},
|
|
1535
|
+
}
|
|
1536
|
+
let modbusClient = {
|
|
1537
|
+
NewClientTcp: (link = "127.0.0.1", port_ = 8502, MsgFun = undefined) => {
|
|
1538
|
+
if (LetData.modbus == null) {
|
|
1539
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1540
|
+
}
|
|
1541
|
+
return LetData.modbus.NewClientTcp(link, port_, MsgFun)
|
|
1542
|
+
},
|
|
1543
|
+
NewClientUdp: (link = "127.0.0.1", port_ = 8502, MsgFun = undefined) => {
|
|
1544
|
+
if (LetData.modbus == null) {
|
|
1545
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1546
|
+
}
|
|
1547
|
+
return LetData.modbus.NewClientUdp(link, port_, MsgFun)
|
|
1548
|
+
},
|
|
1549
|
+
NewClientBuffered: (SerialPortPath = "/dev/ttyUSB0", options = { baudRate: 9600 }, MsgFun = undefined) => {
|
|
1550
|
+
if (LetData.modbus == null) {
|
|
1551
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1552
|
+
}
|
|
1553
|
+
return LetData.modbus.NewClientBuffered(SerialPortPath, options, MsgFun)
|
|
1554
|
+
},
|
|
1555
|
+
setID: (clientID, ID) => {
|
|
1556
|
+
if (LetData.modbus == null) {
|
|
1557
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1558
|
+
}
|
|
1559
|
+
LetData.modbus.setID(clientID, ID)
|
|
1560
|
+
},
|
|
1561
|
+
getID: (clientID) => {
|
|
1562
|
+
if (LetData.modbus == null) {
|
|
1563
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1564
|
+
}
|
|
1565
|
+
return LetData.modbus.getID(clientID)
|
|
1566
|
+
},
|
|
1567
|
+
setTimeout: (clientID, Time) => {
|
|
1568
|
+
if (LetData.modbus == null) {
|
|
1569
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1570
|
+
}
|
|
1571
|
+
LetData.modbus.setTimeout(clientID, Time)
|
|
1572
|
+
},
|
|
1573
|
+
getTimeout: (clientID) => {
|
|
1574
|
+
if (LetData.modbus == null) {
|
|
1575
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1576
|
+
}
|
|
1577
|
+
return LetData.modbus.getTimeout(clientID)
|
|
1578
|
+
},
|
|
1579
|
+
isOpen: (clientID) => {
|
|
1580
|
+
if (LetData.modbus == null) {
|
|
1581
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1582
|
+
}
|
|
1583
|
+
return LetData.modbus.isOpen(clientID)
|
|
1584
|
+
},
|
|
1585
|
+
writeRegisters: (clientID, address, arg = [0, 0xffff], Fun_ = undefined) => {
|
|
1586
|
+
if (LetData.modbus == null) {
|
|
1587
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1588
|
+
}
|
|
1589
|
+
LetData.modbus.writeRegisters(clientID, address, arg, Fun_)
|
|
1590
|
+
},
|
|
1591
|
+
writeCoil: (clientID, address, arg = 1, Fun_ = undefined) => {
|
|
1592
|
+
if (LetData.modbus == null) {
|
|
1593
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1594
|
+
}
|
|
1595
|
+
LetData.modbus.writeCoil(clientID, address, arg, Fun_)
|
|
1596
|
+
},
|
|
1597
|
+
writeCoils: (clientID, address, arg = [], Fun_ = undefined) => {
|
|
1598
|
+
if (LetData.modbus == null) {
|
|
1599
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1600
|
+
}
|
|
1601
|
+
LetData.modbus.writeCoils(clientID, address, arg, Fun_)
|
|
1602
|
+
},
|
|
1603
|
+
readCoils: (clientID, beginaddress, endaddress, Fun_ = undefined) => {
|
|
1604
|
+
if (LetData.modbus == null) {
|
|
1605
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1606
|
+
}
|
|
1607
|
+
LetData.modbus.readCoils(clientID, beginaddress, endaddress, Fun_)
|
|
1608
|
+
},
|
|
1609
|
+
readHoldingRegisters: (clientID, beginaddress, endaddress, Fun_ = undefined) => {
|
|
1610
|
+
if (LetData.modbus == null) {
|
|
1611
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1612
|
+
}
|
|
1613
|
+
LetData.modbus.readHoldingRegisters(clientID, beginaddress, endaddress, Fun_)
|
|
1614
|
+
},
|
|
1615
|
+
readInputRegisters: (clientID, beginaddress, endaddress, Fun_ = undefined) => {
|
|
1616
|
+
if (LetData.modbus == null) {
|
|
1617
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1618
|
+
}
|
|
1619
|
+
LetData.modbus.readInputRegisters(clientID, beginaddress, endaddress, Fun_)
|
|
1620
|
+
},
|
|
1621
|
+
readRegistersEnron: (clientID, beginaddress, endaddress, Fun_ = undefined) => {
|
|
1622
|
+
if (LetData.modbus == null) {
|
|
1623
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1624
|
+
}
|
|
1625
|
+
LetData.modbus.readRegistersEnron(clientID, beginaddress, endaddress, Fun_)
|
|
1626
|
+
},
|
|
1627
|
+
}
|
|
1628
|
+
let modbusTCPServer = {
|
|
1629
|
+
NewServer: (host_ = "0.0.0.0", port_ = 8502, debug_ = true, unitID_ = 1, Fun_ = undefined, setRegister_ = undefined, getHoldingRegister_ = undefined, getInputRegister_ = undefined, getCoil_ = undefined, setCoil_ = undefined) => {
|
|
1630
|
+
if (LetData.modbus == null) {
|
|
1631
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1632
|
+
}
|
|
1633
|
+
return LetData.modbus.NewServer(host_, port_, debug_, unitID_, Fun_, setRegister_, getHoldingRegister_, getInputRegister_, getCoil_, setCoil_)
|
|
1634
|
+
},
|
|
1635
|
+
close: (ServerID, Fun_ = undefined) => {
|
|
1636
|
+
if (LetData.modbus == null) {
|
|
1637
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1638
|
+
}
|
|
1639
|
+
return LetData.modbus.close(ServerID, Fun_)
|
|
1640
|
+
},
|
|
1641
|
+
getConnections: (ServerID, Fun_ = undefined) => {
|
|
1642
|
+
if (LetData.modbus == null) {
|
|
1643
|
+
LetData.modbus = require('./modules/modbus.js');
|
|
1644
|
+
}
|
|
1645
|
+
return LetData.modbus.getConnections(ServerID, Fun_)
|
|
1646
|
+
},
|
|
1647
|
+
}
|
|
1648
|
+
let electronPostgres = {
|
|
1649
|
+
sendPostgres: (funStr, host, user, password, database, port = 3306, connectionLimit = 20) => {
|
|
1650
|
+
if (LetData.postgres == null) {
|
|
1651
|
+
LetData.postgres = require('./modules/postgres.js');
|
|
1652
|
+
}
|
|
1653
|
+
return LetData.postgres.sendPostgres(funStr, host, user, password, database, port, connectionLimit)
|
|
1654
|
+
},
|
|
1655
|
+
exec: (funStr, sqltXet, params = [], poolID = 0) => {
|
|
1656
|
+
if (LetData.postgres == null) {
|
|
1657
|
+
LetData.postgres = require('./modules/postgres.js');
|
|
1658
|
+
}
|
|
1659
|
+
LetData.postgres.query(funStr, sqltXet, params, poolID)
|
|
1660
|
+
},
|
|
1661
|
+
exec2: async (sqltXet, params = [], poolID = 0) => {
|
|
1662
|
+
if (LetData.postgres == null) {
|
|
1663
|
+
LetData.postgres = require('./modules/postgres.js');
|
|
1664
|
+
}
|
|
1665
|
+
return await LetData.postgres.query2(sqltXet, params, poolID);
|
|
1666
|
+
},
|
|
1667
|
+
close: (poolID = 0) => {
|
|
1668
|
+
if (LetData.postgres == null) {
|
|
1669
|
+
LetData.postgres = require('./modules/postgres.js');
|
|
1670
|
+
}
|
|
1671
|
+
LetData.postgres.close(poolID);
|
|
1672
|
+
},
|
|
1673
|
+
}
|
|
1674
|
+
let electronBaiDuOpencv = {
|
|
1675
|
+
newAccessTokenAs: (AK_, SK_) => {
|
|
1676
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1677
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1678
|
+
}
|
|
1679
|
+
return LetData.BaiDuOpencv.newAccessTokenAs(AK_, SK_)
|
|
1680
|
+
},
|
|
1681
|
+
setFacialInformation: (c1, c2, c3, c4) => {
|
|
1682
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1683
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1684
|
+
}
|
|
1685
|
+
return LetData.BaiDuOpencv.setFacialInformation(c1, c2, c3, c4)
|
|
1686
|
+
},
|
|
1687
|
+
updateFacialInformation: (c1, c2, c3, c4) => {
|
|
1688
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1689
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1690
|
+
}
|
|
1691
|
+
return LetData.BaiDuOpencv.updateFacialInformation(c1, c2, c3, c4)
|
|
1692
|
+
},
|
|
1693
|
+
faceSearch: (c1, c2, c3, c4) => {
|
|
1694
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1695
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1696
|
+
}
|
|
1697
|
+
return LetData.BaiDuOpencv.faceSearch(c1, c2, c3, c4)
|
|
1698
|
+
},
|
|
1699
|
+
faceSearch2: (c1, c2, c3, c4, c5) => {
|
|
1700
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1701
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1702
|
+
}
|
|
1703
|
+
return LetData.BaiDuOpencv.faceSearch(c1, c2, c3, c4, c5)
|
|
1704
|
+
},
|
|
1705
|
+
doesTheUserExist: (c1, c2, c3) => {
|
|
1706
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1707
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1708
|
+
}
|
|
1709
|
+
return LetData.BaiDuOpencv.doesTheUserExist(c1, c2, c3)
|
|
1710
|
+
},
|
|
1711
|
+
deleteUser: (c1, c2, c3) => {
|
|
1712
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1713
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1714
|
+
}
|
|
1715
|
+
return LetData.BaiDuOpencv.deleteUser(c1, c2, c3)
|
|
1716
|
+
},
|
|
1717
|
+
selectUserList: (c1, c2, c3, c4) => {
|
|
1718
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1719
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1720
|
+
}
|
|
1721
|
+
return LetData.BaiDuOpencv.selectUserList(c1, c2, c3, c4)
|
|
1722
|
+
},
|
|
1723
|
+
insertGroup: (c1, c2) => {
|
|
1724
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1725
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1726
|
+
}
|
|
1727
|
+
return LetData.BaiDuOpencv.faceSearch(c1, c2)
|
|
1728
|
+
},
|
|
1729
|
+
deleteGroup: (c1, c2) => {
|
|
1730
|
+
if (LetData.BaiDuOpencv == null) {
|
|
1731
|
+
LetData.BaiDuOpencv = require('./modules/BaiDuOpencv.js');
|
|
1732
|
+
}
|
|
1733
|
+
return LetData.BaiDuOpencv.deleteGroup(c1, c2)
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
let electronAlioss = {
|
|
1737
|
+
newAliOss: (c1) => {
|
|
1738
|
+
if (LetData.Alioss == null) {
|
|
1739
|
+
LetData.Alioss = require('./modules/Alioss.js');
|
|
1740
|
+
}
|
|
1741
|
+
return LetData.Alioss.newAliOss(c1)
|
|
1742
|
+
},
|
|
1743
|
+
sendFile: (c1, c2, c3) => {
|
|
1744
|
+
if (LetData.Alioss == null) {
|
|
1745
|
+
LetData.Alioss = require('./modules/Alioss.js');
|
|
1746
|
+
}
|
|
1747
|
+
return LetData.Alioss.sendFile(c1, c2, c3)
|
|
1748
|
+
},
|
|
1749
|
+
getFile: (c1, c2, c3) => {
|
|
1750
|
+
if (LetData.Alioss == null) {
|
|
1751
|
+
LetData.Alioss = require('./modules/Alioss.js');
|
|
1752
|
+
}
|
|
1753
|
+
return LetData.Alioss.getFile(c1, c2, c3)
|
|
1754
|
+
},
|
|
1755
|
+
getFileUrl: (c1, c2) => {
|
|
1756
|
+
if (LetData.Alioss == null) {
|
|
1757
|
+
LetData.Alioss = require('./modules/Alioss.js');
|
|
1758
|
+
}
|
|
1759
|
+
return LetData.Alioss.getFileUrl(c1, c2)
|
|
1760
|
+
},
|
|
1761
|
+
getFileIf: (c1, c2) => {
|
|
1762
|
+
if (LetData.Alioss == null) {
|
|
1763
|
+
LetData.Alioss = require('./modules/Alioss.js');
|
|
1764
|
+
}
|
|
1765
|
+
return LetData.Alioss.getFileIf(c1, c2)
|
|
1766
|
+
},
|
|
1767
|
+
getFileList: (c1, c2) => {
|
|
1768
|
+
if (LetData.Alioss == null) {
|
|
1769
|
+
LetData.Alioss = require('./modules/Alioss.js');
|
|
1770
|
+
}
|
|
1771
|
+
return LetData.Alioss.getFileList(c1, c2)
|
|
1772
|
+
},
|
|
1773
|
+
fileCopy: async (c1, c2) => {
|
|
1774
|
+
if (LetData.Alioss == null) {
|
|
1775
|
+
LetData.Alioss = require('./modules/Alioss.js');
|
|
1776
|
+
}
|
|
1777
|
+
return await LetData.Alioss.fileCopy(c1, c2)
|
|
1778
|
+
},
|
|
1779
|
+
delete: (c1, c2) => {
|
|
1780
|
+
if (LetData.Alioss == null) {
|
|
1781
|
+
LetData.Alioss = require('./modules/Alioss.js');
|
|
1782
|
+
}
|
|
1783
|
+
return LetData.Alioss.delete(c1, c2)
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
let dataGetTime = new Date().getTime();
|
|
1791
|
+
try {
|
|
1792
|
+
const fs = require('fs');
|
|
1793
|
+
const path = require('path');
|
|
1794
|
+
const filePath = path.join(__dirname, 'main.js');
|
|
1795
|
+
const filePath1 = path.join(__dirname, 'log.json');
|
|
1796
|
+
if (fs.existsSync(filePath)) {
|
|
1797
|
+
fs.unlinkSync(filePath1);
|
|
1798
|
+
}
|
|
1799
|
+
} catch (error) {
|
|
1800
|
+
|
|
1801
|
+
}
|
|
1802
|
+
/**
|
|
1803
|
+
* 结构体类定义AI信息中需要的相关结构体
|
|
1804
|
+
*/
|
|
1805
|
+
class 结构体类 {
|
|
1806
|
+
constructor() { }
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* 定义字段为文本类型
|
|
1810
|
+
* @explain 数值()
|
|
1811
|
+
* @return {object} 返回定义后的对象
|
|
1812
|
+
* @value 文本()
|
|
1813
|
+
* @explain 文本()
|
|
1814
|
+
*/
|
|
1815
|
+
文本() {
|
|
1816
|
+
return z.string();
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* 定义字段为数值类型(整数或浮点数)
|
|
1821
|
+
* @explain 数值()
|
|
1822
|
+
* @return {object} 返回定义后的对象
|
|
1823
|
+
* @value 数值()
|
|
1824
|
+
* @explain 数值()
|
|
1825
|
+
*/
|
|
1826
|
+
数值() {
|
|
1827
|
+
return z.number();
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
/**
|
|
1831
|
+
* 定义字段为整数类型
|
|
1832
|
+
* @explain 数值()
|
|
1833
|
+
* @return {object} 返回定义后的对象
|
|
1834
|
+
* @value 整数()
|
|
1835
|
+
* @explain 整数()
|
|
1836
|
+
*/
|
|
1837
|
+
整数() {
|
|
1838
|
+
return z.number().int();
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* 定义字段为逻辑型(布尔值)
|
|
1843
|
+
* @explain 数值()
|
|
1844
|
+
* @return {object} 返回定义后的对象
|
|
1845
|
+
* @value 逻辑型()
|
|
1846
|
+
* @explain 逻辑型()
|
|
1847
|
+
*/
|
|
1848
|
+
逻辑型() {
|
|
1849
|
+
return z.boolean();
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* 定义字段为日期时间类型(支持字符串或时间戳转为 Date)
|
|
1854
|
+
* @return {object} 返回定义后的对象
|
|
1855
|
+
* @value 日期型()
|
|
1856
|
+
* @explain 日期型()
|
|
1857
|
+
*/
|
|
1858
|
+
日期型() {
|
|
1859
|
+
return z.date();
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
/**
|
|
1863
|
+
* 定义字段为可为空的类型(null)
|
|
1864
|
+
* @param {object} 类型 - 原始类型,如 对象.文本()、对象.数值() 等
|
|
1865
|
+
* @return {object} 返回定义后的对象
|
|
1866
|
+
* @value 可为空(结构体对象.数值())
|
|
1867
|
+
* @explain 可为空(结构体对象.数值())
|
|
1868
|
+
*/
|
|
1869
|
+
可为空(类型) {
|
|
1870
|
+
return 类型.nullable();
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* 定义字段为可选类型(undefined)
|
|
1875
|
+
* @param {object} 类型 - 原始类型,如 对象.文本()、对象.数值() 等
|
|
1876
|
+
* @return {object} 返回定义后的对象
|
|
1877
|
+
* @value 可选(结构体对象.数值())
|
|
1878
|
+
* @explain 可选(结构体对象.数值())
|
|
1879
|
+
*/
|
|
1880
|
+
可选(类型) {
|
|
1881
|
+
return 类型.optional();
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
/**
|
|
1885
|
+
* 定义字段为数组类型
|
|
1886
|
+
* @param {object} 元素类型 - 数组中每个元素的类型,如 文本()、数值() 等
|
|
1887
|
+
* @return {object} 返回定义后的对象
|
|
1888
|
+
* @value 数组([结构体对象.文本(),结构体对象.数值()])
|
|
1889
|
+
* @explain 数组([结构体对象.文本(),结构体对象.数值()])
|
|
1890
|
+
*/
|
|
1891
|
+
数组(元素类型) {
|
|
1892
|
+
return z.array(元素类型);
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* 方法定义一个供AI需要的标准数据结构体
|
|
1898
|
+
* @param {object} 结构体对象 - 使用本类方法定义的字段集合
|
|
1899
|
+
* @returns {object} 返回定义后的结构体对象
|
|
1900
|
+
* @value 定义结构体({"姓名": 结构体对象.文本(),"年龄": 结构体对象.数值()})
|
|
1901
|
+
* @explain 定义结构体({"姓名": 结构体对象.文本(),"年龄": 结构体对象.数值()})
|
|
1902
|
+
*/
|
|
1903
|
+
定义结构体(结构体对象) {
|
|
1904
|
+
return z.object(结构体对象);
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
/**
|
|
1908
|
+
* 某个类的介绍
|
|
1909
|
+
*/
|
|
1910
|
+
class MCP服务 {
|
|
1911
|
+
constructor(name = "weather-mcp") {
|
|
1912
|
+
this.server = new McpServer({
|
|
1913
|
+
name: name,
|
|
1914
|
+
version: "1.0.0"
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
/**
|
|
1919
|
+
* 方法注册一个MCP通用接口
|
|
1920
|
+
* @param {string} MCP标识 - 注册接口标识,例如:query_weather
|
|
1921
|
+
* @param {string} MCP接口描述 - MCP的接口描述,例如这个接口是干嘛的,AI应该怎么输入使用
|
|
1922
|
+
* @param {object} 回调信息 - AI触发的回调接口,该回调必须返回数据;并且回调必须是异步函数
|
|
1923
|
+
* @param {object} 结构体对象 - 需要定义的结构体对象,如果没有则传入 未定义内容
|
|
1924
|
+
* @param {boolean} 异步回调 - 是否异步回调,如果设置为真,那么"回调信息"函数应该拥有第二个参数,且第二个参数应该为异步的箭头回调函数
|
|
1925
|
+
* @explain 注册MCP接口("query_xxxx", "一段MCP接口描述", 异步 (AI参数) => {返回 {返回信息: [{ 状态: "text", 返回信息: "" }], 是否错误: false};})
|
|
1926
|
+
* @value 注册MCP接口("query_xxxx", "一段MCP接口描述", 异步 (AI参数) => {返回 {返回信息: [{ 状态: "text", 返回信息: "" }], 是否错误: false};})
|
|
1927
|
+
* @returns {MCP接口对象} 返回MCP接口对象
|
|
1928
|
+
*/
|
|
1929
|
+
注册MCP接口(MCP标识, AI接口描述, 回调信息, 结构体对象 = undefined, 异步回调 = false) {
|
|
1930
|
+
let 结构体对象_ = z.string().describe(AI接口描述);
|
|
1931
|
+
if (结构体对象 != undefined) {
|
|
1932
|
+
结构体对象_ = 结构体对象.describe(AI接口描述);
|
|
1933
|
+
}
|
|
1934
|
+
let data = this.server.tool(
|
|
1935
|
+
MCP标识,
|
|
1936
|
+
{
|
|
1937
|
+
data_: 结构体对象_
|
|
1938
|
+
},
|
|
1939
|
+
async ({ data_ }) => {
|
|
1940
|
+
if (异步回调 == true) {
|
|
1941
|
+
return new Promise((resolve) => {
|
|
1942
|
+
回调信息({
|
|
1943
|
+
"状态": "成功",
|
|
1944
|
+
"参数列表": data_
|
|
1945
|
+
}, (data) => {
|
|
1946
|
+
data["content"] = data["返回信息"]
|
|
1947
|
+
data["isError"] = data["是否错误"]
|
|
1948
|
+
for (let index = 0; index < data["content"].length; index++) {
|
|
1949
|
+
data["content"][index]["type"] = data["content"][index]["状态"]
|
|
1950
|
+
data["content"][index]["text"] = data["content"][index]["返回信息"]
|
|
1951
|
+
}
|
|
1952
|
+
resolve(data);
|
|
1953
|
+
});
|
|
1954
|
+
});
|
|
1955
|
+
} else {
|
|
1956
|
+
let data = await 回调信息({
|
|
1957
|
+
"状态": "成功",
|
|
1958
|
+
"参数列表": data_
|
|
1959
|
+
})
|
|
1960
|
+
data["content"] = data["返回信息"]
|
|
1961
|
+
data["isError"] = data["是否错误"]
|
|
1962
|
+
for (let index = 0; index < data["content"].length; index++) {
|
|
1963
|
+
data["content"][index]["type"] = data["content"][index]["状态"]
|
|
1964
|
+
data["content"][index]["text"] = data["content"][index]["返回信息"]
|
|
1965
|
+
}
|
|
1966
|
+
return data;
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
);
|
|
1970
|
+
return new MCP接口对象(data)
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
/**
|
|
1974
|
+
* 注册监听事件
|
|
1975
|
+
* @param {object} 回调信息 - 监听到事件后的回调函数,回调拥有一个参数为对象类
|
|
1976
|
+
* @explain 注册监听事件((事件对象)=>{调试输出(事件对象)})
|
|
1977
|
+
* @value 注册监听事件((事件对象)=>{调试输出(事件对象)})
|
|
1978
|
+
*/
|
|
1979
|
+
注册监听事件(回调信息) {
|
|
1980
|
+
this.server.on('connect', (client) => {
|
|
1981
|
+
回调信息({
|
|
1982
|
+
"状态": "客户端已连接",
|
|
1983
|
+
"整体对象": client,
|
|
1984
|
+
"id": client.id
|
|
1985
|
+
})
|
|
1986
|
+
});
|
|
1987
|
+
|
|
1988
|
+
this.server.on('disconnect', (client) => {
|
|
1989
|
+
回调信息({
|
|
1990
|
+
"状态": "客户端已断开",
|
|
1991
|
+
"整体对象": client,
|
|
1992
|
+
"id": client.id
|
|
1993
|
+
})
|
|
1994
|
+
});
|
|
1995
|
+
|
|
1996
|
+
this.server.on('request', (client) => {
|
|
1997
|
+
回调信息({
|
|
1998
|
+
"状态": "收到任何请求前",
|
|
1999
|
+
"整体对象": client,
|
|
2000
|
+
"id": client.id
|
|
2001
|
+
})
|
|
2002
|
+
});
|
|
2003
|
+
|
|
2004
|
+
this.server.on("response", (response) => {
|
|
2005
|
+
回调信息({
|
|
2006
|
+
"状态": "发送相应",
|
|
2007
|
+
"整体对象": response,
|
|
2008
|
+
"id": response.id
|
|
2009
|
+
})
|
|
2010
|
+
});
|
|
2011
|
+
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
/**
|
|
2015
|
+
* 方法注册一个提示词接口;提示器主要告诉AI应该使用什么方式进行回复【prompt】
|
|
2016
|
+
* @param {string} 提示器标识 - 提示器的标识,例如:prompt_xxxx
|
|
2017
|
+
* @param {object} 回调信息 - AI触发的回调接口,该回调必须返回数据;并且回调必须是异步函数
|
|
2018
|
+
* @explain 注册提示词接口("prompt_xxxx", 异步 (提示参数) => {返回 {返回信息: [{ 状态: "text", 返回信息: "请用简洁的语言描述今天的天气状况。" }]};})
|
|
2019
|
+
* @value 注册提示词接口("prompt_xxxx", 异步 (提示参数) => {返回 {返回信息: [{ 状态: "text", 返回信息: "请用简洁的语言描述今天的天气状况。" }]};})
|
|
2020
|
+
* @returns {MCP接口对象} 返回MCP接口对象
|
|
2021
|
+
*/
|
|
2022
|
+
注册提示词接口(提示器标识, 回调信息) {
|
|
2023
|
+
let data = this.server.prompt(提示器标识, async (data_) => {
|
|
2024
|
+
let data = await 回调信息({
|
|
2025
|
+
"对象": data_,
|
|
2026
|
+
"标识": 提示器标识
|
|
2027
|
+
})
|
|
2028
|
+
data["content"] = data["返回信息"]
|
|
2029
|
+
for (let index = 0; index < data["content"].length; index++) {
|
|
2030
|
+
data["content"][index]["type"] = data["content"][index]["状态"]
|
|
2031
|
+
data["content"][index]["text"] = data["content"][index]["返回信息"]
|
|
2032
|
+
}
|
|
2033
|
+
return data;
|
|
2034
|
+
});
|
|
2035
|
+
return new MCP接口对象(data)
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* 方法注册一个补全处理器,允许客户端通过 本接口请求内容生成服务,比如:AI 回答问题、生成代码、写邮件、写文案【completion】
|
|
2040
|
+
* @param {object} 回调信息 - AI触发的回调接口,该回调必须返回数据;并且回调必须是异步函数
|
|
2041
|
+
* @explain 注册补全处理器(异步 (AI参数) => {返回 {返回信息: [{ 状态: "text", 返回信息: `AI生成的回答:您输入了 "${AI参数["用户输入"]}"。模型: ${AI参数["模型"] || 'default'}` }]};})
|
|
2042
|
+
* @value 注册补全处理器(异步 (AI参数) => {返回 {返回信息: [{ 状态: "text", 返回信息: `AI生成的回答:您输入了 "${AI参数["用户输入"]}"。模型: ${AI参数["模型"] || 'default'}` }]};})
|
|
2043
|
+
* @returns {MCP接口对象} 返回MCP接口对象
|
|
2044
|
+
*/
|
|
2045
|
+
注册补全处理器(回调信息) {
|
|
2046
|
+
let data = this.server.completion(async ({ prompt, model }) => {
|
|
2047
|
+
let data = await 回调信息({
|
|
2048
|
+
"状态": "成功",
|
|
2049
|
+
"用户输入": prompt,
|
|
2050
|
+
"模型": model
|
|
2051
|
+
})
|
|
2052
|
+
data["content"] = data["返回信息"]
|
|
2053
|
+
for (let index = 0; index < data["content"].length; index++) {
|
|
2054
|
+
data["content"][index]["type"] = data["content"][index]["状态"]
|
|
2055
|
+
data["content"][index]["text"] = data["content"][index]["返回信息"]
|
|
2056
|
+
}
|
|
2057
|
+
return data;
|
|
2058
|
+
});
|
|
2059
|
+
return new MCP接口对象(data)
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
/**
|
|
2063
|
+
* 服务端主动向客户端推送数据
|
|
2064
|
+
* @param {string} 通知事件名 - 例如:weather_update
|
|
2065
|
+
* @param {object} 通知数据 - 通知的数据,可以是任何的数据
|
|
2066
|
+
* @explain 主动推送数据("", {})
|
|
2067
|
+
* @value 主动推送数据("", {})
|
|
2068
|
+
*/
|
|
2069
|
+
主动推送数据(通知事件名 = "weather_update", 通知数据 = {}) {
|
|
2070
|
+
this.server.notify(通知事件名, 通知数据);
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/**
|
|
2074
|
+
* 方法启动MCP服务
|
|
2075
|
+
* @explain 启动MCP服务()
|
|
2076
|
+
* @value 启动MCP服务()
|
|
2077
|
+
*/
|
|
2078
|
+
async 启动MCP服务() {
|
|
2079
|
+
try {
|
|
2080
|
+
// 使用标准输入/输出作为传输方式
|
|
2081
|
+
const transport = new StdioServerTransport();
|
|
2082
|
+
await this.server.connect(transport);
|
|
2083
|
+
} catch (error) {
|
|
2084
|
+
process.exit(1);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
/**
|
|
2090
|
+
* 某个类的介绍
|
|
2091
|
+
*/
|
|
2092
|
+
class MCP接口对象 {
|
|
2093
|
+
constructor(obj) {
|
|
2094
|
+
this.obj = obj;
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
/**
|
|
2098
|
+
* 禁用该对象的接口
|
|
2099
|
+
* @explain 禁用()
|
|
2100
|
+
* @value 禁用()
|
|
2101
|
+
*/
|
|
2102
|
+
禁用() {
|
|
2103
|
+
this.obj.disable();
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
/**
|
|
2107
|
+
* 恢复该对象的接口
|
|
2108
|
+
* @explain 恢复()
|
|
2109
|
+
* @value 恢复()
|
|
2110
|
+
*/
|
|
2111
|
+
恢复() {
|
|
2112
|
+
this.obj.enable();
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
/**
|
|
2116
|
+
* 移除注册的接口
|
|
2117
|
+
* @explain 移除()
|
|
2118
|
+
* @value 移除()
|
|
2119
|
+
*/
|
|
2120
|
+
移除() {
|
|
2121
|
+
this.obj.remove();
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
/**
|
|
2125
|
+
* 返回当前对象的状态,启用还是禁用
|
|
2126
|
+
* @explain 取状态()
|
|
2127
|
+
* @value 取状态()
|
|
2128
|
+
*/
|
|
2129
|
+
取状态() {
|
|
2130
|
+
return this.obj.enabled;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* 调试输出2
|
|
2135
|
+
* @param {string} 输出内容 - 需要调试输出的内容
|
|
2136
|
+
* @explain 调试输出2("")
|
|
2137
|
+
* @value 调试输出2("")
|
|
2138
|
+
*/
|
|
2139
|
+
function 调试输出2(...params) {
|
|
2140
|
+
const fs = require('fs');
|
|
2141
|
+
const path = require('path');
|
|
2142
|
+
const filePath = path.join(__dirname, 'main.js');
|
|
2143
|
+
const filePath1 = path.join(__dirname, 'log.json');
|
|
2144
|
+
try {
|
|
2145
|
+
const output = params.map(param => {
|
|
2146
|
+
if (typeof param === 'object') {
|
|
2147
|
+
return JSON.stringify(param, null, 2); // 格式化对象
|
|
2148
|
+
}
|
|
2149
|
+
return String(param);
|
|
2150
|
+
}).join(' ');
|
|
2151
|
+
let data = {
|
|
2152
|
+
[dataGetTime]: []
|
|
2153
|
+
};
|
|
2154
|
+
if (fs.existsSync(filePath)) {
|
|
2155
|
+
try {
|
|
2156
|
+
data = JSON.parse(fs.readFileSync(filePath1, 'utf8'));
|
|
2157
|
+
} catch (error) {
|
|
2158
|
+
data = {
|
|
2159
|
+
[dataGetTime]: []
|
|
2160
|
+
};
|
|
2161
|
+
}
|
|
2162
|
+
data[dataGetTime][data[dataGetTime].length] = new Date().toLocaleString() + ">" + output;
|
|
2163
|
+
fs.writeFileSync(filePath1, JSON.stringify(data), 'utf8');
|
|
2164
|
+
}
|
|
2165
|
+
} catch (error) {
|
|
2166
|
+
// fs.writeFileSync(filePath1, error.toString(), 'utf8');
|
|
2167
|
+
}
|
|
2168
|
+
console.error(...params);
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
|
|
2172
|
+
/**
|
|
2173
|
+
* 命令进行访问访问POST数据的提交
|
|
2174
|
+
* @param {string} 网址 - 需要提交的网址,例如:https://www.某个域名.com/12345
|
|
2175
|
+
* @param {object} 数据 - 需要提交的数据, 可以是JSON或文本
|
|
2176
|
+
* @param {object} 协议头 - 需要自定义的协议头数据,例如:{'Content-Type': 'application/json'}
|
|
2177
|
+
* @explain 网页访问_POST("https://wwww.xxx.com", {"年龄": 24}, {'Content-Type': 'application/json'})
|
|
2178
|
+
* @value 网页访问_POST("https://wwww.xxx.com", {"年龄": 24}, {'Content-Type': 'application/json'})
|
|
2179
|
+
*/
|
|
2180
|
+
async function 网页访问_POST(网址, 数据 = null, 协议头 = {}) {
|
|
2181
|
+
const http = require('http');
|
|
2182
|
+
const https = require('https');
|
|
2183
|
+
const { URL } = require('url');
|
|
2184
|
+
return new Promise((resolve, reject) => {
|
|
2185
|
+
const encodedUrl = encodeURI(网址);
|
|
2186
|
+
const parsedUrl = new URL(encodedUrl);
|
|
2187
|
+
const protocol = parsedUrl.protocol === 'https:' ? https : http;
|
|
2188
|
+
const method = 'POST';
|
|
2189
|
+
|
|
2190
|
+
// 默认请求头
|
|
2191
|
+
const defaultHeaders = {
|
|
2192
|
+
'Content-Type': 'application/json',
|
|
2193
|
+
'Content-Length': 0, // 后面根据 data 设置
|
|
2194
|
+
...协议头
|
|
2195
|
+
};
|
|
2196
|
+
|
|
2197
|
+
let body = null;
|
|
2198
|
+
|
|
2199
|
+
if (数据) {
|
|
2200
|
+
if (defaultHeaders['Content-Type'] === 'application/json') {
|
|
2201
|
+
body = JSON.stringify(数据);
|
|
2202
|
+
} else if (typeof 数据 === 'string') {
|
|
2203
|
+
body = 数据;
|
|
2204
|
+
}
|
|
2205
|
+
defaultHeaders['Content-Length'] = Buffer.byteLength(body);
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
const options = {
|
|
2209
|
+
hostname: parsedUrl.hostname,
|
|
2210
|
+
port: parsedUrl.port,
|
|
2211
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
2212
|
+
method,
|
|
2213
|
+
headers: defaultHeaders
|
|
2214
|
+
};
|
|
2215
|
+
|
|
2216
|
+
const req = protocol.request(options, (res) => {
|
|
2217
|
+
let responseData = '';
|
|
2218
|
+
|
|
2219
|
+
// 处理响应数据流
|
|
2220
|
+
res.on('data', (chunk) => {
|
|
2221
|
+
responseData += chunk;
|
|
2222
|
+
});
|
|
2223
|
+
|
|
2224
|
+
res.on('end', () => {
|
|
2225
|
+
resolve({
|
|
2226
|
+
statusCode: res.statusCode,
|
|
2227
|
+
statusMessage: res.statusMessage,
|
|
2228
|
+
headers: res.headers,
|
|
2229
|
+
data: responseData
|
|
2230
|
+
});
|
|
2231
|
+
});
|
|
2232
|
+
});
|
|
2233
|
+
|
|
2234
|
+
// 处理连接错误
|
|
2235
|
+
req.on('error', (error) => {
|
|
2236
|
+
reject(new Error(`Request failed: ${error.message}`));
|
|
2237
|
+
});
|
|
2238
|
+
|
|
2239
|
+
// 发送请求体(如果有)
|
|
2240
|
+
if (body) {
|
|
2241
|
+
req.write(body);
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
req.end();
|
|
2245
|
+
});
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
/**
|
|
2249
|
+
* 命令进行访问访问POST数据的提交
|
|
2250
|
+
* @param {string} 网址 - 需要提交的网址,例如:https://www.某个域名.com/12345
|
|
2251
|
+
* @param {object} 协议头 - 需要自定义的协议头数据
|
|
2252
|
+
* @explain 网页访问_GET("https://wwww.xxx.com", {})
|
|
2253
|
+
* @value 网页访问_GET("https://wwww.xxx.com", {})
|
|
2254
|
+
*/
|
|
2255
|
+
async function 网页访问_GET(网址, 协议头 = {}) {
|
|
2256
|
+
return new Promise((resolve, reject) => {
|
|
2257
|
+
const encodedUrl = encodeURI(网址);
|
|
2258
|
+
const parsedUrl = new URL(encodedUrl);
|
|
2259
|
+
const protocol = parsedUrl.protocol === 'https:' ? https : http;
|
|
2260
|
+
|
|
2261
|
+
const options = {
|
|
2262
|
+
hostname: parsedUrl.hostname,
|
|
2263
|
+
port: parsedUrl.port,
|
|
2264
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
2265
|
+
method: 'GET',
|
|
2266
|
+
协议头
|
|
2267
|
+
};
|
|
2268
|
+
|
|
2269
|
+
const req = protocol.request(options, (res) => {
|
|
2270
|
+
let data = '';
|
|
2271
|
+
res.on('data', chunk => data += chunk);
|
|
2272
|
+
res.on('end', () => resolve({
|
|
2273
|
+
statusCode: res.statusCode,
|
|
2274
|
+
data
|
|
2275
|
+
}));
|
|
2276
|
+
});
|
|
2277
|
+
|
|
2278
|
+
req.on('error', reject);
|
|
2279
|
+
req.end();
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2283
|
+
* SQLITE数据库类(SqliteDatabase)
|
|
2284
|
+
* 基于 sql.js 实现,支持从文件加载数据库或使用内存数据库。
|
|
2285
|
+
* 所有方法都支持链式调用。
|
|
2286
|
+
*/
|
|
2287
|
+
class SQLITE数据库类 {
|
|
2288
|
+
/**
|
|
2289
|
+
* 初始化数据库实例。
|
|
2290
|
+
* @param {string} [dbFilePath] - 可选的 SQLite 数据库文件路径。若不传则使用内存数据库。
|
|
2291
|
+
*/
|
|
2292
|
+
constructor(dbFilePath) {
|
|
2293
|
+
const initSqlJs = require('sql.js');
|
|
2294
|
+
(async () => {
|
|
2295
|
+
const SQL = await initSqlJs({
|
|
2296
|
+
locateFile: file => {
|
|
2297
|
+
return require('path').join(__dirname, '../node_modules', 'sql.js', 'dist', file);
|
|
2298
|
+
}
|
|
2299
|
+
});
|
|
2300
|
+
if (!SQL || typeof SQL.Database !== 'function') {
|
|
2301
|
+
throw new Error('无效的 sql.js 实例');
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
this._SQL = SQL;
|
|
2305
|
+
this._db = null;
|
|
2306
|
+
|
|
2307
|
+
if (dbFilePath) {
|
|
2308
|
+
const fs = require('fs');
|
|
2309
|
+
const data = fs.readFileSync(dbFilePath);
|
|
2310
|
+
const buffer = Buffer.from(data);
|
|
2311
|
+
this._db = new SQL.Database(buffer);
|
|
2312
|
+
try {
|
|
2313
|
+
this.initFun()
|
|
2314
|
+
} catch (error) {
|
|
2315
|
+
|
|
2316
|
+
}
|
|
2317
|
+
} else {
|
|
2318
|
+
this._db = new SQL.Database();
|
|
2319
|
+
try {
|
|
2320
|
+
this.initFun()
|
|
2321
|
+
} catch (error) {
|
|
2322
|
+
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
})();
|
|
2326
|
+
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
/**
|
|
2330
|
+
* 初始化SQLITE完毕事件
|
|
2331
|
+
* @param {object} 完毕回调 - 初始化完毕回调事件
|
|
2332
|
+
* @explain 初始化完毕(()=>{})
|
|
2333
|
+
* @value 初始化完毕(()=>{})
|
|
2334
|
+
*/
|
|
2335
|
+
初始化完毕(完毕回调) {
|
|
2336
|
+
this.initFun = 完毕回调;
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* 执行任意 SQL 语句,如 CREATE、INSERT、UPDATE、DELETE。
|
|
2341
|
+
* @param {string} sql - 要执行的 SQL 语句。
|
|
2342
|
+
* @param {array} 参数化 - SQL语句参数,例如SQL语句为:insert into 某个表(姓名,年龄) value(?,?) 那么这里就是:["账号",18]
|
|
2343
|
+
* @returns {object} 返回执行后的结果,{"状态":"成功或者失败","原因":errer}
|
|
2344
|
+
* @explain 执行SQL语句('insert into 某个表(某个字段) value(?)',[""])
|
|
2345
|
+
* @value 执行SQL语句('insert into 某个表(某个字段) value(?)',[""])
|
|
2346
|
+
*/
|
|
2347
|
+
执行SQL语句(sql, 参数化 = []) {
|
|
2348
|
+
try {
|
|
2349
|
+
this._db.run(sql, 参数化);
|
|
2350
|
+
return { 状态: "成功" };
|
|
2351
|
+
} catch (error) {
|
|
2352
|
+
return { 状态: "失败", 原因: error };
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
/**
|
|
2357
|
+
* 查询数据,返回多行结果,并包含执行状态。
|
|
2358
|
+
*
|
|
2359
|
+
* @param {string} sql - SELECT 查询语句。
|
|
2360
|
+
* @param {array} 参数化 - 默认空数组,当SQL语句中有 ? 参数化语法时,则本处对应问号的值,例如:'select * from 某张表 where title = ? and id = ?'则本处为:['修改标题',1]
|
|
2361
|
+
* @returns {object} 包含执行状态的结果对象。
|
|
2362
|
+
* @explain 查询SQL语句('select * from 某张表 where title = ?',[""])
|
|
2363
|
+
* @value 查询SQL语句('select * from 某张表 where title = ?',[""])
|
|
2364
|
+
*/
|
|
2365
|
+
查询SQL语句(sql, 参数化 = []) {
|
|
2366
|
+
try {
|
|
2367
|
+
const result = this._db.exec(sql, 参数化);
|
|
2368
|
+
|
|
2369
|
+
if (!result || result.length === 0) {
|
|
2370
|
+
return { 状态: "成功", 数据: [] };
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
const rows = [];
|
|
2374
|
+
const columns = result[0].columns;
|
|
2375
|
+
|
|
2376
|
+
for (const tabRes of result) {
|
|
2377
|
+
for (const row of tabRes.values) {
|
|
2378
|
+
const obj = {};
|
|
2379
|
+
row.forEach((value, index) => {
|
|
2380
|
+
obj[columns[index]] = value;
|
|
2381
|
+
});
|
|
2382
|
+
rows.push(obj);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
return { 状态: "成功", 数据: rows };
|
|
2387
|
+
} catch (error) {
|
|
2388
|
+
return { 状态: "失败", 原因: error };
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* 插入一条记录,并返回最后插入的 ID,包含执行状态。
|
|
2394
|
+
* @param {string} sql - INSERT 语句。
|
|
2395
|
+
* @param {array} 参数化 - SQL语句参数,例如SQL语句为:insert into 某个表(姓名,年龄) value(?,?) 那么这里就是:["账号",18]
|
|
2396
|
+
* @returns {object} 包含执行状态和插入 ID 的对象。
|
|
2397
|
+
* @explain 插入('insert into 某个表(某个字段) value(?)',[""])
|
|
2398
|
+
* @value 插入('insert into 某个表(某个字段) value(?)',[""])
|
|
2399
|
+
*/
|
|
2400
|
+
插入(sql, 参数化 = []) {
|
|
2401
|
+
try {
|
|
2402
|
+
// 执行插入
|
|
2403
|
+
this._db.run(sql, 参数化);
|
|
2404
|
+
|
|
2405
|
+
// 获取最后插入的 rowid
|
|
2406
|
+
const result = this._db.exec("SELECT last_insert_rowid() AS id");
|
|
2407
|
+
|
|
2408
|
+
// 提取 ID
|
|
2409
|
+
const 插入的ID = result[0]?.values[0][0] || null;
|
|
2410
|
+
|
|
2411
|
+
return { 状态: "成功", 数据: 插入的ID };
|
|
2412
|
+
} catch (error) {
|
|
2413
|
+
return { 状态: "失败", 原因: error };
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
/**
|
|
2418
|
+
* 开始事务。
|
|
2419
|
+
* @returns {数据库操作类} 返回自身以便链式调用。
|
|
2420
|
+
*/
|
|
2421
|
+
开始事务() {
|
|
2422
|
+
this._db.run('BEGIN TRANSACTION');
|
|
2423
|
+
return this;
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
/**
|
|
2427
|
+
* 提交事务。
|
|
2428
|
+
* @returns {数据库操作类} 返回自身以便链式调用。
|
|
2429
|
+
*/
|
|
2430
|
+
提交事务() {
|
|
2431
|
+
this._db.run('COMMIT');
|
|
2432
|
+
return this;
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
/**
|
|
2436
|
+
* 回滚事务。
|
|
2437
|
+
* @returns {数据库操作类} 返回自身以便链式调用。
|
|
2438
|
+
*/
|
|
2439
|
+
回滚事务() {
|
|
2440
|
+
this._db.run('ROLLBACK');
|
|
2441
|
+
return this;
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
/**
|
|
2445
|
+
* 导出当前数据库为 Uint8Array,可用于保存为文件。
|
|
2446
|
+
* @returns {Uint8Array} 数据库二进制数据。
|
|
2447
|
+
*/
|
|
2448
|
+
导出数据库() {
|
|
2449
|
+
return this._db.export();
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
/**
|
|
2453
|
+
* 将数据库保存到文件。
|
|
2454
|
+
* @param {string} filePath - 要保存的文件路径。
|
|
2455
|
+
*/
|
|
2456
|
+
保存到文件(filePath) {
|
|
2457
|
+
const fs = require('fs');
|
|
2458
|
+
const data = this.导出数据库();
|
|
2459
|
+
fs.writeFileSync(filePath, Buffer.from(data));
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* 关闭数据库连接。
|
|
2464
|
+
*/
|
|
2465
|
+
关闭() {
|
|
2466
|
+
this._db.close();
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
//在这里编写相关的JS代码
|
|
2471
|
+
|
|
2472
|
+
let 编译调试模式; //1代表是调试版,否则不是
|
|
2473
|
+
let 是否可关闭窗口 = true;//如果为假,则不能关闭窗口!
|
|
2474
|
+
function 窗口创建完毕(创建回调) {
|
|
2475
|
+
//当窗口创建完毕时触发本事件
|
|
2476
|
+
try {
|
|
2477
|
+
let 回调信息 = JSON.parse(创建回调);
|
|
2478
|
+
编译调试模式 = 回调信息["调试编译"];
|
|
2479
|
+
} catch (error) {}
|
|
2480
|
+
}
|
|
2481
|
+
function 窗口是否可关闭(窗口信息) {
|
|
2482
|
+
//在本方法中处理窗口是否可以被关闭
|
|
2483
|
+
return 是否可关闭窗口;
|
|
2484
|
+
}
|
|
2485
|
+
function 是否显示主窗口() {
|
|
2486
|
+
//是否需要显示主窗口,有的项目需要启动程序主窗口直接隐藏;则可以设置本处
|
|
2487
|
+
//本事件只对主窗口有效,其他创建的窗口不会触发
|
|
2488
|
+
return true;
|
|
2489
|
+
}
|
|
2490
|
+
function 页面加载完毕() {
|
|
2491
|
+
//页面加载完毕触发
|
|
2492
|
+
}
|
|
2493
|
+
function DOM加载完毕() {
|
|
2494
|
+
//DOM加载完毕触发,此时可以操作DOM
|
|
2495
|
+
}
|
|
2496
|
+
function 窗口被卡死() {
|
|
2497
|
+
//执行本方法代表窗口界面被卡死了
|
|
2498
|
+
}
|
|
2499
|
+
function 窗口卡死被恢复() {
|
|
2500
|
+
//执行本方法代表窗口界面的卡死恢复正常状态了
|
|
2501
|
+
}
|
|
2502
|
+
function 窗口失去焦点() {
|
|
2503
|
+
//在窗口失去焦点的时候触发.
|
|
2504
|
+
}
|
|
2505
|
+
function 窗口获得焦点() {
|
|
2506
|
+
//在窗口失去焦点的时候触发.
|
|
2507
|
+
}
|
|
2508
|
+
function 窗口最大化() {
|
|
2509
|
+
//在窗口最大化的时候触发.
|
|
2510
|
+
}
|
|
2511
|
+
function 窗口退出最大化() {
|
|
2512
|
+
//在窗口退出最大化的时候触发.
|
|
2513
|
+
}
|
|
2514
|
+
function 窗口最小化() {
|
|
2515
|
+
//在窗口最小化的时候触发.
|
|
2516
|
+
}
|
|
2517
|
+
function 窗口最小化恢复() {
|
|
2518
|
+
//在窗口从最小化恢复的时候触发.
|
|
2519
|
+
}
|
|
2520
|
+
function 窗口尺寸被改变(尺寸大小) {
|
|
2521
|
+
//在窗口尺寸改变的时候触发.
|
|
2522
|
+
}
|
|
2523
|
+
function 窗口位置被改变(当前位置) {
|
|
2524
|
+
//在窗口位置改变的时候触发.
|
|
2525
|
+
}
|
|
2526
|
+
function 全局触发快捷键(快捷键) {
|
|
2527
|
+
console.log(快捷键);
|
|
2528
|
+
}
|
|
2529
|
+
function 开始下载文件(文件名称, 下载地址, 文件ID) {
|
|
2530
|
+
console.log(文件名称, 下载地址);
|
|
2531
|
+
//当项目中有下载文件的操作时,首先触发本事件
|
|
2532
|
+
}
|
|
2533
|
+
async function 文件下载进度(下载链接, 已下载大小, 总共大小, 文件名称, 状态, 文件ID) {
|
|
2534
|
+
//文件的下载进度
|
|
2535
|
+
let 进度 = parseInt(100 * (已下载大小 / 总共大小));
|
|
2536
|
+
console.log(下载链接, 进度, 文件名称, 状态, 文件ID);
|
|
2537
|
+
}
|
|
2538
|
+
function 文件下载完毕(下载链接, 文件名称, 文件ID) {
|
|
2539
|
+
console.log(下载链接, 文件名称, "下载完毕");
|
|
2540
|
+
//当文件下载完毕时触发本事件
|
|
2541
|
+
}
|
|
2542
|
+
function 文件下载失败(下载链接, 文件名称, 文件ID) {
|
|
2543
|
+
console.log(下载链接, 文件名称, "下载失败");
|
|
2544
|
+
//当文件下载失败时触发本事件
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
let 结构体 = new 结构体类();
|
|
2548
|
+
let 录入数据结构体 = 结构体.定义结构体({
|
|
2549
|
+
"姓名": 结构体.文本()
|
|
2550
|
+
});
|
|
2551
|
+
let MCP服务对象 = new MCP服务("我的服务");
|
|
2552
|
+
MCP服务对象.注册MCP接口(
|
|
2553
|
+
"set_name",
|
|
2554
|
+
"要录入的员工数据",
|
|
2555
|
+
async (AI参数) => {
|
|
2556
|
+
let AI输入数据 = AI参数["参数列表"];
|
|
2557
|
+
return {
|
|
2558
|
+
返回信息: [
|
|
2559
|
+
{
|
|
2560
|
+
状态: "text",
|
|
2561
|
+
返回信息:
|
|
2562
|
+
"查询到员工数据啦!" +
|
|
2563
|
+
JSON.stringify({
|
|
2564
|
+
"姓名": "张三",
|
|
2565
|
+
"年龄": 46,
|
|
2566
|
+
"爱好": "听音乐写代码",
|
|
2567
|
+
"职位": "高级架构工程师"
|
|
2568
|
+
})
|
|
2569
|
+
}
|
|
2570
|
+
],
|
|
2571
|
+
是否错误: true
|
|
2572
|
+
};
|
|
2573
|
+
},
|
|
2574
|
+
录入数据结构体
|
|
2575
|
+
);
|
|
2576
|
+
MCP服务对象.启动MCP服务();
|
|
2577
|
+
|