cgserver 6.6.3 → 6.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1087 -0
- package/dist/lib/Logic/AsyncQueueTool.js +1 -1
- package/package.json +1 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,1087 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
3
|
+
* This devtool is neither made for production nor for readable output files.
|
|
4
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
5
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
6
|
+
* or disable the default devtool with "devtool: false".
|
|
7
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
8
|
+
*/
|
|
9
|
+
/******/ (() => { // webpackBootstrap
|
|
10
|
+
/******/ "use strict";
|
|
11
|
+
/******/ var __webpack_modules__ = ({
|
|
12
|
+
|
|
13
|
+
/***/ "@alicloud/sms-sdk":
|
|
14
|
+
/*!************************************!*\
|
|
15
|
+
!*** external "@alicloud/sms-sdk" ***!
|
|
16
|
+
\************************************/
|
|
17
|
+
/***/ ((module) => {
|
|
18
|
+
|
|
19
|
+
module.exports = require("@alicloud/sms-sdk");
|
|
20
|
+
|
|
21
|
+
/***/ }),
|
|
22
|
+
|
|
23
|
+
/***/ "alipay-sdk":
|
|
24
|
+
/*!*****************************!*\
|
|
25
|
+
!*** external "alipay-sdk" ***!
|
|
26
|
+
\*****************************/
|
|
27
|
+
/***/ ((module) => {
|
|
28
|
+
|
|
29
|
+
module.exports = require("alipay-sdk");
|
|
30
|
+
|
|
31
|
+
/***/ }),
|
|
32
|
+
|
|
33
|
+
/***/ "alipay-sdk/lib/form":
|
|
34
|
+
/*!**************************************!*\
|
|
35
|
+
!*** external "alipay-sdk/lib/form" ***!
|
|
36
|
+
\**************************************/
|
|
37
|
+
/***/ ((module) => {
|
|
38
|
+
|
|
39
|
+
module.exports = require("alipay-sdk/lib/form");
|
|
40
|
+
|
|
41
|
+
/***/ }),
|
|
42
|
+
|
|
43
|
+
/***/ "alipay-sdk/lib/util":
|
|
44
|
+
/*!**************************************!*\
|
|
45
|
+
!*** external "alipay-sdk/lib/util" ***!
|
|
46
|
+
\**************************************/
|
|
47
|
+
/***/ ((module) => {
|
|
48
|
+
|
|
49
|
+
module.exports = require("alipay-sdk/lib/util");
|
|
50
|
+
|
|
51
|
+
/***/ }),
|
|
52
|
+
|
|
53
|
+
/***/ "alipay_sdk2/AliPayUtil":
|
|
54
|
+
/*!*****************************************!*\
|
|
55
|
+
!*** external "alipay_sdk2/AliPayUtil" ***!
|
|
56
|
+
\*****************************************/
|
|
57
|
+
/***/ ((module) => {
|
|
58
|
+
|
|
59
|
+
module.exports = require("alipay_sdk2/AliPayUtil");
|
|
60
|
+
|
|
61
|
+
/***/ }),
|
|
62
|
+
|
|
63
|
+
/***/ "body-parser":
|
|
64
|
+
/*!******************************!*\
|
|
65
|
+
!*** external "body-parser" ***!
|
|
66
|
+
\******************************/
|
|
67
|
+
/***/ ((module) => {
|
|
68
|
+
|
|
69
|
+
module.exports = require("body-parser");
|
|
70
|
+
|
|
71
|
+
/***/ }),
|
|
72
|
+
|
|
73
|
+
/***/ "colors":
|
|
74
|
+
/*!*************************!*\
|
|
75
|
+
!*** external "colors" ***!
|
|
76
|
+
\*************************/
|
|
77
|
+
/***/ ((module) => {
|
|
78
|
+
|
|
79
|
+
module.exports = require("colors");
|
|
80
|
+
|
|
81
|
+
/***/ }),
|
|
82
|
+
|
|
83
|
+
/***/ "cookie-parser":
|
|
84
|
+
/*!********************************!*\
|
|
85
|
+
!*** external "cookie-parser" ***!
|
|
86
|
+
\********************************/
|
|
87
|
+
/***/ ((module) => {
|
|
88
|
+
|
|
89
|
+
module.exports = require("cookie-parser");
|
|
90
|
+
|
|
91
|
+
/***/ }),
|
|
92
|
+
|
|
93
|
+
/***/ "cors":
|
|
94
|
+
/*!***********************!*\
|
|
95
|
+
!*** external "cors" ***!
|
|
96
|
+
\***********************/
|
|
97
|
+
/***/ ((module) => {
|
|
98
|
+
|
|
99
|
+
module.exports = require("cors");
|
|
100
|
+
|
|
101
|
+
/***/ }),
|
|
102
|
+
|
|
103
|
+
/***/ "ec-key":
|
|
104
|
+
/*!*************************!*\
|
|
105
|
+
!*** external "ec-key" ***!
|
|
106
|
+
\*************************/
|
|
107
|
+
/***/ ((module) => {
|
|
108
|
+
|
|
109
|
+
module.exports = require("ec-key");
|
|
110
|
+
|
|
111
|
+
/***/ }),
|
|
112
|
+
|
|
113
|
+
/***/ "events":
|
|
114
|
+
/*!*************************!*\
|
|
115
|
+
!*** external "events" ***!
|
|
116
|
+
\*************************/
|
|
117
|
+
/***/ ((module) => {
|
|
118
|
+
|
|
119
|
+
module.exports = require("events");
|
|
120
|
+
|
|
121
|
+
/***/ }),
|
|
122
|
+
|
|
123
|
+
/***/ "express":
|
|
124
|
+
/*!**************************!*\
|
|
125
|
+
!*** external "express" ***!
|
|
126
|
+
\**************************/
|
|
127
|
+
/***/ ((module) => {
|
|
128
|
+
|
|
129
|
+
module.exports = require("express");
|
|
130
|
+
|
|
131
|
+
/***/ }),
|
|
132
|
+
|
|
133
|
+
/***/ "fs":
|
|
134
|
+
/*!*********************!*\
|
|
135
|
+
!*** external "fs" ***!
|
|
136
|
+
\*********************/
|
|
137
|
+
/***/ ((module) => {
|
|
138
|
+
|
|
139
|
+
module.exports = require("fs");
|
|
140
|
+
|
|
141
|
+
/***/ }),
|
|
142
|
+
|
|
143
|
+
/***/ "http":
|
|
144
|
+
/*!***********************!*\
|
|
145
|
+
!*** external "http" ***!
|
|
146
|
+
\***********************/
|
|
147
|
+
/***/ ((module) => {
|
|
148
|
+
|
|
149
|
+
module.exports = require("http");
|
|
150
|
+
|
|
151
|
+
/***/ }),
|
|
152
|
+
|
|
153
|
+
/***/ "https":
|
|
154
|
+
/*!************************!*\
|
|
155
|
+
!*** external "https" ***!
|
|
156
|
+
\************************/
|
|
157
|
+
/***/ ((module) => {
|
|
158
|
+
|
|
159
|
+
module.exports = require("https");
|
|
160
|
+
|
|
161
|
+
/***/ }),
|
|
162
|
+
|
|
163
|
+
/***/ "jsonc":
|
|
164
|
+
/*!************************!*\
|
|
165
|
+
!*** external "jsonc" ***!
|
|
166
|
+
\************************/
|
|
167
|
+
/***/ ((module) => {
|
|
168
|
+
|
|
169
|
+
module.exports = require("jsonc");
|
|
170
|
+
|
|
171
|
+
/***/ }),
|
|
172
|
+
|
|
173
|
+
/***/ "log4js":
|
|
174
|
+
/*!*************************!*\
|
|
175
|
+
!*** external "log4js" ***!
|
|
176
|
+
\*************************/
|
|
177
|
+
/***/ ((module) => {
|
|
178
|
+
|
|
179
|
+
module.exports = require("log4js");
|
|
180
|
+
|
|
181
|
+
/***/ }),
|
|
182
|
+
|
|
183
|
+
/***/ "mime":
|
|
184
|
+
/*!***********************!*\
|
|
185
|
+
!*** external "mime" ***!
|
|
186
|
+
\***********************/
|
|
187
|
+
/***/ ((module) => {
|
|
188
|
+
|
|
189
|
+
module.exports = require("mime");
|
|
190
|
+
|
|
191
|
+
/***/ }),
|
|
192
|
+
|
|
193
|
+
/***/ "mongodb":
|
|
194
|
+
/*!**************************!*\
|
|
195
|
+
!*** external "mongodb" ***!
|
|
196
|
+
\**************************/
|
|
197
|
+
/***/ ((module) => {
|
|
198
|
+
|
|
199
|
+
module.exports = require("mongodb");
|
|
200
|
+
|
|
201
|
+
/***/ }),
|
|
202
|
+
|
|
203
|
+
/***/ "mssql":
|
|
204
|
+
/*!************************!*\
|
|
205
|
+
!*** external "mssql" ***!
|
|
206
|
+
\************************/
|
|
207
|
+
/***/ ((module) => {
|
|
208
|
+
|
|
209
|
+
module.exports = require("mssql");
|
|
210
|
+
|
|
211
|
+
/***/ }),
|
|
212
|
+
|
|
213
|
+
/***/ "mysql":
|
|
214
|
+
/*!************************!*\
|
|
215
|
+
!*** external "mysql" ***!
|
|
216
|
+
\************************/
|
|
217
|
+
/***/ ((module) => {
|
|
218
|
+
|
|
219
|
+
module.exports = require("mysql");
|
|
220
|
+
|
|
221
|
+
/***/ }),
|
|
222
|
+
|
|
223
|
+
/***/ "nodemailer":
|
|
224
|
+
/*!*****************************!*\
|
|
225
|
+
!*** external "nodemailer" ***!
|
|
226
|
+
\*****************************/
|
|
227
|
+
/***/ ((module) => {
|
|
228
|
+
|
|
229
|
+
module.exports = require("nodemailer");
|
|
230
|
+
|
|
231
|
+
/***/ }),
|
|
232
|
+
|
|
233
|
+
/***/ "protobufjs":
|
|
234
|
+
/*!*****************************!*\
|
|
235
|
+
!*** external "protobufjs" ***!
|
|
236
|
+
\*****************************/
|
|
237
|
+
/***/ ((module) => {
|
|
238
|
+
|
|
239
|
+
module.exports = require("protobufjs");
|
|
240
|
+
|
|
241
|
+
/***/ }),
|
|
242
|
+
|
|
243
|
+
/***/ "qiniu":
|
|
244
|
+
/*!************************!*\
|
|
245
|
+
!*** external "qiniu" ***!
|
|
246
|
+
\************************/
|
|
247
|
+
/***/ ((module) => {
|
|
248
|
+
|
|
249
|
+
module.exports = require("qiniu");
|
|
250
|
+
|
|
251
|
+
/***/ }),
|
|
252
|
+
|
|
253
|
+
/***/ "redis":
|
|
254
|
+
/*!************************!*\
|
|
255
|
+
!*** external "redis" ***!
|
|
256
|
+
\************************/
|
|
257
|
+
/***/ ((module) => {
|
|
258
|
+
|
|
259
|
+
module.exports = require("redis");
|
|
260
|
+
|
|
261
|
+
/***/ }),
|
|
262
|
+
|
|
263
|
+
/***/ "request":
|
|
264
|
+
/*!**************************!*\
|
|
265
|
+
!*** external "request" ***!
|
|
266
|
+
\**************************/
|
|
267
|
+
/***/ ((module) => {
|
|
268
|
+
|
|
269
|
+
module.exports = require("request");
|
|
270
|
+
|
|
271
|
+
/***/ }),
|
|
272
|
+
|
|
273
|
+
/***/ "underscore":
|
|
274
|
+
/*!*****************************!*\
|
|
275
|
+
!*** external "underscore" ***!
|
|
276
|
+
\*****************************/
|
|
277
|
+
/***/ ((module) => {
|
|
278
|
+
|
|
279
|
+
module.exports = require("underscore");
|
|
280
|
+
|
|
281
|
+
/***/ }),
|
|
282
|
+
|
|
283
|
+
/***/ "urlencode":
|
|
284
|
+
/*!****************************!*\
|
|
285
|
+
!*** external "urlencode" ***!
|
|
286
|
+
\****************************/
|
|
287
|
+
/***/ ((module) => {
|
|
288
|
+
|
|
289
|
+
module.exports = require("urlencode");
|
|
290
|
+
|
|
291
|
+
/***/ }),
|
|
292
|
+
|
|
293
|
+
/***/ "uuid":
|
|
294
|
+
/*!***********************!*\
|
|
295
|
+
!*** external "uuid" ***!
|
|
296
|
+
\***********************/
|
|
297
|
+
/***/ ((module) => {
|
|
298
|
+
|
|
299
|
+
module.exports = require("uuid");
|
|
300
|
+
|
|
301
|
+
/***/ }),
|
|
302
|
+
|
|
303
|
+
/***/ "websocket":
|
|
304
|
+
/*!****************************!*\
|
|
305
|
+
!*** external "websocket" ***!
|
|
306
|
+
\****************************/
|
|
307
|
+
/***/ ((module) => {
|
|
308
|
+
|
|
309
|
+
module.exports = require("websocket");
|
|
310
|
+
|
|
311
|
+
/***/ }),
|
|
312
|
+
|
|
313
|
+
/***/ "crypto":
|
|
314
|
+
/*!*************************!*\
|
|
315
|
+
!*** external "crypto" ***!
|
|
316
|
+
\*************************/
|
|
317
|
+
/***/ ((module) => {
|
|
318
|
+
|
|
319
|
+
module.exports = require("crypto");
|
|
320
|
+
|
|
321
|
+
/***/ }),
|
|
322
|
+
|
|
323
|
+
/***/ "os":
|
|
324
|
+
/*!*********************!*\
|
|
325
|
+
!*** external "os" ***!
|
|
326
|
+
\*********************/
|
|
327
|
+
/***/ ((module) => {
|
|
328
|
+
|
|
329
|
+
module.exports = require("os");
|
|
330
|
+
|
|
331
|
+
/***/ }),
|
|
332
|
+
|
|
333
|
+
/***/ "path":
|
|
334
|
+
/*!***********************!*\
|
|
335
|
+
!*** external "path" ***!
|
|
336
|
+
\***********************/
|
|
337
|
+
/***/ ((module) => {
|
|
338
|
+
|
|
339
|
+
module.exports = require("path");
|
|
340
|
+
|
|
341
|
+
/***/ }),
|
|
342
|
+
|
|
343
|
+
/***/ "querystring":
|
|
344
|
+
/*!******************************!*\
|
|
345
|
+
!*** external "querystring" ***!
|
|
346
|
+
\******************************/
|
|
347
|
+
/***/ ((module) => {
|
|
348
|
+
|
|
349
|
+
module.exports = require("querystring");
|
|
350
|
+
|
|
351
|
+
/***/ }),
|
|
352
|
+
|
|
353
|
+
/***/ "./dist/lib/AI/AiObject.js":
|
|
354
|
+
/*!*********************************!*\
|
|
355
|
+
!*** ./dist/lib/AI/AiObject.js ***!
|
|
356
|
+
\*********************************/
|
|
357
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
358
|
+
|
|
359
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AiObject = void 0;\r\nclass AiObject {\r\n onTriggerIn(obj, trigger) {\r\n }\r\n onTriggerOut(obj, trigger) {\r\n }\r\n}\r\nexports.AiObject = AiObject;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/AI/AiObject.js?");
|
|
360
|
+
|
|
361
|
+
/***/ }),
|
|
362
|
+
|
|
363
|
+
/***/ "./dist/lib/AI/Astar.js":
|
|
364
|
+
/*!******************************!*\
|
|
365
|
+
!*** ./dist/lib/AI/Astar.js ***!
|
|
366
|
+
\******************************/
|
|
367
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
368
|
+
|
|
369
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AStar = exports.Rect = void 0;\r\nconst Point_1 = __webpack_require__(/*! ./Point */ \"./dist/lib/AI/Point.js\");\r\nclass Rect {\r\n x = 0;\r\n y = 0;\r\n width = 0;\r\n height = 0;\r\n}\r\nexports.Rect = Rect;\r\nclass AStarNode {\r\n ParentNode = null;\r\n CurTilePos = null;\r\n G = 0;\r\n H = 0;\r\n constructor(node, tilePos) {\r\n this.ParentNode = node;\r\n this.CurTilePos = tilePos;\r\n if (this.ParentNode) {\r\n this.G = this.ParentNode.G + 10;\r\n }\r\n else {\r\n this.G = 0;\r\n }\r\n }\r\n F() {\r\n return this.G + this.H;\r\n }\r\n}\r\nclass AStar {\r\n _markList = null;\r\n _markedList = null;\r\n _routes = null;\r\n _maxTileWidth = 0;\r\n _maxTileHeight = 0;\r\n /**\r\n * 先y在x,p(x:1,y:2),data[2][1]\r\n */\r\n _mapData = null;\r\n getRoutes(srcTilePos, tarTilePos, mapData) {\r\n if (srcTilePos.equals(tarTilePos)) {\r\n return [];\r\n }\r\n this._markList = [];\r\n this._markedList = [];\r\n this._routes = [];\r\n this._mapData = mapData;\r\n this._maxTileWidth = this._mapData.width();\r\n this._maxTileHeight = this._mapData.height();\r\n let tp = srcTilePos.sub(tarTilePos);\r\n let node = new AStarNode(null, srcTilePos);\r\n node.H = (Math.abs(tp.x) + Math.abs(tp.y)) * 10 + mapData.extraWeight(tarTilePos);\r\n this._markList.push(node);\r\n node = this._routing(srcTilePos, tarTilePos);\r\n while (node) {\r\n this._routes.push(node.CurTilePos);\r\n node = node.ParentNode;\r\n }\r\n this._routes.reverse();\r\n this._routes.shift();\r\n return this._routes;\r\n }\r\n _routing(srcTilePos, tarTilePos) {\r\n if (this._markList.length <= 0) //已经没有节点,是死路根本无法到达\r\n {\r\n return null;\r\n }\r\n let node = this._markList[0];\r\n let curIndex = 0;\r\n for (let i = 0; i < this._markList.length; ++i) {\r\n if (node.F() > this._markList[i].F()) {\r\n node = this._markList[i];\r\n curIndex = i;\r\n }\r\n if (this._markList[i].CurTilePos.equals(tarTilePos)) //到达终点\r\n {\r\n return this._markList[i];\r\n }\r\n }\r\n this._markList.splice(curIndex, 1);\r\n this._markedList.push(node);\r\n let tp = new Point_1.Point(0, 0);\r\n //上\r\n tp.x = node.CurTilePos.x;\r\n tp.y = node.CurTilePos.y + 1;\r\n this._addToMark(tp, tarTilePos, node);\r\n //下\r\n tp = new Point_1.Point(0, 0);\r\n tp.x = node.CurTilePos.x;\r\n tp.y = node.CurTilePos.y - 1;\r\n this._addToMark(tp, tarTilePos, node);\r\n //左\r\n tp = new Point_1.Point(0, 0);\r\n tp.x = node.CurTilePos.x - 1;\r\n tp.y = node.CurTilePos.y;\r\n this._addToMark(tp, tarTilePos, node);\r\n //右\r\n tp = new Point_1.Point(0, 0);\r\n tp.x = node.CurTilePos.x + 1;\r\n tp.y = node.CurTilePos.y;\r\n this._addToMark(tp, tarTilePos, node);\r\n return this._routing(srcTilePos, tarTilePos);\r\n }\r\n _isInMark(tilePos) {\r\n for (let i = 0; i < this._markList.length; ++i) {\r\n if (this._markList[i].CurTilePos.equals(tilePos)) {\r\n return true;\r\n }\r\n }\r\n for (let i = 0; i < this._markedList.length; ++i) {\r\n if (this._markedList[i].CurTilePos.equals(tilePos)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n _addToMark(curTilePos, tarTilePos, parentAStarNode) {\r\n //无地图数据\r\n if (curTilePos.x < 0 || curTilePos.y < 0\r\n || !this._mapData.canPass(curTilePos)) {\r\n return;\r\n }\r\n if (!this._isInMark(curTilePos)) //未曾添加\r\n {\r\n let newNode = new AStarNode(parentAStarNode, curTilePos);\r\n let temp_tp = parentAStarNode.CurTilePos.sub(tarTilePos);\r\n newNode.H = (Math.abs(temp_tp.x) + Math.abs(temp_tp.y)) * 10;\r\n this._markList.push(newNode);\r\n }\r\n }\r\n}\r\nexports.AStar = AStar;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/AI/Astar.js?");
|
|
370
|
+
|
|
371
|
+
/***/ }),
|
|
372
|
+
|
|
373
|
+
/***/ "./dist/lib/AI/BehaviorAI.js":
|
|
374
|
+
/*!***********************************!*\
|
|
375
|
+
!*** ./dist/lib/AI/BehaviorAI.js ***!
|
|
376
|
+
\***********************************/
|
|
377
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
378
|
+
|
|
379
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.BehaviorAI = void 0;\r\nconst Log_1 = __webpack_require__(/*! ./../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst Core_1 = __webpack_require__(/*! ./../Core/Core */ \"./dist/lib/Core/Core.js\");\r\nconst _ = __webpack_require__(/*! underscore */ \"underscore\");\r\nconst TriggerMgr_1 = __webpack_require__(/*! ./TriggerMgr */ \"./dist/lib/AI/TriggerMgr.js\");\r\nclass BehaviorAI {\r\n _obj;\r\n _targetObjs;\r\n _triggers;\r\n _behavior_data;\r\n _current_behavior;\r\n _current_behavior_name = \"\";\r\n _current_check;\r\n _targetObj;\r\n constructor(behavior_data, obj, targetObjs) {\r\n this._obj = obj;\r\n this._behavior_data = behavior_data;\r\n if (Core_1.core.isArray(targetObjs)) {\r\n this._targetObjs = targetObjs;\r\n }\r\n else if (targetObjs) {\r\n this._targetObjs[0] = targetObjs;\r\n }\r\n else {\r\n this._targetObjs = [];\r\n }\r\n this._triggers = [];\r\n let code = TriggerMgr_1.GTriggerMgr.addConditionTriggerEvent(TriggerMgr_1.EConditionType.Die, this.onTriggerDie.bind(this), { code: this._obj.getCode() });\r\n this._triggers.push({ type: TriggerMgr_1.EConditionType.Die, code: code });\r\n }\r\n //启动行为树AI\r\n start() {\r\n if (!this._behavior_data) {\r\n Log_1.GLog.info(\"------------error------------this._behavior_data can not be null!\");\r\n return;\r\n }\r\n this.goto(this._behavior_data.start);\r\n }\r\n //结束行为树AI\r\n end() {\r\n for (let i = 0, length = this._triggers.length; i < length; ++i) {\r\n TriggerMgr_1.GTriggerMgr.removeConditionTriggerEvent(this._triggers[i].type, this._triggers[i].code);\r\n }\r\n this._triggers = [];\r\n }\r\n //帧检查\r\n //支持多条件check\r\n update(dt) {\r\n if (this._current_check.length < 0) {\r\n return;\r\n }\r\n for (let i = 0; i < this._current_check.length; ++i) {\r\n let current = this._current_check[i];\r\n //目前只支持同时存在一个update检查\r\n if (current.event_name == \"target_insight\") {\r\n let targetInfo = this._getNearestTarget();\r\n if (targetInfo) {\r\n let target = targetInfo.target;\r\n let distance = targetInfo.distance;\r\n if (distance <= this._behavior_data.insight) //视野发现敌人\r\n {\r\n this._current_check = this._current_check.splice(i, 1);\r\n --i;\r\n let forceReturn = this._doEvents(this._current_behavior.conditions[current.event_name]);\r\n if (forceReturn) {\r\n return; //防止goto修改this._current_check后,做了立刻check\r\n }\r\n }\r\n }\r\n }\r\n else if (current.event_name == \"sure\") {\r\n this._current_check = this._current_check.splice(i, 1);\r\n --i;\r\n let forceReturn = this._doEvents(this._current_behavior.conditions[current.event_name]);\r\n if (forceReturn) {\r\n return; //防止goto修改this._current_check后,做了立刻check\r\n }\r\n }\r\n else if (current.event_name == \"near\") {\r\n if (this._targetObj) {\r\n let objPos = this._obj.getPosition();\r\n let tpos = this._targetObj.getPosition();\r\n let distance = objPos.sub(tpos).length(); //目标和自己的距离\r\n let dty = objPos.y - tpos.y;\r\n dty = dty >= 0 ? dty : -dty;\r\n if (distance <= current.distance && dty <= 10) //视野发现敌人\r\n {\r\n this._current_check = this._current_check.splice(i, 1);\r\n --i;\r\n let forceReturn = this._doEvents(this._current_behavior.conditions[current.event_name]);\r\n if (forceReturn) {\r\n return; //防止goto修改this._current_check后,做了立刻check\r\n }\r\n }\r\n }\r\n else {\r\n this._current_check = this._current_check.splice(i, 1);\r\n --i;\r\n let forceReturn = this._doEvents(this._current_behavior.conditions[current.event_name], true);\r\n if (forceReturn) {\r\n return; //防止goto修改this._current_check后,做了立刻check\r\n }\r\n }\r\n }\r\n else if (current.event_name == \"timeout\") {\r\n current.time -= dt;\r\n if (current.time <= 0) {\r\n this._current_check = this._current_check.splice(i, 1);\r\n --i;\r\n let forceReturn = this._doEvents(this._current_behavior.conditions[current.event_name]);\r\n if (forceReturn) {\r\n return; //防止goto修改this._current_check后,做了立刻check\r\n }\r\n }\r\n }\r\n }\r\n }\r\n //goto事件\r\n goto(behavior_name) {\r\n //GLog.info(\"=====goto behavior=\" + behavior_name);\r\n if (this._behavior_data && this._behavior_data.name == behavior_name) {\r\n return; //拒绝相同行为跳转\r\n }\r\n this._current_check = [];\r\n this._current_behavior = this._behavior_data.behaviors[behavior_name];\r\n //全局条件\r\n if (this._behavior_data.conditions) {\r\n this._checkConditions(this._behavior_data.conditions);\r\n }\r\n //行为条件\r\n if (this._current_behavior.conditions) {\r\n this._checkConditions(this._current_behavior.conditions);\r\n }\r\n if (this._current_behavior.animation) {\r\n if (!this._current_behavior.conditions.animation_done) {\r\n this._obj.behaviorAnimation(this._current_behavior.animation.name, this._current_behavior.animation.loop);\r\n }\r\n else {\r\n let self = this;\r\n this._obj.behaviorAnimation(this._current_behavior.animation.name, this._current_behavior.animation.loop, function () {\r\n self._doEvents(self._current_behavior.conditions.animation_done);\r\n });\r\n }\r\n }\r\n else {\r\n Log_1.GLog.info(\"---------warning--------_goto->behavior_name=\" + behavior_name + \".animaiton not exist!\");\r\n }\r\n }\r\n //检查有没有已经达到的条件,又的话就执行他的相关事件\r\n _checkConditions(conditions) {\r\n if (!conditions) {\r\n return;\r\n }\r\n for (let key in conditions) {\r\n switch (key) {\r\n case \"target_insight\":\r\n {\r\n this._current_check.push({ event_name: key });\r\n }\r\n break;\r\n case \"timeout\":\r\n {\r\n this._current_check.push({ event_name: key, time: conditions[key].time });\r\n }\r\n break;\r\n case \"sure\":\r\n {\r\n this._current_check.push({ event_name: key }); //下次update执行\r\n }\r\n break;\r\n case \"near\":\r\n {\r\n this._targetObj = null;\r\n this._current_check.push({ event_name: key, distance: conditions[key].distance });\r\n let targetInfo = this._getNearestTarget();\r\n if (targetInfo) {\r\n if (this._behavior_data.name == \"sm\")\r\n Log_1.GLog.info(\"distance\" + targetInfo.distance);\r\n this._targetObj = targetInfo.target;\r\n }\r\n }\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n }\r\n //执行事件\r\n _doEvents(events, fail = false) {\r\n if (!events) {\r\n return false;\r\n }\r\n if (fail && events.failto) {\r\n this.goto(events.failto);\r\n return true;\r\n }\r\n let forceReturn = false;\r\n for (let key in events) {\r\n switch (key) {\r\n case \"goto\":\r\n {\r\n this.goto(events[key]);\r\n forceReturn = true;\r\n }\r\n break;\r\n case \"walk_any\":\r\n {\r\n if (this._obj.behaviorWalkAny) {\r\n this._obj.behaviorWalkAny();\r\n }\r\n }\r\n break;\r\n case \"persue\":\r\n {\r\n if (this._obj.behaviorPersue && this._targetObj) {\r\n this._obj.behaviorPersue(this._targetObj);\r\n }\r\n }\r\n break;\r\n case \"call\":\r\n {\r\n if (events[key].fun && this._obj[events[key].fun]) {\r\n this._obj[events[key].fun](events[key].params);\r\n }\r\n }\r\n break;\r\n case \"random\":\r\n {\r\n let r = _.random(0, 100); //百分率\r\n let rate = 0;\r\n let done = false;\r\n //最后一条不参与检测\r\n for (let i = 0, length = events[key].length; i < length - 1; ++i) {\r\n rate += events[key][i].rate;\r\n if (r <= rate) {\r\n forceReturn = this._doEvents(events[key][i].events);\r\n done = true;\r\n break;\r\n }\r\n }\r\n //如果前面都没有成功,必须保证最后一条得到执行\r\n if (!done) {\r\n forceReturn = this._doEvents(events[key][events[key].length - 1].events);\r\n }\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n return forceReturn;\r\n }\r\n //角色死亡触发\r\n onTriggerDie(userDM) {\r\n if (!userDM) {\r\n return;\r\n }\r\n if (this._obj.getCode() === userDM.code) {\r\n this.goto(\"die\");\r\n this.end();\r\n return;\r\n }\r\n for (let i = 0, length = this._targetObjs.length; i < length; ++i) {\r\n if (this._targetObjs[i].getCode() === userDM.code) {\r\n this._targetObjs = this._targetObjs.splice(i, 1);\r\n if (this._targetObj.getCode() === userDM.code) {\r\n this._targetObj = null;\r\n }\r\n return;\r\n }\r\n }\r\n return;\r\n }\r\n //获取最近的target\r\n _getNearestTarget() {\r\n let targetNum = this._targetObjs.length;\r\n if (targetNum <= 0) {\r\n return null;\r\n }\r\n let objPos = this._obj.getPosition();\r\n if (targetNum == 1) {\r\n return { target: this._targetObjs[0], distance: objPos.sub(this._targetObjs[0].getPosition()).length() };\r\n }\r\n let minIndex = 0;\r\n let mindis = objPos.sub(this._targetObjs[0].getPosition()).length();\r\n for (let i = 1; i < targetNum; ++i) {\r\n let dis = objPos.sub(this._targetObjs[i].getPosition()).length();\r\n if (mindis > dis) {\r\n mindis = dis;\r\n minIndex = i;\r\n }\r\n }\r\n return { target: this._targetObjs[minIndex], distance: mindis };\r\n }\r\n //添加target\r\n addTarget(target) {\r\n if (!target) {\r\n return;\r\n }\r\n this._targetObjs.push(target);\r\n }\r\n getTargets() {\r\n return this._targetObjs;\r\n }\r\n}\r\nexports.BehaviorAI = BehaviorAI;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/AI/BehaviorAI.js?");
|
|
380
|
+
|
|
381
|
+
/***/ }),
|
|
382
|
+
|
|
383
|
+
/***/ "./dist/lib/AI/Entity.js":
|
|
384
|
+
/*!*******************************!*\
|
|
385
|
+
!*** ./dist/lib/AI/Entity.js ***!
|
|
386
|
+
\*******************************/
|
|
387
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
388
|
+
|
|
389
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Entity = void 0;\r\nconst Point_1 = __webpack_require__(/*! ./Point */ \"./dist/lib/AI/Point.js\");\r\n//世界物体,具有坐标可移动等特性\r\nclass Entity {\r\n _id = -1;\r\n get id() {\r\n return this._id;\r\n }\r\n _world_pos = new Point_1.Point();\r\n get worldPos() {\r\n return this._world_pos;\r\n }\r\n set worldPos(value) {\r\n this._world_pos = value;\r\n }\r\n _cell = new Point_1.Point();\r\n get cellPos() {\r\n return this._cell;\r\n }\r\n set cellPos(value) {\r\n this._cell = value;\r\n }\r\n initPos(pos) {\r\n //不能直接赋值,因为是引用\r\n this._world_pos.x = pos.x + 0.5;\r\n this._world_pos.y = pos.y + 0.5;\r\n this._cell.x = pos.x;\r\n this._cell.y = pos.y;\r\n }\r\n}\r\nexports.Entity = Entity;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/AI/Entity.js?");
|
|
390
|
+
|
|
391
|
+
/***/ }),
|
|
392
|
+
|
|
393
|
+
/***/ "./dist/lib/AI/Point.js":
|
|
394
|
+
/*!******************************!*\
|
|
395
|
+
!*** ./dist/lib/AI/Point.js ***!
|
|
396
|
+
\******************************/
|
|
397
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
398
|
+
|
|
399
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Point = void 0;\r\nclass Point {\r\n x = 0;\r\n y = 0;\r\n constructor(x = 0, y = 0) {\r\n this.x = x;\r\n this.y = y;\r\n }\r\n sub(pt) {\r\n return new Point(this.x - pt.x, this.y - pt.y);\r\n }\r\n subSelf(pt) {\r\n this.x -= pt.x;\r\n this.y -= pt.y;\r\n }\r\n add(pt) {\r\n return new Point(this.x + pt.x, this.y + pt.y);\r\n }\r\n addSelf(pt) {\r\n this.x += pt.x;\r\n this.y += pt.y;\r\n }\r\n equals(pt) {\r\n return this.x == pt.x && this.y == pt.y;\r\n }\r\n fuzzyEqual(pt, w) {\r\n let dtx = Math.abs(this.x - pt.x);\r\n if (dtx >= w) {\r\n return false;\r\n }\r\n let dty = Math.abs(this.y - pt.y);\r\n if (dty >= w) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n length() {\r\n return Math.sqrt(this.x * this.x + this.y * this.y);\r\n }\r\n mul(n) {\r\n return new Point(this.x * n, this.y * n);\r\n }\r\n mulSelf(n) {\r\n this.x *= n;\r\n this.y *= n;\r\n }\r\n toI() {\r\n return new Point(Math.floor(this.x), Math.floor(this.y));\r\n }\r\n normalize() {\r\n let len = this.length();\r\n if (len == 0) {\r\n return new Point();\r\n }\r\n return new Point(this.x / len, this.y / len);\r\n }\r\n normalizeSelf() {\r\n let len = this.length();\r\n if (len == 0) {\r\n return;\r\n }\r\n this.x /= len;\r\n this.y /= len;\r\n }\r\n}\r\nexports.Point = Point;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/AI/Point.js?");
|
|
400
|
+
|
|
401
|
+
/***/ }),
|
|
402
|
+
|
|
403
|
+
/***/ "./dist/lib/AI/TriggerMgr.js":
|
|
404
|
+
/*!***********************************!*\
|
|
405
|
+
!*** ./dist/lib/AI/TriggerMgr.js ***!
|
|
406
|
+
\***********************************/
|
|
407
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
408
|
+
|
|
409
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GTriggerMgr = exports.Trigger = exports.EConditionType = exports.ETriggerType = void 0;\r\nconst Log_1 = __webpack_require__(/*! ./../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst Core_1 = __webpack_require__(/*! ../Core/Core */ \"./dist/lib/Core/Core.js\");\r\nvar ETriggerType;\r\n(function (ETriggerType) {\r\n ETriggerType[ETriggerType[\"Region\"] = 0] = \"Region\";\r\n ETriggerType[ETriggerType[\"Condition\"] = 1] = \"Condition\";\r\n})(ETriggerType = exports.ETriggerType || (exports.ETriggerType = {}));\r\nvar EConditionType;\r\n(function (EConditionType) {\r\n EConditionType[EConditionType[\"Die\"] = 0] = \"Die\";\r\n EConditionType[EConditionType[\"Hit\"] = 1] = \"Hit\";\r\n EConditionType[EConditionType[\"HP\"] = 2] = \"HP\";\r\n EConditionType[EConditionType[\"MP\"] = 3] = \"MP\";\r\n})(EConditionType = exports.EConditionType || (exports.EConditionType = {}));\r\nclass Trigger {\r\n region = null;\r\n}\r\nexports.Trigger = Trigger;\r\nlet _GTriggerCode = 0;\r\nexports.GTriggerMgr = null;\r\nclass TriggerManager {\r\n _regionTriggers = null;\r\n _conditionTriggers = {};\r\n //触发器的单个个体必须包含x,y,width,height,其他参数为各自需要添加\r\n init() {\r\n this.clearAll();\r\n }\r\n clearAll() {\r\n this.clearRegionTrigger();\r\n this.clearConditionTrigger();\r\n }\r\n clear(triggertype) {\r\n if (triggertype === undefined) {\r\n this.clearAll();\r\n }\r\n else if (triggertype == ETriggerType.Region) {\r\n this.clearRegionTrigger();\r\n }\r\n else {\r\n this.clearConditionTrigger();\r\n }\r\n }\r\n ////////////////////////////////////////////区域触发器//////////////////////////////////////////////////////\r\n //objs 需要检查的对象,regions触发起区域,callBackObj回调的对象\r\n initRegionTrigger(objs, triggers, callBackObj) {\r\n this.clearRegionTrigger();\r\n if (!triggers || triggers.length <= 0) {\r\n return;\r\n }\r\n for (let i = 0, length = triggers.length; i < length; ++i) {\r\n this._regionTriggers.triggerInfos[i] = { trigger: triggers[i] };\r\n }\r\n if (Core_1.core.isArray(objs)) {\r\n for (let i = 0, length = objs.length; i < length; ++i) {\r\n this._regionTriggers.objInfos[i] = { obj: objs[i], prePos: null };\r\n }\r\n }\r\n else {\r\n this._regionTriggers.objInfos[0] = { obj: objs, prePos: null };\r\n }\r\n if (typeof callBackObj !== \"undefined\") {\r\n this._regionTriggers.aiObj = callBackObj;\r\n }\r\n this._checkRegion(); //初始化check\r\n }\r\n clearRegionTrigger() {\r\n this._regionTriggers = { triggerInfos: [], objInfos: [], aiObj: null };\r\n }\r\n addObjToRegionTrigger(obj) {\r\n this._regionTriggers.objInfos[this._regionTriggers.objInfos.length] = { obj: obj, prePos: null };\r\n }\r\n removeObjInRegionTrigger(obj) {\r\n for (let i = 0; i < this._regionTriggers.objInfos.length; ++i) {\r\n let o = this._regionTriggers.objInfos[i].obj;\r\n if (o === obj) {\r\n this._regionTriggers.objInfos = this._regionTriggers.objInfos.splice(i, 1);\r\n return;\r\n }\r\n }\r\n }\r\n //是否在触发器内\r\n _isInTrigger(pos, region) {\r\n if (!pos || typeof region === \"undefined\") {\r\n return false;\r\n }\r\n Log_1.GLog.info(\"pos.x\" + pos.x + \" pos.y=\" + pos.y);\r\n Log_1.GLog.info(\"region.x\" + region.x + \" region.y=\" + region.y);\r\n if (pos.x < (region.x - region.width / 2)) {\r\n return false;\r\n }\r\n if (pos.x > (region.x + region.width / 2)) {\r\n return false;\r\n }\r\n if (pos.y < (region.y - region.height / 2)) {\r\n return false;\r\n }\r\n if (pos.y > (region.y + region.height / 2)) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n //外部需要调用改接口\r\n check() {\r\n this._checkRegion();\r\n }\r\n _checkRegion() {\r\n for (let i = 0, length = this._regionTriggers.objInfos.length; i < length; ++i) {\r\n let info = this._regionTriggers.objInfos[i];\r\n if (!info) {\r\n continue;\r\n }\r\n let obj = info.obj;\r\n if (!obj) {\r\n this.removeObjInRegionTrigger(obj); //改对象已经无效\r\n continue;\r\n }\r\n let pos = obj.cellPos;\r\n if (!info.prePos) {\r\n info.prePos = pos;\r\n for (let i = 0, length = this._regionTriggers.triggerInfos.length; i < length; ++i) {\r\n let triggerInfo = this._regionTriggers.triggerInfos[i];\r\n if (this._isInTrigger(pos, triggerInfo.trigger.region)) {\r\n //原本在外面或首次检测,触发进入事件\r\n if (triggerInfo[obj.id] && triggerInfo[obj.id] == -1) {\r\n this._triggerIn(obj, triggerInfo.trigger);\r\n triggerInfo[obj.id] = 1;\r\n }\r\n }\r\n else {\r\n //原本在里面或者首次检测,现在不在了,触发走出触发器事件\r\n if (triggerInfo[obj.id] && triggerInfo[obj.id] == 1) {\r\n this._triggerOut(obj, triggerInfo.trigger);\r\n }\r\n triggerInfo[obj.id] = -1;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n //从外面进入时触发\r\n _triggerIn(obj, trigger) {\r\n if (!this._regionTriggers.aiObj || !this._regionTriggers.aiObj.onTriggerIn) {\r\n return;\r\n }\r\n Log_1.GLog.info(\"some one triggered in\");\r\n this._regionTriggers.aiObj.onTriggerIn(obj, trigger);\r\n }\r\n //从里面走出去的时候触发\r\n _triggerOut(obj, trigger) {\r\n if (!this._regionTriggers.aiObj || !this._regionTriggers.aiObj.onTriggerOut) {\r\n return;\r\n }\r\n Log_1.GLog.info(\"some one triggered out\");\r\n this._regionTriggers.aiObj.onTriggerOut(obj, trigger);\r\n }\r\n //////////////////////////////////////条件触发器//////////////////////////////////////////////////\r\n initConditionTrigger() {\r\n this._conditionTriggers = {};\r\n for (let conditiontype in EConditionType) {\r\n this._conditionTriggers[conditiontype] = {};\r\n }\r\n }\r\n clearConditionTrigger() {\r\n this._conditionTriggers = [];\r\n for (let conditiontype in EConditionType) {\r\n this._conditionTriggers[EConditionType[conditiontype]] = {};\r\n }\r\n }\r\n triggerCondition(conditiontype, params, conditions) {\r\n params = params || {};\r\n conditions = conditions || {};\r\n for (let code in this._conditionTriggers[conditiontype]) {\r\n let info = this._conditionTriggers[conditiontype][code];\r\n for (let key in info.conditions) {\r\n if (info.conditions[key] !== conditions[key]) {\r\n return false;\r\n }\r\n }\r\n info.callback(params);\r\n }\r\n return true;\r\n }\r\n addConditionTriggerEvent(conditiontype, callback, conditions) {\r\n conditions = conditions || {};\r\n _GTriggerCode += 1;\r\n this._conditionTriggers[conditiontype][_GTriggerCode] = { callback: callback, conditions: conditions };\r\n return { type: conditiontype, code: _GTriggerCode };\r\n }\r\n removeConditionTriggerEvent(conditiontype, code) {\r\n if (code === undefined) {\r\n this._conditionTriggers[conditiontype] = {};\r\n }\r\n else {\r\n delete this._conditionTriggers[conditiontype][code];\r\n }\r\n }\r\n}\r\nexports.GTriggerMgr = new TriggerManager();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/AI/TriggerMgr.js?");
|
|
410
|
+
|
|
411
|
+
/***/ }),
|
|
412
|
+
|
|
413
|
+
/***/ "./dist/lib/Config/Config.js":
|
|
414
|
+
/*!***********************************!*\
|
|
415
|
+
!*** ./dist/lib/Config/Config.js ***!
|
|
416
|
+
\***********************************/
|
|
417
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
418
|
+
|
|
419
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Config = void 0;\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst jsonc_1 = __webpack_require__(/*! jsonc */ \"jsonc\");\r\nclass Config {\r\n _suffix = \"\";\r\n _is_init = false;\r\n _file_name = \"\";\r\n /**\r\n * 是否是debug调试模式,主要区别于读取数据档,debug默认读取file_d文件,release默认读取file_r文件,如果不存在都会读取file文件\r\n */\r\n static debug = false;\r\n constructor(filename) {\r\n this._file_name = filename;\r\n }\r\n init() {\r\n if (this._is_init) {\r\n return false;\r\n }\r\n let suffix2 = \"_r\";\r\n if (Config.debug) {\r\n suffix2 = \"_d\";\r\n }\r\n let path = \"data/\" + this._file_name + \"_\" + this._suffix + suffix2 + \".json\";\r\n path = path.toLowerCase();\r\n if (!fs.existsSync(path)) {\r\n path = \"data/\" + this._file_name + \"_\" + this._suffix + \".json\";\r\n path = path.toLowerCase();\r\n if (!fs.existsSync(path)) {\r\n path = \"data/\" + this._file_name + suffix2 + \".json\";\r\n path = path.toLowerCase();\r\n if (!fs.existsSync(path)) {\r\n path = \"data/\" + this._file_name + \".json\";\r\n path = path.toLowerCase();\r\n if (!fs.existsSync(path)) {\r\n console.error(path + \" not exist!\");\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n let content = fs.readFileSync(path).toString();\r\n let jsonData = jsonc_1.jsonc.parse(content);\r\n for (let key in jsonData) {\r\n this[key] = jsonData[key];\r\n }\r\n console.log(\"loaded cfg=\" + path);\r\n return true;\r\n }\r\n}\r\nexports.Config = Config;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Config/Config.js?");
|
|
420
|
+
|
|
421
|
+
/***/ }),
|
|
422
|
+
|
|
423
|
+
/***/ "./dist/lib/Config/FrameworkConfig.js":
|
|
424
|
+
/*!********************************************!*\
|
|
425
|
+
!*** ./dist/lib/Config/FrameworkConfig.js ***!
|
|
426
|
+
\********************************************/
|
|
427
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
428
|
+
|
|
429
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.FrameworkConfig = exports.WebServerConfig = exports.ESessionType = void 0;\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst Config_1 = __webpack_require__(/*! ./Config */ \"./dist/lib/Config/Config.js\");\r\nvar ESessionType;\r\n(function (ESessionType) {\r\n ESessionType[ESessionType[\"Cache\"] = 0] = \"Cache\";\r\n ESessionType[ESessionType[\"Redis\"] = 1] = \"Redis\";\r\n ESessionType[ESessionType[\"Mongo\"] = 2] = \"Mongo\";\r\n})(ESessionType = exports.ESessionType || (exports.ESessionType = {}));\r\nclass WebServerConfig {\r\n cache = {};\r\n session_type = ESessionType.Cache;\r\n debug = false;\r\n web_name = \"web\";\r\n port = 0;\r\n cookie = {\r\n prefix: \"tiny_cookie_\",\r\n expires: {\r\n account_remember: 7 * 24 * 60 * 60,\r\n account: 10 * 60\r\n }\r\n };\r\n routs = {\r\n /**\r\n * 如果设置了这一项,那网址里面就不用带模块名称,是不回解析的\r\n */\r\n onlyModule: \"Web\",\r\n defaults: { module: \"Web\", controller: \"Index\", action: \"Index\" }\r\n };\r\n ssl = null;\r\n //默认不跨域\r\n cors = null;\r\n}\r\nexports.WebServerConfig = WebServerConfig;\r\nclass FrameworkConfig extends Config_1.Config {\r\n /*\r\n *-1不输出到console,0,仅错误信息输出到console,1,都输出到console\r\n */\r\n console_level = 0;\r\n log = {\r\n appenders: {\r\n console: {\r\n \"type\": \"console\",\r\n \"category\": \"console\"\r\n },\r\n log_file: {\r\n category: \"log_file\",\r\n type: \"file\",\r\n filename: \"./logs/log_file/file.log\",\r\n maxLogSize: 10 * 1024 * 1024,\r\n backups: 100,\r\n },\r\n log_date: {\r\n category: \"log_date\",\r\n type: \"dateFile\",\r\n filename: \"./logs/log_date/date\",\r\n alwaysIncludePattern: true,\r\n pattern: \"yyyy-MM-dd-hh.log\"\r\n },\r\n client_log_file: {\r\n category: \"log_file\",\r\n type: \"file\",\r\n filename: \"./logs/client_log_file/file.log\",\r\n maxLogSize: 10 * 1024 * 1024,\r\n backups: 100,\r\n },\r\n client_log_date: {\r\n category: \"log_date\",\r\n type: \"dateFile\",\r\n filename: \"./logs/client_log_date/date\",\r\n alwaysIncludePattern: true,\r\n pattern: \"yyyy-MM-dd.log\"\r\n },\r\n error_log_file: {\r\n category: \"error_log_file\",\r\n type: \"file\",\r\n filename: \"./logs/error_log_file/file.log\",\r\n maxLogSize: 5 * 1024 * 1024,\r\n backups: 100,\r\n }\r\n },\r\n categories: {\r\n default: {\r\n appenders: ['log_date'],\r\n level: 'ALL'\r\n },\r\n console: {\r\n appenders: ['console'],\r\n level: 'ALL'\r\n },\r\n log_file: {\r\n appenders: ['log_file'],\r\n level: 'ALL'\r\n },\r\n log_date: {\r\n appenders: ['log_date'],\r\n level: 'ALL'\r\n },\r\n client_log_file: {\r\n appenders: ['client_log_file'],\r\n level: 'ALL'\r\n },\r\n client_log_date: {\r\n appenders: ['client_log_date'],\r\n level: 'ALL'\r\n },\r\n error_log_file: {\r\n appenders: ['error_log_file'],\r\n level: 'ALL'\r\n },\r\n }\r\n };\r\n /**\r\n * 控制网络消息的\r\n */\r\n debug_msg = false;\r\n local_host = \"127.0.0.1\";\r\n internet_host = \"127.0.0.1\";\r\n db = {\r\n redis: {\r\n open: false,\r\n host: \"127.0.0.1\",\r\n port: 6379,\r\n database: 0,\r\n password: null\r\n },\r\n mongo: {\r\n open: false,\r\n host: \"www.eryinet.com\",\r\n port: 27017,\r\n options: null,\r\n database: 'achat'\r\n },\r\n mysql: {\r\n open: false,\r\n auto: false,\r\n host: '127.0.0.1',\r\n port: 3306,\r\n user: 'root',\r\n password: 'root',\r\n database: 'gameall',\r\n charset: 'utf8mb4'\r\n },\r\n mssql: {\r\n open: false,\r\n auto: false,\r\n domain: '127.0.0.1',\r\n port: 3306,\r\n user: 'root',\r\n password: 'root',\r\n database: 'gameall',\r\n charset: 'utf8mb4'\r\n }\r\n };\r\n third_cfg = {\r\n open_social: {\r\n app_id: \"appid_42313131\",\r\n app_secret: \"apps_FDS4342J34JL432\",\r\n auth_url: \"http://47.99.195.103:6666/auth/account/\",\r\n user_url: \"http://47.99.195.103:6666/auth/userinfo/\",\r\n update_pwd_url: \"http://47.99.195.103:6666/auth/updatepwd/\"\r\n },\r\n aliSms: {\r\n signName: \"而已网络\",\r\n accessKeyId: \"LTAIeqjiZ5OCev0B\",\r\n secretAccessKey: \"0w1fmDEORshI94QqtampBaAPQDqUAj\",\r\n templateCode: \"SMS_154589473\"\r\n },\r\n qiniu: {\r\n host: \"p0bj0dycx.bkt.clouddn.com\",\r\n bucket: \"eryiniuniu\",\r\n accessKey: \"OETxflxP9V5ZzPcjE30asCv-YxWBvDpmMPJegtI4\",\r\n secretKey: \"kZWsom120P0-cfQt_9_1-wR_X8RwuLeMXKbU_uc4\"\r\n },\r\n email: {\r\n host: \"smtp.live.com\",\r\n port: 587,\r\n secure: false,\r\n auth: {\r\n user: \"chengang01@live.com\",\r\n pass: \"cg123!@#\" // generated ethereal password\r\n },\r\n from: \"OpenSocial <chengang01@live.com>\"\r\n },\r\n qq: {\r\n app_id: \"101775753\",\r\n app_key: \"753d0f02f3c4093062e7b2f56c7fcb0c\",\r\n redirect_uri: \"http://www.eryinet.com/qq/callback\"\r\n },\r\n wechat: {\r\n app_id: \"wx80f0f10fe1304e9d\",\r\n app_key: \"a76fc337c49b309886a6538d31c344e2\",\r\n redirect_uri: \"http://www.eryinet.com/wechat/callback\"\r\n },\r\n alipay: {\r\n open: false,\r\n dev: false,\r\n app_id: \"\",\r\n app_key: \"\",\r\n gateway: \"\",\r\n //RSA1 RSA2\r\n signType: 'RSA2',\r\n /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */\r\n keyType: 'PKCS1',\r\n alipay_root_cert_sn: \"\",\r\n alipay_cert_sn: \"\",\r\n app_cert_sn: \"\",\r\n notify_url: \"\",\r\n app_id_dev: \"\",\r\n app_key_dev: \"\",\r\n gateway_dev: \"\",\r\n //RSA1 RSA2\r\n signType_dev: 'RSA2',\r\n /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */\r\n keyType_dev: 'PKCS1',\r\n alipay_root_cert_sn_dev: \"\",\r\n alipay_cert_sn_dev: \"\",\r\n app_cert_sn_dev: \"\",\r\n notify_url_dev: \"\"\r\n },\r\n apple: {\r\n keyIds: {}\r\n }\r\n };\r\n //key是ip,value是domain\r\n ip_to_domain = {};\r\n root_path = process.cwd();\r\n constructor() {\r\n super(\"FrameworkConfig\");\r\n }\r\n init() {\r\n let ret = super.init();\r\n Log_1.GLog.init(this.log, this.console_level || 0);\r\n return ret;\r\n }\r\n}\r\nexports.FrameworkConfig = FrameworkConfig;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Config/FrameworkConfig.js?");
|
|
430
|
+
|
|
431
|
+
/***/ }),
|
|
432
|
+
|
|
433
|
+
/***/ "./dist/lib/Config/ServerConfig.js":
|
|
434
|
+
/*!*****************************************!*\
|
|
435
|
+
!*** ./dist/lib/Config/ServerConfig.js ***!
|
|
436
|
+
\*****************************************/
|
|
437
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
438
|
+
|
|
439
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ServerConfig = exports.GServerCfg = void 0;\r\nconst FrameworkConfig_1 = __webpack_require__(/*! ./FrameworkConfig */ \"./dist/lib/Config/FrameworkConfig.js\");\r\nexports.GServerCfg = null;\r\nclass ServerConfig extends FrameworkConfig_1.FrameworkConfig {\r\n port = -1;\r\n _server_name = \"\";\r\n webserver = null;\r\n get serverName() {\r\n return this._server_name;\r\n }\r\n constructor(server_name) {\r\n super();\r\n this._suffix = server_name;\r\n this._server_name = server_name;\r\n }\r\n init() {\r\n let ret = super.init();\r\n if (!ret) {\r\n return ret;\r\n }\r\n exports.GServerCfg = this;\r\n return ret;\r\n }\r\n}\r\nexports.ServerConfig = ServerConfig;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Config/ServerConfig.js?");
|
|
440
|
+
|
|
441
|
+
/***/ }),
|
|
442
|
+
|
|
443
|
+
/***/ "./dist/lib/Config/_error_.js":
|
|
444
|
+
/*!************************************!*\
|
|
445
|
+
!*** ./dist/lib/Config/_error_.js ***!
|
|
446
|
+
\************************************/
|
|
447
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
448
|
+
|
|
449
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.FrameworkErrorCode = exports.EErrorCode = void 0;\r\nexports.EErrorCode = null;\r\n/**\r\n * 1-100\r\n */\r\nclass FrameworkErrorCode {\r\n Wrong_Params = { id: 1, des: \"参数错误\" };\r\n Verify_failed = { id: 2, des: \"验证失败\" };\r\n Account_Create_Failed = { id: 3, des: \"账号创建失败\" };\r\n User_Create_Failed = { id: 4, des: \"角色创建失败\" };\r\n Server_Error = { id: 5, des: \"服务器内部错误\" };\r\n No_Account = { id: 6, des: \"账户不存在\" };\r\n Mysql_Error = { id: 7, des: \"数据库异常\" };\r\n No_Mysql = { id: 8, des: \"未开通Mysql数据库\" };\r\n No_Mssql = { id: 8, des: \"未开通Mssql数据库\" };\r\n No_User = { id: 9, des: \"用户不存在\" };\r\n Account_Phone_Exist = { id: 10, des: \"电话已存在\" };\r\n Account_Email_Exist = { id: 11, des: \"邮箱已存在\" };\r\n Account_Name_Exist = { id: 12, des: \"账户名已存在\" };\r\n Account_Type_Error = { id: 13, des: \"账户类型错误\" };\r\n Email_Send_Failed = { id: 14, des: \"邮件发送失败\" };\r\n Login_Failed = { id: 15, des: \"登陆验证失败\" };\r\n Password_Too_Short = { id: 16, des: \"密码太短\" };\r\n Wrong_Phone = { id: 17, des: \"电话号码不正确\" };\r\n PhoneCode_Too_Quick = { id: 18, des: \"验证码获取过快,请稍后再试\" };\r\n PhoneCode_GetFailed = { id: 19, des: \"验证码获取失败\" };\r\n Wrong_Phone_Code = { id: 20, des: \"验证码不正确\" };\r\n No_Mongo = { id: 21, des: \"未开通Mongo数据库\" };\r\n Mongo_Error = { id: 22, des: \"Mongo数据库异常\" };\r\n constructor() { }\r\n}\r\nexports.FrameworkErrorCode = FrameworkErrorCode;\r\nexports.EErrorCode = new FrameworkErrorCode();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Config/_error_.js?");
|
|
450
|
+
|
|
451
|
+
/***/ }),
|
|
452
|
+
|
|
453
|
+
/***/ "./dist/lib/Core/Core.js":
|
|
454
|
+
/*!*******************************!*\
|
|
455
|
+
!*** ./dist/lib/Core/Core.js ***!
|
|
456
|
+
\*******************************/
|
|
457
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
458
|
+
|
|
459
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.core = void 0;\r\nlet os = __webpack_require__(/*! os */ \"os\");\r\nlet request = __webpack_require__(/*! request */ \"request\");\r\nconst _ = __webpack_require__(/*! underscore */ \"underscore\");\r\nconst crypto = __webpack_require__(/*! crypto */ \"crypto\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\n/**\r\n * 常用的工具函数类\r\n */\r\nclass core {\r\n /**\r\n * 判断变量是不是对象\r\n * @param param 需要检查的变量\r\n * @returns true为对象\r\n */\r\n static isObject(param) {\r\n return typeof (param) === \"object\";\r\n }\r\n static isArray(param) {\r\n return param instanceof Array;\r\n }\r\n static isNumber(param) {\r\n return typeof (param) === \"number\";\r\n }\r\n static isNaN(param) {\r\n return isNaN(param);\r\n }\r\n static isFunction(param) {\r\n return typeof (param) === \"function\";\r\n }\r\n static isString(param) {\r\n return typeof (param) === \"string\";\r\n }\r\n static isAsyncFunc(fun) {\r\n if (!this.isFunction(fun)) {\r\n return;\r\n }\r\n return fun[Symbol.toStringTag] === \"AsyncFunction\";\r\n }\r\n /**\r\n * 深度拷贝\r\n * @param obj\r\n * @returns\r\n */\r\n static clone(obj) {\r\n if (!obj) {\r\n return obj;\r\n }\r\n if (core.isArray(obj)) {\r\n let newArray = new Array();\r\n for (let i = 0, length = obj.length; i < length; ++i) {\r\n newArray[i] = this.clone(obj[i]);\r\n }\r\n return newArray;\r\n }\r\n if (core.isObject(obj)) {\r\n let newObj = new Object();\r\n for (let i in obj) {\r\n newObj[i] = this.clone(obj[i]);\r\n }\r\n return newObj;\r\n }\r\n return obj;\r\n }\r\n //合并但是不改变dest\r\n static merge(dest, src) {\r\n let t = core.clone(dest);\r\n if (!src) {\r\n return t;\r\n }\r\n if (core.isArray(src)) {\r\n t = t || [];\r\n let tlen = t.length;\r\n for (let i = 0, len = src.length; i < len; ++i) {\r\n let value = src[i];\r\n if (core.isFunction(value)) {\r\n continue;\r\n }\r\n if (core.isArray(value) || core.isObject(value)) {\r\n if (i < tlen) {\r\n t[i] = core.merge(null, value);\r\n }\r\n else {\r\n t.push(core.merge(null, value));\r\n }\r\n }\r\n else {\r\n if (i < tlen) {\r\n t[i] = value;\r\n }\r\n else {\r\n t.push(value);\r\n }\r\n }\r\n }\r\n }\r\n else if (core.isObject(src)) {\r\n t = t || {};\r\n for (let key in src) {\r\n let value = src[key];\r\n if (core.isFunction(value)) {\r\n continue;\r\n }\r\n if (core.isArray(value) || core.isObject(value)) {\r\n t[key] = core.merge(null, value);\r\n }\r\n else {\r\n t[key] = value;\r\n }\r\n }\r\n }\r\n else {\r\n t = src;\r\n }\r\n return t;\r\n }\r\n //只是取出template里面已经有的部分\r\n static getExit(template, src) {\r\n if (!src || !template) {\r\n return {};\r\n }\r\n let t = {};\r\n for (let key in src) {\r\n if (template[key] === undefined) {\r\n continue;\r\n }\r\n let value = src[key];\r\n if (core.isFunction(value)) {\r\n continue;\r\n }\r\n if (core.isArray(value) || core.isObject(value)) {\r\n t[key] = core.getExit(template[key], value);\r\n }\r\n else {\r\n t[key] = value;\r\n }\r\n }\r\n return t;\r\n }\r\n static toArray(table) {\r\n let array = [];\r\n for (let key in table) {\r\n if (core.isFunction(table[key])) {\r\n continue;\r\n }\r\n array.push(key);\r\n array.push(table[key]);\r\n }\r\n return array;\r\n }\r\n static foreach(items, callback) {\r\n if (!items || !callback) {\r\n return;\r\n }\r\n if (core.isNumber(items)) {\r\n for (let i = 0; i < items; ++i) {\r\n let ret = callback(i);\r\n if (ret) {\r\n return;\r\n }\r\n }\r\n }\r\n else if (core.isString(items)) {\r\n for (let i = 0, length = items.length; i < length; i++) {\r\n let ret = callback(i, items.charAt(i));\r\n if (ret) {\r\n return;\r\n }\r\n }\r\n }\r\n else if (core.isArray(items)) {\r\n for (let i = 0, length = items.length; i < length; ++i) {\r\n let ret = callback(i, items[i]);\r\n if (ret) {\r\n return;\r\n }\r\n }\r\n }\r\n else if (core.isObject(items)) {\r\n for (let key in items) {\r\n let ret = callback(key, items[key]);\r\n if (ret) {\r\n return;\r\n }\r\n }\r\n }\r\n return;\r\n }\r\n static getLength(items) {\r\n if (core.isArray(items)) {\r\n return items.length;\r\n }\r\n if (core.isObject) {\r\n let len = 0;\r\n core.foreach(items, function () {\r\n ++len;\r\n });\r\n return len;\r\n }\r\n return 0;\r\n }\r\n static char2buf(str) {\r\n let out = new ArrayBuffer(str.length * 2);\r\n let u16a = new Uint16Array(out);\r\n let strs = str.split(\"\");\r\n for (let i = 0; i < strs.length; i++) {\r\n u16a[i] = strs[i].charCodeAt();\r\n }\r\n return out;\r\n }\r\n static array2arraybuffer(array) {\r\n let b = new ArrayBuffer(array.length);\r\n let v = new DataView(b, 0);\r\n for (let i = 0; i < array.length; i++) {\r\n v.setUint8(i, array[i]);\r\n }\r\n return b;\r\n }\r\n static arraybuffer2array(buffer) {\r\n let v = new DataView(buffer, 0);\r\n let a = new Uint8Array(v.byteLength);\r\n for (let i = 0; i < v.byteLength; i++) {\r\n a[i] = v.getUint8(i);\r\n }\r\n return a;\r\n }\r\n static firstCharUpCase(str) {\r\n let reg = /\\b(\\w)|\\s(\\w)/g;\r\n str = str.toLowerCase();\r\n return str.replace(reg, function (m) { return m.toUpperCase(); });\r\n }\r\n static convertIntToUInt8Array(num) {\r\n let c2 = num % 256;\r\n let c1 = Math.floor(num / 256);\r\n let arr = new Uint8Array(2);\r\n arr[0] = c1;\r\n arr[1] = c2;\r\n return arr;\r\n }\r\n static convertUInt8ArrayToInt(array) {\r\n if (array.length != 2) {\r\n return 0;\r\n }\r\n return array[0] * 256 + array[1];\r\n }\r\n //从一个数组里面按照下标和长度的方式去获取另一个数组,至少返回空数组\r\n //包含start\r\n static getArrayFromArray(data, start, l) {\r\n let len = data.length;\r\n start = start || 0; //默认最开始\r\n l = l || len; //默认到最后\r\n if (start >= len) {\r\n return new Uint8Array();\r\n }\r\n let arr = new Uint8Array(l);\r\n for (let i = start; i < start + l && i < len; ++i) {\r\n arr[i] = data[i];\r\n }\r\n return arr;\r\n }\r\n static blobToArrayBuffer(data, callback) {\r\n let fileReader = new FileReader();\r\n fileReader.onload = function (progressEvent) {\r\n if (callback) {\r\n callback(this.result);\r\n }\r\n };\r\n fileReader.readAsArrayBuffer(data);\r\n }\r\n static format = function (src, formatStr) {\r\n if (core.isString(src)) {\r\n let args = Array.prototype.slice.call(arguments, 1);\r\n return src.replace(/\\{(\\d+)\\}/g, function (m, i) {\r\n return args[i];\r\n });\r\n }\r\n else {\r\n if (this.isNumber(src)) {\r\n src = new Date(src);\r\n }\r\n let str = formatStr;\r\n let Week = ['日', '一', '二', '三', '四', '五', '六'];\r\n let month = src.getMonth() + 1;\r\n let year = src.getFullYear();\r\n let date = src.getDate();\r\n let hour = src.getHours();\r\n let min = src.getMinutes();\r\n let sec = src.getSeconds();\r\n let day = src.getDay();\r\n str = str.replace(/yyyy|YYYY/, year);\r\n str = str.replace(/yy|YY/, (year % 100) > 9 ? (year % 100).toString() : '0' + (year % 100));\r\n str = str.replace(/MM/, month > 9 ? month.toString() : '0' + month);\r\n str = str.replace(/M/g, month);\r\n str = str.replace(/w|W/g, Week[day]);\r\n str = str.replace(/dd|DD/, date > 9 ? date.toString() : '0' + date);\r\n str = str.replace(/d|D/g, date);\r\n str = str.replace(/hh|HH/, hour > 9 ? hour.toString() : '0' + hour);\r\n str = str.replace(/h|H/g, hour);\r\n str = str.replace(/mm/, min > 9 ? min.toString() : '0' + min);\r\n str = str.replace(/m/g, min);\r\n str = str.replace(/ss|SS/, sec > 9 ? sec.toString() : '0' + sec);\r\n str = str.replace(/s|S/g, sec);\r\n return str;\r\n }\r\n };\r\n /**\r\n * 字符串中间保密\r\n * @param str\r\n */\r\n static fuzzy(str) {\r\n if (!str) {\r\n return str;\r\n }\r\n if (str.length <= 1) {\r\n return str;\r\n }\r\n if (str.length == 2) {\r\n return str[0] + \"*\";\r\n }\r\n let first = str[0];\r\n let last = str[str.length - 1];\r\n let newStr = first;\r\n for (let i = 0; i < str.length - 2; ++i) {\r\n newStr += \"*\";\r\n }\r\n newStr += last;\r\n return newStr;\r\n }\r\n static md5(str) {\r\n let md5_str = crypto.createHash('md5').update(str).digest('hex');\r\n return md5_str;\r\n }\r\n static sha1(str) {\r\n let sha1_str = crypto.createHash('sha1').update(str).digest('hex');\r\n return sha1_str;\r\n }\r\n static getLocalIP = function () {\r\n let iptable = {};\r\n let ifaces = os.networkInterfaces();\r\n for (let dev in ifaces) {\r\n ifaces[dev].forEach(function (details, alias) {\r\n if ((details.family == 'IPv4') && (details.internal == false)) {\r\n iptable['localIP'] = details.address;\r\n }\r\n });\r\n }\r\n return iptable['localIP'];\r\n };\r\n static getIP = async function () {\r\n return new Promise((resolve, reject) => {\r\n request('http://ip.chinaz.com/getip.aspx', function (error, response, body) {\r\n if (!error && response.statusCode == 200) {\r\n body = eval('(' + body + ')');\r\n resolve(body.ip);\r\n }\r\n else {\r\n console.error(\"can not get correct ip!\");\r\n resolve(null);\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * 判断是否是手机号\r\n * @param phone 手机号\r\n */\r\n static isPhoneNo(phone) {\r\n let reg = /^1[3|4|5|7|8][0-9]{9}$/; //验证规则\r\n let flag = reg.test(phone); //true\r\n return flag;\r\n }\r\n /**\r\n * 判断是否是email\r\n * @param email\r\n */\r\n static isEmail(email) {\r\n if (!email) {\r\n return false;\r\n }\r\n var regu = \"^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int|name|asia)$\";\r\n var re = new RegExp(regu);\r\n if (email.search(re) == -1) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n /**\r\n * 根据概率分布获取概率分布的下标\r\n * @param probabilitys 概率分布列表\r\n * @param totalProbability 总概率\r\n */\r\n static getRandomIndex(probabilitys, totalProbability) {\r\n let result = 0;\r\n let random = 0;\r\n totalProbability = totalProbability || -1;\r\n if (totalProbability < 0) {\r\n totalProbability = eval(probabilitys.join(\"+\"));\r\n }\r\n if (totalProbability > 1) {\r\n random = _.random(totalProbability);\r\n }\r\n else {\r\n random = Math.random();\r\n }\r\n let value = 0;\r\n for (let index = 0; index < probabilitys.length; ++index) {\r\n value += probabilitys[index];\r\n if (random < value) {\r\n result = index;\r\n break;\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * 检查是否是闰年\r\n * @param year\r\n */\r\n static checkLeap(year) {\r\n if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {\r\n return true;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n /**\r\n * 获取几月一共有多少天\r\n * @param year\r\n * @param month\r\n */\r\n static getMonthDays(year, month) {\r\n let months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\r\n if (this.checkLeap(year)) {\r\n months[1] = 29;\r\n }\r\n return months[month - 1];\r\n }\r\n /**\r\n * 获取今日开始的时间\r\n */\r\n static getTodayStartTime() {\r\n let now = new Date();\r\n let time = now.getTime();\r\n time = time - (now.getHours() * 60 * 60 * 1000 + now.getMinutes() * 60 * 1000 + now.getSeconds() * 1000 + now.getMilliseconds());\r\n return time;\r\n }\r\n /**\r\n * 获取某个时间的开始时间\r\n * @param time 时间戳\r\n * @returns\r\n */\r\n static getStartTime(time) {\r\n let now = null;\r\n if (time) {\r\n now = new Date(time);\r\n }\r\n else {\r\n now = new Date();\r\n }\r\n time = now.getTime();\r\n time = time - (now.getHours() * 60 * 60 * 1000 + now.getMinutes() * 60 * 1000 + now.getSeconds() * 1000 + now.getMilliseconds());\r\n return time;\r\n }\r\n static getLastMonthStartTime() {\r\n let now = new Date();\r\n let time = null;\r\n if (now.getMonth() != 0) {\r\n time = new Date(now.getFullYear(), now.getMonth() - 1);\r\n }\r\n else {\r\n time = new Date(now.getFullYear() - 1, 12);\r\n }\r\n return time.getTime();\r\n }\r\n static getCurMonthStartTime() {\r\n let now = new Date();\r\n let time = new Date(now.getFullYear(), now.getMonth());\r\n return time.getTime();\r\n }\r\n static getLastWeekStartTime() {\r\n let one_day = 24 * 60 * 60 * 1000;\r\n let time = this.getTodayStartTime();\r\n let day = new Date().getDay();\r\n return time - (day + 7) * one_day;\r\n }\r\n static getCurWeekStartTime() {\r\n let one_day = 24 * 60 * 60 * 1000;\r\n let time = this.getTodayStartTime();\r\n let day = new Date().getDay();\r\n return time - day * one_day;\r\n }\r\n static isSameMonth(src_time, target_time) {\r\n let src_date = new Date(src_time);\r\n let target_date = new Date(target_time);\r\n if (src_date.getFullYear() != target_date.getFullYear()) {\r\n return false;\r\n }\r\n return src_date.getMonth() == target_date.getMonth();\r\n }\r\n static isSameDay(src_time, target_time) {\r\n let oneDayTime = 1000 * 60 * 60 * 24;\r\n let eight_time = 1000 * 60 * 60 * 8;\r\n let old_count = Math.floor((src_time + eight_time) / oneDayTime);\r\n let now_other = Math.floor((target_time + eight_time) / oneDayTime);\r\n return old_count == now_other;\r\n }\r\n /**\r\n * 两个日期是否是同一周\r\n * 思路: 因为1970年1月1 是周4 所以(天数+4)/7 取整 就是周数 如果相同就是同一周反之就不是\r\n * @param old\r\n * @param now\r\n */\r\n static isSameWeek(src_time, target_time) {\r\n let oneDayTime = 1000 * 60 * 60 * 24;\r\n let eight_time = 1000 * 60 * 60 * 8;\r\n let old_count = Math.floor((src_time + eight_time) / oneDayTime);\r\n let now_other = Math.floor((target_time + eight_time) / oneDayTime);\r\n return Math.floor((old_count + 4) / 7) == Math.floor((now_other + 4) / 7);\r\n }\r\n static sum(datas) {\r\n let total = 0;\r\n for (let v of datas) {\r\n total += v;\r\n }\r\n return total;\r\n }\r\n /**\r\n * 转球为全球数字格式,三位数一个逗号\r\n * @param num\r\n */\r\n static convertToGlobalStr(num) {\r\n if (!num) {\r\n return num + \"\";\r\n }\r\n if (num < 1000) {\r\n return num + \"\";\r\n }\r\n let str = \"\";\r\n while (true) {\r\n let n = num % 1000;\r\n if (n > 99) {\r\n str = \",\" + n + str;\r\n }\r\n else if (n > 9) {\r\n str = \",0\" + n + str;\r\n }\r\n else {\r\n str = \",00\" + n + str;\r\n }\r\n num = Math.floor(num / 1000);\r\n if (num < 1000) {\r\n str = num + str;\r\n break;\r\n }\r\n }\r\n return str;\r\n }\r\n static sleep(milliseconds) {\r\n return new Promise((resolve) => {\r\n setTimeout(() => {\r\n resolve(null);\r\n }, milliseconds);\r\n });\r\n }\r\n static async safeCall(func, thisArg = null, ...params) {\r\n if (!func) {\r\n return;\r\n }\r\n try {\r\n let rs = undefined;\r\n if (core.isAsyncFunc(func)) {\r\n if (thisArg) {\r\n rs = await func.call(thisArg, ...params).catch((reason) => {\r\n Log_1.GLog.error(reason);\r\n rs = { errcode: { id: 1008611, des: \"failed\" } };\r\n });\r\n }\r\n else {\r\n rs = await func(...params).catch((reason) => {\r\n Log_1.GLog.error(reason);\r\n rs = { errcode: { id: 1008612, des: \"failed\" } };\r\n });\r\n }\r\n }\r\n else {\r\n if (thisArg) {\r\n rs = func.call(thisArg, ...params);\r\n }\r\n else {\r\n rs = func(...params);\r\n }\r\n }\r\n return rs;\r\n }\r\n catch (e) {\r\n Log_1.GLog.error(e.stack);\r\n return { errcode: { id: 1008613, des: \"failed\" } };\r\n }\r\n }\r\n}\r\nexports.core = core;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Core/Core.js?");
|
|
460
|
+
|
|
461
|
+
/***/ }),
|
|
462
|
+
|
|
463
|
+
/***/ "./dist/lib/Core/Timer.js":
|
|
464
|
+
/*!********************************!*\
|
|
465
|
+
!*** ./dist/lib/Core/Timer.js ***!
|
|
466
|
+
\********************************/
|
|
467
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
468
|
+
|
|
469
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Timer = void 0;\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nclass Timer {\r\n _deadline = -1;\r\n get deadline() {\r\n return this._deadline;\r\n }\r\n _handler = null;\r\n get handler() {\r\n return this._handler;\r\n }\r\n get isRunning() {\r\n if (this._handler) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n _call_back = null;\r\n _left_time = -1;\r\n _is_interval = false;\r\n constructor() {\r\n }\r\n setTimeout(handler, timeout, ...args) {\r\n this._call_back = handler;\r\n this.clear();\r\n if (timeout == undefined) {\r\n timeout = 30000;\r\n }\r\n this._deadline = Date.now() + timeout;\r\n this._handler = setTimeout(() => {\r\n this._deadline = -1;\r\n this._handler = null;\r\n this._left_time = -1;\r\n try {\r\n this._call_back();\r\n }\r\n catch (e) {\r\n if (e && e.stack) {\r\n Log_1.GLog.error(e.stack);\r\n }\r\n else {\r\n Log_1.GLog.error(e);\r\n }\r\n }\r\n }, timeout, ...args);\r\n }\r\n setInterval(handler, timeout, ...args) {\r\n this._call_back = handler;\r\n this.clear();\r\n this._is_interval = true;\r\n if (timeout == undefined) {\r\n timeout = 30000;\r\n }\r\n this._deadline = -1;\r\n this._left_time = timeout;\r\n this._handler = setInterval(() => {\r\n try {\r\n this._call_back();\r\n }\r\n catch (e) {\r\n if (e && e.stack) {\r\n Log_1.GLog.error(e.stack);\r\n }\r\n else {\r\n Log_1.GLog.error(e);\r\n }\r\n }\r\n }, timeout, ...args);\r\n }\r\n pause() {\r\n if (this._handler) {\r\n if (!this._is_interval) {\r\n this._left_time = this._deadline - Date.now();\r\n clearTimeout(this._handler);\r\n }\r\n else {\r\n clearInterval(this._handler);\r\n }\r\n this._deadline = -1;\r\n this._handler = null;\r\n }\r\n }\r\n resume() {\r\n if (this._left_time > 0) {\r\n if (!this._is_interval) {\r\n this._deadline = Date.now() + this._left_time;\r\n this._handler = setTimeout(() => {\r\n this._call_back();\r\n this._deadline = -1;\r\n this._handler = null;\r\n this._left_time = -1;\r\n }, this._left_time);\r\n }\r\n else {\r\n this.setInterval(this._call_back, this._left_time);\r\n }\r\n }\r\n }\r\n clear() {\r\n if (this._handler) {\r\n if (!this._is_interval) {\r\n clearTimeout(this._handler);\r\n }\r\n else {\r\n clearInterval(this._handler);\r\n }\r\n }\r\n this._deadline = -1;\r\n this._handler = null;\r\n this._left_time = -1;\r\n this._is_interval = false;\r\n }\r\n}\r\nexports.Timer = Timer;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Core/Timer.js?");
|
|
470
|
+
|
|
471
|
+
/***/ }),
|
|
472
|
+
|
|
473
|
+
/***/ "./dist/lib/Database/Decorator/AutoIncrement.js":
|
|
474
|
+
/*!******************************************************!*\
|
|
475
|
+
!*** ./dist/lib/Database/Decorator/AutoIncrement.js ***!
|
|
476
|
+
\******************************************************/
|
|
477
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
478
|
+
|
|
479
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AutoIncrement = void 0;\r\nconst Property_1 = __webpack_require__(/*! ./Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nfunction AutoIncrement(target, propertyName) {\r\n let table = target[Property_1.TableProperty.key] = target[Property_1.TableProperty.key] || new Property_1.TableProperty();\r\n table.items[propertyName] = table.items[propertyName] || new Property_1.Property();\r\n let pt = table.items[propertyName];\r\n pt.auto_increment = true;\r\n}\r\nexports.AutoIncrement = AutoIncrement;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/Decorator/AutoIncrement.js?");
|
|
480
|
+
|
|
481
|
+
/***/ }),
|
|
482
|
+
|
|
483
|
+
/***/ "./dist/lib/Database/Decorator/DBCache.js":
|
|
484
|
+
/*!************************************************!*\
|
|
485
|
+
!*** ./dist/lib/Database/Decorator/DBCache.js ***!
|
|
486
|
+
\************************************************/
|
|
487
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
488
|
+
|
|
489
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GDBCache = exports.VersionModel = void 0;\r\nconst Log_1 = __webpack_require__(/*! ./../../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nclass VersionModel {\r\n table = \"\";\r\n version = 0;\r\n /**\r\n * 创建时间\r\n */\r\n create_time = 0;\r\n /**\r\n * 创建时间\r\n */\r\n update_time = 0;\r\n}\r\nexports.VersionModel = VersionModel;\r\nexports.GDBCache = null;\r\nclass DBCache {\r\n _versions = {};\r\n _path = __dirname + \"/tmp_table_version.json\";\r\n async init() {\r\n if (fs.existsSync(this._path)) {\r\n try {\r\n let table = fs.readFileSync(this._path);\r\n this._versions = JSON.parse(table.toString());\r\n }\r\n catch (e) {\r\n Log_1.GLog.info(\"error:\" + this._path);\r\n process.exit();\r\n }\r\n }\r\n else {\r\n this._versions = {};\r\n fs.writeFileSync(this._path, JSON.stringify(this._versions));\r\n }\r\n }\r\n async setVersion(table, version) {\r\n let vm = this._versions[table];\r\n if (!vm) {\r\n vm = new VersionModel();\r\n vm.table = table;\r\n vm.version = version;\r\n vm.create_time = Date.now();\r\n vm.update_time = Date.now();\r\n this._versions[table] = vm;\r\n fs.writeFileSync(this._path, JSON.stringify(this._versions));\r\n }\r\n else if (vm.version != version) {\r\n vm.version = version;\r\n vm.update_time = Date.now();\r\n fs.writeFileSync(this._path, JSON.stringify(this._versions));\r\n }\r\n }\r\n getVersion(table) {\r\n let vm = this._versions[table];\r\n if (!vm) {\r\n return -1;\r\n }\r\n return vm.version;\r\n }\r\n}\r\nexports.GDBCache = new DBCache();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/Decorator/DBCache.js?");
|
|
490
|
+
|
|
491
|
+
/***/ }),
|
|
492
|
+
|
|
493
|
+
/***/ "./dist/lib/Database/Decorator/NotNull.js":
|
|
494
|
+
/*!************************************************!*\
|
|
495
|
+
!*** ./dist/lib/Database/Decorator/NotNull.js ***!
|
|
496
|
+
\************************************************/
|
|
497
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
498
|
+
|
|
499
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.NotNull = void 0;\r\nconst Property_1 = __webpack_require__(/*! ./Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nfunction NotNull(target, propertyName) {\r\n let table = target[Property_1.TableProperty.key] = target[Property_1.TableProperty.key] || new Property_1.TableProperty();\r\n table.items[propertyName] = table.items[propertyName] || new Property_1.Property();\r\n let pt = table.items[propertyName];\r\n pt.is_notnull = true;\r\n}\r\nexports.NotNull = NotNull;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/Decorator/NotNull.js?");
|
|
500
|
+
|
|
501
|
+
/***/ }),
|
|
502
|
+
|
|
503
|
+
/***/ "./dist/lib/Database/Decorator/PrimaryKey.js":
|
|
504
|
+
/*!***************************************************!*\
|
|
505
|
+
!*** ./dist/lib/Database/Decorator/PrimaryKey.js ***!
|
|
506
|
+
\***************************************************/
|
|
507
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
508
|
+
|
|
509
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.PrimaryKey = void 0;\r\nconst Property_1 = __webpack_require__(/*! ./Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nfunction PrimaryKey(target, propertyName) {\r\n let table = target[Property_1.TableProperty.key] = target[Property_1.TableProperty.key] || new Property_1.TableProperty();\r\n table.items[propertyName] = table.items[propertyName] || new Property_1.Property();\r\n let pt = table.items[propertyName];\r\n pt.is_primary = true;\r\n}\r\nexports.PrimaryKey = PrimaryKey;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/Decorator/PrimaryKey.js?");
|
|
510
|
+
|
|
511
|
+
/***/ }),
|
|
512
|
+
|
|
513
|
+
/***/ "./dist/lib/Database/Decorator/Property.js":
|
|
514
|
+
/*!*************************************************!*\
|
|
515
|
+
!*** ./dist/lib/Database/Decorator/Property.js ***!
|
|
516
|
+
\*************************************************/
|
|
517
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
518
|
+
|
|
519
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.TableProperty = exports.Property = exports.EPropertyType = void 0;\r\nclass EPropertyType {\r\n static Char = \"char\";\r\n static NVarchar = \"nvarchar\";\r\n static Varchar = \"varchar\";\r\n static BigInt = \"bigint\";\r\n static Decimal = \"decimal\";\r\n static Double = \"double\";\r\n static Float = \"float\";\r\n static Int = \"int\";\r\n static MediumInt = \"Mediumint\";\r\n static Real = \"real\";\r\n static SmallInt = \"smallint\";\r\n static TinyInt = \"tinyint\";\r\n static LongText = \"longtext\";\r\n static MediumText = \"mediumtext\";\r\n static Text = \"text\";\r\n static TinyText = \"tinytext\";\r\n static defs = {\r\n \"char\": \"\",\r\n \"nvarchar\": \"\",\r\n \"varchar\": \"\",\r\n \"bigint\": 0,\r\n \"decimal\": 0,\r\n \"double\": 0,\r\n \"float\": 0,\r\n \"int\": 0,\r\n \"Mediumint\": 0,\r\n \"real\": 0,\r\n \"smallint\": 0,\r\n \"tinyint\": 0,\r\n \"longtext\": \"\",\r\n \"mediumtext\": \"\",\r\n \"text\": undefined,\r\n \"tinytext\": \"\"\r\n };\r\n}\r\nexports.EPropertyType = EPropertyType;\r\nclass Property {\r\n is_primary = false;\r\n is_notnull = false;\r\n auto_increment = false;\r\n auto_start = 1; //包含\r\n type = EPropertyType.Varchar;\r\n type_len = 45;\r\n default = null;\r\n}\r\nexports.Property = Property;\r\nclass TableProperty {\r\n static key = \"___table___\";\r\n table = null;\r\n version = 1;\r\n engine = \"InnoDB\";\r\n auto_increment = null;\r\n charset = \"utf8mb4\";\r\n comment = null;\r\n items = {};\r\n}\r\nexports.TableProperty = TableProperty;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/Decorator/Property.js?");
|
|
520
|
+
|
|
521
|
+
/***/ }),
|
|
522
|
+
|
|
523
|
+
/***/ "./dist/lib/Database/Decorator/Table.js":
|
|
524
|
+
/*!**********************************************!*\
|
|
525
|
+
!*** ./dist/lib/Database/Decorator/Table.js ***!
|
|
526
|
+
\**********************************************/
|
|
527
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
528
|
+
|
|
529
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Table = void 0;\r\nconst Property_1 = __webpack_require__(/*! ./Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nfunction Table(table_name, version, comment, charset, auto_increment) {\r\n return function (constructor) {\r\n let table = constructor.prototype[Property_1.TableProperty.key] = constructor.prototype[Property_1.TableProperty.key] || new Property_1.TableProperty();\r\n table.table = table_name;\r\n table.version = version;\r\n table.comment = comment || table.comment;\r\n table.charset = charset || table.charset;\r\n table.auto_increment = auto_increment || table.auto_increment;\r\n };\r\n}\r\nexports.Table = Table;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/Decorator/Table.js?");
|
|
530
|
+
|
|
531
|
+
/***/ }),
|
|
532
|
+
|
|
533
|
+
/***/ "./dist/lib/Database/Decorator/Type.js":
|
|
534
|
+
/*!*********************************************!*\
|
|
535
|
+
!*** ./dist/lib/Database/Decorator/Type.js ***!
|
|
536
|
+
\*********************************************/
|
|
537
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
538
|
+
|
|
539
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Type = void 0;\r\nconst Property_1 = __webpack_require__(/*! ./Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nfunction Type(type, def, len) {\r\n return function (target, propertyName) {\r\n let table = target[Property_1.TableProperty.key] = target[Property_1.TableProperty.key] || new Property_1.TableProperty();\r\n table.items[propertyName] = table.items[propertyName] || new Property_1.Property();\r\n let pt = table.items[propertyName];\r\n pt.type = type;\r\n if (def != undefined) {\r\n pt.default = def;\r\n }\r\n else {\r\n pt.default = Property_1.EPropertyType.defs[type];\r\n }\r\n pt.type_len = len || pt.type_len;\r\n };\r\n}\r\nexports.Type = Type;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/Decorator/Type.js?");
|
|
540
|
+
|
|
541
|
+
/***/ }),
|
|
542
|
+
|
|
543
|
+
/***/ "./dist/lib/Database/MSSqlManager.js":
|
|
544
|
+
/*!*******************************************!*\
|
|
545
|
+
!*** ./dist/lib/Database/MSSqlManager.js ***!
|
|
546
|
+
\*******************************************/
|
|
547
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
548
|
+
|
|
549
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GMSSqlMgr = exports.MssqlReturn = void 0;\r\nconst mssql = __webpack_require__(/*! mssql */ \"mssql\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nconst DBCache_1 = __webpack_require__(/*! ./Decorator/DBCache */ \"./dist/lib/Database/Decorator/DBCache.js\");\r\nclass MssqlReturn {\r\n error = null;\r\n fields = null;\r\n list = null;\r\n}\r\nexports.MssqlReturn = MssqlReturn;\r\nexports.GMSSqlMgr = null;\r\nclass MSSqlManager {\r\n _init_cbs = [];\r\n _pool = null;\r\n get pool() {\r\n return this._pool;\r\n }\r\n get isValid() {\r\n return !!this._pool;\r\n }\r\n constructor() {\r\n }\r\n async init() {\r\n if (this._pool\r\n || !ServerConfig_1.GServerCfg.db.mssql\r\n || !ServerConfig_1.GServerCfg.db.mssql.open) {\r\n return;\r\n }\r\n this._pool = await mssql.connect(ServerConfig_1.GServerCfg.db.mssql);\r\n console.log(\"mssql config=\" + JSON.stringify(ServerConfig_1.GServerCfg.db.mssql));\r\n //这个的初始化位置不能变,必须位于cbs前,pool后\r\n await DBCache_1.GDBCache.init();\r\n for (let i = 0; i < this._init_cbs.length; ++i) {\r\n this._init_cbs[i]();\r\n }\r\n }\r\n registerInitCb(cb) {\r\n this._init_cbs.push(cb);\r\n }\r\n}\r\nexports.GMSSqlMgr = new MSSqlManager();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/MSSqlManager.js?");
|
|
550
|
+
|
|
551
|
+
/***/ }),
|
|
552
|
+
|
|
553
|
+
/***/ "./dist/lib/Database/MongoBaseService.js":
|
|
554
|
+
/*!***********************************************!*\
|
|
555
|
+
!*** ./dist/lib/Database/MongoBaseService.js ***!
|
|
556
|
+
\***********************************************/
|
|
557
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
558
|
+
|
|
559
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.MongoBaseService = void 0;\r\nconst MongoManager_1 = __webpack_require__(/*! ./MongoManager */ \"./dist/lib/Database/MongoManager.js\");\r\nclass MongoBaseService {\r\n _table = \"\";\r\n get table() {\r\n return this._table;\r\n }\r\n _inited = false;\r\n get isInited() {\r\n return this._inited;\r\n }\r\n get mongo() {\r\n return MongoManager_1.GMongoMgr.mongo;\r\n }\r\n _t_type = null;\r\n constructor(table, type) {\r\n this._t_type = type;\r\n this._table = table;\r\n }\r\n async getNextId() {\r\n let id = await MongoManager_1.GMongoMgr.getAutoIds(this._table);\r\n return id;\r\n }\r\n /**\r\n * 没有id(非_id)的表不能使用该函数\r\n * @param id\r\n */\r\n async getById(id) {\r\n let rs = await MongoManager_1.GMongoMgr.findOne(this._table, null, { id: id });\r\n return rs.one;\r\n }\r\n async get(proterty, where, sort) {\r\n let rs = await MongoManager_1.GMongoMgr.findOne(this._table, proterty, where, sort);\r\n return rs.one;\r\n }\r\n async countDocuments(where, options) {\r\n let rs = await MongoManager_1.GMongoMgr.countDocuments(this._table, where);\r\n return rs.count;\r\n }\r\n async gets(property, where, sort, skip = 0, limit = 0) {\r\n let rs = await MongoManager_1.GMongoMgr.findMany(this._table, property, where, sort, skip, limit);\r\n return rs.list;\r\n }\r\n async getRandoms(num, proterty, where) {\r\n let rs = await MongoManager_1.GMongoMgr.simpleAggregate(this._table, proterty, where, null, num);\r\n return rs.list;\r\n }\r\n async updateOne(model, where, upsert = false) {\r\n let rs = await MongoManager_1.GMongoMgr.updateOne(this._table, model, where, upsert);\r\n return rs;\r\n }\r\n async updateMany(models, where) {\r\n let rs = await MongoManager_1.GMongoMgr.updateMany(this._table, models, where);\r\n return rs;\r\n }\r\n async insert(model) {\r\n let rs = await MongoManager_1.GMongoMgr.insertOne(this._table, model);\r\n return rs;\r\n }\r\n async deleteOne(where) {\r\n let rs = await MongoManager_1.GMongoMgr.deleteOne(this._table, where);\r\n return rs;\r\n }\r\n async deleteMany(where) {\r\n let rs = await MongoManager_1.GMongoMgr.deleteMany(this._table, where);\r\n return rs;\r\n }\r\n async createIndex(index, options) {\r\n let rs = await MongoManager_1.GMongoMgr.createIndex(this._table, index, options);\r\n return rs;\r\n }\r\n aggregate(pipeline, options) {\r\n let ret = MongoManager_1.GMongoMgr.aggregate(this._table, pipeline, options);\r\n return ret;\r\n }\r\n}\r\nexports.MongoBaseService = MongoBaseService;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/MongoBaseService.js?");
|
|
560
|
+
|
|
561
|
+
/***/ }),
|
|
562
|
+
|
|
563
|
+
/***/ "./dist/lib/Database/MongoManager.js":
|
|
564
|
+
/*!*******************************************!*\
|
|
565
|
+
!*** ./dist/lib/Database/MongoManager.js ***!
|
|
566
|
+
\*******************************************/
|
|
567
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
568
|
+
|
|
569
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GMongoMgr = exports.MgReturn = exports.MrResult = exports.MongoBaseModel = void 0;\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst mongo = __webpack_require__(/*! mongodb */ \"mongodb\");\r\nconst _error_1 = __webpack_require__(/*! ../Config/_error_ */ \"./dist/lib/Config/_error_.js\");\r\nconst Core_1 = __webpack_require__(/*! ../Core/Core */ \"./dist/lib/Core/Core.js\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nclass MongoBaseModel {\r\n _id;\r\n}\r\nexports.MongoBaseModel = MongoBaseModel;\r\nclass MrResult {\r\n /**\r\n * select 的数据量\r\n */\r\n length = 0;\r\n /**\r\n * 插入数据的自增id\r\n */\r\n insertId = null;\r\n insertIds = null;\r\n /**\r\n * update 更新数据的影响条数\r\n */\r\n changedRows = null;\r\n /**\r\n * 插入或删除数据的影响条数\r\n */\r\n affectedRows = null;\r\n}\r\nexports.MrResult = MrResult;\r\nclass MgReturn {\r\n error = null;\r\n result = new MrResult();\r\n list = [];\r\n}\r\nexports.MgReturn = MgReturn;\r\nexports.GMongoMgr = null;\r\nclass MongoManager {\r\n _init_cbs = [];\r\n _mongo = null;\r\n get mongo() {\r\n return this._mongo;\r\n }\r\n _mongo_init_succ = false;\r\n _inited = false;\r\n get isValid() {\r\n return this._inited;\r\n }\r\n constructor() {\r\n }\r\n async init() {\r\n if (this._inited) {\r\n return false;\r\n }\r\n if (this._mongo) {\r\n return true;\r\n }\r\n if (!ServerConfig_1.GServerCfg.db.mongo || !ServerConfig_1.GServerCfg.db.mongo.open) {\r\n return true;\r\n }\r\n this._inited = true;\r\n Log_1.GLog.info(\"mongo config=\" + JSON.stringify(ServerConfig_1.GServerCfg.db.mongo));\r\n let client = new mongo.MongoClient(\"mongodb://\" + ServerConfig_1.GServerCfg.db.mongo.host + \":\" + ServerConfig_1.GServerCfg.db.mongo.port, ServerConfig_1.GServerCfg.db.mongo.options);\r\n await Core_1.core.safeCall(client.connect, client);\r\n this.onConnect();\r\n this._mongo = client.db(ServerConfig_1.GServerCfg.db.mongo.database);\r\n for (let i = 0; i < this._init_cbs.length; ++i) {\r\n this._init_cbs[i]();\r\n }\r\n return true;\r\n }\r\n registerInitCb(cb) {\r\n this._init_cbs.push(cb);\r\n }\r\n onConnect() {\r\n this._mongo_init_succ = true;\r\n Log_1.GLog.info(\"mongo has connected!\");\r\n }\r\n onEnd() {\r\n this._mongo_init_succ = false;\r\n Log_1.GLog.error(\"mongo has ended!\");\r\n Log_1.GLog.info(\"mongo try reconnect\");\r\n this.init();\r\n }\r\n onError(err) {\r\n Log_1.GLog.error(\"Error \" + err);\r\n Log_1.GLog.info(\"mongo try reconnect\");\r\n this.init();\r\n }\r\n async getAutoIds(key) {\r\n if (!this._mongo) {\r\n return -1;\r\n }\r\n let collection = \"auto_ids\";\r\n let col = this._mongo.collection(collection);\r\n try {\r\n let where = this._convertWhere({ _id: key });\r\n let rs = await Core_1.core.safeCall(col.findOneAndUpdate, col, where, { $inc: { id: 1 } }, { upsert: true });\r\n if (rs.ok) {\r\n return rs.value.id + 1;\r\n }\r\n return 0 + 1;\r\n }\r\n catch (e) {\r\n Log_1.GLog.error(e.stack);\r\n }\r\n return -1;\r\n }\r\n _convertWhere(where) {\r\n if (!where || !where._id) {\r\n return;\r\n }\r\n if (Core_1.core.isString(where._id) && where._id.length == 24) {\r\n let _id = where._id;\r\n try {\r\n where._id = new mongo.ObjectId(_id);\r\n }\r\n catch (e) {\r\n where._id = _id;\r\n }\r\n }\r\n return where;\r\n }\r\n /**\r\n * 获取单条消息\r\n * @param collection\r\n */\r\n async findOne(collection, property = {}, where = {}, sort) {\r\n this._convertWhere(where);\r\n let rs = { errcode: null, one: null };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let one = null;\r\n try {\r\n let col = this._mongo.collection(collection);\r\n one = await col.findOne(where, { projection: property });\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, property, where });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.one = one;\r\n return rs;\r\n }\r\n async findMany(collection, property = {}, where = {}, sort, skip = 0, limit = 0) {\r\n this._convertWhere(where);\r\n let rs = { errcode: null, list: null };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let list = [];\r\n try {\r\n let col = this._mongo.collection(collection);\r\n let cursor = col.find(where, property);\r\n if (sort) {\r\n cursor = cursor.sort(sort);\r\n }\r\n if (skip) {\r\n cursor = cursor.skip(skip);\r\n }\r\n if (limit) {\r\n cursor = cursor.limit(limit);\r\n }\r\n list = await cursor.toArray();\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, property, where, sort, skip, limit });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.list = list;\r\n return rs;\r\n }\r\n async countDocuments(collection, where, options) {\r\n this._convertWhere(where);\r\n let rs = { errcode: null, count: -1 };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let count = -1;\r\n try {\r\n let col = this._mongo.collection(collection);\r\n count = await col.countDocuments(where || {}, options);\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, where });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.count = count;\r\n return rs;\r\n }\r\n async deleteOne(collection, where) {\r\n this._convertWhere(where);\r\n let rs = { errcode: null, count: -1 };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let del_rs = null;\r\n try {\r\n let col = this._mongo.collection(collection);\r\n del_rs = await col.deleteOne(where || {});\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, where });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n if (del_rs) {\r\n rs.count = del_rs.deletedCount;\r\n }\r\n return rs;\r\n }\r\n async deleteMany(collection, where) {\r\n this._convertWhere(where);\r\n let rs = { errcode: null, count: -1 };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let del_rs = null;\r\n try {\r\n let col = this._mongo.collection(collection);\r\n del_rs = await col.deleteMany(where || {});\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, where });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n if (del_rs) {\r\n rs.count = del_rs.deletedCount;\r\n }\r\n return rs;\r\n }\r\n /**\r\n * 插入数据\r\n * @param collection\r\n * @param data\r\n */\r\n async insertOne(collection, data) {\r\n let rs = { errcode: null, rs: null };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let in_rs = null;\r\n try {\r\n let col = this._mongo.collection(collection);\r\n in_rs = await col.insertOne(data);\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, data });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.rs = in_rs;\r\n return rs;\r\n }\r\n async insertManay(collection, data) {\r\n let rs = { errcode: null, rs: null };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let in_rs = null;\r\n try {\r\n let col = this._mongo.collection(collection);\r\n in_rs = await col.insertMany(data);\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, data });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.rs = in_rs;\r\n return rs;\r\n }\r\n async updateOne(collection, model, where, upsert = false) {\r\n let _id = model[\"_id\"];\r\n delete model[\"_id\"];\r\n this._convertWhere(where);\r\n let rs = { errcode: null, rs: null };\r\n if (!this._mongo) {\r\n if (_id) {\r\n model[\"_id\"] = _id;\r\n }\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let up_rs = null;\r\n try {\r\n let updatemodel = null;\r\n let money = false;\r\n for (let key in model) {\r\n if (key.startsWith(\"$\")) {\r\n money = true;\r\n }\r\n }\r\n if (!money) {\r\n updatemodel = { \"$set\": model };\r\n }\r\n else {\r\n updatemodel = model;\r\n }\r\n let col = this._mongo.collection(collection);\r\n up_rs = await col.updateOne(where, updatemodel, { upsert: upsert });\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, model, where, upsert });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.rs = up_rs;\r\n if (up_rs?.upsertedId || _id) {\r\n model[\"_id\"] = up_rs?.upsertedId || _id;\r\n }\r\n return rs;\r\n }\r\n async updateMany(collection, model, where, upsert = false) {\r\n this._convertWhere(where);\r\n let rs = { errcode: null, rs: null };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let up_rs = null;\r\n try {\r\n let updateModel = null;\r\n let firstKey = Object.keys(model)[0];\r\n if (!firstKey.startsWith(\"$\")) {\r\n updateModel = { $set: model };\r\n }\r\n else {\r\n updateModel = model;\r\n }\r\n let col = this._mongo.collection(collection);\r\n up_rs = await col.updateMany(where, updateModel, { upsert: upsert });\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, model, where, upsert });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.rs = up_rs;\r\n return rs;\r\n }\r\n async createIndex(collection, index, options) {\r\n let rs = { errcode: null, rs: null };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let i_rs = null;\r\n try {\r\n let col = this._mongo.collection(collection);\r\n i_rs = await col.createIndex(index, options);\r\n }\r\n catch (e) {\r\n Log_1.GLog.error({ collection, index });\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.rs = i_rs;\r\n return rs;\r\n }\r\n async simpleAggregate(collection, property = {}, where = {}, size, random_size) {\r\n this._convertWhere(where);\r\n let rs = { errcode: null, list: null };\r\n if (!this._mongo) {\r\n rs.errcode = _error_1.EErrorCode.No_Mongo;\r\n return rs;\r\n }\r\n let list = [];\r\n try {\r\n let col = this._mongo.collection(collection);\r\n let params = [];\r\n params.push({ '$match': where || {} });\r\n params.push({ '$project': property || {} });\r\n if (random_size) {\r\n params.push({ '$sample': { 'size': random_size } });\r\n }\r\n let agg = col.aggregate(params);\r\n if (size) {\r\n list = await agg.limit(size).toArray();\r\n }\r\n else {\r\n list = await agg.toArray();\r\n }\r\n }\r\n catch (e) {\r\n Log_1.GLog.error(e.stack);\r\n rs.errcode = _error_1.EErrorCode.Mongo_Error;\r\n }\r\n rs.list = list;\r\n return rs;\r\n }\r\n aggregate(collection, pipeline, options) {\r\n if (!this._mongo) {\r\n return;\r\n }\r\n let col = this._mongo.collection(collection);\r\n let agg = col.aggregate(pipeline, options);\r\n return agg;\r\n }\r\n}\r\nexports.GMongoMgr = new MongoManager();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/MongoManager.js?");
|
|
570
|
+
|
|
571
|
+
/***/ }),
|
|
572
|
+
|
|
573
|
+
/***/ "./dist/lib/Database/MysqlBaseService.js":
|
|
574
|
+
/*!***********************************************!*\
|
|
575
|
+
!*** ./dist/lib/Database/MysqlBaseService.js ***!
|
|
576
|
+
\***********************************************/
|
|
577
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
578
|
+
|
|
579
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.MysqlBaseService = exports.BaseModel = void 0;\r\nconst Property_1 = __webpack_require__(/*! ./Decorator/Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nconst MysqlManager_1 = __webpack_require__(/*! ./MysqlManager */ \"./dist/lib/Database/MysqlManager.js\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst DBCache_1 = __webpack_require__(/*! ./Decorator/DBCache */ \"./dist/lib/Database/Decorator/DBCache.js\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nclass BaseModel {\r\n}\r\nexports.BaseModel = BaseModel;\r\nclass MysqlBaseService {\r\n _table = \"\";\r\n get table() {\r\n return this._table;\r\n }\r\n get version() {\r\n let table = this._t_type.prototype[Property_1.TableProperty.key];\r\n return table.version;\r\n }\r\n _inited = false;\r\n get isInited() {\r\n return this._inited;\r\n }\r\n _t_type = null;\r\n constructor(type) {\r\n this._t_type = type;\r\n if (MysqlManager_1.GMysqlMgr.isValid) {\r\n this._init();\r\n }\r\n else {\r\n MysqlManager_1.GMysqlMgr.registerInitCb(this._init.bind(this));\r\n }\r\n }\r\n async _init() {\r\n if (this._inited) {\r\n return;\r\n }\r\n this._inited = true;\r\n let table = this._t_type.prototype[Property_1.TableProperty.key];\r\n if (!table || !table.table) {\r\n throw new Error(\"数据表的类必须要具有Table装饰器\");\r\n }\r\n this._table = \"`\" + table.table + \"`\";\r\n if (!ServerConfig_1.GServerCfg.db.mysql.auto) {\r\n //未开启自动创建数据表\r\n return;\r\n }\r\n let droped = await this._checkDropTable(table.version);\r\n if (!droped) {\r\n Log_1.GLog.info(\"table(\" + this._table + \")无需升级...\");\r\n //既然版本号没变,就快速返回\r\n return;\r\n }\r\n let primary_key = null;\r\n let sql = \"create table if not exists \" + this._table + \" (\";\r\n for (let key in table.items) {\r\n let item = table.items[key];\r\n sql += \"`\" + key + \"`\" + \" \" + item.type;\r\n if (item.type == Property_1.EPropertyType.Varchar\r\n || item.type == Property_1.EPropertyType.Char\r\n || item.type == Property_1.EPropertyType.NVarchar) {\r\n sql += \"(\" + item.type_len + \")\";\r\n }\r\n if (item.is_notnull) {\r\n sql += \" not null\";\r\n }\r\n if (item.default != undefined && !item.is_primary) {\r\n sql += \" default \\'\" + item.default + \"\\'\";\r\n }\r\n if (item.auto_increment) {\r\n sql += \" auto_increment\";\r\n }\r\n if (item.is_primary) {\r\n primary_key = key;\r\n }\r\n sql += \",\";\r\n }\r\n if (primary_key) {\r\n sql += \"primary key (`\" + primary_key + \"`),\";\r\n sql += \"unique key `\" + primary_key + \"_unique` (`\" + primary_key + \"`)\";\r\n }\r\n else {\r\n //去掉最后一个逗号\r\n sql = sql.substr(0, sql.length - 1);\r\n }\r\n sql += \")\";\r\n sql += \" engine=\" + table.engine;\r\n if (table.auto_increment != null) {\r\n sql += \" auto_increment=\" + table.auto_increment;\r\n }\r\n sql += \" default charset=\" + table.charset;\r\n if (table.comment) {\r\n sql += \" comment=\\'\" + table.comment + \"\\';\";\r\n }\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql);\r\n if (sr.error) {\r\n Log_1.GLog.error(sr.error);\r\n throw Error(\"table(\" + this._table + \")创建失败...\");\r\n }\r\n else {\r\n DBCache_1.GDBCache.setVersion(this.table, table.version);\r\n Log_1.GLog.info(\"table(\" + this._table + \")初始化成功...\");\r\n await this._onReCreated();\r\n }\r\n }\r\n async _onReCreated() {\r\n }\r\n async _onDroped() {\r\n }\r\n async _checkDropTable(cur_version) {\r\n let local_version = DBCache_1.GDBCache.getVersion(this._table);\r\n if (local_version == cur_version) {\r\n return false;\r\n }\r\n let sql = \"drop table if exists \" + this._table;\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql);\r\n if (sr.error) {\r\n Log_1.GLog.error(sr.error);\r\n throw Error(sr.error);\r\n }\r\n else {\r\n Log_1.GLog.info(\"table(\" + this._table + \")删除成功...\");\r\n await this._onDroped();\r\n }\r\n return true;\r\n }\r\n /**\r\n * 没有id的表不能使用该函数\r\n * @param id\r\n */\r\n async getById(id) {\r\n let tm = null;\r\n let sr = await MysqlManager_1.GMysqlMgr.query(\"select * from \" + this._table + \" where id=? limit 1\", [id]);\r\n if (sr.error || sr.results.length <= 0) {\r\n return tm;\r\n }\r\n tm = sr.results[0];\r\n return tm;\r\n }\r\n async get(proterty, where, args) {\r\n let sql = \"select \";\r\n sql += proterty || \"*\";\r\n sql += \" from \" + this._table;\r\n if (where) {\r\n sql += \" where \" + where;\r\n }\r\n sql += \" limit 1\";\r\n let tm = null;\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);\r\n if (sr.list && sr.list.length > 0) {\r\n tm = sr.list[0];\r\n }\r\n return tm;\r\n }\r\n async getTotal(where, args) {\r\n let sql = \"select \";\r\n sql += \"count(*) as num\";\r\n sql += \" from \" + this._table;\r\n if (where) {\r\n sql += \" where \" + where;\r\n }\r\n let total = 0;\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);\r\n if (sr.list && sr.list.length > 0) {\r\n total = sr.list[0].num || 0;\r\n }\r\n return total;\r\n }\r\n async gets(proterty, where, args) {\r\n let sql = \"select \";\r\n sql += proterty || \"*\";\r\n sql += \" from \" + this._table;\r\n if (where) {\r\n sql += \" where \" + where;\r\n }\r\n let tms = null;\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);\r\n tms = sr.list;\r\n return tms;\r\n }\r\n async getCount(where, args) {\r\n let sql = \"select count(*) as num from \" + this._table;\r\n if (where) {\r\n sql += \" where \" + where;\r\n }\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);\r\n if (sr.error || sr.results.length <= 0) {\r\n return 0;\r\n }\r\n return sr.results[0][\"num\"] || 0;\r\n }\r\n async getRandoms(num, proterty, where, args) {\r\n num = num || 5;\r\n let sql = \"select \";\r\n sql += proterty || \"*\";\r\n sql += \" from \" + this._table;\r\n if (where) {\r\n sql += \" where \" + where;\r\n }\r\n sql += \" order by rand() limit ?\";\r\n args = args || [];\r\n args.push(num);\r\n let tms = null;\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);\r\n tms = sr.list;\r\n return tms;\r\n }\r\n async updateProperty(set, where, args, limit) {\r\n let sql = \"update \" + this._table + \" set \";\r\n if (set) {\r\n sql += set;\r\n }\r\n else {\r\n sql += \"?\";\r\n }\r\n if (where) {\r\n sql += \" where \" + where;\r\n }\r\n if (limit) {\r\n sql += \" limit \" + limit;\r\n }\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);\r\n return sr;\r\n }\r\n async update(model, where, args, limit) {\r\n let sql = \"update \" + this._table + \" set ?\";\r\n if (!where) {\r\n where = \" id=?\";\r\n }\r\n sql += \" where \" + where;\r\n let id = model[\"id\"];\r\n delete model[\"id\"];\r\n let u_m = JSON.parse(JSON.stringify(model));\r\n if (!args) {\r\n args = [u_m, id];\r\n }\r\n else {\r\n args.unshift(u_m);\r\n }\r\n if (limit) {\r\n sql += \" limit \" + limit;\r\n }\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);\r\n if (id) {\r\n model[\"id\"] = id;\r\n }\r\n return sr;\r\n }\r\n async insert(model, ip) {\r\n let table = model[Property_1.TableProperty.key];\r\n let id_property = table.items[\"id\"];\r\n if (id_property) {\r\n if (id_property.auto_increment) {\r\n delete model[\"id\"];\r\n }\r\n }\r\n if (table.items[\"create_time\"] && model[\"create_time\"] <= 0) {\r\n model[\"create_time\"] = Date.now();\r\n }\r\n if (table.items[\"create_ip\"] && ip) {\r\n model[\"create_ip\"] = ip;\r\n }\r\n let sql = \"insert into \" + this._table + \" set ?\";\r\n //这步的做法是为了去掉model种的TableProperty.key(___table___)\r\n model = JSON.parse(JSON.stringify(model));\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, [model]);\r\n return sr;\r\n }\r\n async removeById(id) {\r\n let sql = \"delete from \" + this._table + \" where id=?\";\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, [id]);\r\n return sr;\r\n }\r\n async remove(where, args) {\r\n let sql = \"delete from \" + this._table + \" where \" + where;\r\n let sr = await MysqlManager_1.GMysqlMgr.query(sql, args);\r\n return sr;\r\n }\r\n}\r\nexports.MysqlBaseService = MysqlBaseService;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/MysqlBaseService.js?");
|
|
580
|
+
|
|
581
|
+
/***/ }),
|
|
582
|
+
|
|
583
|
+
/***/ "./dist/lib/Database/MysqlManager.js":
|
|
584
|
+
/*!*******************************************!*\
|
|
585
|
+
!*** ./dist/lib/Database/MysqlManager.js ***!
|
|
586
|
+
\*******************************************/
|
|
587
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
588
|
+
|
|
589
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GMysqlMgr = exports.SqlReturns = exports.SqlReturn = exports.SqlResult = void 0;\r\nconst _error_1 = __webpack_require__(/*! ./../Config/_error_ */ \"./dist/lib/Config/_error_.js\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst mysql = __webpack_require__(/*! mysql */ \"mysql\");\r\nclass SqlResult {\r\n /**\r\n * select 的数据量\r\n */\r\n length = 0;\r\n /**\r\n * 插入数据的自增id\r\n */\r\n insertId = null;\r\n /**\r\n * update 更新数据的影响条数\r\n */\r\n changedRows = null;\r\n /**\r\n * 插入或删除数据的影响条数\r\n */\r\n affectedRows = null;\r\n}\r\nexports.SqlResult = SqlResult;\r\nclass SqlReturn {\r\n error = null;\r\n results = null;\r\n fields = null;\r\n list = null;\r\n}\r\nexports.SqlReturn = SqlReturn;\r\nclass SqlReturns {\r\n error = null;\r\n srs = [];\r\n}\r\nexports.SqlReturns = SqlReturns;\r\nexports.GMysqlMgr = null;\r\nclass MysqlManager {\r\n _init_cbs = [];\r\n _pool = null;\r\n get isValid() {\r\n return !!this._pool;\r\n }\r\n constructor() {\r\n }\r\n async init() {\r\n return new Promise(async (resolve) => {\r\n if (this._pool\r\n || !ServerConfig_1.GServerCfg.db.mysql\r\n || !ServerConfig_1.GServerCfg.db.mysql.open) {\r\n resolve(null);\r\n return;\r\n }\r\n this._pool = mysql.createPool({\r\n connectionLimit: 100,\r\n host: ServerConfig_1.GServerCfg.db.mysql.host,\r\n port: ServerConfig_1.GServerCfg.db.mysql.port,\r\n user: ServerConfig_1.GServerCfg.db.mysql.user,\r\n password: ServerConfig_1.GServerCfg.db.mysql.password,\r\n database: ServerConfig_1.GServerCfg.db.mysql.database,\r\n supportBigNumbers: true,\r\n charset: \"utf8mb4\"\r\n });\r\n console.log(\"mysql config=\" + JSON.stringify(ServerConfig_1.GServerCfg.db.mysql));\r\n //这个的初始化位置不能变,必须位于cbs前,pool后\r\n await DBCache_1.GDBCache.init();\r\n resolve(null);\r\n for (let i = 0; i < this._init_cbs.length; ++i) {\r\n this._init_cbs[i]();\r\n }\r\n });\r\n }\r\n registerInitCb(cb) {\r\n this._init_cbs.push(cb);\r\n }\r\n query(sqlStr, values, no_err_log) {\r\n return new Promise((resolve, reject) => {\r\n let sr = new SqlReturn();\r\n if (!this._pool) {\r\n //表示没有开通数据库,不用记录错误日志\r\n sr.error = _error_1.EErrorCode.No_Mysql;\r\n Log_1.GLog.error(sr.error);\r\n resolve(sr);\r\n return;\r\n }\r\n this._pool.getConnection((err, conn) => {\r\n if (err) {\r\n sr.error = err;\r\n Log_1.GLog.error(err);\r\n resolve(sr);\r\n return;\r\n }\r\n conn.query(sqlStr, values, (error, results, fields) => {\r\n sr.error = error;\r\n sr.results = results;\r\n if (sr.results && sr.results.length > 0) {\r\n sr.list = [];\r\n for (let i = 0; i < sr.results.length; ++i) {\r\n sr.list.push(sr.results[i]);\r\n }\r\n }\r\n sr.fields = fields;\r\n conn.release();\r\n if (error && !no_err_log) {\r\n Log_1.GLog.error(error);\r\n }\r\n resolve(sr);\r\n });\r\n });\r\n });\r\n }\r\n transaction(sqls) {\r\n return new Promise((resolve, reject) => {\r\n let srs = new SqlReturns();\r\n this._pool.getConnection((err, conn) => {\r\n if (err) {\r\n srs.error = err;\r\n Log_1.GLog.error(err);\r\n resolve(srs);\r\n return;\r\n }\r\n conn.beginTransaction((err) => {\r\n if (err) {\r\n srs.error = err;\r\n Log_1.GLog.error(err);\r\n conn.release();\r\n resolve(srs);\r\n return;\r\n }\r\n let funcs = [];\r\n for (let i = 0; i < sqls.length; ++i) {\r\n let sql = sqls[i];\r\n funcs.push(() => {\r\n conn.query(sql.sql, sql.values, (error, results, fields) => {\r\n srs.srs.push(results);\r\n if (error) {\r\n return conn.rollback(() => {\r\n Log_1.GLog.error(error);\r\n srs.error = error;\r\n conn.release();\r\n resolve(srs);\r\n });\r\n }\r\n else {\r\n if (funcs.length > 0) {\r\n let f = funcs.shift();\r\n f();\r\n }\r\n else {\r\n conn.commit((error) => {\r\n if (error) {\r\n return conn.rollback(() => {\r\n srs.error = error;\r\n Log_1.GLog.error(error);\r\n conn.release();\r\n resolve(srs);\r\n });\r\n }\r\n else {\r\n conn.release();\r\n resolve(srs);\r\n }\r\n });\r\n }\r\n }\r\n });\r\n });\r\n }\r\n let f = funcs.shift();\r\n f();\r\n });\r\n });\r\n });\r\n }\r\n}\r\nexports.GMysqlMgr = new MysqlManager();\r\n//该import必须放在GMysqlMgr实例化之后,否则version基类找不到GMysqlMgr\r\nconst DBCache_1 = __webpack_require__(/*! ./Decorator/DBCache */ \"./dist/lib/Database/Decorator/DBCache.js\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/MysqlManager.js?");
|
|
590
|
+
|
|
591
|
+
/***/ }),
|
|
592
|
+
|
|
593
|
+
/***/ "./dist/lib/Database/RedisManager.js":
|
|
594
|
+
/*!*******************************************!*\
|
|
595
|
+
!*** ./dist/lib/Database/RedisManager.js ***!
|
|
596
|
+
\*******************************************/
|
|
597
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
598
|
+
|
|
599
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.RedisManager = exports.GRedisMgr = void 0;\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst redis = __webpack_require__(/*! redis */ \"redis\");\r\nexports.GRedisMgr = null;\r\nclass RedisManager {\r\n _redis = null;\r\n get redis() {\r\n return this._redis;\r\n }\r\n _resis_init_succ = false;\r\n _redisCfg = null;\r\n constructor() {\r\n }\r\n async init(redisCfg) {\r\n return new Promise((resolve) => {\r\n if (!redisCfg || !redisCfg.open) {\r\n resolve(null);\r\n return;\r\n }\r\n if (this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redisCfg = redisCfg;\r\n Log_1.GLog.info(\"begin conect redis=\" + JSON.stringify(redisCfg));\r\n this._redis = redis.createClient(redisCfg.port, redisCfg.host, { parser: \"javascript\", return_buffers: false, connect_timeout: 3000, password: redisCfg.password });\r\n this._redis.on(\"connect\", () => {\r\n this.onConnect();\r\n resolve(null);\r\n });\r\n this._redis.on(\"end\", this.onEnd.bind(this));\r\n this._redis.on(\"error\", this.onError.bind(this));\r\n });\r\n }\r\n onConnect() {\r\n if (this._redisCfg.database) {\r\n this._redis.select(this._redisCfg.database);\r\n }\r\n this._resis_init_succ = true;\r\n Log_1.GLog.info(\"redis has connected!\");\r\n }\r\n onEnd() {\r\n this._resis_init_succ = false;\r\n this._redis = null;\r\n this.init(this._redisCfg); //重连\r\n }\r\n onError(err) {\r\n Log_1.GLog.info(\"Error connected=\" + this._redis.connected + \": \" + err);\r\n }\r\n expire(key, seconds) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.expire(key, seconds, (err, reply) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(reply);\r\n });\r\n });\r\n }\r\n incr(key) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.incr(key, (err, reply) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(reply);\r\n });\r\n });\r\n }\r\n set(key, value) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.set(key, value, (err, reply) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(reply);\r\n });\r\n });\r\n }\r\n get(key) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.get(key, (err, reply) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(reply);\r\n });\r\n });\r\n }\r\n /**\r\n *\r\n * @param key\r\n * @param cb 有表示异步\r\n */\r\n del(key, cb) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.del(key, (err, reply) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(reply);\r\n });\r\n });\r\n }\r\n hset(h, key, value) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.hset(h, key, value, (err, reply) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(reply);\r\n });\r\n });\r\n }\r\n hget(h, key) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.hget(h, key, (err, reply) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(reply);\r\n });\r\n });\r\n }\r\n hdel(key, sub_key) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.hdel(key, sub_key, (err, reply) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(reply);\r\n });\r\n });\r\n }\r\n /**\r\n * hash值,能转换位整数的就自动转换为整数\r\n * @param h key\r\n */\r\n hgetall(h) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.hgetall(h, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n resolve(replys);\r\n return;\r\n }\r\n let value = {};\r\n for (let k in replys) {\r\n let v = replys[k];\r\n let iv = parseInt(v);\r\n if (v == \"\" + iv) {\r\n value[k] = iv;\r\n }\r\n else {\r\n value[k] = v;\r\n }\r\n }\r\n if (!replys) {\r\n value = null;\r\n }\r\n resolve(value);\r\n });\r\n });\r\n }\r\n /**\r\n *\r\n * @param h\r\n * @param array\r\n */\r\n hmset(h, array) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.hmset(h, array, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n lpush(key, array) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.lpush(key, array, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n lrange(key, start, end) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n if (!this._redis) {\r\n return null;\r\n }\r\n if (!start) {\r\n start = 0;\r\n }\r\n if (!end) {\r\n end = -1;\r\n }\r\n this._redis.lrange(key, start, end, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n ltrim(key, start, end) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n if (!this._redis) {\r\n return null;\r\n }\r\n if (!start) {\r\n start = 0;\r\n }\r\n if (!end) {\r\n end = -1;\r\n }\r\n this._redis.ltrim(key, start, end, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n sadd(key, array) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.sadd(key, array, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n smembers(key) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.smembers(key, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n srem(key, array) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.srem(key, array, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n keys(key) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.keys(key, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n multi() {\r\n if (!this._redis) {\r\n return null;\r\n }\r\n return this._redis.multi();\r\n }\r\n exists(key) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.exists(key, (err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n exec(multi) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis || !multi) {\r\n resolve(null);\r\n return;\r\n }\r\n multi.exec((err, replys) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(replys);\r\n });\r\n });\r\n }\r\n publish(channel, value) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.publish(channel, value, (err, num) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(num);\r\n });\r\n });\r\n }\r\n subscribe(channel) {\r\n return new Promise((resolve, reject) => {\r\n if (!this._redis) {\r\n resolve(null);\r\n return;\r\n }\r\n this._redis.subscribe(channel, (err, msg) => {\r\n if (err) {\r\n Log_1.GLog.error(err);\r\n }\r\n resolve(msg);\r\n });\r\n });\r\n }\r\n on(message, cb) {\r\n if (!this._redis) {\r\n return;\r\n }\r\n this._redis.on(message, cb);\r\n }\r\n}\r\nexports.RedisManager = RedisManager;\r\nexports.GRedisMgr = new RedisManager();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Database/RedisManager.js?");
|
|
600
|
+
|
|
601
|
+
/***/ }),
|
|
602
|
+
|
|
603
|
+
/***/ "./dist/lib/Logic/AsyncQueueTool.js":
|
|
604
|
+
/*!******************************************!*\
|
|
605
|
+
!*** ./dist/lib/Logic/AsyncQueueTool.js ***!
|
|
606
|
+
\******************************************/
|
|
607
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
608
|
+
|
|
609
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GAsyncQueueTool = void 0;\r\nconst Core_1 = __webpack_require__(/*! ../Core/Core */ \"./dist/lib/Core/Core.js\");\r\nclass AsyncQueueItem {\r\n key = \"\";\r\n running = false;\r\n funcs = [];\r\n constructor(key) {\r\n this.key = key;\r\n }\r\n async add(func, thisArg = null, ...params) {\r\n return new Promise((resolve, reject) => {\r\n this.funcs.push({ func: func, thisArg: thisArg, params: params, resolve: resolve });\r\n this._run();\r\n });\r\n }\r\n async _run() {\r\n if (this.running) {\r\n return;\r\n }\r\n this.running = true;\r\n while (this.funcs.length > 0) {\r\n let funcitem = this.funcs.shift();\r\n if (!funcitem.func) {\r\n continue;\r\n }\r\n let rs = await Core_1.core.safeCall(funcitem.func, funcitem.thisArg, ...funcitem.params);\r\n await Core_1.core.safeCall(funcitem.resolve, null, rs);\r\n }\r\n this.running = false;\r\n }\r\n}\r\nclass AsyncQueueTool {\r\n //队列数据,一个key队列必须有先后\r\n _queues = {};\r\n async add(key, func, thisArg = null, ...params) {\r\n this._queues[key] = this._queues[key] || new AsyncQueueItem(key);\r\n let error = await this._queues[key].add(func, thisArg, ...params);\r\n return error;\r\n }\r\n}\r\nexports.GAsyncQueueTool = new AsyncQueueTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Logic/AsyncQueueTool.js?");
|
|
610
|
+
|
|
611
|
+
/***/ }),
|
|
612
|
+
|
|
613
|
+
/***/ "./dist/lib/Logic/CacheTool.js":
|
|
614
|
+
/*!*************************************!*\
|
|
615
|
+
!*** ./dist/lib/Logic/CacheTool.js ***!
|
|
616
|
+
\*************************************/
|
|
617
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
618
|
+
|
|
619
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GCacheTool = void 0;\r\nconst _ = __webpack_require__(/*! underscore */ \"underscore\");\r\nexports.GCacheTool = null;\r\nclass CacheItem {\r\n key = \"\";\r\n value = null;\r\n milliseconds = 0;\r\n expire_time = -1;\r\n}\r\nclass CacheTool {\r\n _items = {};\r\n constructor() {\r\n //一个小时清除一次过期缓存\r\n setInterval(this._refresh.bind(this), 60 * 60 * 1000);\r\n }\r\n /**\r\n * 定时清除缓存\r\n */\r\n _refresh() {\r\n let time = new Date().getTime();\r\n let keys = _.clone(this._items.keys);\r\n for (let i in keys) {\r\n let key = keys[i];\r\n let item = this._items[key];\r\n if (!item) {\r\n delete this._items[key];\r\n continue;\r\n }\r\n if (time > item.expire_time) {\r\n this.remove(key);\r\n }\r\n }\r\n }\r\n get(key, refresh) {\r\n let item = this._items[key];\r\n if (!item) {\r\n return;\r\n }\r\n let time = new Date().getTime();\r\n if (time > item.expire_time) {\r\n this.remove(key);\r\n return;\r\n }\r\n if (refresh) {\r\n item.expire_time = time + item.milliseconds;\r\n }\r\n return item.value;\r\n }\r\n /**\r\n *\r\n * @param key\r\n * @param value\r\n * @param time 缓存的毫秒数\r\n */\r\n add(key, value, milliseconds) {\r\n let item = this._items[key];\r\n if (!item) {\r\n item = new CacheItem();\r\n item.key = key;\r\n this._items[key] = item;\r\n }\r\n item.value = value;\r\n item.milliseconds = milliseconds;\r\n item.expire_time = new Date().getTime() + milliseconds;\r\n }\r\n remove(key) {\r\n this._items[key] = null;\r\n delete this._items[key];\r\n }\r\n}\r\nexports.GCacheTool = new CacheTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Logic/CacheTool.js?");
|
|
620
|
+
|
|
621
|
+
/***/ }),
|
|
622
|
+
|
|
623
|
+
/***/ "./dist/lib/Logic/EventTool.js":
|
|
624
|
+
/*!*************************************!*\
|
|
625
|
+
!*** ./dist/lib/Logic/EventTool.js ***!
|
|
626
|
+
\*************************************/
|
|
627
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
628
|
+
|
|
629
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GEventTool = void 0;\r\nconst EventEmitter = __webpack_require__(/*! events */ \"events\");\r\nclass EventTool {\r\n _event_emitter = new EventEmitter();\r\n constructor() {\r\n this._event_emitter.setMaxListeners(0);\r\n }\r\n on(event, func) {\r\n this._event_emitter.on(event, func);\r\n }\r\n off(event, func) {\r\n this._event_emitter.off(event, func);\r\n }\r\n once(event, func) {\r\n this._event_emitter.once(event, func);\r\n }\r\n emit(event, ...args) {\r\n this._event_emitter.emit(event, ...args);\r\n }\r\n}\r\nexports.GEventTool = new EventTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Logic/EventTool.js?");
|
|
630
|
+
|
|
631
|
+
/***/ }),
|
|
632
|
+
|
|
633
|
+
/***/ "./dist/lib/Logic/HttpTool.js":
|
|
634
|
+
/*!************************************!*\
|
|
635
|
+
!*** ./dist/lib/Logic/HttpTool.js ***!
|
|
636
|
+
\************************************/
|
|
637
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
638
|
+
|
|
639
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GHttpTool = void 0;\r\nconst request = __webpack_require__(/*! request */ \"request\");\r\nconst qs = __webpack_require__(/*! querystring */ \"querystring\");\r\nconst Log_1 = __webpack_require__(/*! ./Log */ \"./dist/lib/Logic/Log.js\");\r\nexports.GHttpTool = null;\r\nclass HttpTool {\r\n httpRequest(url, noParse) {\r\n return new Promise((resolve, reject) => {\r\n request.get(url, {\r\n strictSSL: false,\r\n rejectUnauthorized: false\r\n }, (error, response, body) => {\r\n if (!noParse) {\r\n try {\r\n if (body) {\r\n body = JSON.parse(body);\r\n }\r\n }\r\n catch (e) {\r\n try {\r\n body = qs.parse(body);\r\n }\r\n catch (e) { }\r\n }\r\n }\r\n resolve({ error, response, body });\r\n });\r\n });\r\n }\r\n httpPost(url, form) {\r\n return new Promise((resolve, reject) => {\r\n request.post({ url: url, form: form }, (error, response, body) => {\r\n let bd = body;\r\n if (error) {\r\n Log_1.GLog.error(\"post:\" + url);\r\n Log_1.GLog.error(error);\r\n }\r\n try {\r\n if (body) {\r\n body = JSON.parse(body);\r\n }\r\n }\r\n catch (e) {\r\n try {\r\n body = qs.parse(body);\r\n }\r\n catch (e) {\r\n body = bd;\r\n }\r\n }\r\n resolve({ error, response, body });\r\n });\r\n });\r\n }\r\n}\r\nexports.GHttpTool = new HttpTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Logic/HttpTool.js?");
|
|
640
|
+
|
|
641
|
+
/***/ }),
|
|
642
|
+
|
|
643
|
+
/***/ "./dist/lib/Logic/Log.js":
|
|
644
|
+
/*!*******************************!*\
|
|
645
|
+
!*** ./dist/lib/Logic/Log.js ***!
|
|
646
|
+
\*******************************/
|
|
647
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
648
|
+
|
|
649
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GLog = void 0;\r\nconst colors = __webpack_require__(/*! colors */ \"colors\");\r\nconst log4js = __webpack_require__(/*! log4js */ \"log4js\");\r\n/**\r\n * 输出颜色\r\n */\r\ncolors.setTheme({\r\n silly: 'rainbow',\r\n input: 'grey',\r\n verbose: 'cyan',\r\n prompt: 'red',\r\n info: 'green',\r\n data: 'blue',\r\n help: 'cyan',\r\n warn: 'yellow',\r\n debug: 'magenta',\r\n error: 'red'\r\n});\r\nexports.GLog = null;\r\nclass Log {\r\n //default log\r\n _logger = null;\r\n //the log from client\r\n _client_logger = null;\r\n //error and warn\r\n _errorLogger = null;\r\n _inited = false;\r\n /**\r\n * 该level只是用来控制控制台的显示的\r\n * -1不输出到console,0,仅错误信息输出到console,1,都输出到console\r\n */\r\n _console_level = 0;\r\n init(cfg, console_level = 0) {\r\n if (this._inited) {\r\n return;\r\n }\r\n this._inited = true;\r\n colors.enable();\r\n log4js.configure(cfg);\r\n this._logger = log4js.getLogger(cfg.categories.default.appenders[0] || \"log_date\");\r\n this._client_logger = log4js.getLogger(cfg.categories.default.appenders[1] || \"client_log_date\");\r\n this._errorLogger = log4js.getLogger(cfg.categories.default.appenders[2] || \"error_log_file\");\r\n this._console_level = console_level;\r\n }\r\n error(message) {\r\n if (this._isObject(message)) {\r\n message = JSON.stringify(message);\r\n }\r\n this._errorLogger.error(message);\r\n if (this._console_level >= 0) {\r\n let time_str = this._getTimeStr();\r\n console.error(time_str + \" \" + message);\r\n }\r\n }\r\n info(message) {\r\n if (this._isObject(message)) {\r\n message = JSON.stringify(message);\r\n }\r\n this._logger.info(message);\r\n if (this._console_level >= 0) {\r\n let time_str = this._getTimeStr();\r\n console.log(time_str + \" \" + message);\r\n }\r\n }\r\n warn(message) {\r\n if (this._isObject(message)) {\r\n message = JSON.stringify(message);\r\n }\r\n this._errorLogger.warn(message);\r\n if (this._console_level >= 0) {\r\n let time_str = this._getTimeStr();\r\n console.error(time_str + \" \" + message);\r\n }\r\n }\r\n record(message) {\r\n this.info(message);\r\n }\r\n clientLog(message) {\r\n this._client_logger.error(message);\r\n }\r\n _getTimeStr() {\r\n let time = new Date();\r\n let time_str = this._format(time, \"[YYYY-MM-DD HH:mm:SS.\");\r\n time_str += time.getMilliseconds() + \"]\";\r\n return time_str;\r\n }\r\n _isObject(param) {\r\n return typeof (param) === \"object\";\r\n }\r\n _isString(param) {\r\n return typeof (param) === \"string\";\r\n }\r\n _isNumber(param) {\r\n return typeof (param) === \"number\";\r\n }\r\n _format(src, formatStr) {\r\n if (this._isString(src)) {\r\n let args = Array.prototype.slice.call(arguments, 1);\r\n return src.replace(/\\{(\\d+)\\}/g, function (m, i) {\r\n return args[i];\r\n });\r\n }\r\n else {\r\n if (this._isNumber(src)) {\r\n src = new Date(src);\r\n }\r\n let str = formatStr;\r\n let Week = ['日', '一', '二', '三', '四', '五', '六'];\r\n let month = src.getMonth() + 1;\r\n let year = src.getFullYear();\r\n let date = src.getDate();\r\n let hour = src.getHours();\r\n let min = src.getMinutes();\r\n let sec = src.getSeconds();\r\n let day = src.getDay();\r\n str = str.replace(/yyyy|YYYY/, year);\r\n str = str.replace(/yy|YY/, (year % 100) > 9 ? (year % 100).toString() : '0' + (year % 100));\r\n str = str.replace(/MM/, month > 9 ? month.toString() : '0' + month);\r\n str = str.replace(/M/g, month);\r\n str = str.replace(/w|W/g, Week[day]);\r\n str = str.replace(/dd|DD/, date > 9 ? date.toString() : '0' + date);\r\n str = str.replace(/d|D/g, date);\r\n str = str.replace(/hh|HH/, hour > 9 ? hour.toString() : '0' + hour);\r\n str = str.replace(/h|H/g, hour);\r\n str = str.replace(/mm/, min > 9 ? min.toString() : '0' + min);\r\n str = str.replace(/m/g, min);\r\n str = str.replace(/ss|SS/, sec > 9 ? sec.toString() : '0' + sec);\r\n str = str.replace(/s|S/g, sec);\r\n return str;\r\n }\r\n }\r\n}\r\nexports.GLog = new Log();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Logic/Log.js?");
|
|
650
|
+
|
|
651
|
+
/***/ }),
|
|
652
|
+
|
|
653
|
+
/***/ "./dist/lib/Service/AccountService.js":
|
|
654
|
+
/*!********************************************!*\
|
|
655
|
+
!*** ./dist/lib/Service/AccountService.js ***!
|
|
656
|
+
\********************************************/
|
|
657
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
658
|
+
|
|
659
|
+
eval("\r\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AccountService = exports.GAccountSer = exports.AccountModel = void 0;\r\nconst Property_1 = __webpack_require__(/*! ./../Database/Decorator/Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nconst MysqlBaseService_1 = __webpack_require__(/*! ../Database/MysqlBaseService */ \"./dist/lib/Database/MysqlBaseService.js\");\r\nconst CacheTool_1 = __webpack_require__(/*! ../Logic/CacheTool */ \"./dist/lib/Logic/CacheTool.js\");\r\nconst _error_1 = __webpack_require__(/*! ../Config/_error_ */ \"./dist/lib/Config/_error_.js\");\r\nconst OpenSocial_1 = __webpack_require__(/*! ../ThirdParty/OpenSocial */ \"./dist/lib/ThirdParty/OpenSocial.js\");\r\nconst UserService_1 = __webpack_require__(/*! ./UserService */ \"./dist/lib/Service/UserService.js\");\r\nconst QQTool_1 = __webpack_require__(/*! ../ThirdParty/QQTool */ \"./dist/lib/ThirdParty/QQTool.js\");\r\nconst WechatTool_1 = __webpack_require__(/*! ../ThirdParty/WechatTool */ \"./dist/lib/ThirdParty/WechatTool.js\");\r\nconst Table_1 = __webpack_require__(/*! ../Database/Decorator/Table */ \"./dist/lib/Database/Decorator/Table.js\");\r\nconst PrimaryKey_1 = __webpack_require__(/*! ../Database/Decorator/PrimaryKey */ \"./dist/lib/Database/Decorator/PrimaryKey.js\");\r\nconst NotNull_1 = __webpack_require__(/*! ../Database/Decorator/NotNull */ \"./dist/lib/Database/Decorator/NotNull.js\");\r\nconst Type_1 = __webpack_require__(/*! ../Database/Decorator/Type */ \"./dist/lib/Database/Decorator/Type.js\");\r\nconst AutoIncrement_1 = __webpack_require__(/*! ../Database/Decorator/AutoIncrement */ \"./dist/lib/Database/Decorator/AutoIncrement.js\");\r\nconst ini_1 = __webpack_require__(/*! ./ini */ \"./dist/lib/Service/ini.js\");\r\nlet AccountModel = class AccountModel extends MysqlBaseService_1.BaseModel {\r\n id = -1;\r\n phone = \"\";\r\n email = \"\";\r\n name = \"\";\r\n password = \"\";\r\n unionid = \"\"; //第三方\r\n openid = \"\";\r\n create_time = -1;\r\n create_ip = \"\";\r\n login_time = -1;\r\n login_ip = \"\";\r\n from = 0;\r\n state = ini_1.EAccountState.Waitting;\r\n};\r\n__decorate([\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int),\r\n NotNull_1.NotNull,\r\n PrimaryKey_1.PrimaryKey,\r\n AutoIncrement_1.AutoIncrement\r\n], AccountModel.prototype, \"id\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar)\r\n], AccountModel.prototype, \"phone\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar)\r\n], AccountModel.prototype, \"email\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar)\r\n], AccountModel.prototype, \"name\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar)\r\n], AccountModel.prototype, \"password\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"\", 128)\r\n], AccountModel.prototype, \"unionid\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"\", 128)\r\n], AccountModel.prototype, \"openid\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.BigInt)\r\n], AccountModel.prototype, \"create_time\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar)\r\n], AccountModel.prototype, \"create_ip\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.BigInt)\r\n], AccountModel.prototype, \"login_time\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar)\r\n], AccountModel.prototype, \"login_ip\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int)\r\n], AccountModel.prototype, \"from\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int)\r\n], AccountModel.prototype, \"state\", void 0);\r\nAccountModel = __decorate([\r\n (0, Table_1.Table)(\"account\", 1, \"账号\")\r\n], AccountModel);\r\nexports.AccountModel = AccountModel;\r\n//暂时不实例化,方便重写\r\nexports.GAccountSer = null;\r\nclass AccountService extends MysqlBaseService_1.MysqlBaseService {\r\n _account_cache_key_pre = \"table_account_\";\r\n _account_cache_time_sec = 1 * 60 * 60 * 1000;\r\n constructor() {\r\n super(AccountModel);\r\n exports.GAccountSer = this;\r\n }\r\n _getNewModel() {\r\n return new AccountModel();\r\n }\r\n /**\r\n * 注册新账号\r\n * @param unionid\r\n * @param openid\r\n * @param ip\r\n * @param from\r\n */\r\n async add(unionid, openid, ip, from) {\r\n let account = this._getNewModel();\r\n switch (from) {\r\n case ini_1.EAccountFrom.OpenSocial:\r\n case ini_1.EAccountFrom.WeChat:\r\n case ini_1.EAccountFrom.QQ:\r\n case ini_1.EAccountFrom.Apple:\r\n case ini_1.EAccountFrom.Google:\r\n {\r\n account.unionid = unionid;\r\n account.openid = openid;\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Email:\r\n {\r\n account.email = unionid;\r\n account.password = openid;\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Phone:\r\n case ini_1.EAccountFrom.QuickPhone:\r\n {\r\n account.phone = unionid;\r\n account.password = openid;\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Name:\r\n case ini_1.EAccountFrom.Guest:\r\n {\r\n account.name = unionid;\r\n account.password = openid;\r\n break;\r\n }\r\n }\r\n account.create_time = Date.now();\r\n account.create_ip = ip;\r\n account.login_time = Date.now();\r\n account.login_ip = ip;\r\n account.from = from;\r\n account.state = ini_1.EAccountState.Waitting;\r\n delete account.id;\r\n let sr = await this.insert(account);\r\n if (sr.error\r\n || !sr.results.insertId) {\r\n return null;\r\n }\r\n account.id = sr.results.insertId;\r\n return account;\r\n }\r\n /**\r\n * 通过第三方信息获取账号\r\n * @param unionid\r\n * @param openid\r\n */\r\n async getByThird(unionid, openid) {\r\n let key = this._account_cache_key_pre + unionid;\r\n let am = CacheTool_1.GCacheTool.get(key);\r\n if (am) {\r\n return am;\r\n }\r\n am = await this.get(null, \"unionid=? and openid=?\", [unionid, openid]);\r\n if (am) {\r\n CacheTool_1.GCacheTool.add(key, am, this._account_cache_time_sec);\r\n }\r\n return am;\r\n }\r\n /**\r\n * 通过第三方信息获取账号\r\n * @param unionid\r\n */\r\n async getByUnionid(unionid) {\r\n let key = this._account_cache_key_pre + unionid;\r\n let am = CacheTool_1.GCacheTool.get(key);\r\n if (am) {\r\n return am;\r\n }\r\n am = await this.get(null, \"unionid=?\", [unionid]);\r\n if (am) {\r\n CacheTool_1.GCacheTool.add(key, am, this._account_cache_time_sec);\r\n }\r\n return am;\r\n }\r\n async getByPhone(phone) {\r\n let key = this._account_cache_key_pre + phone;\r\n let am = CacheTool_1.GCacheTool.get(key);\r\n if (am) {\r\n return am;\r\n }\r\n am = await this.get(null, \"phone=?\", [phone]);\r\n if (am) {\r\n CacheTool_1.GCacheTool.add(key, am, this._account_cache_time_sec);\r\n }\r\n return am;\r\n }\r\n /**\r\n * 登陆接口\r\n * @param unionid\r\n * @param openid\r\n * @param ip\r\n * @param from\r\n * @param access_token qq、wechat使用\r\n */\r\n async login(unionid, openid, ip, from, access_token, extra) {\r\n let rs = { errcode: null, account: null, is_new: false };\r\n if (!unionid || !openid) {\r\n rs.errcode = _error_1.EErrorCode.Wrong_Params;\r\n return rs;\r\n }\r\n let login_rs = await this._login(unionid, openid, from);\r\n rs.account = login_rs.account;\r\n rs.errcode = login_rs.errcode;\r\n if (rs.errcode) {\r\n return rs;\r\n }\r\n let account = rs.account;\r\n let extra_info = extra;\r\n if (!account) {\r\n switch (from) {\r\n case ini_1.EAccountFrom.OpenSocial:\r\n case ini_1.EAccountFrom.QQ:\r\n case ini_1.EAccountFrom.WeChat:\r\n case ini_1.EAccountFrom.Guest:\r\n case ini_1.EAccountFrom.QuickPhone:\r\n case ini_1.EAccountFrom.Apple:\r\n case ini_1.EAccountFrom.Google:\r\n {\r\n account = await this.add(unionid, openid, ip, from);\r\n break;\r\n }\r\n default:\r\n {\r\n rs.errcode = _error_1.EErrorCode.No_Account;\r\n return rs;\r\n }\r\n }\r\n }\r\n if (!account) {\r\n rs.errcode = _error_1.EErrorCode.No_Account;\r\n return rs;\r\n }\r\n let user = await UserService_1.GUserSer.getByAccountId(account.id);\r\n if (!user) {\r\n switch (from) {\r\n case ini_1.EAccountFrom.OpenSocial:\r\n case ini_1.EAccountFrom.QQ:\r\n case ini_1.EAccountFrom.WeChat:\r\n case ini_1.EAccountFrom.Apple:\r\n case ini_1.EAccountFrom.Google:\r\n {\r\n if (!extra_info) {\r\n if (from == ini_1.EAccountFrom.OpenSocial) {\r\n let body = await OpenSocial_1.GOpenSocial.getUser(unionid, openid);\r\n if (body && body.errcode) {\r\n rs.errcode = body.errcode;\r\n return rs;\r\n }\r\n else if (body && body.user) {\r\n extra_info =\r\n {\r\n logo: body.user.logo,\r\n sex: body.user.sex,\r\n nickname: body.user.nickname\r\n };\r\n }\r\n }\r\n else if (from == ini_1.EAccountFrom.QQ) {\r\n let userInfo = await QQTool_1.GQQTool.getUserInfo(access_token, openid);\r\n if (userInfo.ret) {\r\n rs.errcode = _error_1.EErrorCode.Server_Error;\r\n return rs;\r\n }\r\n extra_info =\r\n {\r\n logo: userInfo.figureurl_qq,\r\n sex: (userInfo.gender == \"男\" ? 1 : 0),\r\n nickname: userInfo.nickname\r\n };\r\n }\r\n else if (from == ini_1.EAccountFrom.WeChat) {\r\n let userInfo = await WechatTool_1.GWechatTool.getUserInfo(access_token, openid);\r\n if (userInfo.errcode) {\r\n rs.errcode = _error_1.EErrorCode.Server_Error;\r\n return rs;\r\n }\r\n extra_info =\r\n {\r\n logo: userInfo.headimgurl,\r\n sex: (userInfo.sex == 1 ? 1 : 0),\r\n nickname: userInfo.nickname\r\n };\r\n }\r\n else if (from == ini_1.EAccountFrom.Apple || from == ini_1.EAccountFrom.Google) {\r\n extra_info =\r\n {\r\n logo: \"32\",\r\n sex: 0,\r\n nickname: \"noname\"\r\n };\r\n }\r\n }\r\n let user = await UserService_1.GUserSer.add(account.id, extra_info.nickname, extra_info.sex, extra_info.logo);\r\n if (!user) {\r\n this.removeById(account.id);\r\n rs.errcode = _error_1.EErrorCode.User_Create_Failed;\r\n return rs;\r\n }\r\n break;\r\n }\r\n case ini_1.EAccountFrom.QuickPhone:\r\n case ini_1.EAccountFrom.Guest:\r\n {\r\n let user = null;\r\n if (extra_info) {\r\n user = await UserService_1.GUserSer.add(account.id, extra_info.nickname, extra_info.sex, extra_info.logo);\r\n }\r\n else {\r\n user = await UserService_1.GUserSer.add(account.id, null, null, null);\r\n }\r\n if (!user) {\r\n this.removeById(account.id);\r\n rs.errcode = _error_1.EErrorCode.User_Create_Failed;\r\n return rs;\r\n }\r\n break;\r\n }\r\n default:\r\n {\r\n rs.errcode = _error_1.EErrorCode.No_Account;\r\n return rs;\r\n }\r\n }\r\n rs.is_new = true;\r\n if (extra) {\r\n await UserService_1.GUserSer.updateBaseInfoByAccount(account.id, extra_info.nickname, extra_info.sex, extra_info.logo);\r\n }\r\n }\r\n if (user && extra_info) {\r\n await UserService_1.GUserSer.updateProperty(\"nickname=?,sex=?,logo=?\", \"id=?\", [extra_info.nickname, extra_info.sex || 0, extra_info.logo, user.id]);\r\n }\r\n rs.account = account;\r\n return rs;\r\n }\r\n async _login(unionid, openid, from) {\r\n let rs = { errcode: null, account: null };\r\n if (from == ini_1.EAccountFrom.QQ\r\n || from == ini_1.EAccountFrom.WeChat\r\n || from == ini_1.EAccountFrom.OpenSocial\r\n || from == ini_1.EAccountFrom.Apple\r\n || from == ini_1.EAccountFrom.Google) {\r\n rs.account = await this.getByThird(unionid, openid);\r\n }\r\n else if (from == ini_1.EAccountFrom.QuickPhone) {\r\n let key = \"phone_code_\" + unionid;\r\n let code = CacheTool_1.GCacheTool.get(key);\r\n if (!code || code != openid) {\r\n rs.errcode = _error_1.EErrorCode.Wrong_Phone_Code;\r\n return rs;\r\n }\r\n rs.account = await this.getByPhone(unionid);\r\n }\r\n else if (from == ini_1.EAccountFrom.Phone) {\r\n rs.account = await this.get(null, \"phone=? and password=?\", [unionid, openid]);\r\n if (!rs.account) {\r\n rs.errcode = _error_1.EErrorCode.Login_Failed;\r\n }\r\n }\r\n else if (from == ini_1.EAccountFrom.Email) {\r\n rs.account = await this.get(null, \"email=? and password=?\", [unionid, openid]);\r\n if (!rs.account) {\r\n rs.errcode = _error_1.EErrorCode.Login_Failed;\r\n }\r\n }\r\n else if (from == ini_1.EAccountFrom.Name || from == ini_1.EAccountFrom.Guest) {\r\n rs.account = await this.get(null, \"name=? and password=?\", [unionid, openid]);\r\n if (!rs.account && from == ini_1.EAccountFrom.Name) {\r\n rs.errcode = _error_1.EErrorCode.Login_Failed;\r\n }\r\n }\r\n return rs;\r\n }\r\n /**\r\n * 修改密码\r\n * @param unionid\r\n * @param openid\r\n * @param new_pwd\r\n */\r\n async updatePwd(unionid, openid, new_pwd) {\r\n let rs = await OpenSocial_1.GOpenSocial.updatePwd(unionid, openid, new_pwd);\r\n return rs;\r\n }\r\n async register(type, key, password, ip, extra) {\r\n let rs = { user: null, errcode: null };\r\n extra = extra || {};\r\n let am = this._getNewModel();\r\n switch (type) {\r\n case ini_1.EAccountFrom.Phone:\r\n {\r\n am.phone = key;\r\n let temp = await this.get(\"id\", \"phone=?\", [key]);\r\n if (temp) {\r\n rs.errcode = _error_1.EErrorCode.Account_Phone_Exist;\r\n return rs;\r\n }\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Email:\r\n {\r\n am.email = key;\r\n let temp = await this.get(\"id\", \"email=?\", [key]);\r\n if (temp) {\r\n rs.errcode = _error_1.EErrorCode.Account_Email_Exist;\r\n return rs;\r\n }\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Name:\r\n {\r\n am.name = key;\r\n let temp = await this.get(\"id\", \"name=?\", [key]);\r\n if (temp) {\r\n rs.errcode = _error_1.EErrorCode.Account_Name_Exist;\r\n return rs;\r\n }\r\n break;\r\n }\r\n default:\r\n {\r\n rs.errcode = _error_1.EErrorCode.Account_Type_Error;\r\n return rs;\r\n }\r\n }\r\n am.password = password;\r\n am.create_time = Date.now();\r\n am.create_ip = ip;\r\n am.login_time = Date.now();\r\n am.login_ip = ip;\r\n let sr = await this.insert(am);\r\n if (sr.results.insertId) {\r\n am.id = sr.results.insertId;\r\n }\r\n else {\r\n am = null;\r\n }\r\n if (!am) {\r\n rs.errcode = _error_1.EErrorCode.Mysql_Error;\r\n return rs;\r\n }\r\n let user = await UserService_1.GUserSer.add(am.id, extra.nickname, extra.sex, extra.logo);\r\n if (!user) {\r\n this.removeById(am.id);\r\n rs.errcode = _error_1.EErrorCode.User_Create_Failed;\r\n return rs;\r\n }\r\n rs.user = user;\r\n return rs;\r\n }\r\n}\r\nexports.AccountService = AccountService;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Service/AccountService.js?");
|
|
660
|
+
|
|
661
|
+
/***/ }),
|
|
662
|
+
|
|
663
|
+
/***/ "./dist/lib/Service/MongoAccountService.js":
|
|
664
|
+
/*!*************************************************!*\
|
|
665
|
+
!*** ./dist/lib/Service/MongoAccountService.js ***!
|
|
666
|
+
\*************************************************/
|
|
667
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
668
|
+
|
|
669
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AccountService = exports.GAccountSer = exports.AccountModel = void 0;\r\nconst _error_1 = __webpack_require__(/*! ../Config/_error_ */ \"./dist/lib/Config/_error_.js\");\r\nconst MongoBaseService_1 = __webpack_require__(/*! ../Database/MongoBaseService */ \"./dist/lib/Database/MongoBaseService.js\");\r\nconst MongoManager_1 = __webpack_require__(/*! ../Database/MongoManager */ \"./dist/lib/Database/MongoManager.js\");\r\nconst CacheTool_1 = __webpack_require__(/*! ../Logic/CacheTool */ \"./dist/lib/Logic/CacheTool.js\");\r\nconst OpenSocial_1 = __webpack_require__(/*! ../ThirdParty/OpenSocial */ \"./dist/lib/ThirdParty/OpenSocial.js\");\r\nconst QQTool_1 = __webpack_require__(/*! ../ThirdParty/QQTool */ \"./dist/lib/ThirdParty/QQTool.js\");\r\nconst WechatTool_1 = __webpack_require__(/*! ../ThirdParty/WechatTool */ \"./dist/lib/ThirdParty/WechatTool.js\");\r\nconst ini_1 = __webpack_require__(/*! ./ini */ \"./dist/lib/Service/ini.js\");\r\nconst MongoUserService_1 = __webpack_require__(/*! ./MongoUserService */ \"./dist/lib/Service/MongoUserService.js\");\r\nclass AccountModel extends MongoManager_1.MongoBaseModel {\r\n id = -1;\r\n phone = \"\";\r\n email = \"\";\r\n name = \"\";\r\n password = \"\";\r\n unionid = \"\"; //第三方\r\n openid = \"\";\r\n create_time = -1;\r\n create_ip = \"\";\r\n login_time = -1;\r\n login_ip = \"\";\r\n from = 0;\r\n state = ini_1.EAccountState.Waitting;\r\n}\r\nexports.AccountModel = AccountModel;\r\n//暂时不实例化,方便重写\r\nexports.GAccountSer = null;\r\nclass AccountService extends MongoBaseService_1.MongoBaseService {\r\n _account_cache_key_pre = \"table_account_\";\r\n _account_cache_time_sec = 1 * 60 * 60 * 1000;\r\n constructor() {\r\n super(\"account\", AccountModel);\r\n exports.GAccountSer = this;\r\n }\r\n _getNewModel() {\r\n return new AccountModel();\r\n }\r\n /**\r\n * 注册新账号\r\n * @param unionid\r\n * @param openid\r\n * @param ip\r\n * @param from\r\n */\r\n async add(unionid, openid, ip, from) {\r\n let account = this._getNewModel();\r\n switch (from) {\r\n case ini_1.EAccountFrom.OpenSocial:\r\n case ini_1.EAccountFrom.WeChat:\r\n case ini_1.EAccountFrom.QQ:\r\n case ini_1.EAccountFrom.Apple:\r\n case ini_1.EAccountFrom.Google:\r\n {\r\n account.unionid = unionid;\r\n account.openid = openid;\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Email:\r\n {\r\n account.email = unionid;\r\n account.password = openid;\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Phone:\r\n case ini_1.EAccountFrom.QuickPhone:\r\n {\r\n account.phone = unionid;\r\n account.password = openid;\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Name:\r\n case ini_1.EAccountFrom.Guest:\r\n {\r\n account.name = unionid;\r\n account.password = openid;\r\n break;\r\n }\r\n }\r\n account.create_time = Date.now();\r\n account.create_ip = ip;\r\n account.login_time = Date.now();\r\n account.login_ip = ip;\r\n account.from = from;\r\n account.state = ini_1.EAccountState.Waitting;\r\n account.id = await this.getNextId();\r\n let sr = await this.insert(account);\r\n if (sr.errcode) {\r\n return null;\r\n }\r\n account._id = sr.rs.insertedId;\r\n return account;\r\n }\r\n /**\r\n * 通过第三方信息获取账号\r\n * @param unionid\r\n * @param openid\r\n */\r\n async getByThird(unionid, openid) {\r\n let key = this._account_cache_key_pre + unionid;\r\n let am = CacheTool_1.GCacheTool.get(key);\r\n if (am) {\r\n return am;\r\n }\r\n am = await this.get(null, { unionid: unionid, openid: openid });\r\n if (am) {\r\n CacheTool_1.GCacheTool.add(key, am, this._account_cache_time_sec);\r\n }\r\n return am;\r\n }\r\n /**\r\n * 通过第三方信息获取账号\r\n * @param unionid\r\n */\r\n async getByUnionid(unionid) {\r\n let key = this._account_cache_key_pre + unionid;\r\n let am = CacheTool_1.GCacheTool.get(key);\r\n if (am) {\r\n return am;\r\n }\r\n am = await this.get(null, { unionid: unionid });\r\n if (am) {\r\n CacheTool_1.GCacheTool.add(key, am, this._account_cache_time_sec);\r\n }\r\n return am;\r\n }\r\n async getByPhone(phone) {\r\n let key = this._account_cache_key_pre + phone;\r\n let am = CacheTool_1.GCacheTool.get(key);\r\n if (am) {\r\n return am;\r\n }\r\n am = await this.get(null, { phone: phone });\r\n if (am) {\r\n CacheTool_1.GCacheTool.add(key, am, this._account_cache_time_sec);\r\n }\r\n return am;\r\n }\r\n /**\r\n * 登陆接口\r\n * @param unionid\r\n * @param openid\r\n * @param ip\r\n * @param from\r\n * @param access_token qq、wechat使用\r\n */\r\n async login(unionid, openid, ip, from, access_token, extra) {\r\n let rs = { errcode: null, account: null, is_new: false };\r\n if (!unionid || !openid) {\r\n rs.errcode = _error_1.EErrorCode.Wrong_Params;\r\n return rs;\r\n }\r\n let login_rs = await this._login(unionid, openid, from);\r\n rs.account = login_rs.account;\r\n rs.errcode = login_rs.errcode;\r\n if (rs.errcode) {\r\n return rs;\r\n }\r\n let account = rs.account;\r\n let extra_info = extra;\r\n if (!account) {\r\n switch (from) {\r\n case ini_1.EAccountFrom.OpenSocial:\r\n case ini_1.EAccountFrom.QQ:\r\n case ini_1.EAccountFrom.WeChat:\r\n case ini_1.EAccountFrom.Guest:\r\n case ini_1.EAccountFrom.QuickPhone:\r\n case ini_1.EAccountFrom.Apple:\r\n case ini_1.EAccountFrom.Google:\r\n {\r\n account = await this.add(unionid, openid, ip, from);\r\n break;\r\n }\r\n default:\r\n {\r\n rs.errcode = _error_1.EErrorCode.No_Account;\r\n return rs;\r\n }\r\n }\r\n }\r\n if (!account) {\r\n rs.errcode = _error_1.EErrorCode.No_Account;\r\n return rs;\r\n }\r\n let user = await MongoUserService_1.GUserSer.getByAccountId(account.id);\r\n if (!user) {\r\n switch (from) {\r\n case ini_1.EAccountFrom.OpenSocial:\r\n case ini_1.EAccountFrom.QQ:\r\n case ini_1.EAccountFrom.WeChat:\r\n case ini_1.EAccountFrom.Apple:\r\n case ini_1.EAccountFrom.Google:\r\n {\r\n if (!extra_info) {\r\n if (from == ini_1.EAccountFrom.OpenSocial) {\r\n let body = await OpenSocial_1.GOpenSocial.getUser(unionid, openid);\r\n if (body && body.errcode) {\r\n rs.errcode = body.errcode;\r\n return rs;\r\n }\r\n else if (body && body.user) {\r\n extra_info =\r\n {\r\n logo: body.user.logo,\r\n sex: body.user.sex,\r\n nickname: body.user.nickname\r\n };\r\n }\r\n }\r\n else if (from == ini_1.EAccountFrom.QQ) {\r\n let userInfo = await QQTool_1.GQQTool.getUserInfo(access_token, openid);\r\n if (userInfo.ret) {\r\n rs.errcode = _error_1.EErrorCode.Server_Error;\r\n return rs;\r\n }\r\n extra_info =\r\n {\r\n logo: userInfo.figureurl_qq,\r\n sex: (userInfo.gender == \"男\" ? 1 : 0),\r\n nickname: userInfo.nickname\r\n };\r\n }\r\n else if (from == ini_1.EAccountFrom.WeChat) {\r\n let userInfo = await WechatTool_1.GWechatTool.getUserInfo(access_token, openid);\r\n if (userInfo.errcode) {\r\n rs.errcode = _error_1.EErrorCode.Server_Error;\r\n return rs;\r\n }\r\n extra_info =\r\n {\r\n logo: userInfo.headimgurl,\r\n sex: (userInfo.sex == 1 ? 1 : 0),\r\n nickname: userInfo.nickname\r\n };\r\n }\r\n else if (from == ini_1.EAccountFrom.Apple || from == ini_1.EAccountFrom.Google) {\r\n extra_info =\r\n {\r\n logo: \"32\",\r\n sex: 0,\r\n nickname: \"noname\"\r\n };\r\n }\r\n }\r\n let user = await MongoUserService_1.GUserSer.add(account.id, extra_info.nickname, extra_info.sex, extra_info.logo);\r\n if (!user) {\r\n this.deleteOne({ id: account.id });\r\n rs.errcode = _error_1.EErrorCode.User_Create_Failed;\r\n return rs;\r\n }\r\n break;\r\n }\r\n case ini_1.EAccountFrom.QuickPhone:\r\n case ini_1.EAccountFrom.Guest:\r\n {\r\n let user = null;\r\n if (extra_info) {\r\n user = await MongoUserService_1.GUserSer.add(account.id, extra_info.nickname, extra_info.sex, extra_info.logo);\r\n }\r\n else {\r\n user = await MongoUserService_1.GUserSer.add(account.id, null, null, null);\r\n }\r\n if (!user) {\r\n this.deleteOne({ id: account.id });\r\n rs.errcode = _error_1.EErrorCode.User_Create_Failed;\r\n return rs;\r\n }\r\n break;\r\n }\r\n default:\r\n {\r\n rs.errcode = _error_1.EErrorCode.No_Account;\r\n return rs;\r\n }\r\n }\r\n rs.is_new = true;\r\n if (extra) {\r\n await MongoUserService_1.GUserSer.updateBaseInfoByAccount(account.id, extra_info.nickname, extra_info.sex, extra_info.logo);\r\n }\r\n }\r\n rs.account = account;\r\n return rs;\r\n }\r\n async _login(unionid, openid, from) {\r\n let rs = { errcode: null, account: null };\r\n if (from == ini_1.EAccountFrom.QQ\r\n || from == ini_1.EAccountFrom.WeChat\r\n || from == ini_1.EAccountFrom.OpenSocial\r\n || from == ini_1.EAccountFrom.Apple\r\n || from == ini_1.EAccountFrom.Google) {\r\n rs.account = await this.getByThird(unionid, openid);\r\n }\r\n else if (from == ini_1.EAccountFrom.QuickPhone) {\r\n let key = \"phone_code_\" + unionid;\r\n let code = CacheTool_1.GCacheTool.get(key);\r\n if (!code || code != openid) {\r\n rs.errcode = _error_1.EErrorCode.Wrong_Phone_Code;\r\n return rs;\r\n }\r\n rs.account = await this.getByPhone(unionid);\r\n }\r\n else if (from == ini_1.EAccountFrom.Phone) {\r\n rs.account = await this.get(null, { phone: unionid, password: openid });\r\n if (!rs.account) {\r\n rs.errcode = _error_1.EErrorCode.Login_Failed;\r\n }\r\n }\r\n else if (from == ini_1.EAccountFrom.Email) {\r\n rs.account = await this.get(null, { email: unionid, password: openid });\r\n if (!rs.account) {\r\n rs.errcode = _error_1.EErrorCode.Login_Failed;\r\n }\r\n }\r\n else if (from == ini_1.EAccountFrom.Name || from == ini_1.EAccountFrom.Guest) {\r\n rs.account = await this.get(null, { name: unionid, password: openid });\r\n if (!rs.account && from == ini_1.EAccountFrom.Name) {\r\n rs.errcode = _error_1.EErrorCode.Login_Failed;\r\n }\r\n }\r\n return rs;\r\n }\r\n /**\r\n * 修改密码\r\n * @param unionid\r\n * @param openid\r\n * @param new_pwd\r\n */\r\n async updatePwd(unionid, openid, new_pwd) {\r\n let rs = await OpenSocial_1.GOpenSocial.updatePwd(unionid, openid, new_pwd);\r\n return rs;\r\n }\r\n async register(type, key, password, ip, extra) {\r\n let rs = { user: null, errcode: null };\r\n extra = extra || {};\r\n let am = this._getNewModel();\r\n switch (type) {\r\n case ini_1.EAccountFrom.Phone:\r\n {\r\n am.phone = key;\r\n let temp = await this.get({ id: 1 }, { phone: key });\r\n if (temp) {\r\n rs.errcode = _error_1.EErrorCode.Account_Phone_Exist;\r\n return rs;\r\n }\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Email:\r\n {\r\n am.email = key;\r\n let temp = await this.get({ id: 1 }, { email: key });\r\n if (temp) {\r\n rs.errcode = _error_1.EErrorCode.Account_Email_Exist;\r\n return rs;\r\n }\r\n break;\r\n }\r\n case ini_1.EAccountFrom.Name:\r\n {\r\n am.name = key;\r\n let temp = await this.get({ id: 1 }, { name: key });\r\n if (temp) {\r\n rs.errcode = _error_1.EErrorCode.Account_Name_Exist;\r\n return rs;\r\n }\r\n break;\r\n }\r\n default:\r\n {\r\n rs.errcode = _error_1.EErrorCode.Account_Type_Error;\r\n return rs;\r\n }\r\n }\r\n am.password = password;\r\n am.create_time = Date.now();\r\n am.create_ip = ip;\r\n am.login_time = Date.now();\r\n am.login_ip = ip;\r\n am.id = await this.getNextId();\r\n let rs_am = await this.insert(am);\r\n if (!rs_am.rs.insertedId) {\r\n rs.errcode = _error_1.EErrorCode.Mysql_Error;\r\n return rs;\r\n }\r\n let user = await MongoUserService_1.GUserSer.add(am.id, extra.nickname, extra.sex, extra.logo);\r\n if (!user) {\r\n this.deleteOne({ id: am.id });\r\n rs.errcode = _error_1.EErrorCode.User_Create_Failed;\r\n return rs;\r\n }\r\n rs.user = user;\r\n return rs;\r\n }\r\n}\r\nexports.AccountService = AccountService;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Service/MongoAccountService.js?");
|
|
670
|
+
|
|
671
|
+
/***/ }),
|
|
672
|
+
|
|
673
|
+
/***/ "./dist/lib/Service/MongoCacheService.js":
|
|
674
|
+
/*!***********************************************!*\
|
|
675
|
+
!*** ./dist/lib/Service/MongoCacheService.js ***!
|
|
676
|
+
\***********************************************/
|
|
677
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
678
|
+
|
|
679
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GMongoCacheSer = exports.MongoCacheModel = void 0;\r\nconst MongoBaseService_1 = __webpack_require__(/*! ../Database/MongoBaseService */ \"./dist/lib/Database/MongoBaseService.js\");\r\nconst MongoManager_1 = __webpack_require__(/*! ../Database/MongoManager */ \"./dist/lib/Database/MongoManager.js\");\r\n//暂时就用这个了,反正没啥用户\r\nclass MongoCacheModel extends MongoManager_1.MongoBaseModel {\r\n key = \"\";\r\n data = null;\r\n expireAt = Date.now() + 365 * 24 * 60 * 60 * 1000;\r\n}\r\nexports.MongoCacheModel = MongoCacheModel;\r\nexports.GMongoCacheSer = null;\r\nclass MongoCacheService extends MongoBaseService_1.MongoBaseService {\r\n constructor() {\r\n super(\"cache\", MongoCacheModel);\r\n this.createIndex({ \"expireAt\": 1 }, { expireAfterSeconds: 0 });\r\n }\r\n async getData(key) {\r\n let cm = await exports.GMongoCacheSer.get(null, { key: key });\r\n if (!cm) {\r\n return null;\r\n }\r\n return cm.data;\r\n }\r\n}\r\nexports.GMongoCacheSer = new MongoCacheService();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Service/MongoCacheService.js?");
|
|
680
|
+
|
|
681
|
+
/***/ }),
|
|
682
|
+
|
|
683
|
+
/***/ "./dist/lib/Service/MongoUserService.js":
|
|
684
|
+
/*!**********************************************!*\
|
|
685
|
+
!*** ./dist/lib/Service/MongoUserService.js ***!
|
|
686
|
+
\**********************************************/
|
|
687
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
688
|
+
|
|
689
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.UserService = exports.GUserSer = exports.UserModel = void 0;\r\nconst _ = __webpack_require__(/*! underscore */ \"underscore\");\r\nconst MongoBaseService_1 = __webpack_require__(/*! ../Database/MongoBaseService */ \"./dist/lib/Database/MongoBaseService.js\");\r\nconst MongoManager_1 = __webpack_require__(/*! ../Database/MongoManager */ \"./dist/lib/Database/MongoManager.js\");\r\nconst ini_1 = __webpack_require__(/*! ./ini */ \"./dist/lib/Service/ini.js\");\r\nclass UserModel extends MongoManager_1.MongoBaseModel {\r\n id = -1;\r\n account_id = -1;\r\n nickname = \"\";\r\n sex = -1;\r\n logo = \"\";\r\n state = 0;\r\n role_group = 4;\r\n role = 0;\r\n phone = \"\";\r\n wechat = \"\";\r\n qq = \"\";\r\n email = \"\";\r\n about = \"\";\r\n pre_user_id = -1;\r\n exp = 0;\r\n level = 1; //等级\r\n vip_exp = 0;\r\n vip_level = 0; //等级\r\n is_robot = 0;\r\n create_time = 0;\r\n}\r\nexports.UserModel = UserModel;\r\n//暂时不实例化,方便重写\r\nexports.GUserSer = null;\r\nclass UserService extends MongoBaseService_1.MongoBaseService {\r\n constructor(type) {\r\n super(\"user\", type);\r\n exports.GUserSer = this;\r\n }\r\n _newUserModel() {\r\n return (new UserModel());\r\n }\r\n async _createNewUser(account_id, nickname, sex, logo, group) {\r\n group = group || ini_1.ERoleGroup.Common;\r\n let um = this._newUserModel();\r\n um.account_id = account_id;\r\n um.nickname = nickname;\r\n if (!um.nickname || um.nickname.length == 0) {\r\n um.nickname = \"noname\";\r\n }\r\n um.sex = sex || 0;\r\n um.logo = logo || \"\";\r\n um.account_id = account_id;\r\n um.state = 0;\r\n um.role_group = group;\r\n um.role = 0;\r\n //随机userid\r\n let id = 0;\r\n do {\r\n id = _.random(1000000, 9999999);\r\n let p = await this.get({ id: 1 }, { id: id });\r\n if (!p) {\r\n break;\r\n }\r\n } while (true);\r\n um.id = id;\r\n return um;\r\n }\r\n async add(account_id, nickname, sex, logo, group) {\r\n let um = await this._createNewUser(account_id, nickname, sex, logo, group);\r\n let rs = await this.insert(um);\r\n if (rs.errcode || !rs.rs.insertedId) {\r\n return null;\r\n }\r\n um._id = rs.rs.insertedId;\r\n return um;\r\n }\r\n async getByAccountId(account_id) {\r\n let pm = await this.get(null, { account_id: account_id });\r\n return pm;\r\n }\r\n async updateBaseInfoByAccount(account_id, nickname, sex, logo) {\r\n let model = {\r\n nickname: nickname,\r\n sex: sex,\r\n logo: logo\r\n };\r\n let sr = await this.updateOne(model, { account_id: account_id });\r\n if (sr.errcode) {\r\n return \"更新失败\";\r\n }\r\n return;\r\n }\r\n}\r\nexports.UserService = UserService;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Service/MongoUserService.js?");
|
|
690
|
+
|
|
691
|
+
/***/ }),
|
|
692
|
+
|
|
693
|
+
/***/ "./dist/lib/Service/UserService.js":
|
|
694
|
+
/*!*****************************************!*\
|
|
695
|
+
!*** ./dist/lib/Service/UserService.js ***!
|
|
696
|
+
\*****************************************/
|
|
697
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
698
|
+
|
|
699
|
+
eval("\r\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.UserService = exports.GUserSer = exports.UserModel = void 0;\r\nconst _ = __webpack_require__(/*! underscore */ \"underscore\");\r\nconst MysqlBaseService_1 = __webpack_require__(/*! ../Database/MysqlBaseService */ \"./dist/lib/Database/MysqlBaseService.js\");\r\nconst PrimaryKey_1 = __webpack_require__(/*! ../Database/Decorator/PrimaryKey */ \"./dist/lib/Database/Decorator/PrimaryKey.js\");\r\nconst NotNull_1 = __webpack_require__(/*! ../Database/Decorator/NotNull */ \"./dist/lib/Database/Decorator/NotNull.js\");\r\nconst Property_1 = __webpack_require__(/*! ../Database/Decorator/Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nconst Type_1 = __webpack_require__(/*! ../Database/Decorator/Type */ \"./dist/lib/Database/Decorator/Type.js\");\r\nconst ini_1 = __webpack_require__(/*! ./ini */ \"./dist/lib/Service/ini.js\");\r\nclass UserModel extends MysqlBaseService_1.BaseModel {\r\n id = -1;\r\n account_id = -1;\r\n nickname = \"\";\r\n sex = -1;\r\n logo = \"\";\r\n state = ini_1.EUserState.Waitting;\r\n role_group = 4;\r\n role = 0;\r\n phone = \"\";\r\n wechat = \"\";\r\n qq = \"\";\r\n email = \"\";\r\n about = \"\";\r\n pre_user_id = -1;\r\n exp = 0;\r\n level = 1; //等级\r\n vip_exp = 0;\r\n vip_level = 0; //等级\r\n is_robot = 0;\r\n create_time = 0;\r\n}\r\n__decorate([\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int),\r\n NotNull_1.NotNull,\r\n PrimaryKey_1.PrimaryKey\r\n], UserModel.prototype, \"id\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, -1)\r\n], UserModel.prototype, \"account_id\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"noname\", 32)\r\n], UserModel.prototype, \"nickname\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.SmallInt, 0)\r\n], UserModel.prototype, \"sex\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"\", 255)\r\n], UserModel.prototype, \"logo\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, 0)\r\n], UserModel.prototype, \"state\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, 4)\r\n], UserModel.prototype, \"role_group\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, 0)\r\n], UserModel.prototype, \"role\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"\")\r\n], UserModel.prototype, \"phone\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"\")\r\n], UserModel.prototype, \"wechat\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"\")\r\n], UserModel.prototype, \"qq\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"\")\r\n], UserModel.prototype, \"email\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Varchar, \"\", 512)\r\n], UserModel.prototype, \"about\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, -1)\r\n], UserModel.prototype, \"pre_user_id\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, 0)\r\n], UserModel.prototype, \"exp\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, 1)\r\n], UserModel.prototype, \"level\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, 0)\r\n], UserModel.prototype, \"vip_exp\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.Int, 0)\r\n], UserModel.prototype, \"vip_level\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.TinyInt, 0)\r\n], UserModel.prototype, \"is_robot\", void 0);\r\n__decorate([\r\n NotNull_1.NotNull,\r\n (0, Type_1.Type)(Property_1.EPropertyType.BigInt, 0)\r\n], UserModel.prototype, \"create_time\", void 0);\r\nexports.UserModel = UserModel;\r\n//暂时不实例化,方便重写\r\nexports.GUserSer = null;\r\nclass UserService extends MysqlBaseService_1.MysqlBaseService {\r\n constructor(type) {\r\n super(type);\r\n exports.GUserSer = this;\r\n }\r\n _newUserModel() {\r\n return (new UserModel());\r\n }\r\n async _createNewUser(account_id, nickname, sex, logo, group) {\r\n group = group || ini_1.ERoleGroup.Common;\r\n let um = this._newUserModel();\r\n um.account_id = account_id;\r\n um.nickname = nickname;\r\n if (!um.nickname || um.nickname.length == 0) {\r\n um.nickname = \"noname\";\r\n }\r\n um.sex = sex || 0;\r\n um.logo = logo || \"\";\r\n um.account_id = account_id;\r\n um.state = ini_1.EUserState.Waitting;\r\n um.role_group = group;\r\n um.role = 0;\r\n //随机userid\r\n let id = 0;\r\n do {\r\n id = _.random(1000000, 9999999);\r\n let p = await this.get(\"id\", \"id=?\", [id]);\r\n if (!p) {\r\n break;\r\n }\r\n } while (true);\r\n um.id = id;\r\n return um;\r\n }\r\n async updateBaseInfoByAccount(account_id, nickname, sex, logo) {\r\n let sr = await this.updateProperty(\"nickname=?,sex=?,logo=?\", \"account_id=?\", [nickname, sex, logo, account_id]);\r\n if (sr.error && sr.results.affectedRows <= 0) {\r\n return \"更新失败\";\r\n }\r\n return;\r\n }\r\n async add(account_id, nickname, sex, logo, group) {\r\n let um = await this._createNewUser(account_id, nickname, sex, logo, group);\r\n let sr = await this.insert(um);\r\n if (sr.error || sr.results.length <= 0) {\r\n return null;\r\n }\r\n return um;\r\n }\r\n async updateRoleGroup(user_id, role_group) {\r\n let sr = await this.updateProperty(\"role_group=?\", \"id=?\", [role_group, user_id]);\r\n if (sr.error && sr.results.affectedRows <= 0) {\r\n return \"更新失败\";\r\n }\r\n return;\r\n }\r\n async getByAccountId(account_id) {\r\n let pm = await this.get(null, \"account_id=?\", [account_id]);\r\n return pm;\r\n }\r\n}\r\nexports.UserService = UserService;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Service/UserService.js?");
|
|
700
|
+
|
|
701
|
+
/***/ }),
|
|
702
|
+
|
|
703
|
+
/***/ "./dist/lib/Service/ini.js":
|
|
704
|
+
/*!*********************************!*\
|
|
705
|
+
!*** ./dist/lib/Service/ini.js ***!
|
|
706
|
+
\*********************************/
|
|
707
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
708
|
+
|
|
709
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.EAccountFrom = exports.EAccountState = exports.EUserState = exports.ERoleGroup = void 0;\r\nvar ERoleGroup;\r\n(function (ERoleGroup) {\r\n ERoleGroup[ERoleGroup[\"Creator\"] = 1] = \"Creator\";\r\n ERoleGroup[ERoleGroup[\"Admin\"] = 2] = \"Admin\";\r\n ERoleGroup[ERoleGroup[\"Proxy\"] = 3] = \"Proxy\";\r\n ERoleGroup[ERoleGroup[\"Common\"] = 4] = \"Common\"; //普通成员\r\n})(ERoleGroup = exports.ERoleGroup || (exports.ERoleGroup = {}));\r\nvar EUserState;\r\n(function (EUserState) {\r\n EUserState[EUserState[\"Ban\"] = -1] = \"Ban\";\r\n EUserState[EUserState[\"Waitting\"] = 0] = \"Waitting\";\r\n EUserState[EUserState[\"Normarl\"] = 1] = \"Normarl\";\r\n})(EUserState = exports.EUserState || (exports.EUserState = {}));\r\nvar EAccountState;\r\n(function (EAccountState) {\r\n EAccountState[EAccountState[\"Delete\"] = -2] = \"Delete\";\r\n EAccountState[EAccountState[\"Ban\"] = -1] = \"Ban\";\r\n EAccountState[EAccountState[\"Waitting\"] = 0] = \"Waitting\";\r\n EAccountState[EAccountState[\"Normarl\"] = 1] = \"Normarl\";\r\n})(EAccountState = exports.EAccountState || (exports.EAccountState = {}));\r\nvar EAccountFrom;\r\n(function (EAccountFrom) {\r\n EAccountFrom[EAccountFrom[\"Guest\"] = 0] = \"Guest\";\r\n EAccountFrom[EAccountFrom[\"OpenSocial\"] = 1] = \"OpenSocial\";\r\n EAccountFrom[EAccountFrom[\"WeChat\"] = 2] = \"WeChat\";\r\n EAccountFrom[EAccountFrom[\"QQ\"] = 3] = \"QQ\";\r\n EAccountFrom[EAccountFrom[\"Phone\"] = 4] = \"Phone\";\r\n EAccountFrom[EAccountFrom[\"Email\"] = 5] = \"Email\";\r\n EAccountFrom[EAccountFrom[\"Name\"] = 6] = \"Name\";\r\n EAccountFrom[EAccountFrom[\"QuickPhone\"] = 7] = \"QuickPhone\";\r\n EAccountFrom[EAccountFrom[\"Apple\"] = 8] = \"Apple\";\r\n EAccountFrom[EAccountFrom[\"Google\"] = 9] = \"Google\";\r\n})(EAccountFrom = exports.EAccountFrom || (exports.EAccountFrom = {}));\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/Service/ini.js?");
|
|
710
|
+
|
|
711
|
+
/***/ }),
|
|
712
|
+
|
|
713
|
+
/***/ "./dist/lib/SocketServer/IClientWebSocket.js":
|
|
714
|
+
/*!***************************************************!*\
|
|
715
|
+
!*** ./dist/lib/SocketServer/IClientWebSocket.js ***!
|
|
716
|
+
\***************************************************/
|
|
717
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
718
|
+
|
|
719
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.IClientWebSocket = void 0;\r\nconst IWebSocket_1 = __webpack_require__(/*! ./IWebSocket */ \"./dist/lib/SocketServer/IWebSocket.js\");\r\nconst ws = __webpack_require__(/*! websocket */ \"websocket\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst IProtoFilter_1 = __webpack_require__(/*! ./ProtoFilter/IProtoFilter */ \"./dist/lib/SocketServer/ProtoFilter/IProtoFilter.js\");\r\nclass IClientWebSocket extends IWebSocket_1.IWebSocket {\r\n _host = \"\";\r\n /**\r\n * 连接的服务器地址\r\n */\r\n get host() {\r\n return this._host;\r\n }\r\n _port = \"\";\r\n /**\r\n * 连接的服务器端口\r\n */\r\n get port() {\r\n return this._port;\r\n }\r\n _need_close = false;\r\n constructor(protoType = IProtoFilter_1.EProtoType.Json, protoPath = \"\") {\r\n super(protoType, protoPath);\r\n }\r\n connect(domain, port) {\r\n this._host = domain || this._host;\r\n this._port = port || this._port;\r\n this._connect();\r\n }\r\n _connect() {\r\n let url = \"ws://\" + this._host + \":\" + this._port + \"/\";\r\n Log_1.GLog.info(\"Trying to connect to server : \" + url);\r\n let _ws = new ws.client();\r\n _ws.on(\"connect\", super.onConnect.bind(this));\r\n _ws.on(\"connectFailed\", this.onClose.bind(this));\r\n _ws.connect(url, null, null, { cookie: \"client=\" + this._tipKey });\r\n }\r\n onOpen(e) {\r\n super.onOpen(e);\r\n Log_1.GLog.info(\"success to connect to \" + this._host + \":\" + this._port);\r\n }\r\n onClose(reasonCode, description) {\r\n super.onClose(reasonCode, description);\r\n if (!this._need_close) {\r\n setTimeout(() => {\r\n if (!this._need_close) {\r\n this.connect(this._host, this._port);\r\n }\r\n }, 1000);\r\n return true;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n close() {\r\n this._need_close = true;\r\n super.close();\r\n }\r\n _onDecode(message, ...params) {\r\n let msg = super._onDecode(message, \"msgRes\");\r\n return msg;\r\n }\r\n _onEncode(data, ...params) {\r\n let msg = super._onEncode(data, \"msgReq\");\r\n return msg;\r\n }\r\n}\r\nexports.IClientWebSocket = IClientWebSocket;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/SocketServer/IClientWebSocket.js?");
|
|
720
|
+
|
|
721
|
+
/***/ }),
|
|
722
|
+
|
|
723
|
+
/***/ "./dist/lib/SocketServer/IServerWebSocket.js":
|
|
724
|
+
/*!***************************************************!*\
|
|
725
|
+
!*** ./dist/lib/SocketServer/IServerWebSocket.js ***!
|
|
726
|
+
\***************************************************/
|
|
727
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
728
|
+
|
|
729
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.IServerWebSocket = void 0;\r\nconst IWebSocket_1 = __webpack_require__(/*! ./IWebSocket */ \"./dist/lib/SocketServer/IWebSocket.js\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst IProtoFilter_1 = __webpack_require__(/*! ./ProtoFilter/IProtoFilter */ \"./dist/lib/SocketServer/ProtoFilter/IProtoFilter.js\");\r\nclass IServerWebSocket extends IWebSocket_1.IWebSocket {\r\n _server = null;\r\n get server() {\r\n return this._server;\r\n }\r\n constructor(server, protoType = IProtoFilter_1.EProtoType.Json, protoPath = \"\") {\r\n super(protoType, protoPath);\r\n this._server = server;\r\n this._tipKey = this._server.name;\r\n }\r\n onClose(reasonCode, description) {\r\n super.onClose(reasonCode, description);\r\n this._server.removeServerWebSocketBySocketId(this._socket_id);\r\n }\r\n broadCast(data) {\r\n let serverWS = this._server.serverWebSocket;\r\n if (!data) {\r\n Log_1.GLog.info(\"Send Message warning:null data!\");\r\n return;\r\n }\r\n Log_1.GLog.info(\"broadCast:----------------------------------\");\r\n Log_1.GLog.info(data);\r\n let msg = this._protoFilter.encode(data);\r\n serverWS.broadcast(msg);\r\n }\r\n _onDecode(message, ...params) {\r\n let msg = super._onDecode(message, \"msgReq\");\r\n return msg;\r\n }\r\n _onEncode(data, ...params) {\r\n let msg = super._onEncode(data, \"msgRes\");\r\n return msg;\r\n }\r\n}\r\nexports.IServerWebSocket = IServerWebSocket;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/SocketServer/IServerWebSocket.js?");
|
|
730
|
+
|
|
731
|
+
/***/ }),
|
|
732
|
+
|
|
733
|
+
/***/ "./dist/lib/SocketServer/ISocketServer.js":
|
|
734
|
+
/*!************************************************!*\
|
|
735
|
+
!*** ./dist/lib/SocketServer/ISocketServer.js ***!
|
|
736
|
+
\************************************************/
|
|
737
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
738
|
+
|
|
739
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ISocketServer = void 0;\r\nconst MysqlManager_1 = __webpack_require__(/*! ../Database/MysqlManager */ \"./dist/lib/Database/MysqlManager.js\");\r\nconst RedisManager_1 = __webpack_require__(/*! ../Database/RedisManager */ \"./dist/lib/Database/RedisManager.js\");\r\nconst ws = __webpack_require__(/*! websocket */ \"websocket\");\r\nconst Log_1 = __webpack_require__(/*! ./../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst http = __webpack_require__(/*! http */ \"http\");\r\nconst https = __webpack_require__(/*! https */ \"https\");\r\nconst MongoManager_1 = __webpack_require__(/*! ../Database/MongoManager */ \"./dist/lib/Database/MongoManager.js\");\r\nconst MSSqlManager_1 = __webpack_require__(/*! ../Database/MSSqlManager */ \"./dist/lib/Database/MSSqlManager.js\");\r\nconst EventTool_1 = __webpack_require__(/*! ../Logic/EventTool */ \"./dist/lib/Logic/EventTool.js\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nconst cgserver_1 = __webpack_require__(/*! ../cgserver */ \"./dist/lib/cgserver.js\");\r\nclass ISocketServer {\r\n //服务器已被关闭\r\n _is_closed = false;\r\n get isClosed() {\r\n return this._is_closed;\r\n }\r\n _code = -1; //服务器唯一编码\r\n get code() {\r\n return this._code;\r\n }\r\n set code(value) {\r\n this._code = value;\r\n }\r\n _name = \"\";\r\n get name() {\r\n return this._name;\r\n }\r\n get fullServerName() {\r\n return this._name + \"@\" + this._code;\r\n }\r\n //监听websocket\r\n _web_socket = null;\r\n get serverWebSocket() {\r\n return this._web_socket;\r\n }\r\n //来自于用户的链接\r\n _ws_clients = {};\r\n _listen_port = 0;\r\n get listenPort() {\r\n return this._listen_port;\r\n }\r\n set listenPort(value) {\r\n this._listen_port = value;\r\n }\r\n /**\r\n * websocket can accepted protocol\r\n */\r\n _accepted_protocol = null;\r\n //服务器管理相关\r\n /*\r\n item=servername:class\r\n */\r\n _name_vs_class = {};\r\n registerWebSocketHandleClass(name, cls) {\r\n if (!name || name == \"\") {\r\n throw \"registerWebSocketHandleClass name must be not null or empty!\";\r\n }\r\n this._name_vs_class[name] = cls;\r\n }\r\n constructor(server_name) {\r\n this._name = server_name;\r\n }\r\n removeServerWebSocketBySocketId(socketId) {\r\n this._ws_clients[socketId] = null;\r\n delete this._ws_clients[socketId];\r\n }\r\n async run() {\r\n cgserver_1.GCgServer.addSocketServer(this);\r\n await MSSqlManager_1.GMSSqlMgr.init();\r\n await MysqlManager_1.GMysqlMgr.init();\r\n await RedisManager_1.GRedisMgr.init(ServerConfig_1.GServerCfg.db.redis);\r\n await MongoManager_1.GMongoMgr.init();\r\n let code = await RedisManager_1.GRedisMgr.incr(\"server_code\");\r\n this._code = code;\r\n this.initWebSocket();\r\n }\r\n stop() {\r\n this._is_closed = true;\r\n this._web_socket.closeAllConnections();\r\n }\r\n /*\r\n 把所有的客户端链接保存起来\r\n 方便统计,广播等\r\n */\r\n addClient(client_server) {\r\n this._ws_clients[client_server.socketId] = client_server;\r\n }\r\n isOriginAllowed(origin) {\r\n return true;\r\n }\r\n initWebSocket(wss) {\r\n let server = null;\r\n if (wss) {\r\n console.log(\"wss:---\");\r\n let options = {\r\n key: fs.readFileSync(\"ssl/ssl2.key\"),\r\n cert: fs.readFileSync(\"ssl/ssl2.crt\"),\r\n //passphrase:'1234'//如果秘钥文件有密码的话,用这个属性设置密码\r\n };\r\n server = https.createServer(options, (request, response) => {\r\n Log_1.GLog.info((new Date()) + 'wss Received request for ' + request.url);\r\n response.writeHead(404);\r\n response.end();\r\n });\r\n }\r\n else {\r\n server = http.createServer((request, response) => {\r\n Log_1.GLog.info((new Date()) + 'ws Received request for ' + request.url);\r\n response.writeHead(404);\r\n response.end();\r\n });\r\n }\r\n server.listen(this._listen_port, this.onListenning.bind(this));\r\n this._web_socket = new ws.server({\r\n httpServer: server,\r\n // You should not use autoAcceptConnections for production \r\n // applications, as it defeats all standard cross-origin protection \r\n // facilities built into the protocol and the browser. You should \r\n // *always* verify the connection's origin and decide whether or not \r\n // to accept it. \r\n autoAcceptConnections: false\r\n });\r\n this._web_socket.on('request', this.onRequest.bind(this));\r\n this._web_socket.on('close', this.onClose.bind(this));\r\n }\r\n onClose(connection, reason, desc) {\r\n }\r\n onListenning() {\r\n EventTool_1.GEventTool.emit(\"socket_server_init_done\");\r\n let info = (new Date()) + \" Server \" + this.fullServerName + \" is listening on port \" + this._listen_port;\r\n Log_1.GLog.info(info);\r\n console.log(info);\r\n }\r\n onRequest(req) {\r\n if (this._is_closed) {\r\n return;\r\n }\r\n let protocol = null;\r\n if (req.requestedProtocols.length > 0) {\r\n protocol = req.requestedProtocols[0];\r\n }\r\n let allowed = this.isOriginAllowed(req.origin);\r\n if (!allowed) {\r\n req.reject();\r\n Log_1.GLog.info(' Connection from origin ' + req.origin + ' rejected.');\r\n return;\r\n }\r\n try {\r\n let conn = req.accept(this._accepted_protocol, req.origin);\r\n if (!conn) {\r\n Log_1.GLog.info(' protocol reject');\r\n return;\r\n }\r\n Log_1.GLog.info((new Date()) + ' Connection accepted.');\r\n let server_name = this._getServerNameByCookies(req.cookies);\r\n this.createWebSocketObjectByProtocol(server_name, conn);\r\n }\r\n catch (e) {\r\n Log_1.GLog.info(' protocol reject');\r\n }\r\n }\r\n createWebSocketObjectByProtocol(server_name, _ws) {\r\n server_name = server_name || \"default\";\r\n let cls = this._name_vs_class[server_name];\r\n if (!cls) {\r\n Log_1.GLog.error(\"(createWebSocketObjectByProtocol in server(\" + this.name + \"))no this websocket handle class=\" + server_name);\r\n return null;\r\n }\r\n let ws_server = (new cls(this));\r\n this.addClient(ws_server);\r\n ws_server.onConnect(_ws);\r\n return ws_server;\r\n }\r\n _getServerNameByCookies(cookies) {\r\n let server_name = \"\";\r\n if (!cookies) {\r\n return server_name;\r\n }\r\n for (let index in cookies) {\r\n let cookie = cookies[index];\r\n if (cookie.name == \"server\") {\r\n server_name = cookie.value;\r\n break;\r\n }\r\n }\r\n return server_name;\r\n }\r\n}\r\nexports.ISocketServer = ISocketServer;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/SocketServer/ISocketServer.js?");
|
|
740
|
+
|
|
741
|
+
/***/ }),
|
|
742
|
+
|
|
743
|
+
/***/ "./dist/lib/SocketServer/IWebSocket.js":
|
|
744
|
+
/*!*********************************************!*\
|
|
745
|
+
!*** ./dist/lib/SocketServer/IWebSocket.js ***!
|
|
746
|
+
\*********************************************/
|
|
747
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
748
|
+
|
|
749
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.IWebSocket = void 0;\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst ProtoFactory_1 = __webpack_require__(/*! ./ProtoFilter/ProtoFactory */ \"./dist/lib/SocketServer/ProtoFilter/ProtoFactory.js\");\r\nconst IProtoFilter_1 = __webpack_require__(/*! ./ProtoFilter/IProtoFilter */ \"./dist/lib/SocketServer/ProtoFilter/IProtoFilter.js\");\r\nconst Core_1 = __webpack_require__(/*! ../Core/Core */ \"./dist/lib/Core/Core.js\");\r\nconst _ = __webpack_require__(/*! underscore */ \"underscore\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nlet WebSocketIdMgr = {\r\n id: _.random(0, 99999999),\r\n getNewID() {\r\n return this.id++;\r\n },\r\n};\r\nclass IWebSocket {\r\n _await = false;\r\n get await() {\r\n return this._await;\r\n }\r\n _debug_msg = false;\r\n get debug_msg() {\r\n return this._debug_msg;\r\n }\r\n set debug_msg(value) {\r\n this._debug_msg = value;\r\n }\r\n _socket_id = 0;\r\n get socketId() {\r\n return this._socket_id;\r\n }\r\n _tipKey = \"\";\r\n get tipKey() {\r\n return this._tipKey;\r\n }\r\n _ws = null;\r\n _protoType = IProtoFilter_1.EProtoType.Json;\r\n _protoFilter = null;\r\n _protoPath = \"\";\r\n _ip = null;\r\n get remoteHost() {\r\n if (!this._ip) {\r\n this._ip = this._ws.remoteAddress;\r\n this._ip = this._ip.substring(this._ip.lastIndexOf(\":\") + 1);\r\n }\r\n return this._ip;\r\n }\r\n get connected() {\r\n if (this._ws\r\n && this._ws.connected == true) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n constructor(protoType = IProtoFilter_1.EProtoType.Json, protoPath = \"\") {\r\n this._debug_msg = ServerConfig_1.GServerCfg.debug_msg;\r\n this._socket_id = WebSocketIdMgr.getNewID();\r\n this._protoType = protoType;\r\n this._protoPath = protoPath;\r\n }\r\n getNewMsg(cmd, errcode) {\r\n let msg = {\r\n cmd: cmd,\r\n errcode: errcode,\r\n servertime: new Date().getTime()\r\n };\r\n return msg;\r\n }\r\n receive_heartbeat(jsonData) {\r\n this.send_heartbeat();\r\n }\r\n send_heartbeat() {\r\n let msg = this.getNewMsg(\"heartbeat\");\r\n this.send(msg);\r\n }\r\n onConnect(_ws) {\r\n this._ws = _ws;\r\n if (!this._protoFilter) {\r\n this._protoFilter = ProtoFactory_1.GProtoFactory.createFilter(this._protoType);\r\n this._protoFilter.init(this._protoPath);\r\n }\r\n this._ws.on(\"message\", this.onMessage.bind(this));\r\n this._ws.on(\"error\", this.onError.bind(this));\r\n this._ws.on(\"close\", this.onClose.bind(this));\r\n this.onOpen();\r\n }\r\n _msgs = [];\r\n onMessage(message) {\r\n try {\r\n let msg = this._onDecode(message);\r\n if (this._await) {\r\n this._msgs.push(msg);\r\n if (!this._run_await) {\r\n this._awaitMessages();\r\n }\r\n }\r\n else {\r\n this._onMessage(msg);\r\n }\r\n }\r\n catch (e) {\r\n Log_1.GLog.error(this.tipKey + ' Received Message Handle Error: ' + e);\r\n }\r\n }\r\n _onDecode(message, ...params) {\r\n let msg = null;\r\n if (message.type === 'utf8') {\r\n msg = this._protoFilter.decode(message.utf8Data, ...params);\r\n }\r\n else if (message.type === 'binary') {\r\n msg = this._protoFilter.decode(message.binaryData, ...params);\r\n }\r\n return msg;\r\n }\r\n _onEncode(data, ...params) {\r\n let msg = this._protoFilter.encode(data, ...params);\r\n return msg;\r\n }\r\n _run_await = false;\r\n async _awaitMessages() {\r\n this._run_await = true;\r\n while (this._msgs.length > 0) {\r\n let msg = this._msgs.shift();\r\n await this._onMessage(msg);\r\n }\r\n this._run_await = false;\r\n }\r\n /**\r\n * 过滤消息,每个消息处理之前调用\r\n * @param jsonData\r\n * @returns\r\n */\r\n filterMsg(jsonData) {\r\n if (this._debug_msg\r\n && jsonData\r\n && jsonData.cmd != \"heartbeat\") {\r\n Log_1.GLog.info(this.tipKey + \" receive:--------\");\r\n Log_1.GLog.info({ tipKey: this.tipKey, jsonData });\r\n }\r\n if (!jsonData.cmd || jsonData.cmd == \"\") {\r\n Log_1.GLog.error(this.tipKey + ' Received Message warning: no cmd param,data=');\r\n Log_1.GLog.error({ tipKey: this.tipKey, jsonData });\r\n return false;\r\n }\r\n return true;\r\n }\r\n async _onMessage(data) {\r\n let jsonData = data;\r\n let func = this[\"receive_\" + jsonData.cmd];\r\n let ret = this.filterMsg(jsonData);\r\n if (!ret) {\r\n return;\r\n }\r\n else if (!func) {\r\n let otherfunc = this[\"receive_other_all\"];\r\n if (otherfunc) {\r\n try {\r\n if (Core_1.core.isAsyncFunc(otherfunc)) {\r\n //默认支持其他所有处理消息\r\n await otherfunc.call(this, jsonData).catch((reason) => {\r\n Log_1.GLog.error(reason);\r\n });\r\n }\r\n else {\r\n otherfunc.call(this, jsonData);\r\n }\r\n }\r\n catch (e) {\r\n Log_1.GLog.error(this.tipKey + e.stack);\r\n }\r\n }\r\n else {\r\n Log_1.GLog.error(this.tipKey + ' Received Message warning: no cmd handle,cmd=' + jsonData.cmd);\r\n }\r\n }\r\n else {\r\n try {\r\n if (Core_1.core.isAsyncFunc(func)) {\r\n //默认支持其他所有处理消息\r\n await func.call(this, jsonData).catch((reason) => {\r\n Log_1.GLog.error(reason);\r\n });\r\n }\r\n else {\r\n func.call(this, jsonData);\r\n }\r\n }\r\n catch (e) {\r\n Log_1.GLog.error(this.tipKey + \" error msg:data=\" + JSON.stringify(jsonData) + \"\\n\" + e.stack);\r\n }\r\n }\r\n }\r\n onOpen(e) {\r\n }\r\n onError(e) {\r\n }\r\n onClose(reasonCode, description) {\r\n Log_1.GLog.info(this.tipKey + \" onClose resonCode=\" + reasonCode + \" des=\" + description);\r\n }\r\n send(data) {\r\n if (!this.connected) {\r\n return;\r\n }\r\n if (!data) {\r\n Log_1.GLog.error(this.tipKey + \" Send Message warning:null data!\");\r\n return;\r\n }\r\n if (this._debug_msg\r\n && data.cmd != \"heartbeat\") {\r\n Log_1.GLog.info(this.tipKey + \" send:-----------------------------------\");\r\n Log_1.GLog.info({ tipKey: this.tipKey, data });\r\n }\r\n let msg = this._onEncode(data);\r\n this._ws.send(msg);\r\n }\r\n close() {\r\n this._ws.close();\r\n }\r\n getServerNameFromCmd(cmd) {\r\n if (!cmd || !Core_1.core.isString(cmd)) {\r\n return null;\r\n }\r\n let index = cmd.indexOf(\"_\");\r\n if (index <= 0) {\r\n return null;\r\n }\r\n return cmd.substring(0, index);\r\n }\r\n}\r\nexports.IWebSocket = IWebSocket;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/SocketServer/IWebSocket.js?");
|
|
750
|
+
|
|
751
|
+
/***/ }),
|
|
752
|
+
|
|
753
|
+
/***/ "./dist/lib/SocketServer/ProtoFilter/GoogleProtoFilter.js":
|
|
754
|
+
/*!****************************************************************!*\
|
|
755
|
+
!*** ./dist/lib/SocketServer/ProtoFilter/GoogleProtoFilter.js ***!
|
|
756
|
+
\****************************************************************/
|
|
757
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
758
|
+
|
|
759
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GoogleProtoFilter = void 0;\r\nconst Log_1 = __webpack_require__(/*! ../../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst protobufjs = __webpack_require__(/*! protobufjs */ \"protobufjs\");\r\nclass GoogleProtoFilter {\r\n _root = new protobufjs.Root();\r\n _inited = false;\r\n init(path) {\r\n if (this._inited) {\r\n return;\r\n }\r\n this._inited = true;\r\n try {\r\n this._root.loadSync(path, { keepCase: true });\r\n }\r\n catch (e) {\r\n Log_1.GLog.error(e);\r\n return false;\r\n }\r\n return true;\r\n }\r\n encode(data, root) {\r\n let msg = { cmd: data.cmd };\r\n msg[msg.cmd] = data;\r\n msg[msg.cmd].cmd = undefined;\r\n msg[\"errcode\"] = data.errcode;\r\n msg[\"tip\"] = data.tip;\r\n data.errcode = undefined;\r\n delete data.errcode;\r\n delete msg[msg.cmd].cmd;\r\n let body = this._root.lookupType(root);\r\n var errMsg = body.verify(msg);\r\n if (errMsg)\r\n throw Error(errMsg);\r\n var msgBody = body.create(msg);\r\n var bufferBody = body.encode(msgBody).finish();\r\n return bufferBody;\r\n }\r\n decode(data, root) {\r\n let body = this._root.lookupType(root);\r\n if (!body) {\r\n Log_1.GLog.info(\"proto body not in proto(!\" + root + \")\");\r\n return null;\r\n }\r\n let msgBody = body.decode(data);\r\n if (!msgBody) {\r\n Log_1.GLog.info(\"proto body decode wrong!\");\r\n return null;\r\n }\r\n let objBody = body.toObject(msgBody);\r\n let obj = objBody[objBody.cmd];\r\n obj.cmd = objBody.cmd;\r\n return obj;\r\n }\r\n}\r\nexports.GoogleProtoFilter = GoogleProtoFilter;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/SocketServer/ProtoFilter/GoogleProtoFilter.js?");
|
|
760
|
+
|
|
761
|
+
/***/ }),
|
|
762
|
+
|
|
763
|
+
/***/ "./dist/lib/SocketServer/ProtoFilter/IProtoFilter.js":
|
|
764
|
+
/*!***********************************************************!*\
|
|
765
|
+
!*** ./dist/lib/SocketServer/ProtoFilter/IProtoFilter.js ***!
|
|
766
|
+
\***********************************************************/
|
|
767
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
768
|
+
|
|
769
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.EProtoType = void 0;\r\nvar EProtoType;\r\n(function (EProtoType) {\r\n EProtoType[EProtoType[\"Json\"] = 1] = \"Json\";\r\n EProtoType[EProtoType[\"GoogleProtoBuffer\"] = 2] = \"GoogleProtoBuffer\";\r\n})(EProtoType = exports.EProtoType || (exports.EProtoType = {}));\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/SocketServer/ProtoFilter/IProtoFilter.js?");
|
|
770
|
+
|
|
771
|
+
/***/ }),
|
|
772
|
+
|
|
773
|
+
/***/ "./dist/lib/SocketServer/ProtoFilter/JsonProtoFilter.js":
|
|
774
|
+
/*!**************************************************************!*\
|
|
775
|
+
!*** ./dist/lib/SocketServer/ProtoFilter/JsonProtoFilter.js ***!
|
|
776
|
+
\**************************************************************/
|
|
777
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
778
|
+
|
|
779
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.JsonProtoFilter = void 0;\r\nconst Core_1 = __webpack_require__(/*! ../../Core/Core */ \"./dist/lib/Core/Core.js\");\r\nconst Log_1 = __webpack_require__(/*! ../../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nclass JsonProtoFilter {\r\n init(path) {\r\n return true;\r\n }\r\n encode(data) {\r\n if (!Core_1.core.isString(data)) {\r\n data = JSON.stringify(data);\r\n }\r\n return data;\r\n }\r\n decode(data) {\r\n try {\r\n if (Core_1.core.isString(data)) {\r\n data = JSON.parse(data);\r\n }\r\n }\r\n catch (e) {\r\n Log_1.GLog.error(\"decode json data Failed-----data=\" + data);\r\n return;\r\n }\r\n return data;\r\n }\r\n}\r\nexports.JsonProtoFilter = JsonProtoFilter;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/SocketServer/ProtoFilter/JsonProtoFilter.js?");
|
|
780
|
+
|
|
781
|
+
/***/ }),
|
|
782
|
+
|
|
783
|
+
/***/ "./dist/lib/SocketServer/ProtoFilter/ProtoFactory.js":
|
|
784
|
+
/*!***********************************************************!*\
|
|
785
|
+
!*** ./dist/lib/SocketServer/ProtoFilter/ProtoFactory.js ***!
|
|
786
|
+
\***********************************************************/
|
|
787
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
788
|
+
|
|
789
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GProtoFactory = void 0;\r\nconst GoogleProtoFilter_1 = __webpack_require__(/*! ./GoogleProtoFilter */ \"./dist/lib/SocketServer/ProtoFilter/GoogleProtoFilter.js\");\r\nconst JsonProtoFilter_1 = __webpack_require__(/*! ./JsonProtoFilter */ \"./dist/lib/SocketServer/ProtoFilter/JsonProtoFilter.js\");\r\nconst IProtoFilter_1 = __webpack_require__(/*! ./IProtoFilter */ \"./dist/lib/SocketServer/ProtoFilter/IProtoFilter.js\");\r\nexports.GProtoFactory = null;\r\nclass ProtoFactory {\r\n _filters = new Map();\r\n createFilter(type) {\r\n let filter = this._filters.get(type);\r\n if (filter) {\r\n return filter;\r\n }\r\n switch (type) {\r\n case IProtoFilter_1.EProtoType.GoogleProtoBuffer:\r\n {\r\n filter = new GoogleProtoFilter_1.GoogleProtoFilter();\r\n break;\r\n }\r\n default:\r\n {\r\n filter = new JsonProtoFilter_1.JsonProtoFilter();\r\n break;\r\n }\r\n }\r\n this._filters.set(type, filter);\r\n return filter;\r\n }\r\n}\r\nexports.GProtoFactory = new ProtoFactory();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/SocketServer/ProtoFilter/ProtoFactory.js?");
|
|
790
|
+
|
|
791
|
+
/***/ }),
|
|
792
|
+
|
|
793
|
+
/***/ "./dist/lib/ThirdParty/AlipayTool.js":
|
|
794
|
+
/*!*******************************************!*\
|
|
795
|
+
!*** ./dist/lib/ThirdParty/AlipayTool.js ***!
|
|
796
|
+
\*******************************************/
|
|
797
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
798
|
+
|
|
799
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GAlipayTool = exports.AlipayCallBack = exports.AlipayResult = void 0;\r\nconst alipay_sdk_1 = __webpack_require__(/*! alipay-sdk */ \"alipay-sdk\");\r\nconst aliUtil = __webpack_require__(/*! alipay-sdk/lib/util */ \"alipay-sdk/lib/util\");\r\nconst AliPayUtil_1 = __webpack_require__(/*! alipay_sdk2/AliPayUtil */ \"alipay_sdk2/AliPayUtil\");\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst form_1 = __webpack_require__(/*! alipay-sdk/lib/form */ \"alipay-sdk/lib/form\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nclass AlipayResult {\r\n alipay_trade_app_pay_response = {\r\n code: \"10000\",\r\n msg: \"Success\",\r\n app_id: \"2021003143637369\",\r\n auth_app_id: \"2021003143637369\",\r\n charset: \"utf-8\",\r\n timestamp: \"2022-08-10 16:38:04\",\r\n out_trade_no: \"62f36e657a355ecc1cb8eec2\",\r\n total_amount: \"0.05\",\r\n trade_no: \"2022081022001489431433911625\",\r\n seller_id: \"2088441785429273\"\r\n };\r\n sign = \"d/Guf6QYnuk9fFlRS1EUFTY+n3/jQKp7IwQENG4WXO+qxMGglPXa3RhUHaJELTMwC4tcKhz8Z8GCiiI1Y7G84kAql1jyoekaOMWvdPRDOjkAqouP3oh5v9r23BziJUxgv/kanBRfOoTKvIT7R0L5DyfxMpEoHdssPHAtENMiniCVZlRUkAhHxjmgMrP0rzMtBvqctC5Me6UiV1yBdGWecLk9RNwMTZF8QSXKVpWXmhmimdjjFjGMcE6r7LoV9YW1Bsvjoq2kdRMX7CJZufGk1Y5Qz8Cv+E9QxTnDJMtA0XyYzte53/dSw0W3Z4Gbosn/kV4QDBRzN39NwwuoFwGuVg==\";\r\n sign_type = \"RSA2\";\r\n}\r\nexports.AlipayResult = AlipayResult;\r\nclass AlipayCallBack {\r\n gmt_create = \"2022-08-10 16=38=03\";\r\n charset = \"utf-8\";\r\n seller_email = \"zdpuke@163.com\";\r\n subject = \"一把砖石\";\r\n sign = \"gytkeBGeea9V05lI6Qvvut8CZnXtXJmbb0dMDd76a6fgN2k2IO0HH4wkJylMQG3EXYJQctysURDtIB0dhqaZbDVtePsM3iQVeI2jwT3YS3XGS4xi13k8foag9vCcSgojKjxJS3ihfzuyK/Pc+KDTOQftoWP2s1dPUpJNGLcZp4sUFysl0Iyzf+2vXh4OJUPQ3DvCqePnDUawq1+AUUj63WHWvdsGCP70+eTsbKxJxWBhHfMVrwkOmUI0zivcHpHLVHbfTFvaM5LAa/ivSU8jiDHqgHYFZqqzTyZ1DLxEy0Ypo3sKBs5eK/UhdsNf5tjse7PxYJwMU2ziIo9gnqv6fQ==\";\r\n buyer_id = 2088202482689432;\r\n invoice_amount = \"0.05\";\r\n notify_id = 2.022081000222164e+33;\r\n fund_bill_list = [{ amount: \"0.05\", fundChannel: \"PCREDIT\" }];\r\n notify_type = \"trade_status_sync\";\r\n trade_status = \"TRADE_SUCCESS\";\r\n receipt_amount = \"0.05\";\r\n app_id = 2021003143637369;\r\n buyer_pay_amount = \"0.05\";\r\n sign_type = \"RSA2\";\r\n seller_id = 2088441785429273;\r\n gmt_payment = \"2022-08-10 16:38:03\";\r\n notify_time = \"2022-08-10 16:38:04\";\r\n version = 1;\r\n out_trade_no = \"62f36e657a355ecc1cb8eec2\";\r\n total_amount = \"0.05\";\r\n trade_no = 2.0220810220014894e+27;\r\n auth_app_id = 2021003143637369;\r\n buyer_logon_id = \"138****3531\";\r\n point_amount = 0;\r\n}\r\nexports.AlipayCallBack = AlipayCallBack;\r\nexports.GAlipayTool = null;\r\nclass AlipayTool {\r\n _alipaySdk = null;\r\n _aliPay = null;\r\n _cfg = {\r\n app_id: \"\",\r\n app_key: \"\",\r\n gateway: \"\",\r\n //RSA1 RSA2\r\n signType: 'RSA2',\r\n /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */\r\n keyType: 'PKCS1',\r\n alipay_root_cert_sn: \"\",\r\n alipay_cert_sn: \"\",\r\n app_cert_sn: \"\",\r\n notify_url: \"\"\r\n };\r\n init() {\r\n if (!ServerConfig_1.GServerCfg.third_cfg.alipay\r\n || !ServerConfig_1.GServerCfg.third_cfg.alipay.open) {\r\n return false;\r\n }\r\n let suffix = \"\";\r\n if (ServerConfig_1.GServerCfg.third_cfg.alipay.dev) {\r\n suffix = \"_dev\";\r\n }\r\n this._cfg = {\r\n app_id: ServerConfig_1.GServerCfg.third_cfg.alipay[\"app_id\" + suffix],\r\n app_key: ServerConfig_1.GServerCfg.third_cfg.alipay[\"app_key\" + suffix],\r\n gateway: ServerConfig_1.GServerCfg.third_cfg.alipay[\"gateway\" + suffix],\r\n //RSA1 RSA2\r\n signType: ServerConfig_1.GServerCfg.third_cfg.alipay[\"signType\" + suffix],\r\n /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */\r\n keyType: ServerConfig_1.GServerCfg.third_cfg.alipay[\"signType\" + suffix],\r\n alipay_root_cert_sn: ServerConfig_1.GServerCfg.third_cfg.alipay[\"alipay_root_cert_sn\" + suffix],\r\n alipay_cert_sn: ServerConfig_1.GServerCfg.third_cfg.alipay[\"alipay_cert_sn\" + suffix],\r\n app_cert_sn: ServerConfig_1.GServerCfg.third_cfg.alipay[\"app_cert_sn\" + suffix],\r\n notify_url: ServerConfig_1.GServerCfg.third_cfg.alipay[\"notify_url\" + suffix]\r\n };\r\n if (this._cfg.alipay_cert_sn) {\r\n this._aliPay = new AliPayUtil_1.AliPayUtil(this._cfg.alipay_cert_sn, this._cfg.app_key);\r\n }\r\n else {\r\n let app_key = \"\";\r\n if (this._cfg.app_key.indexOf(\".pem\") > 0) {\r\n app_key = fs.readFileSync(this._cfg.app_key, 'ascii');\r\n }\r\n else {\r\n app_key = this._cfg.app_key;\r\n }\r\n this._alipaySdk = new alipay_sdk_1.default({\r\n appId: this._cfg.app_id,\r\n privateKey: app_key,\r\n gateway: this._cfg.gateway,\r\n signType: this._cfg.signType,\r\n keyType: this._cfg.keyType\r\n });\r\n }\r\n }\r\n /**\r\n * charset:\"utf-8\",method:\"alipay.trade.app.pay\",sign_type:\"RSA2,version:\"1.0\"\r\n * @param out_trade_no\r\n * @param total_amount\r\n * @param subject\r\n * @param body\r\n * @param timeout_express\r\n * @param product_code\r\n * @returns\r\n */\r\n _buildOrderParams(out_trade_no, total_amount, subject = \"1\", body = \"我是测试数据\", timeout_express = \"30m\", product_code = \"QUICK_MSECURITY_PAY\") {\r\n let order_params = {\r\n notifyUrl: this._cfg.notify_url,\r\n bizContent: {\r\n timeout_express: timeout_express,\r\n product_code: product_code,\r\n total_amount: total_amount,\r\n subject: encodeURIComponent(subject),\r\n body: encodeURIComponent(body),\r\n out_trade_no: out_trade_no\r\n }\r\n };\r\n return order_params;\r\n }\r\n _sign(order_params) {\r\n let sign = aliUtil.sign(\"alipay.trade.app.pay\", order_params, this._alipaySdk.config);\r\n return sign;\r\n }\r\n getOrderInfo(out_trade_no, total_amount, subject = \"1\", body = \"我是测试数据\") {\r\n let order_params = this._buildOrderParams(out_trade_no, total_amount, subject, body);\r\n let sign = this._sign(order_params);\r\n let { url, execParams } = this._alipaySdk[\"formatUrl\"](\"\", sign);\r\n const order_info = (url + '&biz_content=' + encodeURIComponent(execParams.biz_content)).substring(1);\r\n return order_info;\r\n }\r\n /**\r\n *\r\n * @param title\r\n * @param order_id\r\n * @param money\r\n */\r\n doPay(title, order_id, money) {\r\n const param = {\r\n app_id: this._cfg.app_id,\r\n notify_url: this._cfg.notify_url,\r\n app_cert_sn: this._cfg.app_cert_sn,\r\n alipay_root_cert_sn: this._cfg.alipay_root_cert_sn,\r\n subject: title,\r\n trade_no: order_id,\r\n total_amount: money,\r\n };\r\n var str = this._aliPay.getPayCode(param);\r\n return str;\r\n }\r\n rsaCheck(payInfo) {\r\n return this._aliPay.rsaCheck(payInfo);\r\n }\r\n /**\r\n *\r\n * @param method get|post\r\n * @param notifyUrl 通知回调\r\n * @param returnUrl\r\n * @param outTradeNo\r\n * @param money 价格\r\n * @param subject 标题\r\n * @param body 内容介绍\r\n */\r\n async getAlipayPage(method, notifyUrl, returnUrl, outTradeNo, money, subject, body) {\r\n if (!this._alipaySdk) {\r\n Log_1.GLog.error(\"并未配置alipay或者初始化失败\");\r\n return;\r\n }\r\n const formData = new form_1.default();\r\n // 调用 setMethod 并传入 get,会返回可以跳转到支付页面的 url\r\n formData.setMethod(method);\r\n formData.addField(\"return_url\", returnUrl);\r\n formData.addField('notifyUrl', notifyUrl);\r\n formData.addField('bizContent', {\r\n outTradeNo: outTradeNo,\r\n productCode: \"FAST_INSTANT_TRADE_PAY\",\r\n totalAmount: money,\r\n subject: subject,\r\n body: body,\r\n });\r\n let url_or_html = await this._alipaySdk.exec('alipay.trade.page.pay', {}, { formData: formData });\r\n return url_or_html;\r\n }\r\n}\r\nexports.GAlipayTool = new AlipayTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/AlipayTool.js?");
|
|
800
|
+
|
|
801
|
+
/***/ }),
|
|
802
|
+
|
|
803
|
+
/***/ "./dist/lib/ThirdParty/Alisms.js":
|
|
804
|
+
/*!***************************************!*\
|
|
805
|
+
!*** ./dist/lib/ThirdParty/Alisms.js ***!
|
|
806
|
+
\***************************************/
|
|
807
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
808
|
+
|
|
809
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GSmsTool = void 0;\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nconst Log_1 = __webpack_require__(/*! ./../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nlet SMSClient = __webpack_require__(/*! @alicloud/sms-sdk */ \"@alicloud/sms-sdk\");\r\nexports.GSmsTool = null;\r\nclass SMSTool {\r\n _is_init = false;\r\n _sms_client = null;\r\n init() {\r\n if (this._is_init) {\r\n return true;\r\n }\r\n this._is_init = true;\r\n this._sms_client = new SMSClient({ accessKeyId: ServerConfig_1.GServerCfg.third_cfg.aliSms.accessKeyId, secretAccessKey: ServerConfig_1.GServerCfg.third_cfg.aliSms.secretAccessKey });\r\n }\r\n /**\r\n * 发送短信验证码\r\n * @param code 验证码\r\n * @param phone 手机号\r\n * @param callback 回调\r\n */\r\n sendSMS(code, phone) {\r\n return new Promise((resolve, reject) => {\r\n this._sms_client.sendSMS({\r\n PhoneNumbers: phone,\r\n SignName: ServerConfig_1.GServerCfg.third_cfg.aliSms.signName,\r\n TemplateCode: ServerConfig_1.GServerCfg.third_cfg.aliSms.templateCode,\r\n TemplateParam: JSON.stringify({ code: code })\r\n }).then((res) => {\r\n if (res.Code == \"OK\") {\r\n resolve(null);\r\n }\r\n else {\r\n Log_1.GLog.error(\"phone:\" + phone + \" code:\" + res.Code);\r\n resolve(res.Code);\r\n }\r\n }, (err) => {\r\n Log_1.GLog.error(err);\r\n resolve(err);\r\n });\r\n });\r\n }\r\n}\r\nexports.GSmsTool = new SMSTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/Alisms.js?");
|
|
810
|
+
|
|
811
|
+
/***/ }),
|
|
812
|
+
|
|
813
|
+
/***/ "./dist/lib/ThirdParty/AppleTool.js":
|
|
814
|
+
/*!******************************************!*\
|
|
815
|
+
!*** ./dist/lib/ThirdParty/AppleTool.js ***!
|
|
816
|
+
\******************************************/
|
|
817
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
818
|
+
|
|
819
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GAppleTool = exports.NotificationBody = exports.NotificationType = exports.ResponseBody = void 0;\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst HttpTool_1 = __webpack_require__(/*! ./../Logic/HttpTool */ \"./dist/lib/Logic/HttpTool.js\");\r\nconst ec_key_1 = __webpack_require__(/*! ec-key */ \"ec-key\");\r\nconst uuid_1 = __webpack_require__(/*! uuid */ \"uuid\");\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\n//developer.apple.com/documentation/appstorereceipts/responsebody\r\nclass ReceiptInfo {\r\n cancellation_date = \"\";\r\n cancellation_date_ms = \"\";\r\n cancellation_date_pst = \"\";\r\n cancellation_date_reason = \"\";\r\n expires_date = \"2021-03-10 14:25:54 Etc/GMT\";\r\n expires_date_ms = \"1615386354000\";\r\n expires_date_pst = \"2021-03-10 06:25:54 America/Los_Angeles\";\r\n in_app_ownership_type;\r\n is_in_intro_offer_period = false;\r\n is_trial_period = false;\r\n is_upgraded = false;\r\n offer_code_ref_name = \"\";\r\n original_purchase_date = \"2021-03-10 08:22:26 Etc/GMT\";\r\n original_purchase_date_ms = \"1615364546000\";\r\n original_purchase_date_pst = \"2021-03-10 00:22:26 America/Los_Angeles\";\r\n original_transaction_id = \"1000000786747716\";\r\n purchase_date = \"2021-03-10 14:22:54 Etc/GMT\";\r\n purchase_date_ms = \"1615386174000\";\r\n purchase_date_pst = \"2021-03-10 06:22:54 America/Los_Angeles\";\r\n quantity = 1;\r\n subscription_group_identifier = \"20745320\";\r\n web_order_line_item_id = \"1000000060695307\";\r\n transaction_id = \"1000000786974540\";\r\n product_id = \"com.eryi.eyreader.week\";\r\n}\r\nclass PendingRenewalInfo {\r\n auto_renew_product_id = \"com.eryi.eyreader.week\";\r\n auto_renew_status = 0;\r\n expiration_intent = 1;\r\n grace_period_expires_date = \"\";\r\n grace_period_expires_date_ms = \"\";\r\n grace_period_expires_date_pst = \"\";\r\n is_in_billing_retry_period = 0;\r\n offer_code_ref_name = \"\";\r\n original_transaction_id = \"1000000786747716\";\r\n price_consent_status = \"\";\r\n product_id = \"com.eryi.eyreader.week\";\r\n promotional_offer_id = \"\";\r\n}\r\nclass InApp {\r\n cancellation_date = \"\";\r\n cancellation_date_ms = \"\";\r\n cancellation_date_pst = \"\";\r\n cancellation_reason = \"\";\r\n expires_date = \"2021-03-10 14:25:54 Etc/GMT\";\r\n expires_date_ms = \"1615386354000\";\r\n expires_date_pst = \"2021-03-10 06:25:54 America/Los_Angeles\";\r\n is_in_intro_offer_period = false;\r\n is_trial_period = false;\r\n original_purchase_date = \"2021-03-10 08:22:26 Etc/GMT\";\r\n original_purchase_date_ms = \"1615364546000\";\r\n original_purchase_date_pst = \"2021-03-10 00:22:26 America/Los_Angeles\";\r\n original_transaction_id = \"1000000786747716\";\r\n product_id = \"com.eryi.eyreader.week\";\r\n promotional_offer_id = \"\";\r\n purchase_date = \"2021-03-10 14:22:54 Etc/GMT\";\r\n purchase_date_ms = \"1615386174000\";\r\n purchase_date_pst = \"2021-03-10 06:22:54 America/Los_Angeles\";\r\n quantity = 1;\r\n transaction_id = \"1000000786974540\";\r\n web_order_line_item_id = \"1000000060695307\";\r\n}\r\nclass Receipt {\r\n adam_id = -1;\r\n app_item_id = -1;\r\n application_version = \"\";\r\n bundle_id = \"\";\r\n download_id = -1;\r\n expiration_date = \"\";\r\n expiration_date_ms = \"\";\r\n expiration_date_pst = \"\";\r\n in_app = null;\r\n original_application_version = \"\";\r\n original_purchase_date = \"\";\r\n original_purchase_date_ms = \"\";\r\n original_purchase_date_pst = \"\";\r\n preorder_date = \"\";\r\n preorder_date_ms = \"\";\r\n preorder_date_pst = \"\";\r\n receipt_creation_date = \"\";\r\n receipt_creation_date_ms = \"\";\r\n receipt_creation_date_pst = \"\";\r\n receipt_type = \"\";\r\n request_date = \"\";\r\n request_date_ms = \"\";\r\n request_date_pst = \"\";\r\n version_external_identifier = -1;\r\n}\r\nclass ResponseBody {\r\n environment = \"Sandbox\";\r\n is_retryable = false; //出错之后的重试\r\n latest_receipt = \"0OkG/Sw==\";\r\n latest_receipt_info = null;\r\n pending_renewal_info = null;\r\n receipt = null;\r\n status = 0;\r\n}\r\nexports.ResponseBody = ResponseBody;\r\nclass NotificationType {\r\n //退款\r\n static CANCEL = \"CANCEL\";\r\n //变更续订方式,下次续订的时候生效,当前不变\r\n static DID_CHANGE_RENEWAL_PREF = \"DID_CHANGE_RENEWAL_PREF\";\r\n /*\r\n 续订状态发生变化的时候通知\r\n 检查auto_renew_status_change_date_ms获取最新的状态更新时间.\r\n 通过auto_renew_status了解当前续订状态.\r\n */\r\n static DID_CHANGE_RENEWAL_STATUS = \"DID_CHANGE_RENEWAL_STATUS\";\r\n //自动续订了一个之前续订失败了的续订\r\n static DID_RECOVER = \"DID_RECOVER\";\r\n //自动续订成功\r\n static DID_RENEW = \"DID_RENEW\";\r\n //客户交互更新订阅,订阅可以立刻生效\r\n static INTERACTIVE_RENEWAL = \"INTERACTIVE_RENEWAL\";\r\n}\r\nexports.NotificationType = NotificationType;\r\nclass NotificationBody {\r\n unified_receipt = null;\r\n environment = \"Sandbox\";\r\n auto_renew_status = \"false\";\r\n auto_renew_status_change_date = \"2021-03-11 03:03:14 Etc/GMT\";\r\n bvrs = \"1\";\r\n bid = \"com.eryi.eyreader\";\r\n password = \"5203c7781e254aac8942290a0a2467ac\";\r\n auto_renew_product_id = \"com.eryi.eyreader.week\";\r\n notification_type = NotificationType.DID_RECOVER;\r\n}\r\nexports.NotificationBody = NotificationBody;\r\nclass RequestBody {\r\n \"receipt-data\" = \"\";\r\n password = \"5203c7781e254aac8942290a0a2467ac\";\r\n \"exclude-old-transactions\" = true;\r\n}\r\nexports.GAppleTool = null;\r\nclass AppleTool {\r\n _verifyUrl = \"https://buy.itunes.apple.com/verifyReceipt\";\r\n _sandboxVerifyUrl = \"https://sandbox.itunes.apple.com/verifyReceipt\";\r\n async onNotify(nb) {\r\n let ris = nb.unified_receipt?.latest_receipt_info;\r\n var latest_one = (ris?.length > 0 ? ris[0] : null);\r\n let msg = {\r\n \"notification_type\": nb.notification_type,\r\n \"status\": nb.unified_receipt.status,\r\n \"environment\": nb.environment,\r\n \"auto_renew_status\": nb.auto_renew_status,\r\n \"orginal_transaction_id\": latest_one?.original_transaction_id,\r\n \"transaction_id\": latest_one?.transaction_id,\r\n \"expire_date\": latest_one?.expires_date,\r\n \"receipt_expire_date\": nb.unified_receipt?.receipt?.expiration_date\r\n };\r\n Log_1.GLog.info(msg);\r\n Log_1.GLog.info(nb);\r\n }\r\n async onVerify(receipt, environment) {\r\n Log_1.GLog.info(\"begin onVerify============================\" + environment);\r\n let url = this._verifyUrl;\r\n // if(environment.toLowerCase()==\"sandbox\")\r\n // {\r\n // url=this._sandboxVerifyUrl\r\n // }\r\n Log_1.GLog.info(\"url============================\" + url);\r\n let reqb = new RequestBody();\r\n reqb['receipt-data'] = receipt;\r\n //先验证生产环境\r\n var resb = (await HttpTool_1.GHttpTool.httpPost(url, JSON.stringify(reqb))).body;\r\n Log_1.GLog.info(\"production end onVerify_Res============================status=\" + (resb ? resb.status : \"null\"));\r\n //状态21007表示是沙盒环境\r\n if (resb && resb.status == 21007) {\r\n url = this._sandboxVerifyUrl;\r\n resb = (await HttpTool_1.GHttpTool.httpPost(url, JSON.stringify(reqb))).body;\r\n Log_1.GLog.info(\"sandbox end onVerify_Res============================status=\" + (resb ? resb.status : \"null\"));\r\n }\r\n Log_1.GLog.info(resb);\r\n return resb;\r\n }\r\n signature(nickname, create_time, appBundleID, productIdentifier, offerIdentifier) {\r\n let keyIdentifier = \"\";\r\n for (var k in ServerConfig_1.GServerCfg.third_cfg.apple.keyIds) {\r\n keyIdentifier = k;\r\n break;\r\n }\r\n var nonce = (0, uuid_1.v4)();\r\n var payload = appBundleID + '\\u2063' +\r\n keyIdentifier + '\\u2063' +\r\n productIdentifier + '\\u2063' +\r\n offerIdentifier + '\\u2063' +\r\n nickname + '\\u2063' +\r\n nonce.toLowerCase() + '\\u2063' +\r\n create_time;\r\n // Get the PEM-formatted private key string associated with the Key ID.\r\n const path = ServerConfig_1.GServerCfg.third_cfg.apple.keyIds[keyIdentifier];\r\n const keyString = fs.readFileSync(path).toString();\r\n // Create an Elliptic Curve Digital Signature Algorithm (ECDSA) object using the private key.\r\n const key = new ec_key_1.default(keyString, 'pem');\r\n // Set up the cryptographic format used to sign the key with the SHA-256 hashing algorithm.\r\n const cryptoSign = key.createSign('SHA256');\r\n // Add the payload string to sign.\r\n cryptoSign.update(payload);\r\n /*\r\n The Node.js crypto library creates a DER-formatted binary value signature,\r\n and then base-64 encodes it to create the string that you will use in StoreKit.\r\n */\r\n const signature = cryptoSign.sign('base64');\r\n /*\r\n Check that the signature passes verification by using the ec-key library.\r\n The verification process is similar to creating the signature, except it uses 'createVerify'\r\n instead of 'createSign', and after updating it with the payload, it uses `verify` to pass in\r\n the signature and encoding, instead of `sign` to get the signature.\r\n\r\n This step is not required, but it's useful to check when implementing your signature code.\r\n This helps debug issues with signing before sending transactions to Apple.\r\n If verification succeeds, the next recommended testing step is attempting a purchase\r\n in the Sandbox environment.\r\n */\r\n const verificationResult = key.createVerify('SHA256').update(payload).verify(signature, 'base64');\r\n if (verificationResult) {\r\n return { 'keyIdentifier': keyIdentifier, 'nonce': nonce, 'timestamp': create_time, 'signature': signature };\r\n }\r\n return;\r\n }\r\n}\r\nexports.GAppleTool = new AppleTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/AppleTool.js?");
|
|
820
|
+
|
|
821
|
+
/***/ }),
|
|
822
|
+
|
|
823
|
+
/***/ "./dist/lib/ThirdParty/EmailTool.js":
|
|
824
|
+
/*!******************************************!*\
|
|
825
|
+
!*** ./dist/lib/ThirdParty/EmailTool.js ***!
|
|
826
|
+
\******************************************/
|
|
827
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
828
|
+
|
|
829
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GEmailTool = void 0;\r\nconst nodeMailer = __webpack_require__(/*! nodemailer */ \"nodemailer\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nexports.GEmailTool = null;\r\nclass EmailTool {\r\n send(to, subject, html) {\r\n return new Promise((resolve, reject) => {\r\n let transport = nodeMailer.createTransport({\r\n host: ServerConfig_1.GServerCfg.third_cfg.email.host,\r\n port: ServerConfig_1.GServerCfg.third_cfg.email.port,\r\n secure: ServerConfig_1.GServerCfg.third_cfg.email.secure,\r\n auth: {\r\n user: ServerConfig_1.GServerCfg.third_cfg.email.auth.user,\r\n pass: ServerConfig_1.GServerCfg.third_cfg.email.auth.pass\r\n }\r\n });\r\n let mail = {\r\n from: ServerConfig_1.GServerCfg.third_cfg.email.from,\r\n to: to,\r\n subject: subject,\r\n html: html\r\n };\r\n transport.sendMail(mail, (_err, msg) => {\r\n Log_1.GLog.error(JSON.stringify(_err));\r\n resolve(_err);\r\n });\r\n });\r\n }\r\n}\r\nexports.GEmailTool = new EmailTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/EmailTool.js?");
|
|
830
|
+
|
|
831
|
+
/***/ }),
|
|
832
|
+
|
|
833
|
+
/***/ "./dist/lib/ThirdParty/OpenSocial.js":
|
|
834
|
+
/*!*******************************************!*\
|
|
835
|
+
!*** ./dist/lib/ThirdParty/OpenSocial.js ***!
|
|
836
|
+
\*******************************************/
|
|
837
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
838
|
+
|
|
839
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GOpenSocial = void 0;\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nconst HttpTool_1 = __webpack_require__(/*! ../Logic/HttpTool */ \"./dist/lib/Logic/HttpTool.js\");\r\nexports.GOpenSocial = null;\r\nclass OpenSocial {\r\n _getNewMsg() {\r\n return {\r\n app_id: ServerConfig_1.GServerCfg.third_cfg.open_social.app_id,\r\n app_secret: ServerConfig_1.GServerCfg.third_cfg.open_social.app_secret\r\n };\r\n }\r\n async getUser(unionid, openid) {\r\n let msg = {\r\n unionid: unionid,\r\n openid: openid\r\n };\r\n let rs = await HttpTool_1.GHttpTool.httpPost(ServerConfig_1.GServerCfg.third_cfg.open_social.user_url, msg);\r\n return rs.body;\r\n }\r\n async updatePwd(unionid, openid, new_pwd) {\r\n let msg = {\r\n unionid: unionid,\r\n openid: openid,\r\n password: new_pwd\r\n };\r\n let jsonData = await HttpTool_1.GHttpTool.httpPost(ServerConfig_1.GServerCfg.third_cfg.open_social.update_pwd_url, msg);\r\n return jsonData.body || jsonData.error;\r\n }\r\n}\r\nexports.GOpenSocial = new OpenSocial();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/OpenSocial.js?");
|
|
840
|
+
|
|
841
|
+
/***/ }),
|
|
842
|
+
|
|
843
|
+
/***/ "./dist/lib/ThirdParty/QQTool.js":
|
|
844
|
+
/*!***************************************!*\
|
|
845
|
+
!*** ./dist/lib/ThirdParty/QQTool.js ***!
|
|
846
|
+
\***************************************/
|
|
847
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
848
|
+
|
|
849
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.QQTool = exports.GQQTool = exports.QQUserInfo = void 0;\r\nconst _ = __webpack_require__(/*! underscore */ \"underscore\");\r\nconst URLEncode = __webpack_require__(/*! urlencode */ \"urlencode\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nconst HttpTool_1 = __webpack_require__(/*! ../Logic/HttpTool */ \"./dist/lib/Logic/HttpTool.js\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nclass QQUserInfo {\r\n ret = 0;\r\n msg = \"\";\r\n is_lost = 0;\r\n nickname = \"\";\r\n gender = \"\"; //\"男\"\r\n province = \"\"; //\"四川\"\r\n city = \"\"; //\"成都\"\r\n year = \"\"; //\"1988\"\r\n constellation = \"\";\r\n figureurl = \"\"; //http://qzapp.qlogo.cn/qzapp/101775753/B5EA2E2138715A07DE91B5BACBA0CCE5/30\r\n figureurl_1 = \"\"; //http://qzapp.qlogo.cn/qzapp/101775753/B5EA2E2138715A07DE91B5BACBA0CCE5/50\r\n figureurl_2 = \"\"; //http://qzapp.qlogo.cn/qzapp/101775753/B5EA2E2138715A07DE91B5BACBA0CCE5/100\r\n figureurl_qq_1 = \"\"; //http://thirdqq.qlogo.cn/g?b=oidb&k=jgOibQ4eLHDBT57oAib1DrOg&s=40&t=1556419177\r\n figureurl_qq_2 = \"\"; //http://thirdqq.qlogo.cn/g?b=oidb&k=jgOibQ4eLHDBT57oAib1DrOg&s=100&t=1556419177\r\n figureurl_qq = \"\"; //http://thirdqq.qlogo.cn/g?b=oidb&k=jgOibQ4eLHDBT57oAib1DrOg&s=140&t=1556419177\r\n figureurl_type = \"\"; //\"1\"\r\n is_yellow_vip; //\"0\"\r\n vip = \"\"; //\"0\"\r\n yellow_vip_level = \"\"; //\"0\"\r\n level = \"\"; //\"0\"\r\n is_yellow_year_vip = \"\"; //\"0\"\r\n}\r\nexports.QQUserInfo = QQUserInfo;\r\nexports.GQQTool = null;\r\nclass QQTool {\r\n /**\r\n * 获取Authorization Code\r\n * @param scope 可选\t请求用户授权时向用户显示的可进行授权的列表。\r\n 可填写的值是API文档中列出的接口,以及一些动作型的授权(目前仅有:do_like),如果要填写多个接口名称,请用逗号隔开。\r\n 例如:scope=get_user_info,list_album,upload_pic,do_like\r\n 不传则默认请求对接口get_user_info进行授权。\r\n 建议控制授权项的数量,只传入必要的接口名称,因为授权项越多,用户越可能拒绝进行任何授权。\r\n * @param display 仅PC网站接入时使用。\r\n 用于展示的样式。不传则默认展示为PC下的样式。\r\n 如果传入“mobile”,则展示为mobile端下的样式。\r\n */\r\n getAuthCodeUrl(scope, display) {\r\n //必须\t成功授权后的回调地址,必须是注册appid时填写的主域名下的地址,建议设置为网站首页或网站的用户中心\r\n let redirect_uri = URLEncode.encode(ServerConfig_1.GServerCfg.third_cfg.qq.redirect_uri);\r\n //必须\t申请QQ登录成功后,分配给应用的appid。\r\n let client_id = ServerConfig_1.GServerCfg.third_cfg.qq.app_id;\r\n //必须\t授权类型,此值固定为“code”。\r\n let response_type = \"code\";\r\n //必须\tclient端的状态值。用于第三方应用防止CSRF攻击,成功授权后回调时会原样带回。请务必严格按照流程检查用户与state参数状态的绑定。\r\n let state = _.random(1000000, 9999999);\r\n //PC网站\r\n let url = \"https://graph.qq.com/oauth2.0/authorize?redirect_uri=\" + redirect_uri + \"&response_type=\" + response_type + \"&state=\" + state + \"&client_id=\" + client_id;\r\n if (scope) {\r\n url += \"&scope=\" + scope;\r\n }\r\n if (display) {\r\n url += \"&display=\" + display;\r\n }\r\n return url;\r\n }\r\n async getAccessToken(auth_code) {\r\n if (!auth_code) {\r\n return null;\r\n }\r\n //必须\t授权类型,在本步骤中,此值为“authorization_code”。\r\n let grant_type = \"authorization_code\";\r\n //必须\t申请QQ登录成功后,分配给应用的appid。\r\n let client_id = ServerConfig_1.GServerCfg.third_cfg.qq.app_id;\r\n //必须\t申请QQ登录成功后,分配给网站的appkey。\r\n let client_secret = ServerConfig_1.GServerCfg.third_cfg.qq.app_key;\r\n //必须\t成功授权后的回调地址,必须是注册appid时填写的主域名下的地址,建议设置为网站首页或网站的用户中心\r\n let redirect_uri = URLEncode.encode(ServerConfig_1.GServerCfg.third_cfg.qq.redirect_uri);\r\n let url = \"https://graph.qq.com/oauth2.0/token?code=\" + auth_code + \"&grant_type=\" + grant_type + \"&client_id=\" + client_id + \"&client_secret=\" + client_secret + \"&redirect_uri=\" + redirect_uri;\r\n let rs = await HttpTool_1.GHttpTool.httpRequest(url);\r\n if (rs.body && rs.body.access_token) {\r\n return rs.body.access_token;\r\n }\r\n else {\r\n Log_1.GLog.error(rs.body);\r\n }\r\n return null;\r\n }\r\n async getOpenId(access_token) {\r\n let url = \"https://graph.qq.com/oauth2.0/me?access_token=\" + access_token;\r\n let rs = await HttpTool_1.GHttpTool.httpRequest(url);\r\n let body = rs.response ? rs.response.body : null;\r\n if (body) {\r\n body = body.replace(\"callback( \", \"\");\r\n body = body.replace(\" );\\n\", \"\");\r\n try {\r\n body = JSON.parse(body);\r\n }\r\n catch (e) { }\r\n if (!body.openid) {\r\n Log_1.GLog.error(rs.response.body);\r\n }\r\n return body.openid;\r\n }\r\n return null;\r\n }\r\n async getUserInfo(access_token, openid) {\r\n let url = \"https://graph.qq.com/user/get_user_info?access_token=\" + access_token + \"&oauth_consumer_key=\" + ServerConfig_1.GServerCfg.third_cfg.qq.app_id + \"&openid=\" + openid;\r\n let rs = await HttpTool_1.GHttpTool.httpRequest(url);\r\n if (rs.body) {\r\n return rs.body;\r\n }\r\n return null;\r\n }\r\n}\r\nexports.QQTool = QQTool;\r\nexports.GQQTool = new QQTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/QQTool.js?");
|
|
850
|
+
|
|
851
|
+
/***/ }),
|
|
852
|
+
|
|
853
|
+
/***/ "./dist/lib/ThirdParty/QiniuTool.js":
|
|
854
|
+
/*!******************************************!*\
|
|
855
|
+
!*** ./dist/lib/ThirdParty/QiniuTool.js ***!
|
|
856
|
+
\******************************************/
|
|
857
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
858
|
+
|
|
859
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GQiniuTool = void 0;\r\nconst qiniu = __webpack_require__(/*! qiniu */ \"qiniu\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nexports.GQiniuTool = null;\r\nclass QiniuTool {\r\n get host() {\r\n return ServerConfig_1.GServerCfg.third_cfg.qiniu.host;\r\n }\r\n getUploadToken(filename) {\r\n let mac = new qiniu.auth.digest.Mac(ServerConfig_1.GServerCfg.third_cfg.qiniu.accessKey, ServerConfig_1.GServerCfg.third_cfg.qiniu.secretKey);\r\n let options = {\r\n scope: ServerConfig_1.GServerCfg.third_cfg.qiniu.bucket + \":\" + filename,\r\n };\r\n let putPolicy = new qiniu.rs.PutPolicy(options);\r\n let uploadToken = putPolicy.uploadToken(mac);\r\n return uploadToken;\r\n }\r\n}\r\nexports.GQiniuTool = new QiniuTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/QiniuTool.js?");
|
|
860
|
+
|
|
861
|
+
/***/ }),
|
|
862
|
+
|
|
863
|
+
/***/ "./dist/lib/ThirdParty/WechatOATool.js":
|
|
864
|
+
/*!*********************************************!*\
|
|
865
|
+
!*** ./dist/lib/ThirdParty/WechatOATool.js ***!
|
|
866
|
+
\*********************************************/
|
|
867
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
868
|
+
|
|
869
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.WechatOATool = exports.GWechatOATool = exports.WechatOAMsg = void 0;\r\n//OA=offical account公众号\r\nclass WechatOAMsg {\r\n // <xml>\r\n // <ToUserName><![CDATA[toUser]]></ToUserName>\r\n // <FromUserName><![CDATA[fromUser]]></FromUserName>\r\n // <CreateTime>1348831860</CreateTime>\r\n // <MsgType><![CDATA[text]]></MsgType>\r\n // <Content><![CDATA[this is a test]]></Content>\r\n // <MsgId>1234567890123456</MsgId>\r\n // </xml>\r\n toUserName = \"\";\r\n fromUserName = \"\"; //其实是一个userid\r\n createTime = -1;\r\n msgType = \"\"; //text文本\r\n content = \"\";\r\n msgId = -1; //只有收到消息才会有\r\n}\r\nexports.WechatOAMsg = WechatOAMsg;\r\nexports.GWechatOATool = null;\r\nclass WechatOATool {\r\n convertMsg(xmlStr) {\r\n if (!xmlStr) {\r\n return null;\r\n }\r\n let msg = new WechatOAMsg();\r\n let pre = \"<ToUserName><![CDATA[\";\r\n xmlStr = xmlStr.substr(xmlStr.indexOf(pre) + pre.length);\r\n msg.toUserName = xmlStr.substr(0, xmlStr.indexOf(\"]\"));\r\n pre = \"<FromUserName><![CDATA[\";\r\n xmlStr = xmlStr.substr(xmlStr.indexOf(pre) + pre.length);\r\n msg.fromUserName = xmlStr.substr(0, xmlStr.indexOf(\"]\"));\r\n pre = \"<CreateTime>\";\r\n xmlStr = xmlStr.substr(xmlStr.indexOf(pre) + pre.length);\r\n msg.createTime = parseInt(xmlStr.substr(0, xmlStr.indexOf(\"<\")));\r\n pre = \"<MsgType><![CDATA[\";\r\n xmlStr = xmlStr.substr(xmlStr.indexOf(pre) + pre.length);\r\n msg.msgType = xmlStr.substr(0, xmlStr.indexOf(\"]\"));\r\n pre = \"<Content><![CDATA[\";\r\n xmlStr = xmlStr.substr(xmlStr.indexOf(pre) + pre.length);\r\n msg.content = xmlStr.substr(0, xmlStr.indexOf(\"]\"));\r\n pre = \"<MsgId>\";\r\n xmlStr = xmlStr.substr(xmlStr.indexOf(pre) + pre.length);\r\n msg.msgId = parseInt(xmlStr.substr(0, xmlStr.indexOf(\"<\")));\r\n return msg;\r\n }\r\n toReplyXmlStr(msg) {\r\n let xmlStr = \"<xml>\";\r\n xmlStr += \"<ToUserName><![CDATA[\" + msg.toUserName + \"]]></ToUserName>\";\r\n xmlStr += \"<FromUserName><![CDATA[\" + msg.fromUserName + \"]]></FromUserName>\";\r\n xmlStr += \"<CreateTime>\" + msg.createTime + \"</CreateTime>\";\r\n xmlStr += \"<MsgType><![CDATA[\" + msg.msgType + \"]]></MsgType>\";\r\n xmlStr += \"<Content><![CDATA[\" + msg.content + \"]]></Content>\";\r\n xmlStr += \"</xml>\";\r\n return xmlStr;\r\n }\r\n}\r\nexports.WechatOATool = WechatOATool;\r\nexports.GWechatOATool = new WechatOATool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/WechatOATool.js?");
|
|
870
|
+
|
|
871
|
+
/***/ }),
|
|
872
|
+
|
|
873
|
+
/***/ "./dist/lib/ThirdParty/WechatTool.js":
|
|
874
|
+
/*!*******************************************!*\
|
|
875
|
+
!*** ./dist/lib/ThirdParty/WechatTool.js ***!
|
|
876
|
+
\*******************************************/
|
|
877
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
878
|
+
|
|
879
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.WechatTool = exports.GWechatTool = exports.WechatUserInfo = void 0;\r\nconst _ = __webpack_require__(/*! underscore */ \"underscore\");\r\nconst URLEncode = __webpack_require__(/*! urlencode */ \"urlencode\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nconst HttpTool_1 = __webpack_require__(/*! ../Logic/HttpTool */ \"./dist/lib/Logic/HttpTool.js\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nclass WechatUserInfo {\r\n openid = \"OPENID\";\r\n nickname = \"NICKNAME\";\r\n sex = 1;\r\n province = \"PROVINCE\";\r\n city = \"CITY\";\r\n country = \"COUNTRY\";\r\n headimgurl = \"http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/0\";\r\n privilege = [\r\n \"PRIVILEGE1\",\r\n \"PRIVILEGE2\"\r\n ];\r\n unionid = \"o6_bmasdasdsad6_2sgVt7hMZOPfL\";\r\n}\r\nexports.WechatUserInfo = WechatUserInfo;\r\nexports.GWechatTool = null;\r\nclass WechatTool {\r\n /**\r\n * 获取获取code的url\r\n */\r\n getAuthCodeUrl() {\r\n let appid = \"wx80f0f10fe1304e9d\";\r\n let url = \"https://open.weixin.qq.com/connect/qrconnect?appid=\" + ServerConfig_1.GServerCfg.third_cfg.wechat.app_id;\r\n url += \"&redirect_uri=\" + URLEncode.encode(ServerConfig_1.GServerCfg.third_cfg.wechat.redirect_uri);\r\n url += \"&response_type=code&scope=snsapi_login\";\r\n //必须\tclient端的状态值。用于第三方应用防止CSRF攻击,成功授权后回调时会原样带回。请务必严格按照流程检查用户与state参数状态的绑定。\r\n let state = _.random(1000000, 9999999);\r\n url += \"&state=\" + state;\r\n return url;\r\n }\r\n async getAccessInfo(auth_code) {\r\n if (!auth_code) {\r\n return null;\r\n }\r\n let url = \"https://api.weixin.qq.com/sns/oauth2/access_token?appid=\" + ServerConfig_1.GServerCfg.third_cfg.wechat.app_id + \"&secret=\" + ServerConfig_1.GServerCfg.third_cfg.wechat.app_key + \"&code=\" + auth_code + \"&grant_type=authorization_code\";\r\n let rs = await HttpTool_1.GHttpTool.httpRequest(url);\r\n /*\r\n {\r\n \"access_token\":\"ACCESS_TOKEN\",\r\n \"expires_in\":7200,\r\n \"refresh_token\":\"REFRESH_TOKEN\",\r\n \"openid\":\"OPENID\",\r\n \"scope\":\"SCOPE\",\r\n \"unionid\": \"o6_bmasdasdsad6_2sgVt7hMZOPfL\"\r\n }\r\n {\"errcode\":40029,\"errmsg\":\"invalid code\"}\r\n */\r\n if (rs.body && rs.body.access_token) {\r\n return rs.body;\r\n }\r\n else {\r\n Log_1.GLog.error(rs.body);\r\n }\r\n return null;\r\n }\r\n async getUserInfo(access_token, openid) {\r\n let url = \"https://api.weixin.qq.com/sns/userinfo?access_token=\" + access_token + \"&openid=\" + openid;\r\n let rs = await HttpTool_1.GHttpTool.httpRequest(url);\r\n if (rs.body) {\r\n return rs.body;\r\n }\r\n return null;\r\n }\r\n}\r\nexports.WechatTool = WechatTool;\r\nexports.GWechatTool = new WechatTool();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/ThirdParty/WechatTool.js?");
|
|
880
|
+
|
|
881
|
+
/***/ }),
|
|
882
|
+
|
|
883
|
+
/***/ "./dist/lib/WebServer/Controller/BaseController.js":
|
|
884
|
+
/*!*********************************************************!*\
|
|
885
|
+
!*** ./dist/lib/WebServer/Controller/BaseController.js ***!
|
|
886
|
+
\*********************************************************/
|
|
887
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
888
|
+
|
|
889
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.BaseController = void 0;\r\nclass BaseController {\r\n _request = null;\r\n get request() {\r\n return this._request;\r\n }\r\n _response = null;\r\n get response() {\r\n return this._response;\r\n }\r\n //模块名称\r\n _module = \"\";\r\n _ctr_name = \"\";\r\n get ctrName() {\r\n return this._ctr_name;\r\n }\r\n _engine = null;\r\n get postData() {\r\n if (!this._request) {\r\n return {};\r\n }\r\n return this._request.postData || {};\r\n }\r\n get paramData() {\r\n if (!this._request) {\r\n return {};\r\n }\r\n return this._request.params || {};\r\n }\r\n constructor(req, res, engine) {\r\n this._engine = engine;\r\n this._request = req;\r\n this._response = res;\r\n //静态控制器,传过来全是空\r\n if (this._request) {\r\n this._request.debugInfo();\r\n }\r\n }\r\n async init() {\r\n }\r\n /**\r\n * 方便static ctr使用\r\n * @param req\r\n * @param res\r\n * @param engine\r\n */\r\n initStatic(req, res, engine) {\r\n this._engine = engine;\r\n this._request = req;\r\n this._response = res;\r\n this._request.debugInfo();\r\n }\r\n //填充每个页面需要的通用数据\r\n _init_data(model) {\r\n model = model || {};\r\n model.webName = this._engine.cfg.web_name;\r\n return { model };\r\n }\r\n showJson(model) {\r\n this._response.renderJson(model, this._request.headers.origin);\r\n }\r\n show(model) {\r\n let html = this._engine.getRenderHtml(this._request, this._response, this._init_data(model));\r\n this._response.renderHtml(html);\r\n }\r\n showText(text, noMeta) {\r\n if (!noMeta) {\r\n text = \"<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\" + text;\r\n }\r\n this._response.renderHtml(text);\r\n }\r\n redirect(module, controller, action, params) {\r\n module = module || this._module;\r\n controller = controller || this._ctr_name;\r\n let url = this.parseFullUrl(module, controller, action);\r\n params = params || {};\r\n let str_p = \"\";\r\n for (let key in params) {\r\n str_p += \"&\" + key + \"=\" + params[key];\r\n }\r\n if (str_p.length > 0) {\r\n str_p = \"?\" + str_p.substring(1);\r\n }\r\n url += str_p;\r\n this._response.redirect(url);\r\n }\r\n parseFullUrl(module, controller, action) {\r\n if (typeof action === \"undefined\" || !action) {\r\n action = \"index\";\r\n if (this._engine.cfg.routs.defaults.action == action) {\r\n action = null;\r\n }\r\n }\r\n let url = \"\";\r\n if (this._engine.cfg.routs.onlyModule) {\r\n url = this._request.root + \"/\" + controller;\r\n }\r\n else {\r\n url = this._request.root + \"/\" + module + \"/\" + controller;\r\n }\r\n if (action) {\r\n url += \"/\" + action;\r\n }\r\n return url;\r\n }\r\n get remoteHost() {\r\n return this._request.remoteHost;\r\n }\r\n}\r\nexports.BaseController = BaseController;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Controller/BaseController.js?");
|
|
890
|
+
|
|
891
|
+
/***/ }),
|
|
892
|
+
|
|
893
|
+
/***/ "./dist/lib/WebServer/Controller/BaseUserController.js":
|
|
894
|
+
/*!*************************************************************!*\
|
|
895
|
+
!*** ./dist/lib/WebServer/Controller/BaseUserController.js ***!
|
|
896
|
+
\*************************************************************/
|
|
897
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
898
|
+
|
|
899
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.BaseUserController = void 0;\r\nconst BaseController_1 = __webpack_require__(/*! ./BaseController */ \"./dist/lib/WebServer/Controller/BaseController.js\");\r\nconst UserService_1 = __webpack_require__(/*! ../../Service/UserService */ \"./dist/lib/Service/UserService.js\");\r\nconst CacheTool_1 = __webpack_require__(/*! ../../Logic/CacheTool */ \"./dist/lib/Logic/CacheTool.js\");\r\nconst FrameworkConfig_1 = __webpack_require__(/*! ../../Config/FrameworkConfig */ \"./dist/lib/Config/FrameworkConfig.js\");\r\nconst RedisManager_1 = __webpack_require__(/*! ../../Database/RedisManager */ \"./dist/lib/Database/RedisManager.js\");\r\nconst MongoCacheService_1 = __webpack_require__(/*! ../../Service/MongoCacheService */ \"./dist/lib/Service/MongoCacheService.js\");\r\nconst ini_1 = __webpack_require__(/*! ../../Service/ini */ \"./dist/lib/Service/ini.js\");\r\nclass BaseUserController extends BaseController_1.BaseController {\r\n _user_session_id = \"user_session_id\";\r\n _self_user = null;\r\n _user = null; //网页内容的所属,比如,查看别人的博客,那这个信息就是作者的\r\n _session_id = null;\r\n get selfUser() {\r\n return this._self_user;\r\n }\r\n get isSelf() {\r\n return this._self_user && (this._self_user.id == this._user.id);\r\n }\r\n get isLogin() {\r\n return this._self_user && true;\r\n }\r\n get isCreator() {\r\n return this._self_user && (this._self_user.role_group == ini_1.ERoleGroup.Creator);\r\n }\r\n get isAdmin() {\r\n return this._self_user && (this._self_user.role_group == ini_1.ERoleGroup.Admin || this._self_user.role_group == ini_1.ERoleGroup.Creator);\r\n }\r\n get isProxy() {\r\n return this._self_user && (this._self_user.role_group == ini_1.ERoleGroup.Proxy);\r\n }\r\n get isCommon() {\r\n return this._self_user && (this._self_user.role_group == ini_1.ERoleGroup.Common);\r\n }\r\n async init() {\r\n this._engine.cfg.session_type = this._engine.cfg.session_type || FrameworkConfig_1.ESessionType.Cache;\r\n this._session_id = this._request.getCookie(this._user_session_id) || this._request.params.session_id || this._request.postData.session_id;\r\n let userId = -1;\r\n if (this._session_id) {\r\n let user = await this._getUserBySession(this._session_id);\r\n if (!user) {\r\n this._update_session();\r\n //Session不存在清除客户端cookie\r\n this._response.clearCookie(this._user_session_id);\r\n }\r\n else {\r\n this._login(user);\r\n userId = user.id;\r\n }\r\n }\r\n let params = this._request.params;\r\n if (params.userId && params.userId != userId + \"\") {\r\n this._user = (await UserService_1.GUserSer.getById(params.userId));\r\n }\r\n else {\r\n //不是别人的信息就查看自己的\r\n this._user = this._self_user;\r\n }\r\n }\r\n async _getUserBySession(session) {\r\n let user = null;\r\n if (!session) {\r\n return user;\r\n }\r\n //每次强制从cache中先找,提高效率\r\n //if(this._engine.cfg.session_type==ESessionType.Cache)\r\n {\r\n user = CacheTool_1.GCacheTool.get(this._session_id);\r\n }\r\n if (user) {\r\n return user;\r\n }\r\n if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Redis) {\r\n let user_id = parseInt((await RedisManager_1.GRedisMgr.get(this._session_id)) || \"-1\");\r\n if (user_id > 0) {\r\n user = (await UserService_1.GUserSer.getById(user_id));\r\n }\r\n }\r\n else if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Mongo) {\r\n let user_id = (await MongoCacheService_1.GMongoCacheSer.getData(this._session_id)) || -1;\r\n if (user_id > 0) {\r\n user = (await UserService_1.GUserSer.getById(user_id));\r\n }\r\n }\r\n if (user) {\r\n this._login(user);\r\n }\r\n return user;\r\n }\r\n _logout() {\r\n if (this._session_id) {\r\n if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Cache) {\r\n CacheTool_1.GCacheTool.remove(this._session_id);\r\n }\r\n else if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Redis) {\r\n RedisManager_1.GRedisMgr.del(this._session_id);\r\n }\r\n else if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Mongo) {\r\n MongoCacheService_1.GMongoCacheSer.deleteOne({ key: this._session_id });\r\n }\r\n this._session_id = null;\r\n }\r\n this._response.clearCookie(this._user_session_id);\r\n }\r\n _login(user) {\r\n if (!user) {\r\n return;\r\n }\r\n if (!this._session_id) {\r\n this._session_id = Math.random().toString(36).substring(2) + user.id;\r\n }\r\n let time = 0;\r\n if (this._request.postData.remember == \"on\") {\r\n time = this._engine.cfg.cookie.expires.account_remember;\r\n }\r\n else {\r\n time = this._engine.cfg.cookie.expires.account;\r\n }\r\n this._response.setCookie(this._user_session_id, this._session_id, time);\r\n //if(this._engine.cfg.session_type==ESessionType.Cache)\r\n {\r\n if (time > 24 * 60 * 60) {\r\n CacheTool_1.GCacheTool.add(this._session_id, user, 24 * 60 * 60 * 1000);\r\n }\r\n else {\r\n CacheTool_1.GCacheTool.add(this._session_id, user, time * 1000);\r\n }\r\n }\r\n if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Redis) {\r\n RedisManager_1.GRedisMgr.set(this._session_id, user.id).then(() => {\r\n RedisManager_1.GRedisMgr.expire(this._session_id, time);\r\n });\r\n }\r\n else if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Mongo) {\r\n let cm = new MongoCacheService_1.MongoCacheModel();\r\n cm.key = this._session_id;\r\n cm.data = user.id;\r\n cm.expireAt = Date.now() + time * 1000;\r\n MongoCacheService_1.GMongoCacheSer.updateOne(cm, { key: cm.key }, true);\r\n }\r\n this._self_user = user;\r\n }\r\n /**\r\n * 已经被启用\r\n */\r\n async _update_session() {\r\n }\r\n async update_user(user_id) {\r\n let user = (await UserService_1.GUserSer.getById(user_id));\r\n if (this._user && this._user.id == user.id) {\r\n this._user = user;\r\n }\r\n if (this._self_user && this._self_user.id == user.id) {\r\n this._login(user);\r\n }\r\n }\r\n //填充每个页面需要的通用数据\r\n _init_data(datas) {\r\n let data = super._init_data(datas);\r\n data.model.isLogin = this.isLogin;\r\n data.model.user = this._user;\r\n data.model.selfUser = this._self_user;\r\n data.model.isSelf = this.isSelf;\r\n return data;\r\n }\r\n}\r\nexports.BaseUserController = BaseUserController;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Controller/BaseUserController.js?");
|
|
900
|
+
|
|
901
|
+
/***/ }),
|
|
902
|
+
|
|
903
|
+
/***/ "./dist/lib/WebServer/Controller/MongoBaseUserController.js":
|
|
904
|
+
/*!******************************************************************!*\
|
|
905
|
+
!*** ./dist/lib/WebServer/Controller/MongoBaseUserController.js ***!
|
|
906
|
+
\******************************************************************/
|
|
907
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
908
|
+
|
|
909
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.MongoBaseUserController = void 0;\r\nconst BaseController_1 = __webpack_require__(/*! ./BaseController */ \"./dist/lib/WebServer/Controller/BaseController.js\");\r\nconst CacheTool_1 = __webpack_require__(/*! ../../Logic/CacheTool */ \"./dist/lib/Logic/CacheTool.js\");\r\nconst FrameworkConfig_1 = __webpack_require__(/*! ../../Config/FrameworkConfig */ \"./dist/lib/Config/FrameworkConfig.js\");\r\nconst RedisManager_1 = __webpack_require__(/*! ../../Database/RedisManager */ \"./dist/lib/Database/RedisManager.js\");\r\nconst MongoCacheService_1 = __webpack_require__(/*! ../../Service/MongoCacheService */ \"./dist/lib/Service/MongoCacheService.js\");\r\nconst ini_1 = __webpack_require__(/*! ../../Service/ini */ \"./dist/lib/Service/ini.js\");\r\nconst MongoUserService_1 = __webpack_require__(/*! ../../Service/MongoUserService */ \"./dist/lib/Service/MongoUserService.js\");\r\nclass MongoBaseUserController extends BaseController_1.BaseController {\r\n _user_session_id = \"user_session_id\";\r\n _self_user = null;\r\n _user = null; //网页内容的所属,比如,查看别人的博客,那这个信息就是作者的\r\n _session_id = null;\r\n get selfUser() {\r\n return this._self_user;\r\n }\r\n get isSelf() {\r\n return this._self_user && (this._self_user.id == this._user.id);\r\n }\r\n get isLogin() {\r\n return this._self_user && true;\r\n }\r\n get isCreator() {\r\n return this._self_user && (this._self_user.role_group == ini_1.ERoleGroup.Creator);\r\n }\r\n get isAdmin() {\r\n return this._self_user && (this._self_user.role_group == ini_1.ERoleGroup.Admin || this._self_user.role_group == ini_1.ERoleGroup.Creator);\r\n }\r\n get isProxy() {\r\n return this._self_user && (this._self_user.role_group == ini_1.ERoleGroup.Proxy);\r\n }\r\n get isCommon() {\r\n return this._self_user && (this._self_user.role_group == ini_1.ERoleGroup.Common);\r\n }\r\n async init() {\r\n this._engine.cfg.session_type = this._engine.cfg.session_type || FrameworkConfig_1.ESessionType.Cache;\r\n this._session_id = this._request.getCookie(this._user_session_id) || this._request.params.session_id || this._request.postData.session_id;\r\n let userId = -1;\r\n if (this._session_id) {\r\n let user = await this._getUserBySession(this._session_id);\r\n if (!user) {\r\n this._update_session();\r\n //Session不存在清除客户端cookie\r\n this._response.clearCookie(this._user_session_id);\r\n }\r\n else {\r\n this._login(user);\r\n userId = user.id;\r\n }\r\n }\r\n let params = this._request.params;\r\n if (params.userId && params.userId != userId + \"\") {\r\n this._user = (await MongoUserService_1.GUserSer.getById(params.userId));\r\n }\r\n else {\r\n //不是别人的信息就查看自己的\r\n this._user = this._self_user;\r\n }\r\n }\r\n async _getUserBySession(session) {\r\n let user = null;\r\n if (!session) {\r\n return user;\r\n }\r\n //每次强制从cache中先找,提高效率\r\n //if(this._engine.cfg.session_type==ESessionType.Cache)\r\n {\r\n user = CacheTool_1.GCacheTool.get(this._session_id);\r\n }\r\n if (user) {\r\n return user;\r\n }\r\n if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Redis) {\r\n let user_id = parseInt((await RedisManager_1.GRedisMgr.get(this._session_id)) || \"-1\");\r\n if (user_id > 0) {\r\n user = (await MongoUserService_1.GUserSer.getById(user_id));\r\n }\r\n }\r\n else if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Mongo) {\r\n let user_id = (await MongoCacheService_1.GMongoCacheSer.getData(this._session_id)) || -1;\r\n if (user_id > 0) {\r\n user = (await MongoUserService_1.GUserSer.getById(user_id));\r\n }\r\n }\r\n if (user) {\r\n this._login(user);\r\n }\r\n return user;\r\n }\r\n _logout() {\r\n if (this._session_id) {\r\n if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Cache) {\r\n CacheTool_1.GCacheTool.remove(this._session_id);\r\n }\r\n else if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Redis) {\r\n RedisManager_1.GRedisMgr.del(this._session_id);\r\n }\r\n else if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Mongo) {\r\n MongoCacheService_1.GMongoCacheSer.deleteOne({ key: this._session_id });\r\n }\r\n this._session_id = null;\r\n }\r\n this._response.clearCookie(this._user_session_id);\r\n }\r\n _login(user) {\r\n if (!user) {\r\n return;\r\n }\r\n if (!this._session_id) {\r\n this._session_id = Math.random().toString(36).substring(2) + user.id;\r\n }\r\n let time = 0;\r\n if (this._request.postData.remember == \"on\") {\r\n time = this._engine.cfg.cookie.expires.account_remember;\r\n }\r\n else {\r\n time = this._engine.cfg.cookie.expires.account;\r\n }\r\n this._response.setCookie(this._user_session_id, this._session_id, time);\r\n //if(this._engine.cfg.session_type==ESessionType.Cache)\r\n {\r\n if (time > 24 * 60 * 60) {\r\n CacheTool_1.GCacheTool.add(this._session_id, user, 24 * 60 * 60 * 1000);\r\n }\r\n else {\r\n CacheTool_1.GCacheTool.add(this._session_id, user, time * 1000);\r\n }\r\n }\r\n if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Redis) {\r\n RedisManager_1.GRedisMgr.set(this._session_id, user.id).then(() => {\r\n RedisManager_1.GRedisMgr.expire(this._session_id, time);\r\n });\r\n }\r\n else if (this._engine.cfg.session_type == FrameworkConfig_1.ESessionType.Mongo) {\r\n let cm = new MongoCacheService_1.MongoCacheModel();\r\n cm.key = this._session_id;\r\n cm.data = user.id;\r\n cm.expireAt = Date.now() + time * 1000;\r\n MongoCacheService_1.GMongoCacheSer.updateOne(cm, { key: cm.key }, true);\r\n }\r\n this._self_user = user;\r\n }\r\n /**\r\n * 已经被启用\r\n */\r\n async _update_session() {\r\n }\r\n async update_user(user_id) {\r\n let user = (await MongoUserService_1.GUserSer.getById(user_id));\r\n if (this._user && this._user.id == user.id) {\r\n this._user = user;\r\n }\r\n if (this._self_user && this._self_user.id == user.id) {\r\n this._login(user);\r\n }\r\n }\r\n //填充每个页面需要的通用数据\r\n _init_data(datas) {\r\n let data = super._init_data(datas);\r\n data.model.isLogin = this.isLogin;\r\n data.model.user = this._user;\r\n data.model.selfUser = this._self_user;\r\n data.model.isSelf = this.isSelf;\r\n return data;\r\n }\r\n}\r\nexports.MongoBaseUserController = MongoBaseUserController;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Controller/MongoBaseUserController.js?");
|
|
910
|
+
|
|
911
|
+
/***/ }),
|
|
912
|
+
|
|
913
|
+
/***/ "./dist/lib/WebServer/Decorator/AdminValidate.js":
|
|
914
|
+
/*!*******************************************************!*\
|
|
915
|
+
!*** ./dist/lib/WebServer/Decorator/AdminValidate.js ***!
|
|
916
|
+
\*******************************************************/
|
|
917
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
918
|
+
|
|
919
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AdminValidate = void 0;\r\nfunction AdminValidate(target, propertyName, descriptor) {\r\n let method = descriptor.value;\r\n descriptor.value = function () {\r\n let self = this;\r\n if (!self.isLogin) {\r\n self.redirect(null, \"Login\");\r\n return;\r\n }\r\n if (!self.isAdmin) {\r\n self.showText(\"需要管理员权限\");\r\n return;\r\n }\r\n return method.apply(this, arguments);\r\n };\r\n}\r\nexports.AdminValidate = AdminValidate;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Decorator/AdminValidate.js?");
|
|
920
|
+
|
|
921
|
+
/***/ }),
|
|
922
|
+
|
|
923
|
+
/***/ "./dist/lib/WebServer/Decorator/AuthorityValidate.js":
|
|
924
|
+
/*!***********************************************************!*\
|
|
925
|
+
!*** ./dist/lib/WebServer/Decorator/AuthorityValidate.js ***!
|
|
926
|
+
\***********************************************************/
|
|
927
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
928
|
+
|
|
929
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AuthorityValidate = void 0;\r\nlet AuthorityValidate = function (rg, ctr_name) {\r\n ctr_name = ctr_name || \"Wechat\";\r\n return function (target, propertyName, descriptor) {\r\n let method = descriptor.value;\r\n descriptor.value = function () {\r\n let self = this;\r\n if (!self.isLogin) {\r\n self.redirect(null, ctr_name);\r\n return;\r\n }\r\n if (rg && self.selfUser.role_group != rg) {\r\n self.redirect(null, ctr_name); //权限不足\r\n return;\r\n }\r\n return method.apply(this, arguments);\r\n };\r\n };\r\n};\r\nexports.AuthorityValidate = AuthorityValidate;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Decorator/AuthorityValidate.js?");
|
|
930
|
+
|
|
931
|
+
/***/ }),
|
|
932
|
+
|
|
933
|
+
/***/ "./dist/lib/WebServer/Decorator/CreatorValidate.js":
|
|
934
|
+
/*!*********************************************************!*\
|
|
935
|
+
!*** ./dist/lib/WebServer/Decorator/CreatorValidate.js ***!
|
|
936
|
+
\*********************************************************/
|
|
937
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
938
|
+
|
|
939
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.CreatorValidate = void 0;\r\nfunction CreatorValidate(target, propertyName, descriptor) {\r\n let method = descriptor.value;\r\n descriptor.value = function () {\r\n let self = this;\r\n if (!self.isLogin) {\r\n self.redirect(null, \"Login\");\r\n return;\r\n }\r\n if (!self.isCreator) {\r\n self.showText(\"需要创始人权限\");\r\n return;\r\n }\r\n return method.apply(this, arguments);\r\n };\r\n}\r\nexports.CreatorValidate = CreatorValidate;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Decorator/CreatorValidate.js?");
|
|
940
|
+
|
|
941
|
+
/***/ }),
|
|
942
|
+
|
|
943
|
+
/***/ "./dist/lib/WebServer/Decorator/JsonAdminValidate.js":
|
|
944
|
+
/*!***********************************************************!*\
|
|
945
|
+
!*** ./dist/lib/WebServer/Decorator/JsonAdminValidate.js ***!
|
|
946
|
+
\***********************************************************/
|
|
947
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
948
|
+
|
|
949
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.JsonAdminValidate = void 0;\r\nfunction JsonAdminValidate(target, propertyName, descriptor) {\r\n let method = descriptor.value;\r\n descriptor.value = function () {\r\n let self = this;\r\n if (!self.isAdmin) {\r\n self.showJson({ errcode: { id: 1, des: \"需要管理员或创始人权限\" }, err: \"需要管理员或创始人权限\" });\r\n return;\r\n }\r\n return method.apply(this, arguments);\r\n };\r\n}\r\nexports.JsonAdminValidate = JsonAdminValidate;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Decorator/JsonAdminValidate.js?");
|
|
950
|
+
|
|
951
|
+
/***/ }),
|
|
952
|
+
|
|
953
|
+
/***/ "./dist/lib/WebServer/Decorator/JsonAuthorityValidate.js":
|
|
954
|
+
/*!***************************************************************!*\
|
|
955
|
+
!*** ./dist/lib/WebServer/Decorator/JsonAuthorityValidate.js ***!
|
|
956
|
+
\***************************************************************/
|
|
957
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
958
|
+
|
|
959
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.JsonAuthorityValidate = void 0;\r\nlet JsonAuthorityValidate = function (rg) {\r\n return function (target, propertyName, descriptor) {\r\n let method = descriptor.value;\r\n descriptor.value = function () {\r\n let self = this;\r\n if (!self.isLogin) {\r\n self.showJson({ errcode: { id: 1, des: \"未登陆\" }, err: \"未登陆\" });\r\n }\r\n if (rg && self.selfUser.role_group != rg) {\r\n self.showJson({ errcode: { id: 2, des: \"权限不足\" }, err: \"权限不足\" });\r\n return;\r\n }\r\n return method.apply(this, arguments);\r\n };\r\n };\r\n};\r\nexports.JsonAuthorityValidate = JsonAuthorityValidate;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Decorator/JsonAuthorityValidate.js?");
|
|
960
|
+
|
|
961
|
+
/***/ }),
|
|
962
|
+
|
|
963
|
+
/***/ "./dist/lib/WebServer/Decorator/JsonCreatorValidate.js":
|
|
964
|
+
/*!*************************************************************!*\
|
|
965
|
+
!*** ./dist/lib/WebServer/Decorator/JsonCreatorValidate.js ***!
|
|
966
|
+
\*************************************************************/
|
|
967
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
968
|
+
|
|
969
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.JsonCreatorValidate = void 0;\r\nfunction JsonCreatorValidate(target, propertyName, descriptor) {\r\n let method = descriptor.value;\r\n descriptor.value = function () {\r\n let self = this;\r\n if (!self.isLogin) {\r\n self.showJson({ errcode: { id: 1, des: \"请登陆后尝试\" }, err: \"请登陆后尝试\" });\r\n return;\r\n }\r\n if (!self.isCreator) {\r\n self.showJson({ errcode: { id: 1, des: \"需要创始人权限\" }, err: \"需要创始人权限\" });\r\n return;\r\n }\r\n return method.apply(this, arguments);\r\n };\r\n}\r\nexports.JsonCreatorValidate = JsonCreatorValidate;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Decorator/JsonCreatorValidate.js?");
|
|
970
|
+
|
|
971
|
+
/***/ }),
|
|
972
|
+
|
|
973
|
+
/***/ "./dist/lib/WebServer/Engine/ControllerManager.js":
|
|
974
|
+
/*!********************************************************!*\
|
|
975
|
+
!*** ./dist/lib/WebServer/Engine/ControllerManager.js ***!
|
|
976
|
+
\********************************************************/
|
|
977
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
978
|
+
|
|
979
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GCtrMgr = void 0;\r\nexports.GCtrMgr = null;\r\nclass ControllerManager {\r\n _static_ctr = {};\r\n _ctr_cls = {};\r\n //module ctrname lower normal\r\n _cache_action_names = {};\r\n registerController(module_name, ctr_name, cls) {\r\n module_name = module_name.toLowerCase();\r\n ctr_name = ctr_name.toLowerCase();\r\n if (module_name == ctr_name) {\r\n throw (\"模块名称不能和控制器名称相同:\" + module_name);\r\n }\r\n this._ctr_cls[module_name] = this._ctr_cls[module_name] || {};\r\n this._ctr_cls[module_name][ctr_name] = cls;\r\n this._cacheActionName(module_name, ctr_name, cls);\r\n }\r\n _cacheActionName(module_name, ctr_name, cls) {\r\n module_name = module_name.toLowerCase();\r\n ctr_name = ctr_name.toLowerCase();\r\n //不能通过cls.name来获取ctr名称,因为混淆之后类名会变化\r\n let prototype = cls.prototype;\r\n let map_names = {};\r\n while (prototype && prototype.constructor.name != \"BaseController\") {\r\n let names = Object.getOwnPropertyNames(prototype);\r\n for (let action_name of names) {\r\n if (action_name.indexOf(\"on\") != 0\r\n && action_name.indexOf(\"show\") != 0) {\r\n continue;\r\n }\r\n if (map_names[action_name.toLowerCase()]) {\r\n continue;\r\n }\r\n map_names[action_name.toLowerCase()] = action_name;\r\n }\r\n prototype = Object.getPrototypeOf(prototype);\r\n }\r\n this._cache_action_names[module_name] = this._cache_action_names[module_name] || {};\r\n this._cache_action_names[module_name][ctr_name] = map_names;\r\n }\r\n getActionName(module_name, ctr_name, action_name) {\r\n module_name = module_name.toLowerCase();\r\n ctr_name = ctr_name.toLowerCase();\r\n action_name = action_name.toLowerCase();\r\n if (!this._cache_action_names[module_name]) {\r\n return null;\r\n }\r\n if (!this._cache_action_names[module_name][ctr_name]) {\r\n return null;\r\n }\r\n return this._cache_action_names[module_name][ctr_name][action_name];\r\n }\r\n /**\r\n * 静态ctr,这样,ctr就不会被多次创建\r\n * @param module_name\r\n * @param ctr_name\r\n * @param obj\r\n */\r\n registerStaticController(module_name, ctr_name, obj) {\r\n module_name = module_name.toLowerCase();\r\n ctr_name = ctr_name.toLowerCase();\r\n this._static_ctr[module_name] = this._static_ctr[module_name] || {};\r\n this._static_ctr[module_name][ctr_name] = obj;\r\n this._cacheActionNameForStatic(module_name, ctr_name, obj);\r\n }\r\n _cacheActionNameForStatic(module_name, ctr_name, obj) {\r\n module_name = module_name.toLowerCase();\r\n ctr_name = ctr_name.toLowerCase();\r\n let prototype = Object.getPrototypeOf(obj);\r\n let map_names = {};\r\n while (prototype && prototype.constructor.name != \"BaseController\") {\r\n let names = Object.getOwnPropertyNames(prototype);\r\n for (let func_name of names) {\r\n let low_name = func_name.toLowerCase();\r\n if (!map_names[low_name]) //有可能遭遇重载\r\n {\r\n map_names[low_name] = func_name;\r\n }\r\n }\r\n prototype = Object.getPrototypeOf(prototype);\r\n }\r\n this._cache_action_names[module_name] = this._cache_action_names[module_name] || {};\r\n this._cache_action_names[module_name][ctr_name] = map_names;\r\n }\r\n getStaticCtr(module_name, controller_name) {\r\n if (module_name) {\r\n module_name = module_name.toLowerCase();\r\n }\r\n if (controller_name) {\r\n controller_name = controller_name.toLowerCase();\r\n }\r\n if (!this._static_ctr[module_name]) {\r\n return;\r\n }\r\n return this._static_ctr[module_name][controller_name];\r\n }\r\n getClass(module_name, controller_name) {\r\n if (module_name) {\r\n module_name = module_name.toLowerCase();\r\n }\r\n if (controller_name) {\r\n controller_name = controller_name.toLowerCase();\r\n }\r\n if (!this._ctr_cls[module_name]) {\r\n return;\r\n }\r\n return this._ctr_cls[module_name][controller_name];\r\n }\r\n}\r\nexports.GCtrMgr = new ControllerManager();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Engine/ControllerManager.js?");
|
|
980
|
+
|
|
981
|
+
/***/ }),
|
|
982
|
+
|
|
983
|
+
/***/ "./dist/lib/WebServer/Engine/Engine.js":
|
|
984
|
+
/*!*********************************************!*\
|
|
985
|
+
!*** ./dist/lib/WebServer/Engine/Engine.js ***!
|
|
986
|
+
\*********************************************/
|
|
987
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
988
|
+
|
|
989
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Engine = void 0;\r\nconst Response_1 = __webpack_require__(/*! ./Response */ \"./dist/lib/WebServer/Engine/Response.js\");\r\nconst Request_1 = __webpack_require__(/*! ./Request */ \"./dist/lib/WebServer/Engine/Request.js\");\r\nconst ControllerManager_1 = __webpack_require__(/*! ./ControllerManager */ \"./dist/lib/WebServer/Engine/ControllerManager.js\");\r\nconst http = __webpack_require__(/*! http */ \"http\");\r\nconst Log_1 = __webpack_require__(/*! ../../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst cors = __webpack_require__(/*! cors */ \"cors\");\r\nconst Express = __webpack_require__(/*! express */ \"express\");\r\nconst bodyParser = __webpack_require__(/*! body-parser */ \"body-parser\");\r\nconst cookieParser = __webpack_require__(/*! cookie-parser */ \"cookie-parser\");\r\nclass Engine {\r\n _app = Express();\r\n _cfg = null;\r\n get cfg() {\r\n return this._cfg;\r\n }\r\n _server = null;\r\n _razorJs = null;\r\n _root_path = process.cwd();\r\n constructor(cfg, razorJs) {\r\n this._cfg = cfg;\r\n this._razorJs = razorJs;\r\n }\r\n start() {\r\n let port = this._cfg.port;\r\n let https = __webpack_require__(/*! https */ \"https\");\r\n let fs = __webpack_require__(/*! fs */ \"fs\");\r\n if (!port) {\r\n Log_1.GLog.error(this._cfg);\r\n return;\r\n }\r\n http.createServer(this._app).listen(port, () => {\r\n Log_1.GLog.info(\"Server(\" + this._cfg.web_name + \") running at http://127.0.0.1:\" + port + \"/\");\r\n });\r\n if (this._cfg.ssl) {\r\n const httpsOption = {\r\n key: fs.readFileSync(this._cfg.ssl.key),\r\n cert: fs.readFileSync(this._cfg.ssl.crt)\r\n };\r\n https.createServer(httpsOption, this._app).listen(port + 1);\r\n Log_1.GLog.info(\"Server(\" + this._cfg.web_name + \") running at https://127.0.0.1:\" + (port + 1) + \"/\");\r\n }\r\n this._app.use(cookieParser());\r\n this._app.use(bodyParser.json({ limit: '10mb' }));\r\n this._app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }));\r\n //处理跨域\r\n if (this._cfg.cors) {\r\n let origin = this._cfg.cors.origin || \"*\";\r\n if (this._cfg.cors.credentials == true && origin == \"*\") {\r\n origin = (origin, callback) => {\r\n callback(null, true);\r\n };\r\n }\r\n this._app.use(cors({\r\n origin: origin,\r\n methods: this._cfg.cors.methods || 'GET,HEAD,PUT,PATCH,POST,DELETE',\r\n allowedHeaders: this._cfg.cors.allowedHeaders || ['Content-Type'],\r\n credentials: this._cfg.cors.credentials || false\r\n }));\r\n }\r\n this._app.all(\"/*\", (_req, _res) => {\r\n this._all(_req, _res).catch((reason) => {\r\n Log_1.GLog.error(reason);\r\n let res = new Response_1.Response(_res, this._cfg);\r\n let method = _req.method.toLowerCase();\r\n if (method == \"post\") {\r\n res.renderJson500();\r\n }\r\n else if (method == \"get\") {\r\n res.render500();\r\n }\r\n });\r\n });\r\n }\r\n async _all(_req, _res) {\r\n let req = new Request_1.Request(_req, this._cfg);\r\n let res = new Response_1.Response(_res, this._cfg);\r\n if (req.fileUrl) {\r\n res.renderFile(this._root_path + req.fileUrl);\r\n return;\r\n }\r\n let method = req.method.toLowerCase();\r\n if (method != \"get\" && method != \"post\") {\r\n return;\r\n }\r\n let pre_action = \"show\";\r\n let action_name = \"\";\r\n if (method == \"post\") {\r\n pre_action = \"on\";\r\n }\r\n //大小写还原\r\n action_name = ControllerManager_1.GCtrMgr.getActionName(req.module, req.controller, pre_action + req.action);\r\n //尝试一次on,变态支持\r\n if (!action_name && method == \"get\") {\r\n pre_action = \"on\";\r\n action_name = ControllerManager_1.GCtrMgr.getActionName(req.module, req.controller, pre_action + req.action);\r\n }\r\n if (!action_name) {\r\n if (method == \"get\") {\r\n res.render404();\r\n }\r\n else if (method == \"post\") {\r\n res.renderJson404();\r\n }\r\n return;\r\n }\r\n let ctr = ControllerManager_1.GCtrMgr.getStaticCtr(req.module, req.controller);\r\n let cls_ctr = null;\r\n if (!ctr) {\r\n cls_ctr = ControllerManager_1.GCtrMgr.getClass(req.module, req.controller);\r\n }\r\n if (!ctr) {\r\n ctr = new cls_ctr(req, res, this);\r\n await ctr.init();\r\n }\r\n else {\r\n ctr.initStatic(req, res, this);\r\n }\r\n ctr[action_name].call(ctr);\r\n }\r\n stop() {\r\n }\r\n getRenderHtml(req, res, datas) {\r\n let tmpl = \"view/\" + req.controller.toLowerCase() + \"/\" + req.action.toLowerCase();\r\n //if(!this._cfg.routs.onlyModule)\r\n {\r\n tmpl = \"modules/\" + req.module.toLowerCase() + \"/\" + tmpl;\r\n }\r\n let html = this._getRenderHtml(req, res, tmpl, datas);\r\n return html;\r\n }\r\n _getRenderHtml(req, res, tmpl, params) {\r\n let html = null;\r\n try {\r\n html = this._razorJs.render(req, res, tmpl, params, { compileDebug: true });\r\n html = html.replace(/\\\"~/g, \"\\\"\" + req.root);\r\n html = html.replace(/\\'~/g, \"\\'\" + req.root);\r\n }\r\n catch (e) {\r\n html = \"error!\" + e;\r\n }\r\n return html;\r\n }\r\n}\r\nexports.Engine = Engine;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Engine/Engine.js?");
|
|
990
|
+
|
|
991
|
+
/***/ }),
|
|
992
|
+
|
|
993
|
+
/***/ "./dist/lib/WebServer/Engine/RazorJs.js":
|
|
994
|
+
/*!**********************************************!*\
|
|
995
|
+
!*** ./dist/lib/WebServer/Engine/RazorJs.js ***!
|
|
996
|
+
\**********************************************/
|
|
997
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
998
|
+
|
|
999
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.RazorJs = void 0;\r\nconst Log_1 = __webpack_require__(/*! ./../../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\n'use strict';\r\nvar _suffix = \".cshtml\";\r\nvar _MATCH_HTML = /[&<>\\'\"]/g;\r\nvar _ENCODE_HTML_RULES = {\r\n '&': '&',\r\n '<': '<',\r\n '>': '>',\r\n '\"': '"',\r\n \"'\": '''\r\n};\r\nvar encode_char = function (c) {\r\n return _ENCODE_HTML_RULES[c] || c;\r\n};\r\nvar utils = {\r\n regExpChars: /[|\\\\{}()[\\]^$+*?.]/g,\r\n escapeRegExpChars: function (string) {\r\n // istanbul ignore if\r\n if (!string) {\r\n return '';\r\n }\r\n return String(string).replace(this.regExpChars, '\\\\$&');\r\n },\r\n escapeFuncStr: 'var _ENCODE_HTML_RULES = {\\n'\r\n + ' \"&\": \"&\"\\n'\r\n + ' , \"<\": \"<\"\\n'\r\n + ' , \">\": \">\"\\n'\r\n + ' , \\'\"\\': \""\"\\n'\r\n + ' , \"\\'\": \"'\"\\n'\r\n + ' }\\n'\r\n + ' , _MATCH_HTML = /[&<>\\'\"]/g;\\n'\r\n + 'function encode_char(c) {\\n'\r\n + ' return _ENCODE_HTML_RULES[c] || c;\\n'\r\n + '};\\n',\r\n escapeXML: function (markup) {\r\n return markup == undefined\r\n ? ''\r\n : String(markup)\r\n .replace(_MATCH_HTML, encode_char);\r\n },\r\n shallowCopy: function (to, from) {\r\n from = from || {};\r\n for (var p in from) {\r\n to[p] = from[p];\r\n }\r\n return to;\r\n },\r\n cache: {\r\n _data: {},\r\n set: function (key, val) {\r\n this._data[key] = val;\r\n },\r\n get: function (key) {\r\n return this._data[key];\r\n },\r\n reset: function () {\r\n this._data = {};\r\n }\r\n },\r\n};\r\nutils.escapeXML.toString = function () {\r\n return Function.prototype.toString.call(this) + ';\\n' + this.escapeFuncStr;\r\n};\r\nvar fs = __webpack_require__(/*! fs */ \"fs\");\r\nvar scopeOptionWarned = false;\r\nvar _DEFAULT_DELIMITER = '%';\r\nvar _DEFAULT_LOCALS_NAME = 'locals';\r\nvar _REGEX_STRING = '(<%%|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)';\r\nvar _OPTS = ['cache', 'filename', 'delimiter', 'scope', 'context',\r\n 'debug', 'compileDebug', 'client', '_with', 'rmWhitespace',\r\n 'strict', 'localsName'\r\n];\r\nvar _TRAILING_SEMCOL = /;\\s*$/;\r\nvar _BOM = /^\\uFEFF/;\r\nclass RazorJs {\r\n _request = null;\r\n _response = null;\r\n cache = utils.cache;\r\n localsName = _DEFAULT_LOCALS_NAME;\r\n constructor() {\r\n }\r\n resolveInclude(name, filename) {\r\n var path = __webpack_require__(/*! path */ \"path\"), dirname = path.dirname, extname = path.extname, resolve = path.resolve, includePath = resolve(dirname(filename), name), ext = extname(name);\r\n if (!ext) {\r\n includePath += _suffix;\r\n }\r\n return includePath;\r\n }\r\n _handleCache(options, template) {\r\n var fn;\r\n var path = options.filename;\r\n var hasTemplate = arguments.length > 1;\r\n if (options.cache) {\r\n if (!path) {\r\n throw new Error('cache option requires a filename');\r\n }\r\n fn = exports.cache.get(path);\r\n if (fn) {\r\n return fn;\r\n }\r\n if (!hasTemplate) {\r\n template = fs.readFileSync(path).toString().replace(_BOM, '');\r\n }\r\n }\r\n else if (!hasTemplate) {\r\n // istanbul ignore if: should not happen at all\r\n if (!path) {\r\n throw new Error('Internal Razor error: no file name or template '\r\n + 'provided');\r\n }\r\n template = fs.readFileSync(path).toString().replace(_BOM, '');\r\n }\r\n fn = this.compile(template, options);\r\n if (options.cache) {\r\n this.cache.set(path, fn);\r\n }\r\n return fn;\r\n }\r\n includeFile(path, options) {\r\n var opts = utils.shallowCopy({}, options);\r\n if (!opts.filename) {\r\n throw new Error('`include` requires the \\'filename\\' option.');\r\n }\r\n opts.filename = this.resolveInclude(path, opts.filename);\r\n return this._handleCache(opts);\r\n }\r\n includeSource(path, options) {\r\n var opts = utils.shallowCopy({}, options), includePath, template;\r\n includePath = path;\r\n /*\r\n if (!opts.filename)\r\n {\r\n includePath = path;\r\n }\r\n else\r\n {\r\n includePath = this.resolveInclude(path, opts.filename);\r\n }\r\n */\r\n /*解决view里面使用其他controller的action返回的分部view,,,但是该功能暂时搁置,因为按照现在的写法无法支持异步操作\r\n * 而nodejs异步操作是特点所以不去扼杀它的优势了\r\n if (includePath.lastIndexOf(\".\") <= 0)\r\n {\r\n engine.getEngine().getHtmlFromPath(this._request,this._response,includePath)\r\n return null\r\n }\r\n * */\r\n template = fs.readFileSync(includePath).toString().replace(_BOM, '');\r\n options.filename = includePath;\r\n opts.filename = includePath;\r\n var templ = new Template(this, template, opts);\r\n templ.generateSource();\r\n return templ.source;\r\n }\r\n _cpOptsInData(data, opts) {\r\n _OPTS.forEach(function (p) {\r\n if (typeof data[p] != 'undefined') {\r\n opts[p] = data[p];\r\n }\r\n });\r\n }\r\n compile(template, opts) {\r\n var templ;\r\n // v1 compat\r\n // 'scope' is 'context'\r\n // FIXME: Remove this in a future version\r\n if (opts && opts.scope) {\r\n if (!scopeOptionWarned) {\r\n console.warn('`scope` option is deprecated and will be removed in Razor 3');\r\n scopeOptionWarned = true;\r\n }\r\n if (!opts.context) {\r\n opts.context = opts.scope;\r\n }\r\n delete opts.scope;\r\n }\r\n templ = new Template(this, template, opts);\r\n return templ.compile();\r\n }\r\n render(req, res, tmpl_path, data, opts) {\r\n this._request = req;\r\n this._response = res;\r\n var cs_path = tmpl_path + \".cshtml\";\r\n var template = fs.readFileSync(cs_path).toString();\r\n if (!template) {\r\n var h5_path = tmpl_path + \".html\";\r\n var html = fs.readFileSync(h5_path).toString();\r\n if (html) {\r\n return html;\r\n }\r\n Log_1.GLog.error(\"no view:\" + tmpl_path);\r\n return \"Server Error(No View)\";\r\n }\r\n data = data || {};\r\n opts = opts || {};\r\n var fn;\r\n // No options object -- if there are optiony names\r\n // in the data, copy them to options\r\n if (arguments.length == 2) {\r\n this._cpOptsInData(data, opts);\r\n }\r\n return this._handleCache(opts, template)(data);\r\n }\r\n renderFile() {\r\n var args = Array.prototype.slice.call(arguments), path = args.shift(), cb = args.pop(), data = args.shift() || {}, opts = args.pop() || {}, result;\r\n // Don't pollute passed in opts obj with new vals\r\n opts = utils.shallowCopy({}, opts);\r\n // No options object -- if there are optiony names\r\n // in the data, copy them to options\r\n if (arguments.length == 3) {\r\n // Express 4\r\n if (data.settings && data.settings['view options']) {\r\n this._cpOptsInData(data.settings['view options'], opts);\r\n }\r\n // Express 3 and lower\r\n else {\r\n this._cpOptsInData(data, opts);\r\n }\r\n }\r\n opts.filename = path;\r\n try {\r\n result = this._handleCache(opts)(data);\r\n }\r\n catch (err) {\r\n return cb(err);\r\n }\r\n return cb(null, result);\r\n }\r\n clearCache() {\r\n this.cache.reset();\r\n }\r\n}\r\nexports.RazorJs = RazorJs;\r\nvar rethrow = function (err, str, filename, lineno) {\r\n var lines = str.split('\\n'), start = Math.max(lineno - 3, 0), end = Math.min(lines.length, lineno + 3);\r\n // Error context\r\n var context = lines.slice(start, end).map(function (line, i) {\r\n var curr = i + start + 1;\r\n return (curr == lineno ? ' >> ' : ' ')\r\n + curr\r\n + '| '\r\n + line;\r\n }).join('\\n');\r\n // Alter exception message\r\n err.path = filename;\r\n err.message = (filename || 'razor') + ':'\r\n + lineno + '\\n'\r\n + context + '\\n\\n'\r\n + err.message;\r\n throw err;\r\n};\r\nclass Template {\r\n _razorJs = null;\r\n templateText = \"\";\r\n mode = null;\r\n truncate = false;\r\n currentLine = 1;\r\n source = \"\";\r\n dependencies = [];\r\n opts = null;\r\n regex = null;\r\n modes = {\r\n EVAL: 'eval',\r\n ESCAPED: 'escaped',\r\n RAW: 'raw',\r\n COMMENT: 'comment',\r\n LITERAL: 'literal'\r\n };\r\n constructor(razorjs, text, opts) {\r\n this._razorJs = razorjs;\r\n opts = opts || {};\r\n this.templateText = text;\r\n var options = {\r\n client: opts.client || false,\r\n escapeFunction: opts.escape || utils.escapeXML,\r\n compileDebug: opts.compileDebug !== false,\r\n debug: !!opts.debug,\r\n filename: opts.filename,\r\n delimiter: opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER,\r\n strict: opts.strict || false,\r\n context: opts.context,\r\n cache: opts.cache || false,\r\n rmWhitespace: opts.rmWhitespace,\r\n localsName: opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME,\r\n _with: false,\r\n };\r\n if (!options.strict) {\r\n options._with = typeof opts._with != 'undefined' ? opts._with : true;\r\n }\r\n this.opts = options;\r\n this.regex = this.createRegex();\r\n }\r\n createRegex() {\r\n var str = _REGEX_STRING, delim = utils.escapeRegExpChars(this.opts.delimiter);\r\n str = str.replace(/%/g, delim);\r\n return new RegExp(str);\r\n }\r\n compile() {\r\n var src, fn, opts = this.opts, prepended = '', appended = '', escape = opts.escapeFunction;\r\n if (opts.rmWhitespace) {\r\n // Have to use two separate replace here as `^` and `$` operators don't\r\n // work well with `\\r`.\r\n this.templateText =\r\n this.templateText.replace(/\\r/g, '').replace(/^\\s+|\\s+$/gm, '');\r\n }\r\n // Slurp spaces and tabs before <%_ and after _%>\r\n this.templateText =\r\n this.templateText.replace(/[ \\t]*<%_/gm, '<%_').replace(/_%>[ \\t]*/gm, '_%>');\r\n if (!this.source) {\r\n this.generateSource();\r\n prepended += ' var __output = [], __append = __output.push.bind(__output);' + '\\n';\r\n if (opts._with !== false) {\r\n prepended += ' with (' + opts.localsName + ' || {}) {' + '\\n';\r\n appended += ' }' + '\\n';\r\n }\r\n appended += ' return __output.join(\"\");' + '\\n';\r\n this.source = prepended + this.source + appended;\r\n }\r\n if (opts.compileDebug) {\r\n src = 'var __line = 1' + '\\n'\r\n + ' , __lines = ' + JSON.stringify(this.templateText) + '\\n'\r\n + ' , __filename = ' + (opts.filename ?\r\n JSON.stringify(opts.filename) : 'undefined') + ';' + '\\n'\r\n + 'try {' + '\\n'\r\n + this.source\r\n + '} catch (e) {' + '\\n'\r\n + ' rethrow(e, __lines, __filename, __line);' + '\\n'\r\n + '}' + '\\n';\r\n }\r\n else {\r\n src = this.source;\r\n }\r\n if (opts.debug) {\r\n console.log(src);\r\n }\r\n if (opts.client) {\r\n src = 'escape = escape || ' + escape.toString() + ';' + '\\n' + src;\r\n if (opts.compileDebug) {\r\n src = 'rethrow = rethrow || ' + rethrow.toString() + ';' + '\\n' + src;\r\n }\r\n }\r\n if (opts.strict) {\r\n src = '\"use strict\";\\n' + src;\r\n }\r\n try {\r\n fn = new Function(opts.localsName + ', escape, include, rethrow', src);\r\n }\r\n catch (e) {\r\n // istanbul ignore else\r\n if (e instanceof SyntaxError) {\r\n if (opts.filename) {\r\n e.message += ' in ' + opts.filename;\r\n }\r\n e.message += ' while compiling razor';\r\n }\r\n throw e;\r\n }\r\n if (opts.client) {\r\n fn.dependencies = this.dependencies;\r\n return fn;\r\n }\r\n // Return a callable function which will execute the function\r\n // created by the source-code, with the passed data as locals\r\n // Adds a local `include` function which allows full recursive include\r\n var returnedFn = (data) => {\r\n var include = (path, includeData) => {\r\n var d = utils.shallowCopy({}, data);\r\n if (includeData) {\r\n d = utils.shallowCopy(d, includeData);\r\n }\r\n return this._razorJs.includeFile(path, opts)(d);\r\n };\r\n return fn.apply(opts.context, [data || {}, escape, include, rethrow]);\r\n };\r\n returnedFn.dependencies = this.dependencies;\r\n return returnedFn;\r\n }\r\n generateSource() {\r\n var self = this;\r\n var matches = this.parseTemplateText();\r\n var d = this.opts.delimiter;\r\n if (matches && matches.length) {\r\n matches.forEach(function (line, index) {\r\n var opening;\r\n var closing;\r\n var include;\r\n var includeOpts;\r\n var includeSrc;\r\n // If this is an opening tag, check for closing tags\r\n // FIXME: May end up with some false positives here\r\n // Better to store modes as k/v with '<' + delimiter as key\r\n // Then this can simply check against the map\r\n if (line.indexOf('<' + d) === 0 // If it is a tag\r\n && line.indexOf('<' + d + d) !== 0) { // and is not escaped\r\n closing = matches[index + 2];\r\n if (!(closing == d + '>' || closing == '-' + d + '>' || closing == '_' + d + '>')) {\r\n throw new Error('Could not find matching close tag for \"' + line + '\".');\r\n }\r\n }\r\n // HACK: backward-compat `include` preprocessor directives\r\n if ((include = line.match(/^\\s*include\\s+(\\S+)/))) {\r\n opening = matches[index - 1];\r\n // Must be in EVAL or RAW mode\r\n if (opening && (opening == '<' + d || opening == '<' + d + '-' || opening == '<' + d + '_')) {\r\n includeOpts = utils.shallowCopy({}, self.opts);\r\n includeSrc = self._razorJs.includeSource(include[1], includeOpts);\r\n includeSrc = ' ; (function(){' + '\\n' + includeSrc +\r\n ' ; })()' + '\\n';\r\n self.source += includeSrc;\r\n self.dependencies.push(self._razorJs.resolveInclude(include[1], includeOpts.filename));\r\n return;\r\n }\r\n }\r\n self.scanLine(line);\r\n });\r\n }\r\n }\r\n parseTemplateText() {\r\n var str = this.templateText, pat = this.regex, result = pat.exec(str), arr = [], firstPos, lastPos;\r\n while (result) {\r\n firstPos = result.index;\r\n lastPos = pat.lastIndex;\r\n if (firstPos !== 0) {\r\n arr.push(str.substring(0, firstPos));\r\n str = str.slice(firstPos);\r\n }\r\n arr.push(result[0]);\r\n str = str.slice(result[0].length);\r\n result = pat.exec(str);\r\n }\r\n if (str) {\r\n arr.push(str);\r\n }\r\n return arr;\r\n }\r\n scanLine(line) {\r\n var self = this, d = this.opts.delimiter, newLineCount = 0;\r\n function _addOutput() {\r\n if (self.truncate) {\r\n // Only replace single leading linebreak in the line after\r\n // -%> tag -- this is the single, trailing linebreak\r\n // after the tag that the truncation mode replaces\r\n // Handle Win / Unix / old Mac linebreaks -- do the \\r\\n\r\n // combo first in the regex-or\r\n line = line.replace(/^(?:\\r\\n|\\r|\\n)/, '');\r\n self.truncate = false;\r\n }\r\n else if (self.opts.rmWhitespace) {\r\n // Gotta be more careful here.\r\n // .replace(/^(\\s*)\\n/, '$1') might be more appropriate here but as\r\n // rmWhitespace already removes trailing spaces anyway so meh.\r\n line = line.replace(/^\\n/, '');\r\n }\r\n if (!line) {\r\n return;\r\n }\r\n // Preserve literal slashes\r\n line = line.replace(/\\\\/g, '\\\\\\\\');\r\n // Convert linebreaks\r\n line = line.replace(/\\n/g, '\\\\n');\r\n line = line.replace(/\\r/g, '\\\\r');\r\n // Escape double-quotes\r\n // - this will be the delimiter during execution\r\n line = line.replace(/\"/g, '\\\\\"');\r\n self.source += ' ; __append(\"' + line + '\")' + '\\n';\r\n }\r\n newLineCount = (line.split('\\n').length - 1);\r\n switch (line) {\r\n case '<' + d:\r\n case '<' + d + '_':\r\n this.mode = this.modes.EVAL;\r\n break;\r\n case '<' + d + '=':\r\n this.mode = this.modes.ESCAPED;\r\n break;\r\n case '<' + d + '-':\r\n this.mode = this.modes.RAW;\r\n break;\r\n case '<' + d + '#':\r\n this.mode = this.modes.COMMENT;\r\n break;\r\n case '<' + d + d:\r\n this.mode = this.modes.LITERAL;\r\n this.source += ' ; __append(\"' + line.replace('<' + d + d, '<' + d) + '\")' + '\\n';\r\n break;\r\n case d + '>':\r\n case '-' + d + '>':\r\n case '_' + d + '>':\r\n if (this.mode == this.modes.LITERAL) {\r\n _addOutput();\r\n }\r\n this.mode = null;\r\n this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;\r\n break;\r\n default:\r\n // In script mode, depends on type of tag\r\n if (this.mode) {\r\n // If '//' is found without a line break, add a line break.\r\n switch (this.mode) {\r\n case this.modes.EVAL:\r\n case this.modes.ESCAPED:\r\n case this.modes.RAW:\r\n if (line.lastIndexOf('//') > line.lastIndexOf('\\n')) {\r\n line += '\\n';\r\n }\r\n }\r\n switch (this.mode) {\r\n // Just executing code\r\n case this.modes.EVAL:\r\n this.source += ' ; ' + line + '\\n';\r\n break;\r\n // Exec, esc, and output\r\n case this.modes.ESCAPED:\r\n this.source += ' ; __append(escape(' +\r\n line.replace(_TRAILING_SEMCOL, '').trim() + '))' + '\\n';\r\n break;\r\n // Exec and output\r\n case this.modes.RAW:\r\n this.source += ' ; __append(' +\r\n line.replace(_TRAILING_SEMCOL, '').trim() + ')' + '\\n';\r\n break;\r\n case this.modes.COMMENT:\r\n // Do nothing\r\n break;\r\n // Literal <%% mode, append as raw output\r\n case this.modes.LITERAL:\r\n _addOutput();\r\n break;\r\n }\r\n }\r\n // In string mode, just add the output\r\n else {\r\n _addOutput();\r\n }\r\n }\r\n if (self.opts.compileDebug && newLineCount) {\r\n this.currentLine += newLineCount;\r\n this.source += ' ; __line = ' + this.currentLine + '\\n';\r\n }\r\n }\r\n}\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Engine/RazorJs.js?");
|
|
1000
|
+
|
|
1001
|
+
/***/ }),
|
|
1002
|
+
|
|
1003
|
+
/***/ "./dist/lib/WebServer/Engine/Request.js":
|
|
1004
|
+
/*!**********************************************!*\
|
|
1005
|
+
!*** ./dist/lib/WebServer/Engine/Request.js ***!
|
|
1006
|
+
\**********************************************/
|
|
1007
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1008
|
+
|
|
1009
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Request = void 0;\r\nconst qs = __webpack_require__(/*! querystring */ \"querystring\");\r\nconst Core_1 = __webpack_require__(/*! ../../Core/Core */ \"./dist/lib/Core/Core.js\");\r\nconst Log_1 = __webpack_require__(/*! ../../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nclass Request {\r\n _req = null;\r\n get baseReq() {\r\n return this._req;\r\n }\r\n _cfg = null;\r\n _post_cb = null;\r\n set onPost(value) {\r\n this._post_cb = value;\r\n }\r\n _module = \"\";\r\n get module() {\r\n return this._module;\r\n }\r\n _controller = \"\";\r\n get controller() {\r\n return this._controller;\r\n }\r\n _action = \"\";\r\n get action() {\r\n return this._action;\r\n }\r\n _suffix = \"\";\r\n get suffix() {\r\n return this._suffix;\r\n }\r\n _file_url = null;\r\n get fileUrl() {\r\n return this._file_url;\r\n }\r\n _params = {};\r\n get params() {\r\n var body = (this._req.query || {});\r\n for (let k in body) {\r\n var v = body[k];\r\n if (!Core_1.core.isString(v)) {\r\n continue;\r\n }\r\n if (parseInt(v) == v) {\r\n body[k] = parseInt(v);\r\n }\r\n else if (parseFloat(v) == v) {\r\n body[k] == parseFloat(v);\r\n }\r\n }\r\n return body;\r\n }\r\n get postData() {\r\n var body = this._req.body || {};\r\n //服务器会有一层空key的json解析\r\n for (let k in body) {\r\n var v = body[k];\r\n if (!Core_1.core.isString(v)) {\r\n continue;\r\n }\r\n if (parseInt(v) == v) {\r\n body[k] = parseInt(v);\r\n }\r\n else if (parseFloat(v) == v) {\r\n body[k] == parseFloat(v);\r\n }\r\n }\r\n return body;\r\n }\r\n get url() {\r\n return this._req.url;\r\n }\r\n get root() {\r\n let root = this._req.headers.host;\r\n if (root != \"\") {\r\n root = this._req.protocol + \"://\" + root;\r\n }\r\n return root;\r\n }\r\n get method() {\r\n return this._req.method;\r\n }\r\n get headers() {\r\n return this._req.headers;\r\n }\r\n get remoteHost() {\r\n let ips = this._req.headers['x-forwarded-for'];\r\n let ip = \"\";\r\n if (Core_1.core.isArray(ips)) {\r\n ip = ips[0];\r\n }\r\n else {\r\n ip = ips;\r\n }\r\n ip = ip ||\r\n this._req.connection.remoteAddress ||\r\n this._req.socket.remoteAddress ||\r\n this._req.ip || \"\";\r\n ip = ip.replace(\"::ffff:\", \"\");\r\n return ip;\r\n }\r\n constructor(req, cfg) {\r\n this._cfg = cfg;\r\n this._req = req;\r\n this._init();\r\n }\r\n getCookie(key) {\r\n let cookie_key = this._cfg.cookie.prefix + key;\r\n if (!this._req.cookies) {\r\n return null;\r\n }\r\n return this._req.cookies[cookie_key];\r\n }\r\n _init() {\r\n let method = this._req.method.toLowerCase();\r\n if (method != \"get\" && method != \"post\") {\r\n return;\r\n }\r\n let path = this._req.url;\r\n //服务器根目录路径写法,链接转换\r\n let _i = path.lastIndexOf(\"~\");\r\n if (_i >= 0) {\r\n path = path.substr(_i + 1);\r\n }\r\n //处理参数\r\n this._parseParams(path);\r\n }\r\n _addListener(event, listener) {\r\n this._req.addListener(event, listener);\r\n }\r\n _parseParams(path) {\r\n this._module = this._cfg.routs.onlyModule || this._cfg.routs.defaults.module;\r\n this._controller = this._cfg.routs.defaults.controller;\r\n this._action = this._cfg.routs.defaults.action;\r\n this._suffix = null;\r\n this._file_url = null;\r\n this._params = {};\r\n if (path == \"/\") {\r\n return;\r\n }\r\n let firstQuoteIndex = path.indexOf(\"?\");\r\n let preQuoteStr = path;\r\n if (firstQuoteIndex > 0) {\r\n preQuoteStr = path.substr(0, firstQuoteIndex);\r\n }\r\n let lastDotIndex = preQuoteStr.lastIndexOf(\".\");\r\n if (lastDotIndex > 0) {\r\n let dotStr = preQuoteStr.substr(lastDotIndex + 1);\r\n this._suffix = dotStr;\r\n this._file_url = preQuoteStr;\r\n return;\r\n }\r\n let quote_index = path.indexOf(\"?\");\r\n if (quote_index >= 0) {\r\n let p = path.substr(quote_index + 1);\r\n path = path.substr(0, quote_index);\r\n this._params = qs.parse(p);\r\n }\r\n let params = path.split(\"/\");\r\n let default_module = false;\r\n if (this._cfg.routs.onlyModule) {\r\n default_module = true;\r\n }\r\n if (params.length > 1 && params[1].length > 0) {\r\n /**\r\n * 如果是only模式,那么就不支持controller和module相同,\r\n * 如果相同则认为是模块名,这样就可以同时支持,带模块的路径模式和非带模块的路径模式了\r\n */\r\n if (default_module\r\n && params[1].toLowerCase() == this._cfg.routs.onlyModule.toLowerCase()) {\r\n default_module = false;\r\n }\r\n if (default_module) {\r\n this._controller = params[1];\r\n }\r\n else {\r\n this._module = params[1];\r\n }\r\n }\r\n if (params.length > 2 && params[2].length > 0) {\r\n if (default_module) {\r\n this._action = params[2];\r\n }\r\n else {\r\n this._controller = params[2];\r\n }\r\n }\r\n if (params.length > 3\r\n && params[3].length > 0\r\n && !default_module) {\r\n this._action = params[3];\r\n }\r\n this._params = this._params || {};\r\n return;\r\n }\r\n debugInfo() {\r\n if (!this._cfg.debug) {\r\n return;\r\n }\r\n let debuginfo = {\r\n module: this._module,\r\n controller: this._controller,\r\n action: this._action,\r\n suffix: this._suffix,\r\n file_url: this._file_url,\r\n params: this._params,\r\n post: this.postData,\r\n method: this._req.method.toLowerCase()\r\n };\r\n Log_1.GLog.info(debuginfo);\r\n }\r\n}\r\nexports.Request = Request;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Engine/Request.js?");
|
|
1010
|
+
|
|
1011
|
+
/***/ }),
|
|
1012
|
+
|
|
1013
|
+
/***/ "./dist/lib/WebServer/Engine/Response.js":
|
|
1014
|
+
/*!***********************************************!*\
|
|
1015
|
+
!*** ./dist/lib/WebServer/Engine/Response.js ***!
|
|
1016
|
+
\***********************************************/
|
|
1017
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1018
|
+
|
|
1019
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Response = void 0;\r\nconst fs = __webpack_require__(/*! fs */ \"fs\");\r\nconst mime = __webpack_require__(/*! mime */ \"mime\");\r\nconst Log_1 = __webpack_require__(/*! ../../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nclass Response {\r\n _res = null;\r\n _cookie_prefix = \"\";\r\n _cfg = null;\r\n _create_time = -1;\r\n constructor(res, cfg) {\r\n this._cfg = cfg;\r\n this._res = res;\r\n this._cookie_prefix = this._cfg.cookie.prefix;\r\n this._init();\r\n }\r\n _init() {\r\n this._create_time = Date.now();\r\n }\r\n /**\r\n *\r\n * @param key\r\n * @param value\r\n * @param time 秒\r\n */\r\n setCookie(key, value, time) {\r\n key = this._cookie_prefix + key;\r\n if (time) {\r\n this._res.cookie(key, value, { maxAge: time * 1000, httpOnly: true });\r\n }\r\n else {\r\n this._res.cookie(key, value, { httpOnly: true });\r\n }\r\n }\r\n clearCookie(key) {\r\n this.setCookie(key, \"\", -1000);\r\n }\r\n redirect(path) {\r\n this._res.writeHead(302, { 'Location': path });\r\n this._res.end();\r\n }\r\n renderJson(data, origin) {\r\n this._res.json(data);\r\n this.debugInfo(data);\r\n }\r\n renderJson404(origin) {\r\n this._res.status(404).json();\r\n }\r\n renderJson500(origin) {\r\n this._res.status(500).json();\r\n this.debugInfo(\"500\");\r\n }\r\n renderHtml(html) {\r\n this._res.send(html || \"\");\r\n }\r\n render404(html) {\r\n this._res.status(404).send(html || \"没找到该页面\");\r\n }\r\n render500(html) {\r\n this._res.status(500).send(html || \"服务器内部错误500\");\r\n }\r\n renderOptions(method, origin) {\r\n this._res.sendStatus(204);\r\n }\r\n renderFile(fullPath) {\r\n this._res.sendFile(fullPath);\r\n }\r\n downloadFile(fullPath) {\r\n let fileName = \"\";\r\n let quote_index = fullPath.indexOf(\"/\");\r\n if (quote_index > 0) {\r\n fileName = fullPath.substring(quote_index + 1);\r\n }\r\n fs.stat(fullPath, (err, stats) => {\r\n if (!stats || stats.isDirectory()) {\r\n return this.render404(\"\");\r\n }\r\n let size = stats.size;\r\n var f = fs.createReadStream(fullPath);\r\n this._res.writeHead(200, {\r\n 'Content-Type': mime.getType(fullPath) || 'application/octet-stream',\r\n 'Content-Disposition': 'attachment; filename=' + fileName,\r\n 'Content-Length': size\r\n });\r\n f.pipe(this._res);\r\n });\r\n }\r\n render304() {\r\n this._res.sendStatus(304);\r\n }\r\n debugInfo(data) {\r\n if (!this._cfg.debug) {\r\n return;\r\n }\r\n Log_1.GLog.info(\"dttime:\" + (Date.now() - this._create_time).toLocaleString() + \"ms\");\r\n Log_1.GLog.info(data);\r\n }\r\n}\r\nexports.Response = Response;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/Engine/Response.js?");
|
|
1020
|
+
|
|
1021
|
+
/***/ }),
|
|
1022
|
+
|
|
1023
|
+
/***/ "./dist/lib/WebServer/IWebServer.js":
|
|
1024
|
+
/*!******************************************!*\
|
|
1025
|
+
!*** ./dist/lib/WebServer/IWebServer.js ***!
|
|
1026
|
+
\******************************************/
|
|
1027
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1028
|
+
|
|
1029
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.IWebServer = void 0;\r\nconst Engine_1 = __webpack_require__(/*! ./Engine/Engine */ \"./dist/lib/WebServer/Engine/Engine.js\");\r\nconst Log_1 = __webpack_require__(/*! ../Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst RedisManager_1 = __webpack_require__(/*! ../Database/RedisManager */ \"./dist/lib/Database/RedisManager.js\");\r\nconst MysqlManager_1 = __webpack_require__(/*! ../Database/MysqlManager */ \"./dist/lib/Database/MysqlManager.js\");\r\nconst RazorJs_1 = __webpack_require__(/*! ./Engine/RazorJs */ \"./dist/lib/WebServer/Engine/RazorJs.js\");\r\nconst MongoManager_1 = __webpack_require__(/*! ../Database/MongoManager */ \"./dist/lib/Database/MongoManager.js\");\r\nconst AlipayTool_1 = __webpack_require__(/*! ../ThirdParty/AlipayTool */ \"./dist/lib/ThirdParty/AlipayTool.js\");\r\nconst ServerConfig_1 = __webpack_require__(/*! ../Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nconst EventTool_1 = __webpack_require__(/*! ../Logic/EventTool */ \"./dist/lib/Logic/EventTool.js\");\r\nconst cgserver_1 = __webpack_require__(/*! ../cgserver */ \"./dist/lib/cgserver.js\");\r\n//实现对controller的手动注册\r\nclass IWebServer {\r\n _engine = null;\r\n /**\r\n * 启动服务器\r\n * @param server_index 这个是服务器的配置index\r\n */\r\n async start(cfg) {\r\n cgserver_1.GCgServer.addWebServer(this);\r\n if (!cfg) {\r\n Log_1.GLog.error(\"webserver 配置不存在,启动服务器失败\");\r\n return false;\r\n }\r\n await RedisManager_1.GRedisMgr.init(ServerConfig_1.GServerCfg.db.redis);\r\n await MysqlManager_1.GMysqlMgr.init();\r\n await MongoManager_1.GMongoMgr.init();\r\n AlipayTool_1.GAlipayTool.init();\r\n //初始化web引擎\r\n this._engine = new Engine_1.Engine(cfg, new RazorJs_1.RazorJs());\r\n this._engine.start();\r\n this._registerController();\r\n this._registerRouter();\r\n EventTool_1.GEventTool.emit(\"web_server_init_done\");\r\n }\r\n stop() {\r\n this._engine.stop();\r\n }\r\n /**\r\n * 注册控制器\r\n * eg:GControllerMgr.registerController(\"Admin\",\"System\",SystemController)\r\n */\r\n _registerController() {\r\n }\r\n /**\r\n * 注册路由\r\n */\r\n _registerRouter() {\r\n }\r\n}\r\nexports.IWebServer = IWebServer;\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/WebServer/IWebServer.js?");
|
|
1030
|
+
|
|
1031
|
+
/***/ }),
|
|
1032
|
+
|
|
1033
|
+
/***/ "./dist/lib/cgserver.js":
|
|
1034
|
+
/*!******************************!*\
|
|
1035
|
+
!*** ./dist/lib/cgserver.js ***!
|
|
1036
|
+
\******************************/
|
|
1037
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1038
|
+
|
|
1039
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GCgServer = void 0;\r\nconst Log_1 = __webpack_require__(/*! ./Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nconst EventTool_1 = __webpack_require__(/*! ./Logic/EventTool */ \"./dist/lib/Logic/EventTool.js\");\r\nconst Core_1 = __webpack_require__(/*! ./Core/Core */ \"./dist/lib/Core/Core.js\");\r\nconst Config_1 = __webpack_require__(/*! ./Config/Config */ \"./dist/lib/Config/Config.js\");\r\nclass CgServer {\r\n _webservers = [];\r\n get webServers() {\r\n return this._webservers;\r\n }\r\n _socketservers = [];\r\n get socketServers() {\r\n return this._socketservers;\r\n }\r\n _events = {};\r\n _debug = false;\r\n get debug() {\r\n return this._debug;\r\n }\r\n constructor() {\r\n this.init();\r\n }\r\n init(servernum = 1) {\r\n process.on(\"uncaughtException\", this.onUnCaughtException.bind(this));\r\n process.env.TZ = \"Asia/Shanghai\";\r\n EventTool_1.GEventTool.on(\"socket_server_init_done\", this.onStart.bind(this));\r\n EventTool_1.GEventTool.on(\"web_server_init_done\", this.onStart.bind(this));\r\n let argv = process.argv || [];\r\n for (let i = 0; i < argv.length; ++i) {\r\n let arg = argv[i].toLowerCase();\r\n if (arg == \"-d\" || arg == \"-debug\") {\r\n Config_1.Config.debug = true;\r\n this._debug = true;\r\n }\r\n }\r\n }\r\n _done = 0;\r\n onStart() {\r\n ++this._done;\r\n let total = this._webservers.length + this._socketservers.length;\r\n if (this._done != total) {\r\n return;\r\n }\r\n let events = this._events[\"start\"] || [];\r\n for (let i = 0; i < events.length; ++i) {\r\n Core_1.core.safeCall(events[i]);\r\n }\r\n }\r\n addListener(event, func) {\r\n this._events[event] = this._events[event] || [];\r\n this._events[event].push(func);\r\n }\r\n removeListener(event, func) {\r\n let events = this._events[event];\r\n if (!events) {\r\n return false;\r\n }\r\n let index = events.findIndex((_func) => _func == func);\r\n if (index < 0) {\r\n return false;\r\n }\r\n events.splice(index, 1);\r\n return true;\r\n }\r\n onUnCaughtException(e) {\r\n Log_1.GLog.error(e.stack);\r\n }\r\n addWebServer(server) {\r\n this._webservers.push(server);\r\n }\r\n addSocketServer(server) {\r\n this._socketservers.push(server);\r\n }\r\n}\r\nexports.GCgServer = new CgServer();\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/cgserver.js?");
|
|
1040
|
+
|
|
1041
|
+
/***/ }),
|
|
1042
|
+
|
|
1043
|
+
/***/ "./dist/lib/index.js":
|
|
1044
|
+
/*!***************************!*\
|
|
1045
|
+
!*** ./dist/lib/index.js ***!
|
|
1046
|
+
\***************************/
|
|
1047
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1048
|
+
|
|
1049
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.GoogleProtoFilter = exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.GMongoAccountSer = exports.MongoAccountService = exports.GMysqlAccountSer = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = exports.MongoBaseModel = exports.MysqlBaseModel = exports.MongoBaseService = exports.EPropertyType = exports.Type = exports.Table = exports.Property = exports.PrimaryKey = exports.NotNull = exports.AutoIncrement = exports.Timer = exports.core = exports.GServerCfg = exports.ServerConfig = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GProtoFactory = exports.GCgServer = void 0;\r\nexports.EAccountState = exports.GEventTool = exports.GAsyncQueueTool = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = exports.IServerWebSocket = exports.IClientWebSocket = exports.JsonProtoFilter = void 0;\r\nvar cgserver_1 = __webpack_require__(/*! ./cgserver */ \"./dist/lib/cgserver.js\");\r\nObject.defineProperty(exports, \"GCgServer\", ({ enumerable: true, get: function () { return cgserver_1.GCgServer; } }));\r\nvar ProtoFactory_1 = __webpack_require__(/*! ./SocketServer/ProtoFilter/ProtoFactory */ \"./dist/lib/SocketServer/ProtoFilter/ProtoFactory.js\");\r\nObject.defineProperty(exports, \"GProtoFactory\", ({ enumerable: true, get: function () { return ProtoFactory_1.GProtoFactory; } }));\r\nvar DBCache_1 = __webpack_require__(/*! ./Database/Decorator/DBCache */ \"./dist/lib/Database/Decorator/DBCache.js\");\r\nObject.defineProperty(exports, \"GDBCache\", ({ enumerable: true, get: function () { return DBCache_1.GDBCache; } }));\r\nvar AiObject_1 = __webpack_require__(/*! ./AI/AiObject */ \"./dist/lib/AI/AiObject.js\");\r\nObject.defineProperty(exports, \"AiObject\", ({ enumerable: true, get: function () { return AiObject_1.AiObject; } }));\r\nvar Astar_1 = __webpack_require__(/*! ./AI/Astar */ \"./dist/lib/AI/Astar.js\");\r\nObject.defineProperty(exports, \"AStar\", ({ enumerable: true, get: function () { return Astar_1.AStar; } }));\r\nvar BehaviorAI_1 = __webpack_require__(/*! ./AI/BehaviorAI */ \"./dist/lib/AI/BehaviorAI.js\");\r\nObject.defineProperty(exports, \"BehaviorAI\", ({ enumerable: true, get: function () { return BehaviorAI_1.BehaviorAI; } }));\r\nvar Entity_1 = __webpack_require__(/*! ./AI/Entity */ \"./dist/lib/AI/Entity.js\");\r\nObject.defineProperty(exports, \"Entity\", ({ enumerable: true, get: function () { return Entity_1.Entity; } }));\r\nvar Point_1 = __webpack_require__(/*! ./AI/Point */ \"./dist/lib/AI/Point.js\");\r\nObject.defineProperty(exports, \"Point\", ({ enumerable: true, get: function () { return Point_1.Point; } }));\r\nvar TriggerMgr_1 = __webpack_require__(/*! ./AI/TriggerMgr */ \"./dist/lib/AI/TriggerMgr.js\");\r\nObject.defineProperty(exports, \"Trigger\", ({ enumerable: true, get: function () { return TriggerMgr_1.Trigger; } }));\r\nObject.defineProperty(exports, \"GTriggerMgr\", ({ enumerable: true, get: function () { return TriggerMgr_1.GTriggerMgr; } }));\r\nvar _error_1 = __webpack_require__(/*! ./Config/_error_ */ \"./dist/lib/Config/_error_.js\");\r\nObject.defineProperty(exports, \"FrameworkErrorCode\", ({ enumerable: true, get: function () { return _error_1.FrameworkErrorCode; } }));\r\nvar Config_1 = __webpack_require__(/*! ./Config/Config */ \"./dist/lib/Config/Config.js\");\r\nObject.defineProperty(exports, \"Config\", ({ enumerable: true, get: function () { return Config_1.Config; } }));\r\nvar FrameworkConfig_1 = __webpack_require__(/*! ./Config/FrameworkConfig */ \"./dist/lib/Config/FrameworkConfig.js\");\r\nObject.defineProperty(exports, \"FrameworkConfig\", ({ enumerable: true, get: function () { return FrameworkConfig_1.FrameworkConfig; } }));\r\nvar ServerConfig_1 = __webpack_require__(/*! ./Config/ServerConfig */ \"./dist/lib/Config/ServerConfig.js\");\r\nObject.defineProperty(exports, \"ServerConfig\", ({ enumerable: true, get: function () { return ServerConfig_1.ServerConfig; } }));\r\nObject.defineProperty(exports, \"GServerCfg\", ({ enumerable: true, get: function () { return ServerConfig_1.GServerCfg; } }));\r\nvar Core_1 = __webpack_require__(/*! ./Core/Core */ \"./dist/lib/Core/Core.js\");\r\nObject.defineProperty(exports, \"core\", ({ enumerable: true, get: function () { return Core_1.core; } }));\r\nvar Timer_1 = __webpack_require__(/*! ./Core/Timer */ \"./dist/lib/Core/Timer.js\");\r\nObject.defineProperty(exports, \"Timer\", ({ enumerable: true, get: function () { return Timer_1.Timer; } }));\r\nvar AutoIncrement_1 = __webpack_require__(/*! ./Database/Decorator/AutoIncrement */ \"./dist/lib/Database/Decorator/AutoIncrement.js\");\r\nObject.defineProperty(exports, \"AutoIncrement\", ({ enumerable: true, get: function () { return AutoIncrement_1.AutoIncrement; } }));\r\nvar NotNull_1 = __webpack_require__(/*! ./Database/Decorator/NotNull */ \"./dist/lib/Database/Decorator/NotNull.js\");\r\nObject.defineProperty(exports, \"NotNull\", ({ enumerable: true, get: function () { return NotNull_1.NotNull; } }));\r\nvar PrimaryKey_1 = __webpack_require__(/*! ./Database/Decorator/PrimaryKey */ \"./dist/lib/Database/Decorator/PrimaryKey.js\");\r\nObject.defineProperty(exports, \"PrimaryKey\", ({ enumerable: true, get: function () { return PrimaryKey_1.PrimaryKey; } }));\r\nvar Property_1 = __webpack_require__(/*! ./Database/Decorator/Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nObject.defineProperty(exports, \"Property\", ({ enumerable: true, get: function () { return Property_1.Property; } }));\r\nvar Table_1 = __webpack_require__(/*! ./Database/Decorator/Table */ \"./dist/lib/Database/Decorator/Table.js\");\r\nObject.defineProperty(exports, \"Table\", ({ enumerable: true, get: function () { return Table_1.Table; } }));\r\nvar Type_1 = __webpack_require__(/*! ./Database/Decorator/Type */ \"./dist/lib/Database/Decorator/Type.js\");\r\nObject.defineProperty(exports, \"Type\", ({ enumerable: true, get: function () { return Type_1.Type; } }));\r\nvar Property_2 = __webpack_require__(/*! ./Database/Decorator/Property */ \"./dist/lib/Database/Decorator/Property.js\");\r\nObject.defineProperty(exports, \"EPropertyType\", ({ enumerable: true, get: function () { return Property_2.EPropertyType; } }));\r\nvar MongoBaseService_1 = __webpack_require__(/*! ./Database/MongoBaseService */ \"./dist/lib/Database/MongoBaseService.js\");\r\nObject.defineProperty(exports, \"MongoBaseService\", ({ enumerable: true, get: function () { return MongoBaseService_1.MongoBaseService; } }));\r\nvar MysqlBaseService_1 = __webpack_require__(/*! ./Database/MysqlBaseService */ \"./dist/lib/Database/MysqlBaseService.js\");\r\nObject.defineProperty(exports, \"MysqlBaseModel\", ({ enumerable: true, get: function () { return MysqlBaseService_1.BaseModel; } }));\r\nvar MongoManager_1 = __webpack_require__(/*! ./Database/MongoManager */ \"./dist/lib/Database/MongoManager.js\");\r\nObject.defineProperty(exports, \"MongoBaseModel\", ({ enumerable: true, get: function () { return MongoManager_1.MongoBaseModel; } }));\r\nvar MongoManager_2 = __webpack_require__(/*! ./Database/MongoManager */ \"./dist/lib/Database/MongoManager.js\");\r\nObject.defineProperty(exports, \"GMongoMgr\", ({ enumerable: true, get: function () { return MongoManager_2.GMongoMgr; } }));\r\nvar MSSqlManager_1 = __webpack_require__(/*! ./Database/MSSqlManager */ \"./dist/lib/Database/MSSqlManager.js\");\r\nObject.defineProperty(exports, \"GMSSqlMgr\", ({ enumerable: true, get: function () { return MSSqlManager_1.GMSSqlMgr; } }));\r\nvar MysqlBaseService_2 = __webpack_require__(/*! ./Database/MysqlBaseService */ \"./dist/lib/Database/MysqlBaseService.js\");\r\nObject.defineProperty(exports, \"MysqlBaseService\", ({ enumerable: true, get: function () { return MysqlBaseService_2.MysqlBaseService; } }));\r\nvar MysqlManager_1 = __webpack_require__(/*! ./Database/MysqlManager */ \"./dist/lib/Database/MysqlManager.js\");\r\nObject.defineProperty(exports, \"GMysqlMgr\", ({ enumerable: true, get: function () { return MysqlManager_1.GMysqlMgr; } }));\r\nvar RedisManager_1 = __webpack_require__(/*! ./Database/RedisManager */ \"./dist/lib/Database/RedisManager.js\");\r\nObject.defineProperty(exports, \"GRedisMgr\", ({ enumerable: true, get: function () { return RedisManager_1.GRedisMgr; } }));\r\nObject.defineProperty(exports, \"RedisManager\", ({ enumerable: true, get: function () { return RedisManager_1.RedisManager; } }));\r\nvar CacheTool_1 = __webpack_require__(/*! ./Logic/CacheTool */ \"./dist/lib/Logic/CacheTool.js\");\r\nObject.defineProperty(exports, \"GCacheTool\", ({ enumerable: true, get: function () { return CacheTool_1.GCacheTool; } }));\r\nvar HttpTool_1 = __webpack_require__(/*! ./Logic/HttpTool */ \"./dist/lib/Logic/HttpTool.js\");\r\nObject.defineProperty(exports, \"GHttpTool\", ({ enumerable: true, get: function () { return HttpTool_1.GHttpTool; } }));\r\nvar Log_1 = __webpack_require__(/*! ./Logic/Log */ \"./dist/lib/Logic/Log.js\");\r\nObject.defineProperty(exports, \"GLog\", ({ enumerable: true, get: function () { return Log_1.GLog; } }));\r\nvar ini_1 = __webpack_require__(/*! ./Service/ini */ \"./dist/lib/Service/ini.js\");\r\nObject.defineProperty(exports, \"ERoleGroup\", ({ enumerable: true, get: function () { return ini_1.ERoleGroup; } }));\r\nObject.defineProperty(exports, \"EUserState\", ({ enumerable: true, get: function () { return ini_1.EUserState; } }));\r\nObject.defineProperty(exports, \"EAccountFrom\", ({ enumerable: true, get: function () { return ini_1.EAccountFrom; } }));\r\nvar AccountService_1 = __webpack_require__(/*! ./Service/AccountService */ \"./dist/lib/Service/AccountService.js\");\r\nObject.defineProperty(exports, \"MysqlAccountService\", ({ enumerable: true, get: function () { return AccountService_1.AccountService; } }));\r\nObject.defineProperty(exports, \"GMysqlAccountSer\", ({ enumerable: true, get: function () { return AccountService_1.GAccountSer; } }));\r\nvar MongoAccountService_1 = __webpack_require__(/*! ./Service/MongoAccountService */ \"./dist/lib/Service/MongoAccountService.js\");\r\nObject.defineProperty(exports, \"MongoAccountService\", ({ enumerable: true, get: function () { return MongoAccountService_1.AccountService; } }));\r\nObject.defineProperty(exports, \"GMongoAccountSer\", ({ enumerable: true, get: function () { return MongoAccountService_1.GAccountSer; } }));\r\nvar UserService_1 = __webpack_require__(/*! ./Service/UserService */ \"./dist/lib/Service/UserService.js\");\r\nObject.defineProperty(exports, \"MysqlUserService\", ({ enumerable: true, get: function () { return UserService_1.UserService; } }));\r\nvar MongoUserService_1 = __webpack_require__(/*! ./Service/MongoUserService */ \"./dist/lib/Service/MongoUserService.js\");\r\nObject.defineProperty(exports, \"MongoUserService\", ({ enumerable: true, get: function () { return MongoUserService_1.UserService; } }));\r\nvar UserService_2 = __webpack_require__(/*! ./Service/UserService */ \"./dist/lib/Service/UserService.js\");\r\nObject.defineProperty(exports, \"MysqlUserModel\", ({ enumerable: true, get: function () { return UserService_2.UserModel; } }));\r\nvar MongoUserService_2 = __webpack_require__(/*! ./Service/MongoUserService */ \"./dist/lib/Service/MongoUserService.js\");\r\nObject.defineProperty(exports, \"MongoUserModel\", ({ enumerable: true, get: function () { return MongoUserService_2.UserModel; } }));\r\nvar MongoCacheService_1 = __webpack_require__(/*! ./Service/MongoCacheService */ \"./dist/lib/Service/MongoCacheService.js\");\r\nObject.defineProperty(exports, \"GMongoCacheSer\", ({ enumerable: true, get: function () { return MongoCacheService_1.GMongoCacheSer; } }));\r\nObject.defineProperty(exports, \"MongoCacheModel\", ({ enumerable: true, get: function () { return MongoCacheService_1.MongoCacheModel; } }));\r\nvar GoogleProtoFilter_1 = __webpack_require__(/*! ./SocketServer/ProtoFilter/GoogleProtoFilter */ \"./dist/lib/SocketServer/ProtoFilter/GoogleProtoFilter.js\");\r\nObject.defineProperty(exports, \"GoogleProtoFilter\", ({ enumerable: true, get: function () { return GoogleProtoFilter_1.GoogleProtoFilter; } }));\r\nvar JsonProtoFilter_1 = __webpack_require__(/*! ./SocketServer/ProtoFilter/JsonProtoFilter */ \"./dist/lib/SocketServer/ProtoFilter/JsonProtoFilter.js\");\r\nObject.defineProperty(exports, \"JsonProtoFilter\", ({ enumerable: true, get: function () { return JsonProtoFilter_1.JsonProtoFilter; } }));\r\nvar IClientWebSocket_1 = __webpack_require__(/*! ./SocketServer/IClientWebSocket */ \"./dist/lib/SocketServer/IClientWebSocket.js\");\r\nObject.defineProperty(exports, \"IClientWebSocket\", ({ enumerable: true, get: function () { return IClientWebSocket_1.IClientWebSocket; } }));\r\nvar IServerWebSocket_1 = __webpack_require__(/*! ./SocketServer/IServerWebSocket */ \"./dist/lib/SocketServer/IServerWebSocket.js\");\r\nObject.defineProperty(exports, \"IServerWebSocket\", ({ enumerable: true, get: function () { return IServerWebSocket_1.IServerWebSocket; } }));\r\nvar ISocketServer_1 = __webpack_require__(/*! ./SocketServer/ISocketServer */ \"./dist/lib/SocketServer/ISocketServer.js\");\r\nObject.defineProperty(exports, \"ISocketServer\", ({ enumerable: true, get: function () { return ISocketServer_1.ISocketServer; } }));\r\nvar IWebSocket_1 = __webpack_require__(/*! ./SocketServer/IWebSocket */ \"./dist/lib/SocketServer/IWebSocket.js\");\r\nObject.defineProperty(exports, \"IWebSocket\", ({ enumerable: true, get: function () { return IWebSocket_1.IWebSocket; } }));\r\nvar AlipayTool_1 = __webpack_require__(/*! ./ThirdParty/AlipayTool */ \"./dist/lib/ThirdParty/AlipayTool.js\");\r\nObject.defineProperty(exports, \"GAlipayTool\", ({ enumerable: true, get: function () { return AlipayTool_1.GAlipayTool; } }));\r\nvar Alisms_1 = __webpack_require__(/*! ./ThirdParty/Alisms */ \"./dist/lib/ThirdParty/Alisms.js\");\r\nObject.defineProperty(exports, \"GSmsTool\", ({ enumerable: true, get: function () { return Alisms_1.GSmsTool; } }));\r\nvar AppleTool_1 = __webpack_require__(/*! ./ThirdParty/AppleTool */ \"./dist/lib/ThirdParty/AppleTool.js\");\r\nObject.defineProperty(exports, \"GAppleTool\", ({ enumerable: true, get: function () { return AppleTool_1.GAppleTool; } }));\r\nvar EmailTool_1 = __webpack_require__(/*! ./ThirdParty/EmailTool */ \"./dist/lib/ThirdParty/EmailTool.js\");\r\nObject.defineProperty(exports, \"GEmailTool\", ({ enumerable: true, get: function () { return EmailTool_1.GEmailTool; } }));\r\nvar OpenSocial_1 = __webpack_require__(/*! ./ThirdParty/OpenSocial */ \"./dist/lib/ThirdParty/OpenSocial.js\");\r\nObject.defineProperty(exports, \"GOpenSocial\", ({ enumerable: true, get: function () { return OpenSocial_1.GOpenSocial; } }));\r\nvar QiniuTool_1 = __webpack_require__(/*! ./ThirdParty/QiniuTool */ \"./dist/lib/ThirdParty/QiniuTool.js\");\r\nObject.defineProperty(exports, \"GQiniuTool\", ({ enumerable: true, get: function () { return QiniuTool_1.GQiniuTool; } }));\r\nvar QQTool_1 = __webpack_require__(/*! ./ThirdParty/QQTool */ \"./dist/lib/ThirdParty/QQTool.js\");\r\nObject.defineProperty(exports, \"GQQTool\", ({ enumerable: true, get: function () { return QQTool_1.GQQTool; } }));\r\nvar WechatOATool_1 = __webpack_require__(/*! ./ThirdParty/WechatOATool */ \"./dist/lib/ThirdParty/WechatOATool.js\");\r\nObject.defineProperty(exports, \"GWechatOATool\", ({ enumerable: true, get: function () { return WechatOATool_1.GWechatOATool; } }));\r\nvar WechatTool_1 = __webpack_require__(/*! ./ThirdParty/WechatTool */ \"./dist/lib/ThirdParty/WechatTool.js\");\r\nObject.defineProperty(exports, \"GWechatTool\", ({ enumerable: true, get: function () { return WechatTool_1.GWechatTool; } }));\r\nvar IWebServer_1 = __webpack_require__(/*! ./WebServer/IWebServer */ \"./dist/lib/WebServer/IWebServer.js\");\r\nObject.defineProperty(exports, \"IWebServer\", ({ enumerable: true, get: function () { return IWebServer_1.IWebServer; } }));\r\nvar BaseController_1 = __webpack_require__(/*! ./WebServer/Controller/BaseController */ \"./dist/lib/WebServer/Controller/BaseController.js\");\r\nObject.defineProperty(exports, \"BaseController\", ({ enumerable: true, get: function () { return BaseController_1.BaseController; } }));\r\nvar BaseUserController_1 = __webpack_require__(/*! ./WebServer/Controller/BaseUserController */ \"./dist/lib/WebServer/Controller/BaseUserController.js\");\r\nObject.defineProperty(exports, \"BaseUserController\", ({ enumerable: true, get: function () { return BaseUserController_1.BaseUserController; } }));\r\nvar MongoBaseUserController_1 = __webpack_require__(/*! ./WebServer/Controller/MongoBaseUserController */ \"./dist/lib/WebServer/Controller/MongoBaseUserController.js\");\r\nObject.defineProperty(exports, \"MongoBaseUserController\", ({ enumerable: true, get: function () { return MongoBaseUserController_1.MongoBaseUserController; } }));\r\nvar AccountService_2 = __webpack_require__(/*! ./Service/AccountService */ \"./dist/lib/Service/AccountService.js\");\r\nObject.defineProperty(exports, \"MysqlAccountModel\", ({ enumerable: true, get: function () { return AccountService_2.AccountModel; } }));\r\nvar MongoAccountService_2 = __webpack_require__(/*! ./Service/MongoAccountService */ \"./dist/lib/Service/MongoAccountService.js\");\r\nObject.defineProperty(exports, \"MongoAccountModel\", ({ enumerable: true, get: function () { return MongoAccountService_2.AccountModel; } }));\r\nvar AdminValidate_1 = __webpack_require__(/*! ./WebServer/Decorator/AdminValidate */ \"./dist/lib/WebServer/Decorator/AdminValidate.js\");\r\nObject.defineProperty(exports, \"AdminValidate\", ({ enumerable: true, get: function () { return AdminValidate_1.AdminValidate; } }));\r\nvar AuthorityValidate_1 = __webpack_require__(/*! ./WebServer/Decorator/AuthorityValidate */ \"./dist/lib/WebServer/Decorator/AuthorityValidate.js\");\r\nObject.defineProperty(exports, \"AuthorityValidate\", ({ enumerable: true, get: function () { return AuthorityValidate_1.AuthorityValidate; } }));\r\nvar CreatorValidate_1 = __webpack_require__(/*! ./WebServer/Decorator/CreatorValidate */ \"./dist/lib/WebServer/Decorator/CreatorValidate.js\");\r\nObject.defineProperty(exports, \"CreatorValidate\", ({ enumerable: true, get: function () { return CreatorValidate_1.CreatorValidate; } }));\r\nvar JsonAdminValidate_1 = __webpack_require__(/*! ./WebServer/Decorator/JsonAdminValidate */ \"./dist/lib/WebServer/Decorator/JsonAdminValidate.js\");\r\nObject.defineProperty(exports, \"JsonAdminValidate\", ({ enumerable: true, get: function () { return JsonAdminValidate_1.JsonAdminValidate; } }));\r\nvar JsonAuthorityValidate_1 = __webpack_require__(/*! ./WebServer/Decorator/JsonAuthorityValidate */ \"./dist/lib/WebServer/Decorator/JsonAuthorityValidate.js\");\r\nObject.defineProperty(exports, \"JsonAuthorityValidate\", ({ enumerable: true, get: function () { return JsonAuthorityValidate_1.JsonAuthorityValidate; } }));\r\nvar JsonCreatorValidate_1 = __webpack_require__(/*! ./WebServer/Decorator/JsonCreatorValidate */ \"./dist/lib/WebServer/Decorator/JsonCreatorValidate.js\");\r\nObject.defineProperty(exports, \"JsonCreatorValidate\", ({ enumerable: true, get: function () { return JsonCreatorValidate_1.JsonCreatorValidate; } }));\r\nvar ControllerManager_1 = __webpack_require__(/*! ./WebServer/Engine/ControllerManager */ \"./dist/lib/WebServer/Engine/ControllerManager.js\");\r\nObject.defineProperty(exports, \"GCtrMgr\", ({ enumerable: true, get: function () { return ControllerManager_1.GCtrMgr; } }));\r\nvar Engine_1 = __webpack_require__(/*! ./WebServer/Engine/Engine */ \"./dist/lib/WebServer/Engine/Engine.js\");\r\nObject.defineProperty(exports, \"Engine\", ({ enumerable: true, get: function () { return Engine_1.Engine; } }));\r\nvar RazorJs_1 = __webpack_require__(/*! ./WebServer/Engine/RazorJs */ \"./dist/lib/WebServer/Engine/RazorJs.js\");\r\nObject.defineProperty(exports, \"RazorJs\", ({ enumerable: true, get: function () { return RazorJs_1.RazorJs; } }));\r\nvar Request_1 = __webpack_require__(/*! ./WebServer/Engine/Request */ \"./dist/lib/WebServer/Engine/Request.js\");\r\nObject.defineProperty(exports, \"Request\", ({ enumerable: true, get: function () { return Request_1.Request; } }));\r\nvar Response_1 = __webpack_require__(/*! ./WebServer/Engine/Response */ \"./dist/lib/WebServer/Engine/Response.js\");\r\nObject.defineProperty(exports, \"Response\", ({ enumerable: true, get: function () { return Response_1.Response; } }));\r\nvar FrameworkConfig_2 = __webpack_require__(/*! ./Config/FrameworkConfig */ \"./dist/lib/Config/FrameworkConfig.js\");\r\nObject.defineProperty(exports, \"WebServerConfig\", ({ enumerable: true, get: function () { return FrameworkConfig_2.WebServerConfig; } }));\r\nvar AsyncQueueTool_1 = __webpack_require__(/*! ./Logic/AsyncQueueTool */ \"./dist/lib/Logic/AsyncQueueTool.js\");\r\nObject.defineProperty(exports, \"GAsyncQueueTool\", ({ enumerable: true, get: function () { return AsyncQueueTool_1.GAsyncQueueTool; } }));\r\nvar EventTool_1 = __webpack_require__(/*! ./Logic/EventTool */ \"./dist/lib/Logic/EventTool.js\");\r\nObject.defineProperty(exports, \"GEventTool\", ({ enumerable: true, get: function () { return EventTool_1.GEventTool; } }));\r\nvar ini_2 = __webpack_require__(/*! ./Service/ini */ \"./dist/lib/Service/ini.js\");\r\nObject.defineProperty(exports, \"EAccountState\", ({ enumerable: true, get: function () { return ini_2.EAccountState; } }));\r\n\n\n//# sourceURL=webpack://cgserver/./dist/lib/index.js?");
|
|
1050
|
+
|
|
1051
|
+
/***/ })
|
|
1052
|
+
|
|
1053
|
+
/******/ });
|
|
1054
|
+
/************************************************************************/
|
|
1055
|
+
/******/ // The module cache
|
|
1056
|
+
/******/ var __webpack_module_cache__ = {};
|
|
1057
|
+
/******/
|
|
1058
|
+
/******/ // The require function
|
|
1059
|
+
/******/ function __webpack_require__(moduleId) {
|
|
1060
|
+
/******/ // Check if module is in cache
|
|
1061
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
1062
|
+
/******/ if (cachedModule !== undefined) {
|
|
1063
|
+
/******/ return cachedModule.exports;
|
|
1064
|
+
/******/ }
|
|
1065
|
+
/******/ // Create a new module (and put it into the cache)
|
|
1066
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
1067
|
+
/******/ // no module.id needed
|
|
1068
|
+
/******/ // no module.loaded needed
|
|
1069
|
+
/******/ exports: {}
|
|
1070
|
+
/******/ };
|
|
1071
|
+
/******/
|
|
1072
|
+
/******/ // Execute the module function
|
|
1073
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
1074
|
+
/******/
|
|
1075
|
+
/******/ // Return the exports of the module
|
|
1076
|
+
/******/ return module.exports;
|
|
1077
|
+
/******/ }
|
|
1078
|
+
/******/
|
|
1079
|
+
/************************************************************************/
|
|
1080
|
+
/******/
|
|
1081
|
+
/******/ // startup
|
|
1082
|
+
/******/ // Load entry module and return exports
|
|
1083
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
1084
|
+
/******/ var __webpack_exports__ = __webpack_require__("./dist/lib/index.js");
|
|
1085
|
+
/******/
|
|
1086
|
+
/******/ })()
|
|
1087
|
+
;
|