@pisell/core 1.0.0 → 1.0.1

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.
Files changed (281) hide show
  1. package/es/app/app.d.ts +122 -0
  2. package/es/app/app.js +166 -0
  3. package/es/app/const.d.ts +4 -0
  4. package/es/app/const.js +6 -0
  5. package/es/app/index.d.ts +14 -0
  6. package/es/app/index.js +54 -0
  7. package/es/applicationManager/application.d.ts +50 -0
  8. package/es/applicationManager/application.js +226 -0
  9. package/es/applicationManager/index.d.ts +13 -0
  10. package/es/applicationManager/index.js +190 -0
  11. package/es/config.d.ts +3 -3
  12. package/es/cookie/index.d.ts +13 -0
  13. package/es/cookie/index.js +47 -0
  14. package/es/css/global.less +73 -0
  15. package/es/css/index.less +31 -0
  16. package/es/css/variables.css +84 -0
  17. package/es/data/index.d.ts +29 -0
  18. package/es/data/index.js +8 -0
  19. package/es/history/config.d.ts +24 -0
  20. package/es/history/config.js +43 -0
  21. package/es/history/index.d.ts +20 -0
  22. package/es/history/index.js +41 -0
  23. package/es/history/type.d.ts +2 -0
  24. package/es/hooks/index.d.ts +12 -0
  25. package/es/hooks/index.js +13 -0
  26. package/es/hooks/useDelayedValue/index.d.ts +2 -0
  27. package/es/hooks/useDelayedValue/index.js +26 -0
  28. package/es/hooks/useDispatch/index.d.ts +2 -0
  29. package/es/hooks/useDispatch/index.js +2 -0
  30. package/es/hooks/useLowCode/index.d.ts +13 -0
  31. package/es/hooks/useLowCode/index.js +74 -0
  32. package/es/hooks/useStore/index.d.ts +6 -0
  33. package/es/hooks/useStore/index.js +11 -0
  34. package/es/index.d.ts +7 -1
  35. package/es/index.js +8 -2
  36. package/es/indexDB/index.d.ts +176 -0
  37. package/es/indexDB/index.js +536 -0
  38. package/es/locales/config.js +10 -8
  39. package/es/locales/en.d.ts +2 -1
  40. package/es/locales/en.js +5 -1
  41. package/es/locales/index.d.ts +44 -1
  42. package/es/locales/index.js +192 -8
  43. package/es/locales/original.d.ts +3 -0
  44. package/es/locales/original.js +7 -0
  45. package/es/locales/type.d.ts +15 -5
  46. package/es/locales/zh-CN.d.ts +2 -1
  47. package/es/locales/zh-CN.js +5 -1
  48. package/es/locales/zh-HK.d.ts +2 -1
  49. package/es/locales/zh-HK.js +5 -1
  50. package/es/logger/feishu.d.ts +11 -0
  51. package/es/logger/feishu.js +50 -0
  52. package/es/logger/index.d.ts +122 -0
  53. package/es/logger/index.js +531 -0
  54. package/es/menuManager/hooks.d.ts +8 -0
  55. package/es/menuManager/hooks.js +138 -0
  56. package/es/menuManager/index.d.ts +28 -0
  57. package/es/menuManager/index.js +142 -0
  58. package/es/models/global.d.ts +32 -0
  59. package/es/models/global.js +65 -0
  60. package/es/models/index.d.ts +45 -0
  61. package/es/models/index.js +66 -0
  62. package/es/models/tasks.d.ts +31 -0
  63. package/es/models/tasks.js +331 -0
  64. package/es/models/tasksUtils.d.ts +65 -0
  65. package/es/models/tasksUtils.js +179 -0
  66. package/es/models/type.d.ts +2 -0
  67. package/es/models/type.js +1 -0
  68. package/es/plugin/index.d.ts +0 -0
  69. package/es/plugin/index.js +0 -0
  70. package/es/pubsub/example.d.ts +5 -0
  71. package/es/pubsub/example.js +92 -0
  72. package/es/pubsub/index.d.ts +63 -0
  73. package/es/pubsub/index.js +144 -0
  74. package/es/request/cache.d.ts +46 -0
  75. package/es/request/cache.js +310 -0
  76. package/es/request/cancelToken.d.ts +38 -0
  77. package/es/request/cancelToken.js +59 -0
  78. package/es/request/config.d.ts +3 -0
  79. package/es/request/config.js +58 -0
  80. package/es/request/constants.d.ts +2 -0
  81. package/es/request/constants.js +6 -0
  82. package/es/request/index.d.ts +24 -0
  83. package/es/request/index.js +175 -0
  84. package/es/request/pisell2Request.d.ts +6 -0
  85. package/es/request/pisell2Request.js +62 -0
  86. package/es/request/type.d.ts +40 -0
  87. package/es/request/type.js +1 -0
  88. package/es/request/utils.d.ts +46 -0
  89. package/es/request/utils.js +145 -0
  90. package/es/routes/config.d.ts +7 -0
  91. package/es/routes/config.js +17 -0
  92. package/es/routes/index.d.ts +28 -0
  93. package/es/routes/index.js +154 -0
  94. package/es/socket/components/SocketMonitorPage.d.ts +6 -0
  95. package/es/socket/components/SocketMonitorPage.js +692 -0
  96. package/es/socket/components/index.d.ts +2 -0
  97. package/es/socket/components/index.js +2 -0
  98. package/es/socket/constants.d.ts +33 -0
  99. package/es/socket/constants.js +39 -0
  100. package/es/socket/events.d.ts +31 -0
  101. package/es/socket/events.js +19 -0
  102. package/es/socket/heartbeat.d.ts +66 -0
  103. package/es/socket/heartbeat.js +185 -0
  104. package/es/socket/index.d.ts +61 -0
  105. package/es/socket/index.js +246 -0
  106. package/es/socket/monitor.d.ts +169 -0
  107. package/es/socket/monitor.js +438 -0
  108. package/es/socket/reconnect.d.ts +61 -0
  109. package/es/socket/reconnect.js +199 -0
  110. package/es/socket/socket.d.ts +129 -0
  111. package/es/socket/socket.js +597 -0
  112. package/es/socket/types.d.ts +84 -0
  113. package/es/socket/types.js +19 -0
  114. package/es/storage/config.d.ts +3 -0
  115. package/es/{date → storage}/config.js +1 -6
  116. package/es/storage/index.d.ts +42 -0
  117. package/es/storage/index.js +62 -0
  118. package/es/storage/type.d.ts +5 -0
  119. package/es/storage/type.js +1 -0
  120. package/es/tasks/index.d.ts +77 -0
  121. package/es/tasks/index.js +719 -0
  122. package/es/tasks/type.d.ts +62 -0
  123. package/es/tasks/type.js +1 -0
  124. package/es/tasks/useTasks.d.ts +4 -0
  125. package/es/tasks/useTasks.js +25 -0
  126. package/es/type.d.ts +1 -1
  127. package/es/variables/VariablesProvider.d.ts +7 -0
  128. package/es/variables/VariablesProvider.js +14 -0
  129. package/es/variables/config.d.ts +3 -0
  130. package/es/{date/index.js → variables/config.js} +8 -14
  131. package/es/variables/index.d.ts +6 -0
  132. package/es/variables/index.js +5 -0
  133. package/es/variables/type.d.ts +2 -0
  134. package/es/variables/type.js +1 -0
  135. package/es/website/index.d.ts +6 -0
  136. package/es/website/index.js +65 -0
  137. package/lib/app/app.d.ts +122 -0
  138. package/lib/app/app.js +128 -0
  139. package/lib/app/const.d.ts +4 -0
  140. package/lib/app/const.js +33 -0
  141. package/lib/app/index.d.ts +14 -0
  142. package/lib/app/index.js +76 -0
  143. package/lib/applicationManager/application.d.ts +50 -0
  144. package/lib/applicationManager/application.js +110 -0
  145. package/lib/applicationManager/index.d.ts +13 -0
  146. package/lib/applicationManager/index.js +76 -0
  147. package/lib/config.d.ts +3 -3
  148. package/lib/cookie/index.d.ts +13 -0
  149. package/lib/cookie/index.js +64 -0
  150. package/lib/css/global.less +73 -0
  151. package/lib/css/index.less +31 -0
  152. package/lib/css/variables.css +84 -0
  153. package/lib/data/index.d.ts +29 -0
  154. package/lib/{date → data}/index.js +19 -20
  155. package/lib/history/config.d.ts +24 -0
  156. package/lib/history/config.js +41 -0
  157. package/lib/history/index.d.ts +20 -0
  158. package/lib/history/index.js +58 -0
  159. package/lib/history/type.d.ts +2 -0
  160. package/lib/history/type.js +17 -0
  161. package/lib/hooks/index.d.ts +12 -0
  162. package/lib/hooks/index.js +44 -0
  163. package/lib/hooks/useDelayedValue/index.d.ts +2 -0
  164. package/lib/hooks/useDelayedValue/index.js +36 -0
  165. package/lib/hooks/useDispatch/index.d.ts +2 -0
  166. package/lib/hooks/useDispatch/index.js +26 -0
  167. package/lib/hooks/useLowCode/index.d.ts +13 -0
  168. package/lib/hooks/useLowCode/index.js +75 -0
  169. package/lib/hooks/useStore/index.d.ts +6 -0
  170. package/lib/hooks/useStore/index.js +33 -0
  171. package/lib/index.d.ts +7 -1
  172. package/lib/index.js +23 -5
  173. package/lib/indexDB/index.d.ts +176 -0
  174. package/lib/indexDB/index.js +287 -0
  175. package/lib/locales/config.js +10 -7
  176. package/lib/locales/en.d.ts +2 -1
  177. package/lib/locales/en.js +5 -1
  178. package/lib/locales/index.d.ts +44 -1
  179. package/lib/locales/index.js +106 -4
  180. package/lib/locales/original.d.ts +3 -0
  181. package/lib/locales/original.js +31 -0
  182. package/lib/locales/type.d.ts +15 -5
  183. package/lib/locales/zh-CN.d.ts +2 -1
  184. package/lib/locales/zh-CN.js +5 -1
  185. package/lib/locales/zh-HK.d.ts +2 -1
  186. package/lib/locales/zh-HK.js +5 -1
  187. package/lib/logger/feishu.d.ts +11 -0
  188. package/lib/logger/feishu.js +52 -0
  189. package/lib/logger/index.d.ts +122 -0
  190. package/lib/logger/index.js +288 -0
  191. package/lib/menuManager/hooks.d.ts +8 -0
  192. package/lib/menuManager/hooks.js +135 -0
  193. package/lib/menuManager/index.d.ts +28 -0
  194. package/lib/menuManager/index.js +110 -0
  195. package/lib/models/global.d.ts +32 -0
  196. package/lib/models/global.js +62 -0
  197. package/lib/models/index.d.ts +45 -0
  198. package/lib/models/index.js +70 -0
  199. package/lib/models/tasks.d.ts +31 -0
  200. package/lib/models/tasks.js +199 -0
  201. package/lib/models/tasksUtils.d.ts +65 -0
  202. package/lib/models/tasksUtils.js +160 -0
  203. package/lib/models/type.d.ts +2 -0
  204. package/lib/models/type.js +17 -0
  205. package/lib/plugin/index.d.ts +0 -0
  206. package/lib/plugin/index.js +0 -0
  207. package/lib/pubsub/example.d.ts +5 -0
  208. package/lib/pubsub/example.js +61 -0
  209. package/lib/pubsub/index.d.ts +63 -0
  210. package/lib/pubsub/index.js +129 -0
  211. package/lib/request/cache.d.ts +46 -0
  212. package/lib/request/cache.js +159 -0
  213. package/lib/request/cancelToken.d.ts +38 -0
  214. package/lib/request/cancelToken.js +59 -0
  215. package/lib/request/config.d.ts +3 -0
  216. package/lib/request/config.js +74 -0
  217. package/lib/request/constants.d.ts +2 -0
  218. package/lib/request/constants.js +34 -0
  219. package/lib/request/index.d.ts +24 -0
  220. package/lib/request/index.js +143 -0
  221. package/lib/request/pisell2Request.d.ts +6 -0
  222. package/lib/request/pisell2Request.js +75 -0
  223. package/lib/request/type.d.ts +40 -0
  224. package/lib/request/type.js +17 -0
  225. package/lib/request/utils.d.ts +46 -0
  226. package/lib/request/utils.js +111 -0
  227. package/lib/routes/config.d.ts +7 -0
  228. package/lib/routes/config.js +50 -0
  229. package/lib/routes/index.d.ts +28 -0
  230. package/lib/routes/index.js +118 -0
  231. package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
  232. package/lib/socket/components/SocketMonitorPage.js +346 -0
  233. package/lib/socket/components/index.d.ts +2 -0
  234. package/lib/socket/components/index.js +39 -0
  235. package/lib/socket/constants.d.ts +33 -0
  236. package/lib/socket/constants.js +62 -0
  237. package/lib/socket/events.d.ts +31 -0
  238. package/lib/socket/events.js +44 -0
  239. package/lib/socket/heartbeat.d.ts +66 -0
  240. package/lib/socket/heartbeat.js +152 -0
  241. package/lib/socket/index.d.ts +61 -0
  242. package/lib/socket/index.js +200 -0
  243. package/lib/socket/monitor.d.ts +169 -0
  244. package/lib/socket/monitor.js +346 -0
  245. package/lib/socket/reconnect.d.ts +61 -0
  246. package/lib/socket/reconnect.js +153 -0
  247. package/lib/socket/socket.d.ts +129 -0
  248. package/lib/socket/socket.js +410 -0
  249. package/lib/socket/types.d.ts +84 -0
  250. package/lib/socket/types.js +36 -0
  251. package/lib/storage/config.d.ts +3 -0
  252. package/lib/{date → storage}/config.js +2 -7
  253. package/lib/storage/index.d.ts +42 -0
  254. package/lib/storage/index.js +66 -0
  255. package/lib/storage/type.d.ts +5 -0
  256. package/lib/storage/type.js +17 -0
  257. package/lib/tasks/index.d.ts +77 -0
  258. package/lib/tasks/index.js +438 -0
  259. package/lib/tasks/type.d.ts +62 -0
  260. package/lib/{date → tasks}/type.js +1 -1
  261. package/lib/tasks/useTasks.d.ts +4 -0
  262. package/lib/tasks/useTasks.js +37 -0
  263. package/lib/type.d.ts +1 -1
  264. package/lib/variables/VariablesProvider.d.ts +7 -0
  265. package/lib/variables/VariablesProvider.js +51 -0
  266. package/lib/variables/config.d.ts +3 -0
  267. package/lib/variables/config.js +38 -0
  268. package/lib/variables/index.d.ts +6 -0
  269. package/lib/variables/index.js +29 -0
  270. package/lib/variables/type.d.ts +2 -0
  271. package/lib/variables/type.js +17 -0
  272. package/lib/website/index.d.ts +6 -0
  273. package/lib/website/index.js +75 -0
  274. package/package.json +13 -3
  275. package/es/date/config.d.ts +0 -3
  276. package/es/date/index.d.ts +0 -7
  277. package/es/date/type.d.ts +0 -7
  278. package/lib/date/config.d.ts +0 -3
  279. package/lib/date/index.d.ts +0 -7
  280. package/lib/date/type.d.ts +0 -7
  281. /package/es/{date → history}/type.js +0 -0
@@ -0,0 +1,531 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
12
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
16
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
+ import dayjs from "dayjs";
21
+ import { sendWarningLog } from "./feishu";
22
+ /**
23
+ * 日志管理器类
24
+ */
25
+ var LoggerManager = /*#__PURE__*/function () {
26
+ // 私有属性
27
+ // 日志缓冲区
28
+ // 定时器
29
+ // 检查间隔时间(毫秒)
30
+ // 日志文件前缀
31
+
32
+ // IndexDB 实例
33
+
34
+ // 日志保留天数
35
+
36
+ /**
37
+ * 构造函数
38
+ * @param prefix 日志前缀
39
+ * @param checkInterval 检查间隔时间,默认5分钟
40
+ */
41
+ function LoggerManager(app, options) {
42
+ _classCallCheck(this, LoggerManager);
43
+ _defineProperty(this, "logBuffer", []);
44
+ _defineProperty(this, "timer", null);
45
+ _defineProperty(this, "checkInterval", void 0);
46
+ _defineProperty(this, "prefix", "app");
47
+ _defineProperty(this, "metadata", void 0);
48
+ _defineProperty(this, "db", null);
49
+ _defineProperty(this, "app", void 0);
50
+ _defineProperty(this, "feishuConfig", void 0);
51
+ _defineProperty(this, "retentionDays", void 0);
52
+ _defineProperty(this, "metadataFunction", void 0);
53
+ this.prefix = (options === null || options === void 0 ? void 0 : options.prefix) || "app";
54
+ this.checkInterval = (options === null || options === void 0 ? void 0 : options.checkInterval) || 5 * 60 * 1000;
55
+ this.app = app;
56
+ this.feishuConfig = options === null || options === void 0 ? void 0 : options.feishuConfig;
57
+ this.retentionDays = (options === null || options === void 0 ? void 0 : options.retentionDays) || 7; // 默认保留7天
58
+ this.initDB();
59
+ }
60
+ _createClass(LoggerManager, [{
61
+ key: "init",
62
+ value: function init() {
63
+ this.initTimer();
64
+ // 定期清理旧日志
65
+ this.cleanupOldLogs();
66
+ }
67
+
68
+ /**
69
+ * 初始化 IndexDB
70
+ */
71
+ }, {
72
+ key: "initDB",
73
+ value: function () {
74
+ var _initDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
75
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
76
+ while (1) switch (_context.prev = _context.next) {
77
+ case 0:
78
+ if (this.app.dbManager) {
79
+ this.db = this.app.dbManager;
80
+ }
81
+ case 1:
82
+ case "end":
83
+ return _context.stop();
84
+ }
85
+ }, _callee, this);
86
+ }));
87
+ function initDB() {
88
+ return _initDB.apply(this, arguments);
89
+ }
90
+ return initDB;
91
+ }()
92
+ /**
93
+ * 设置元数据
94
+ * @param metadata 元数据
95
+ */
96
+ }, {
97
+ key: "setMetadata",
98
+ value: function setMetadata(metadata) {
99
+ this.metadata = metadata;
100
+ }
101
+ }, {
102
+ key: "setMetadataFunction",
103
+ value: function setMetadataFunction(metadataFunction) {
104
+ this.metadataFunction = metadataFunction;
105
+ }
106
+
107
+ /**
108
+ * 初始化定时器
109
+ */
110
+ }, {
111
+ key: "initTimer",
112
+ value: function initTimer() {
113
+ var _this = this;
114
+ this.timer = setInterval(function () {
115
+ if (_this.logBuffer.length > 0) {
116
+ _this.storeLog();
117
+ }
118
+ }, this.checkInterval);
119
+ }
120
+
121
+ /**
122
+ * 添加日志
123
+ * @param log 日志项
124
+ */
125
+ }, {
126
+ key: "addLog",
127
+ value: function addLog(log) {
128
+ var logItem = _objectSpread(_objectSpread({}, log), {}, {
129
+ date: log.date || dayjs().format("YYYY-MM-DD HH:mm:ss"),
130
+ metadata: JSON.stringify(log.metadata || "{}")
131
+ });
132
+ console.log("---- 行为日志", logItem);
133
+ if (log.type === "error") {
134
+ this.sendFeishuNotification(logItem);
135
+ }
136
+ this.logBuffer.push(logItem);
137
+ }
138
+
139
+ /**
140
+ * 发送飞书通知
141
+ * @param log 日志项
142
+ */
143
+ }, {
144
+ key: "sendFeishuNotification",
145
+ value: function sendFeishuNotification(log) {
146
+ if (this.feishuConfig) {
147
+ var _this$metadataFunctio;
148
+ var _metadata = ((_this$metadataFunctio = this.metadataFunction) === null || _this$metadataFunctio === void 0 ? void 0 : _this$metadataFunctio.call(this)) || {};
149
+ sendWarningLog({
150
+ title: log.title,
151
+ content: [{
152
+ key: "日志类型",
153
+ value: log.type
154
+ }, {
155
+ key: "日志时间",
156
+ value: log.date || dayjs().format("YYYY-MM-DD HH:mm:ss")
157
+ }, {
158
+ key: "日志来源",
159
+ value: JSON.stringify(_objectSpread(_objectSpread({}, this.metadata || {}), _metadata))
160
+ }, {
161
+ key: "日志内容",
162
+ value: JSON.stringify(log.metadata)
163
+ }],
164
+ webhook: this.feishuConfig.webhook
165
+ });
166
+ console.log("-------- 发送飞书通知", log);
167
+ }
168
+ }
169
+
170
+ /**
171
+ * 创建日志文件名
172
+ * @returns 日志文件名
173
+ */
174
+ }, {
175
+ key: "createFileName",
176
+ value: function createFileName(date) {
177
+ var _date = date || dayjs().format("YYYY-MM-DD-HH");
178
+ var fileName = "".concat(this.prefix, "_").concat(_date, ".log");
179
+ return fileName;
180
+ }
181
+
182
+ /**
183
+ * 创建日志文件
184
+ * @param _fileName 文件名
185
+ * @returns 日志文件对象
186
+ */
187
+ }, {
188
+ key: "createFile",
189
+ value: function createFile(_fileName) {
190
+ var _date = dayjs().format("YYYY-MM-DD-HH");
191
+ var fileName = _fileName || this.createFileName(_date);
192
+ return {
193
+ fileName: fileName,
194
+ date: _date,
195
+ fileContent: {
196
+ metadata: this.metadata,
197
+ logs: []
198
+ }
199
+ };
200
+ }
201
+
202
+ /**
203
+ * 存储日志到持久化存储
204
+ */
205
+ }, {
206
+ key: "storeLog",
207
+ value: function () {
208
+ var _storeLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
209
+ var fileName, logFile;
210
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
211
+ while (1) switch (_context2.prev = _context2.next) {
212
+ case 0:
213
+ if (!(this.logBuffer.length === 0 || !this.db)) {
214
+ _context2.next = 2;
215
+ break;
216
+ }
217
+ return _context2.abrupt("return");
218
+ case 2:
219
+ fileName = this.createFileName();
220
+ _context2.prev = 3;
221
+ _context2.next = 6;
222
+ return this.db.get("logs", fileName);
223
+ case 6:
224
+ logFile = _context2.sent;
225
+ if (logFile) {
226
+ _context2.next = 11;
227
+ break;
228
+ }
229
+ logFile = this.createFile(fileName);
230
+ _context2.next = 11;
231
+ return this.db.add("logs", logFile);
232
+ case 11:
233
+ // 添加日志到文件内容
234
+ logFile.fileContent.logs = [].concat(_toConsumableArray(logFile.fileContent.logs), _toConsumableArray(this.logBuffer));
235
+
236
+ // 更新日志文件
237
+ _context2.next = 14;
238
+ return this.db.update("logs", logFile);
239
+ case 14:
240
+ console.log("-------- 存储日志", {
241
+ fileName: fileName,
242
+ logFile: logFile
243
+ });
244
+ _context2.next = 20;
245
+ break;
246
+ case 17:
247
+ _context2.prev = 17;
248
+ _context2.t0 = _context2["catch"](3);
249
+ console.error("存储日志到IndexDB失败:", _context2.t0);
250
+ case 20:
251
+ // 清空缓冲区
252
+ this.logBuffer = [];
253
+ case 21:
254
+ case "end":
255
+ return _context2.stop();
256
+ }
257
+ }, _callee2, this, [[3, 17]]);
258
+ }));
259
+ function storeLog() {
260
+ return _storeLog.apply(this, arguments);
261
+ }
262
+ return storeLog;
263
+ }()
264
+ /**
265
+ * 清理旧日志,只保留最近指定天数的日志
266
+ */
267
+ }, {
268
+ key: "cleanupOldLogs",
269
+ value: function () {
270
+ var _cleanupOldLogs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
271
+ var logFiles, cutoffDate, filesToDelete, _iterator, _step, file;
272
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
273
+ while (1) switch (_context3.prev = _context3.next) {
274
+ case 0:
275
+ if (this.db) {
276
+ _context3.next = 2;
277
+ break;
278
+ }
279
+ return _context3.abrupt("return");
280
+ case 2:
281
+ _context3.prev = 2;
282
+ _context3.next = 5;
283
+ return this.getLogFiles();
284
+ case 5:
285
+ logFiles = _context3.sent;
286
+ // 计算保留日志的截止日期
287
+ cutoffDate = dayjs().subtract(this.retentionDays, "day").format("YYYY-MM-DD"); // 筛选出需要删除的日志文件
288
+ filesToDelete = logFiles.filter(function (file) {
289
+ return file.date < cutoffDate;
290
+ });
291
+ console.log("-------- \u6E05\u7406\u65E7\u65E5\u5FD7\uFF0C\u4FDD\u7559 ".concat(this.retentionDays, " \u5929\u5185\u7684\u65E5\u5FD7\uFF0C\u622A\u6B62\u65E5\u671F: ").concat(cutoffDate));
292
+
293
+ // 删除旧日志文件
294
+ _iterator = _createForOfIteratorHelper(filesToDelete);
295
+ _context3.prev = 10;
296
+ _iterator.s();
297
+ case 12:
298
+ if ((_step = _iterator.n()).done) {
299
+ _context3.next = 19;
300
+ break;
301
+ }
302
+ file = _step.value;
303
+ _context3.next = 16;
304
+ return this.db.delete("logs", file.fileName);
305
+ case 16:
306
+ console.log("-------- \u5220\u9664\u65E7\u65E5\u5FD7\u6587\u4EF6: ".concat(file.fileName, ", \u65E5\u671F: ").concat(file.date));
307
+ case 17:
308
+ _context3.next = 12;
309
+ break;
310
+ case 19:
311
+ _context3.next = 24;
312
+ break;
313
+ case 21:
314
+ _context3.prev = 21;
315
+ _context3.t0 = _context3["catch"](10);
316
+ _iterator.e(_context3.t0);
317
+ case 24:
318
+ _context3.prev = 24;
319
+ _iterator.f();
320
+ return _context3.finish(24);
321
+ case 27:
322
+ if (filesToDelete.length > 0) {
323
+ console.log("-------- \u5171\u6E05\u7406 ".concat(filesToDelete.length, " \u4E2A\u65E7\u65E5\u5FD7\u6587\u4EF6"));
324
+ }
325
+ _context3.next = 33;
326
+ break;
327
+ case 30:
328
+ _context3.prev = 30;
329
+ _context3.t1 = _context3["catch"](2);
330
+ console.error("清理旧日志失败:", _context3.t1);
331
+ case 33:
332
+ case "end":
333
+ return _context3.stop();
334
+ }
335
+ }, _callee3, this, [[2, 30], [10, 21, 24, 27]]);
336
+ }));
337
+ function cleanupOldLogs() {
338
+ return _cleanupOldLogs.apply(this, arguments);
339
+ }
340
+ return cleanupOldLogs;
341
+ }()
342
+ /**
343
+ * 获取日志文件列表
344
+ * @returns 日志文件列表
345
+ */
346
+ }, {
347
+ key: "getLogFiles",
348
+ value: function () {
349
+ var _getLogFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
350
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
351
+ while (1) switch (_context4.prev = _context4.next) {
352
+ case 0:
353
+ if (this.db) {
354
+ _context4.next = 2;
355
+ break;
356
+ }
357
+ return _context4.abrupt("return", []);
358
+ case 2:
359
+ _context4.prev = 2;
360
+ _context4.next = 5;
361
+ return this.db.getAll("logs");
362
+ case 5:
363
+ return _context4.abrupt("return", _context4.sent);
364
+ case 8:
365
+ _context4.prev = 8;
366
+ _context4.t0 = _context4["catch"](2);
367
+ console.error("获取日志文件列表失败:", _context4.t0);
368
+ return _context4.abrupt("return", []);
369
+ case 12:
370
+ case "end":
371
+ return _context4.stop();
372
+ }
373
+ }, _callee4, this, [[2, 8]]);
374
+ }));
375
+ function getLogFiles() {
376
+ return _getLogFiles.apply(this, arguments);
377
+ }
378
+ return getLogFiles;
379
+ }()
380
+ /**
381
+ * 获取指定日志文件的内容
382
+ * @param fileName 日志文件名
383
+ * @returns 日志文件内容
384
+ */
385
+ }, {
386
+ key: "getLogFile",
387
+ value: function () {
388
+ var _getLogFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(fileName) {
389
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
390
+ while (1) switch (_context5.prev = _context5.next) {
391
+ case 0:
392
+ if (this.db) {
393
+ _context5.next = 2;
394
+ break;
395
+ }
396
+ return _context5.abrupt("return", null);
397
+ case 2:
398
+ _context5.prev = 2;
399
+ _context5.next = 5;
400
+ return this.db.get("logs", fileName);
401
+ case 5:
402
+ return _context5.abrupt("return", _context5.sent);
403
+ case 8:
404
+ _context5.prev = 8;
405
+ _context5.t0 = _context5["catch"](2);
406
+ console.error("获取日志文件内容失败:", _context5.t0);
407
+ return _context5.abrupt("return", null);
408
+ case 12:
409
+ case "end":
410
+ return _context5.stop();
411
+ }
412
+ }, _callee5, this, [[2, 8]]);
413
+ }));
414
+ function getLogFile(_x) {
415
+ return _getLogFile.apply(this, arguments);
416
+ }
417
+ return getLogFile;
418
+ }()
419
+ /**
420
+ * 清空指定日志文件
421
+ * @param fileName 日志文件名,不指定则清空所有日志
422
+ * @returns 是否成功
423
+ */
424
+ }, {
425
+ key: "clearLogs",
426
+ value: function () {
427
+ var _clearLogs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(fileName) {
428
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
429
+ while (1) switch (_context6.prev = _context6.next) {
430
+ case 0:
431
+ if (this.db) {
432
+ _context6.next = 2;
433
+ break;
434
+ }
435
+ return _context6.abrupt("return", false);
436
+ case 2:
437
+ _context6.prev = 2;
438
+ if (!fileName) {
439
+ _context6.next = 8;
440
+ break;
441
+ }
442
+ _context6.next = 6;
443
+ return this.db.delete("logs", fileName);
444
+ case 6:
445
+ _context6.next = 10;
446
+ break;
447
+ case 8:
448
+ _context6.next = 10;
449
+ return this.db.clear("logs");
450
+ case 10:
451
+ return _context6.abrupt("return", true);
452
+ case 13:
453
+ _context6.prev = 13;
454
+ _context6.t0 = _context6["catch"](2);
455
+ console.error("清空日志失败:", _context6.t0);
456
+ return _context6.abrupt("return", false);
457
+ case 17:
458
+ case "end":
459
+ return _context6.stop();
460
+ }
461
+ }, _callee6, this, [[2, 13]]);
462
+ }));
463
+ function clearLogs(_x2) {
464
+ return _clearLogs.apply(this, arguments);
465
+ }
466
+ return clearLogs;
467
+ }()
468
+ /**
469
+ * 设置日志保留天数
470
+ * @param days 保留天数
471
+ */
472
+ }, {
473
+ key: "setRetentionDays",
474
+ value: function setRetentionDays(days) {
475
+ if (days > 0) {
476
+ this.retentionDays = days;
477
+ console.log("-------- \u8BBE\u7F6E\u65E5\u5FD7\u4FDD\u7559\u5929\u6570\u4E3A ".concat(days, " \u5929"));
478
+ } else {
479
+ console.error("日志保留天数必须大于0");
480
+ }
481
+ }
482
+
483
+ /**
484
+ * 手动触发清理旧日志
485
+ */
486
+ }, {
487
+ key: "manualCleanup",
488
+ value: function () {
489
+ var _manualCleanup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
490
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
491
+ while (1) switch (_context7.prev = _context7.next) {
492
+ case 0:
493
+ _context7.next = 2;
494
+ return this.cleanupOldLogs();
495
+ case 2:
496
+ case "end":
497
+ return _context7.stop();
498
+ }
499
+ }, _callee7, this);
500
+ }));
501
+ function manualCleanup() {
502
+ return _manualCleanup.apply(this, arguments);
503
+ }
504
+ return manualCleanup;
505
+ }()
506
+ /**
507
+ * 销毁实例
508
+ */
509
+ }, {
510
+ key: "destroy",
511
+ value: function destroy() {
512
+ if (this.timer) {
513
+ clearInterval(this.timer);
514
+ this.timer = null;
515
+ }
516
+
517
+ // 存储剩余的日志
518
+ if (this.logBuffer.length > 0) {
519
+ this.storeLog();
520
+ }
521
+
522
+ // 关闭数据库连接
523
+ if (this.db) {
524
+ this.db.close();
525
+ this.db = null;
526
+ }
527
+ }
528
+ }]);
529
+ return LoggerManager;
530
+ }();
531
+ export default LoggerManager;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { MenuItem } from "./index";
3
+ export declare const isHttp: (url: string) => boolean;
4
+ export declare const MenuProvider: React.FC<{
5
+ children: React.ReactNode;
6
+ menus: MenuItem[];
7
+ }>;
8
+ export declare const useMenu: () => any;