GlobalTools

挂载到window下一级 enjoy_tl6属性集合-常用工具函数

当前为 2024-12-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GlobalTools
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.10
  5. // @description 挂载到window下一级 enjoy_tl6属性集合-常用工具函数
  6. // @author Enjoy
  7. // @include *://*/*
  8. // @include file:///*
  9. // @homepage https://greasyfork.org/zh-CN/scripts/468302-%E5%B7%A5%E5%85%B7%E5%87%BD%E6%95%B0tls
  10. // @license MIT
  11. // @icon https://foruda.gitee.com/avatar/1698283059572409586/4867929_enjoy_li_1698283059.png!avatar200
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. /******/ (() => { // webpackBootstrap
  16. /******/ var __webpack_modules__ = ({
  17.  
  18. /***/ 342:
  19. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  20.  
  21. var _typeof = (__webpack_require__(882)["default"]);
  22. function _regeneratorRuntime() {
  23. "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  24. module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
  25. return e;
  26. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  27. var t,
  28. e = {},
  29. r = Object.prototype,
  30. n = r.hasOwnProperty,
  31. o = Object.defineProperty || function (t, e, r) {
  32. t[e] = r.value;
  33. },
  34. i = "function" == typeof Symbol ? Symbol : {},
  35. a = i.iterator || "@@iterator",
  36. c = i.asyncIterator || "@@asyncIterator",
  37. u = i.toStringTag || "@@toStringTag";
  38. function define(t, e, r) {
  39. return Object.defineProperty(t, e, {
  40. value: r,
  41. enumerable: !0,
  42. configurable: !0,
  43. writable: !0
  44. }), t[e];
  45. }
  46. try {
  47. define({}, "");
  48. } catch (t) {
  49. define = function define(t, e, r) {
  50. return t[e] = r;
  51. };
  52. }
  53. function wrap(t, e, r, n) {
  54. var i = e && e.prototype instanceof Generator ? e : Generator,
  55. a = Object.create(i.prototype),
  56. c = new Context(n || []);
  57. return o(a, "_invoke", {
  58. value: makeInvokeMethod(t, r, c)
  59. }), a;
  60. }
  61. function tryCatch(t, e, r) {
  62. try {
  63. return {
  64. type: "normal",
  65. arg: t.call(e, r)
  66. };
  67. } catch (t) {
  68. return {
  69. type: "throw",
  70. arg: t
  71. };
  72. }
  73. }
  74. e.wrap = wrap;
  75. var h = "suspendedStart",
  76. l = "suspendedYield",
  77. f = "executing",
  78. s = "completed",
  79. y = {};
  80. function Generator() {}
  81. function GeneratorFunction() {}
  82. function GeneratorFunctionPrototype() {}
  83. var p = {};
  84. define(p, a, function () {
  85. return this;
  86. });
  87. var d = Object.getPrototypeOf,
  88. v = d && d(d(values([])));
  89. v && v !== r && n.call(v, a) && (p = v);
  90. var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
  91. function defineIteratorMethods(t) {
  92. ["next", "throw", "return"].forEach(function (e) {
  93. define(t, e, function (t) {
  94. return this._invoke(e, t);
  95. });
  96. });
  97. }
  98. function AsyncIterator(t, e) {
  99. function invoke(r, o, i, a) {
  100. var c = tryCatch(t[r], t, o);
  101. if ("throw" !== c.type) {
  102. var u = c.arg,
  103. h = u.value;
  104. return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
  105. invoke("next", t, i, a);
  106. }, function (t) {
  107. invoke("throw", t, i, a);
  108. }) : e.resolve(h).then(function (t) {
  109. u.value = t, i(u);
  110. }, function (t) {
  111. return invoke("throw", t, i, a);
  112. });
  113. }
  114. a(c.arg);
  115. }
  116. var r;
  117. o(this, "_invoke", {
  118. value: function value(t, n) {
  119. function callInvokeWithMethodAndArg() {
  120. return new e(function (e, r) {
  121. invoke(t, n, e, r);
  122. });
  123. }
  124. return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  125. }
  126. });
  127. }
  128. function makeInvokeMethod(e, r, n) {
  129. var o = h;
  130. return function (i, a) {
  131. if (o === f) throw Error("Generator is already running");
  132. if (o === s) {
  133. if ("throw" === i) throw a;
  134. return {
  135. value: t,
  136. done: !0
  137. };
  138. }
  139. for (n.method = i, n.arg = a;;) {
  140. var c = n.delegate;
  141. if (c) {
  142. var u = maybeInvokeDelegate(c, n);
  143. if (u) {
  144. if (u === y) continue;
  145. return u;
  146. }
  147. }
  148. if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
  149. if (o === h) throw o = s, n.arg;
  150. n.dispatchException(n.arg);
  151. } else "return" === n.method && n.abrupt("return", n.arg);
  152. o = f;
  153. var p = tryCatch(e, r, n);
  154. if ("normal" === p.type) {
  155. if (o = n.done ? s : l, p.arg === y) continue;
  156. return {
  157. value: p.arg,
  158. done: n.done
  159. };
  160. }
  161. "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
  162. }
  163. };
  164. }
  165. function maybeInvokeDelegate(e, r) {
  166. var n = r.method,
  167. o = e.iterator[n];
  168. if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
  169. var i = tryCatch(o, e.iterator, r.arg);
  170. if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
  171. var a = i.arg;
  172. return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
  173. }
  174. function pushTryEntry(t) {
  175. var e = {
  176. tryLoc: t[0]
  177. };
  178. 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
  179. }
  180. function resetTryEntry(t) {
  181. var e = t.completion || {};
  182. e.type = "normal", delete e.arg, t.completion = e;
  183. }
  184. function Context(t) {
  185. this.tryEntries = [{
  186. tryLoc: "root"
  187. }], t.forEach(pushTryEntry, this), this.reset(!0);
  188. }
  189. function values(e) {
  190. if (e || "" === e) {
  191. var r = e[a];
  192. if (r) return r.call(e);
  193. if ("function" == typeof e.next) return e;
  194. if (!isNaN(e.length)) {
  195. var o = -1,
  196. i = function next() {
  197. for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
  198. return next.value = t, next.done = !0, next;
  199. };
  200. return i.next = i;
  201. }
  202. }
  203. throw new TypeError(_typeof(e) + " is not iterable");
  204. }
  205. return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
  206. value: GeneratorFunctionPrototype,
  207. configurable: !0
  208. }), o(GeneratorFunctionPrototype, "constructor", {
  209. value: GeneratorFunction,
  210. configurable: !0
  211. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
  212. var e = "function" == typeof t && t.constructor;
  213. return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
  214. }, e.mark = function (t) {
  215. return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
  216. }, e.awrap = function (t) {
  217. return {
  218. __await: t
  219. };
  220. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
  221. return this;
  222. }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
  223. void 0 === i && (i = Promise);
  224. var a = new AsyncIterator(wrap(t, r, n, o), i);
  225. return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
  226. return t.done ? t.value : a.next();
  227. });
  228. }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
  229. return this;
  230. }), define(g, "toString", function () {
  231. return "[object Generator]";
  232. }), e.keys = function (t) {
  233. var e = Object(t),
  234. r = [];
  235. for (var n in e) r.push(n);
  236. return r.reverse(), function next() {
  237. for (; r.length;) {
  238. var t = r.pop();
  239. if (t in e) return next.value = t, next.done = !1, next;
  240. }
  241. return next.done = !0, next;
  242. };
  243. }, e.values = values, Context.prototype = {
  244. constructor: Context,
  245. reset: function reset(e) {
  246. if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
  247. },
  248. stop: function stop() {
  249. this.done = !0;
  250. var t = this.tryEntries[0].completion;
  251. if ("throw" === t.type) throw t.arg;
  252. return this.rval;
  253. },
  254. dispatchException: function dispatchException(e) {
  255. if (this.done) throw e;
  256. var r = this;
  257. function handle(n, o) {
  258. return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
  259. }
  260. for (var o = this.tryEntries.length - 1; o >= 0; --o) {
  261. var i = this.tryEntries[o],
  262. a = i.completion;
  263. if ("root" === i.tryLoc) return handle("end");
  264. if (i.tryLoc <= this.prev) {
  265. var c = n.call(i, "catchLoc"),
  266. u = n.call(i, "finallyLoc");
  267. if (c && u) {
  268. if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
  269. if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
  270. } else if (c) {
  271. if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
  272. } else {
  273. if (!u) throw Error("try statement without catch or finally");
  274. if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
  275. }
  276. }
  277. }
  278. },
  279. abrupt: function abrupt(t, e) {
  280. for (var r = this.tryEntries.length - 1; r >= 0; --r) {
  281. var o = this.tryEntries[r];
  282. if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
  283. var i = o;
  284. break;
  285. }
  286. }
  287. i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
  288. var a = i ? i.completion : {};
  289. return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
  290. },
  291. complete: function complete(t, e) {
  292. if ("throw" === t.type) throw t.arg;
  293. return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
  294. },
  295. finish: function finish(t) {
  296. for (var e = this.tryEntries.length - 1; e >= 0; --e) {
  297. var r = this.tryEntries[e];
  298. if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
  299. }
  300. },
  301. "catch": function _catch(t) {
  302. for (var e = this.tryEntries.length - 1; e >= 0; --e) {
  303. var r = this.tryEntries[e];
  304. if (r.tryLoc === t) {
  305. var n = r.completion;
  306. if ("throw" === n.type) {
  307. var o = n.arg;
  308. resetTryEntry(r);
  309. }
  310. return o;
  311. }
  312. }
  313. throw Error("illegal catch attempt");
  314. },
  315. delegateYield: function delegateYield(e, r, n) {
  316. return this.delegate = {
  317. iterator: values(e),
  318. resultName: r,
  319. nextLoc: n
  320. }, "next" === this.method && (this.arg = t), y;
  321. }
  322. }, e;
  323. }
  324. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
  325.  
  326. /***/ }),
  327.  
  328. /***/ 882:
  329. /***/ ((module) => {
  330.  
  331. function _typeof(o) {
  332. "@babel/helpers - typeof";
  333.  
  334. return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  335. return typeof o;
  336. } : function (o) {
  337. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  338. }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
  339. }
  340. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  341.  
  342. /***/ }),
  343.  
  344. /***/ 501:
  345. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  346.  
  347. // TODO(Babel 8): Remove this file.
  348.  
  349. var runtime = __webpack_require__(342)();
  350. module.exports = runtime;
  351.  
  352. // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
  353. try {
  354. regeneratorRuntime = runtime;
  355. } catch (accidentalStrictMode) {
  356. if (typeof globalThis === "object") {
  357. globalThis.regeneratorRuntime = runtime;
  358. } else {
  359. Function("r", "regeneratorRuntime = r")(runtime);
  360. }
  361. }
  362.  
  363.  
  364. /***/ })
  365.  
  366. /******/ });
  367. /************************************************************************/
  368. /******/ // The module cache
  369. /******/ var __webpack_module_cache__ = {};
  370. /******/
  371. /******/ // The require function
  372. /******/ function __webpack_require__(moduleId) {
  373. /******/ // Check if module is in cache
  374. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  375. /******/ if (cachedModule !== undefined) {
  376. /******/ return cachedModule.exports;
  377. /******/ }
  378. /******/ // Create a new module (and put it into the cache)
  379. /******/ var module = __webpack_module_cache__[moduleId] = {
  380. /******/ // no module.id needed
  381. /******/ // no module.loaded needed
  382. /******/ exports: {}
  383. /******/ };
  384. /******/
  385. /******/ // Execute the module function
  386. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  387. /******/
  388. /******/ // Return the exports of the module
  389. /******/ return module.exports;
  390. /******/ }
  391. /******/
  392. /************************************************************************/
  393. /******/ /* webpack/runtime/compat get default export */
  394. /******/ (() => {
  395. /******/ // getDefaultExport function for compatibility with non-harmony modules
  396. /******/ __webpack_require__.n = (module) => {
  397. /******/ var getter = module && module.__esModule ?
  398. /******/ () => (module['default']) :
  399. /******/ () => (module);
  400. /******/ __webpack_require__.d(getter, { a: getter });
  401. /******/ return getter;
  402. /******/ };
  403. /******/ })();
  404. /******/
  405. /******/ /* webpack/runtime/define property getters */
  406. /******/ (() => {
  407. /******/ // define getter functions for harmony exports
  408. /******/ __webpack_require__.d = (exports, definition) => {
  409. /******/ for(var key in definition) {
  410. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  411. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  412. /******/ }
  413. /******/ }
  414. /******/ };
  415. /******/ })();
  416. /******/
  417. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  418. /******/ (() => {
  419. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  420. /******/ })();
  421. /******/
  422. /************************************************************************/
  423. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  424. (() => {
  425. "use strict";
  426.  
  427. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
  428. function asyncGeneratorStep(n, t, e, r, o, a, c) {
  429. try {
  430. var i = n[a](c),
  431. u = i.value;
  432. } catch (n) {
  433. return void e(n);
  434. }
  435. i.done ? t(u) : Promise.resolve(u).then(r, o);
  436. }
  437. function asyncToGenerator_asyncToGenerator(n) {
  438. return function () {
  439. var t = this,
  440. e = arguments;
  441. return new Promise(function (r, o) {
  442. var a = n.apply(t, e);
  443. function _next(n) {
  444. asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
  445. }
  446. function _throw(n) {
  447. asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
  448. }
  449. _next(void 0);
  450. });
  451. };
  452. }
  453.  
  454. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/typeof.js
  455. function typeof_typeof(o) {
  456. "@babel/helpers - typeof";
  457.  
  458. return typeof_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  459. return typeof o;
  460. } : function (o) {
  461. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  462. }, typeof_typeof(o);
  463. }
  464.  
  465. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/toPrimitive.js
  466.  
  467. function toPrimitive(t, r) {
  468. if ("object" != typeof_typeof(t) || !t) return t;
  469. var e = t[Symbol.toPrimitive];
  470. if (void 0 !== e) {
  471. var i = e.call(t, r || "default");
  472. if ("object" != typeof_typeof(i)) return i;
  473. throw new TypeError("@@toPrimitive must return a primitive value.");
  474. }
  475. return ("string" === r ? String : Number)(t);
  476. }
  477.  
  478. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
  479.  
  480.  
  481. function toPropertyKey(t) {
  482. var i = toPrimitive(t, "string");
  483. return "symbol" == typeof_typeof(i) ? i : i + "";
  484. }
  485.  
  486. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/defineProperty.js
  487.  
  488. function defineProperty_defineProperty(e, r, t) {
  489. return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
  490. value: t,
  491. enumerable: !0,
  492. configurable: !0,
  493. writable: !0
  494. }) : e[r] = t, e;
  495. }
  496.  
  497. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
  498. function _arrayWithHoles(r) {
  499. if (Array.isArray(r)) return r;
  500. }
  501.  
  502. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
  503. function _iterableToArrayLimit(r, l) {
  504. var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  505. if (null != t) {
  506. var e,
  507. n,
  508. i,
  509. u,
  510. a = [],
  511. f = !0,
  512. o = !1;
  513. try {
  514. if (i = (t = t.call(r)).next, 0 === l) {
  515. if (Object(t) !== t) return;
  516. f = !1;
  517. } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
  518. } catch (r) {
  519. o = !0, n = r;
  520. } finally {
  521. try {
  522. if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
  523. } finally {
  524. if (o) throw n;
  525. }
  526. }
  527. return a;
  528. }
  529. }
  530.  
  531. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
  532. function _arrayLikeToArray(r, a) {
  533. (null == a || a > r.length) && (a = r.length);
  534. for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  535. return n;
  536. }
  537.  
  538. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
  539.  
  540. function _unsupportedIterableToArray(r, a) {
  541. if (r) {
  542. if ("string" == typeof r) return _arrayLikeToArray(r, a);
  543. var t = {}.toString.call(r).slice(8, -1);
  544. return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  545. }
  546. }
  547.  
  548. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
  549. function _nonIterableRest() {
  550. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  551. }
  552.  
  553. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/slicedToArray.js
  554.  
  555.  
  556.  
  557.  
  558. function _slicedToArray(r, e) {
  559. return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
  560. }
  561.  
  562. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
  563.  
  564. function _arrayWithoutHoles(r) {
  565. if (Array.isArray(r)) return _arrayLikeToArray(r);
  566. }
  567.  
  568. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/iterableToArray.js
  569. function _iterableToArray(r) {
  570. if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
  571. }
  572.  
  573. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
  574. function _nonIterableSpread() {
  575. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  576. }
  577.  
  578. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
  579.  
  580.  
  581.  
  582.  
  583. function _toConsumableArray(r) {
  584. return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
  585. }
  586.  
  587. // EXTERNAL MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/regenerator/index.js
  588. var regenerator = __webpack_require__(501);
  589. var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);
  590. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/createClass.js
  591.  
  592. function _defineProperties(e, r) {
  593. for (var t = 0; t < r.length; t++) {
  594. var o = r[t];
  595. o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
  596. }
  597. }
  598. function createClass_createClass(e, r, t) {
  599. return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
  600. writable: !1
  601. }), e;
  602. }
  603.  
  604. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/classCallCheck.js
  605. function classCallCheck_classCallCheck(a, n) {
  606. if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
  607. }
  608.  
  609. ;// CONCATENATED MODULE: ./tools/GM.js
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616. function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
  617. function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { defineProperty_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
  618. /** @描述 函数文档 https://www.tampermonkey.net/documentation.php#api:GM_addElement */
  619.  
  620. /**
  621. * @description 创建element
  622. * @export
  623. * @param {*} tag
  624. * @param {*} [options={}]
  625. * @param {*} [win=window]
  626. * @returns {*}
  627. */
  628. function createElement(tag) {
  629. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  630. var win = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
  631. if (!win.GM_createElement) {
  632. win.GM_createElement = GM_createElement;
  633. }
  634. return GM_createElement(tag, options);
  635. /**
  636. * @param {*} tag
  637. * @param {*} options {
  638. * idPrefix = `enjoy_${ENV_CRX}_${tag}`,
  639. * el = 'html',
  640. * autoInsert = true,
  641. * randomType = 'single',
  642. * id = '',
  643. * addPrefix = true,
  644. * insertType = tag === 'style' ? 'appendChild' : 'prepend',
  645. * }
  646. * @returns {*} dom
  647. */
  648. function GM_createElement(tag, options) {
  649. var _options$idPrefix = options.idPrefix,
  650. idPrefix = _options$idPrefix === void 0 ? "enjoy_".concat("GlobalTools", "_").concat(tag, "_") : _options$idPrefix,
  651. _options$el = options.el,
  652. el = _options$el === void 0 ? 'html' : _options$el,
  653. _options$autoInsert = options.autoInsert,
  654. autoInsert = _options$autoInsert === void 0 ? true : _options$autoInsert,
  655. _options$randomType = options.randomType,
  656. randomType = _options$randomType === void 0 ? 'single' : _options$randomType,
  657. _options$id = options.id,
  658. id = _options$id === void 0 ? '' : _options$id,
  659. _options$addPrefix = options.addPrefix,
  660. addPrefix = _options$addPrefix === void 0 ? true : _options$addPrefix,
  661. _options$insertType = options.insertType,
  662. insertType = _options$insertType === void 0 ? tag === 'style' ? 'appendChild' : 'prepend' : _options$insertType;
  663. if (addPrefix) {
  664. id = "".concat(idPrefix).concat(id);
  665. }
  666. if (randomType !== 'single') {
  667. id = "".concat(id, "_").concat(Math.floor(Math.random() * 1000));
  668. }
  669. options.id = id;
  670. var dom = document.querySelector("#".concat(id));
  671. if (!dom) {
  672. dom = document.createElement(tag);
  673. }
  674. for (var key in options) {
  675. if (Object.hasOwnProperty.call(options, key) && key !== 'el') {
  676. dom[key] = options[key];
  677. }
  678. }
  679. if (autoInsert) {
  680. if (typeof el === 'string') {
  681. el = document.querySelector(el);
  682. }
  683.  
  684. //insertType prepend | appendChild
  685. el[insertType](dom);
  686. }
  687. return dom;
  688. }
  689. }
  690.  
  691. /** @描述 是否匹配到目标url */
  692. function isMatched() {
  693. var urls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  694. var currentUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : location.href;
  695. if (typeof urls === 'string') {
  696. urls = [urls];
  697. }
  698. return !!urls.find(function (regUrl) {
  699. return new RegExp(regUrl).test(currentUrl);
  700. });
  701. }
  702. function prependMetaUF8() {
  703. return document.querySelector('meta[charset="UTF-8"]') || createElement('meta', {
  704. charset: 'utf-8'
  705. });
  706. }
  707.  
  708. /**
  709. * @description doCopy 复制文本到剪贴板
  710. * @export
  711. * @param {*} text
  712. */
  713. function doCopy(text) {
  714. var _navigator;
  715. if (!text) return console.warn('doCopy 参数为空');
  716. if (document.hasFocus() && (_navigator = navigator) !== null && _navigator !== void 0 && (_navigator = _navigator.clipboard) !== null && _navigator !== void 0 && _navigator.writeText) {
  717. // localhost、127.0.0.1或者https中才能正常使用
  718. // 读取剪贴板
  719. // navigator.clipboard.readText().then((clipText) => {console.log('clipText=',clipText)})
  720.  
  721. // 写入剪贴板
  722. navigator.clipboard.writeText(text)["catch"](function (err) {
  723. return console.error("clipboard.writeText\uFF1A".concat(err));
  724. });
  725. return;
  726. }
  727. var textarea = document.createElement('textarea');
  728. document.body.appendChild(textarea);
  729. textarea.value = text;
  730. textarea.select();
  731. document.execCommand('Copy');
  732. setTimeout(function () {
  733. textarea.remove();
  734. }, 1000);
  735. }
  736.  
  737. /**
  738. * 检测element元素的可见性,即 非display:none
  739. * @param {*} element
  740. * @returns {*} {Boolean}
  741. */
  742. function checkVisibility(element) {
  743. if (element.checkVisibility) {
  744. return element.checkVisibility();
  745. }
  746. return !!element.offsetParent;
  747. }
  748. /**
  749. * @description 创建element的提示
  750. * @export
  751. * @param {*} [options={}]
  752. * @returns {*}
  753. */
  754. function createElementTipFn() {
  755. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  756. var _options$setTimeoutSt = options.setTimeoutStep,
  757. setTimeoutStep = _options$setTimeoutSt === void 0 ? 1000 : _options$setTimeoutSt,
  758. _options$backgroundCo = options.backgroundColors,
  759. backgroundColors = _options$backgroundCo === void 0 ? {
  760. warn: 'rgb(181 156 51 / 60%)',
  761. success: 'rgb(3 113 3 / 60%)',
  762. error: 'rgb(165 2 2 / 60%)',
  763. info: 'rgb(67 62 62 / 60%)'
  764. } : _options$backgroundCo,
  765. _options$color = options.color,
  766. color = _options$color === void 0 ? '#ffffff' : _options$color,
  767. _options$opacity = options.opacity,
  768. opacity = _options$opacity === void 0 ? 1 : _options$opacity;
  769. var setTimeoutStamp = 0;
  770. return function createElementTip() {
  771. var configs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  772. var content = configs.content,
  773. e = configs.e,
  774. _configs$type = configs.type,
  775. type = _configs$type === void 0 ? 'info' : _configs$type,
  776. _configs$tagType = configs.tagType,
  777. tagType = _configs$tagType === void 0 ? 'span' : _configs$tagType;
  778. if (!content) return;
  779. console.log("content => %O ", content);
  780. clearTimeout(setTimeoutStamp);
  781. var contentDom = createElement(tagType, {
  782. id: 'createElementTip',
  783. innerText: content,
  784. style: "\n font-size:14px;\n font-weight:600;\n color:".concat(color, ";\n position: fixed;\n left: ").concat(numbericalInterval(e.clientX - 46), "px;\n top: ").concat(numbericalInterval(e.clientY - 35, [5, window.innerHeight - 35]), "px;\n background-color:").concat(backgroundColors[type], ";\n opacity: ").concat(opacity, ";\n border-radius: 4px;\n padding: 4px 8px;\n box-shadow:0 0 5px 0 rgb(255 255 255 / 60%) inset;\n pointer-event:none;\n z-index:").concat((Math.floor(Date.now() / 1000) + '').slice(-5), ";\n\t\t\t\t\t\tdisplay:inline-block;\n ")
  785. });
  786. setTimeoutStamp = setTimeout(function () {
  787. // contentDom.remove()
  788. contentDom.style.display = 'none';
  789. }, setTimeoutStep);
  790. };
  791. }
  792. /**
  793. * @description dom是否可编辑
  794. * @param {*} [dom=document.activeElement]
  795. * @returns {*} {boolean}
  796. */
  797.  
  798. function isContentEditableOfDOM() {
  799. var dom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.activeElement;
  800. if (dom.tagName === 'INPUT' || dom.tagName === 'TEXTAREA') {
  801. return !dom.disabled;
  802. } else {
  803. return !!findParentElement(dom, function (dom) {
  804. return dom.contentEditable === 'true';
  805. }, null);
  806. }
  807. }
  808.  
  809. /**
  810. * @description 数字区间
  811. * @param {*} val
  812. * @param {*} [interval=[10, window.innerWidth]]
  813. * @returns {*}
  814. */
  815. function numbericalInterval(val) {
  816. var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [5, window.innerWidth - 130];
  817. var indexStart = interval[0];
  818. var indexEnd = interval[1];
  819. if (val < indexStart) return indexStart;
  820. if (val > indexEnd) return indexEnd;
  821. return val;
  822. }
  823.  
  824. /**
  825. * @description 可滚动的dom
  826. * @param {*} dom
  827. * @returns {*}
  828. */
  829. function findHasScrollbarDom(dom) {
  830. if (!(dom instanceof HTMLElement)) {
  831. console.warn("\u53EF\u6EDA\u52A8\u7684dom\u51FD\u6570 findHasScrollbarDom:\u53C2\u6570dom\u5FC5\u987B\u4E3Aelement\u5143\u7D20 ");
  832. return void 0;
  833. }
  834. while (dom) {
  835. if (dom.offsetHeight < dom.scrollHeight && !(window.getComputedStyle(dom).overflowY == 'visible' || window.getComputedStyle(dom).overflowY == 'hidden')) {
  836. break;
  837. }
  838. dom = dom.parentElement;
  839. }
  840. if (!dom || dom === document.body) {
  841. // 始终是 documentElement等同于window
  842. dom = document.documentElement;
  843. }
  844. console.warn("\u9875\u9762\u6EDA\u52A8\u5143\u7D20\u7684tagName: ", dom.tagName.toLocaleLowerCase(), 'dom.className:', dom.className);
  845. return dom;
  846. }
  847.  
  848. /**
  849. * @description 获取方法配置
  850. * @param {string} [key='']
  851. * @param {*} [defaultOpt={ includedUrls: [] }]
  852. * @returns {*} {Object}
  853. **/
  854. function getSettingFromLocalStorage() {
  855. var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  856. var defaultOpt = arguments.length > 1 ? arguments[1] : undefined;
  857. var mergedSettingOpt = _objectSpread({
  858. runType: '0',
  859. includedUrls: [],
  860. excludeUrls: []
  861. }, defaultOpt);
  862. var fullSettingKey = "enjoy_setting";
  863. var storageData = localStorage.getItem(fullSettingKey);
  864. var fullSettings = storageData ? JSON.parse(storageData) : {};
  865. var SETTING = _objectSpread(_objectSpread({}, mergedSettingOpt), fullSettings === null || fullSettings === void 0 ? void 0 : fullSettings[fileName]);
  866. fullSettings[fileName] = SETTING;
  867. fullSettings.runTypeDest = undefined;
  868. fullSettings.instructions = "\n\u4E00\u3001\u5339\u914D\u89C4\u5219\u4F18\u5148\u7EA7\uFF1Aruntype > * > excludedUrls > includedUrls\n\u4E8C\u3001runType\u662F\u9488\u5BF9\u5728\u5F53\u524D\u57DF\u540D\u89C4\u5219\uFF1A0(\u9ED8\u8BA4\u6267\u884C\u5339\u914D\u89C4\u5219)\uFF1B1(\u5F3A\u5236\u6267\u884C,\u5373\u8DF3\u8FC7\u5339\u914D\u89C4\u5219)\uFF1B2(\u4E0D\u6267\u884C)\n";
  869. localStorage.setItem(fullSettingKey, JSON.stringify(fullSettings || {}, null, 2));
  870. return SETTING;
  871. }
  872.  
  873. /**
  874. * @description 是否执行该方法
  875. * @param {*} [settingOpt={}]
  876. * @returns {*} {Boolean}
  877. */
  878. function isExcutableBySetting() {
  879. var settingOpt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  880. var runType = settingOpt.runType,
  881. _settingOpt$excludeUr = settingOpt.excludeUrls,
  882. excludeUrls = _settingOpt$excludeUr === void 0 ? [] : _settingOpt$excludeUr,
  883. _settingOpt$includedU = settingOpt.includedUrls,
  884. includedUrls = _settingOpt$includedU === void 0 ? [] : _settingOpt$includedU;
  885. if (runType == '1') return true;
  886. if (runType == '2') return false;
  887. var HREF = location.href;
  888. if (excludeUrls !== null && excludeUrls !== void 0 && excludeUrls.length && isMatched(excludeUrls, HREF)) {
  889. return false;
  890. }
  891. if ((includedUrls === null || includedUrls === void 0 ? void 0 : includedUrls.length) === 0) return true;
  892. var findOne = isMatched(includedUrls, HREF);
  893. return !!findOne;
  894. }
  895.  
  896. /**
  897. * @description 是否不执行
  898. * @param {String} fileName
  899. * @param {Object} settingOpt { excludeUrls: [ ],feature:"feature",includedUrls: [ ],name: "name",runType: "0",}
  900. * @returns {Boolean}
  901. */
  902. function codeIsNotExcutable(fileName, settingOpt) {
  903. try {
  904. // logSettingOptWithColor()
  905. var setting = getSettingFromLocalStorage(fileName, settingOpt);
  906. return _objectSpread({
  907. notExcutable: !isExcutableBySetting(setting)
  908. }, setting);
  909. } catch (error) {
  910. // base64路径下,禁用storage
  911. console.error(error);
  912. return _objectSpread({
  913. notExcutable: true
  914. }, settingOpt);
  915. }
  916. }
  917.  
  918. /**
  919. * @description 彩色打印
  920. * @param {string} [key='enjoy_setting']
  921. */
  922. function logSettingOptWithColor(key) {
  923. var dataKey = 'is-log-of-enjoy';
  924. if (true) return;
  925. // if (document.body.getAttribute(dataKey)) return
  926. document.body.setAttribute(dataKey, '1');
  927.  
  928. // clearTimeout(window.EnjoyColorLogTimer || 0)
  929. window.EnjoyColorLogTimer = setTimeout(function () {
  930. var _key;
  931. (_key = key) !== null && _key !== void 0 ? _key : key = 'enjoy_setting';
  932. var SETTINGS = JSON.parse(localStorage[key] || '{}');
  933. console.log("%c\uD83D\uDC47 ".concat(key, " \u8BBE\u7F6E\u53C2\u6570\uFF1A"), 'background:#4e0ab780;color:#fff;', '\n', SETTINGS, "\n\nkeyNameList:", Object.keys(SETTINGS));
  934. console.log("%c\uD83D\uDC47\u81EA\u5B9A\u4E49\u914D\u7F6E\uFF0C\u4EE3\u7801\u5982\u4E0B\uFF1A", 'background:#4e0ab747;color:#fff;', "\n\u5F53\u524D\u57DF\u540D\u4E0B\u662F\u5426\u8FD0\u884C\u76F8\u5E94\u51FD\u6570,", "\n\u8BBE\u7F6ErunType(1\u3001\u5F3A\u5236\u8FD0\u884C\uFF1B2\u3001\u4E0D\u8FD0\u884C)\u3002", '\n\n', modifyRuntype.toString(), "\nmodifyRuntype('keyName',2)");
  935. }, 3 * 1000);
  936. }
  937. /**
  938. * @description 修改运行机制
  939. * @export
  940. * @param {string} keyName
  941. * @param {0|1|2} runType
  942. */
  943. function modifyRuntype(keyName, runType) {
  944. var keyOfSETTINGS = 'enjoy_setting';
  945. var SETTINGS = JSON.parse(localStorage.getItem(keyOfSETTINGS) || '{}');
  946. if (!SETTINGS[keyName]) return;
  947. SETTINGS[keyName].runType = runType || 2;
  948. localStorage.setItem(keyOfSETTINGS, JSON.stringify(SETTINGS, null, 2));
  949. }
  950.  
  951. /**
  952. * @description 查找特定条件的父级元素
  953. * @export
  954. * @param {Element} dom
  955. * @param {Function} callback
  956. * @param {Element} [defaultVal=document.documentElement]
  957. * @returns {Element}
  958. */
  959. function findParentElement(dom, callback) {
  960. var defaultVal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document.documentElement;
  961. if (!(dom instanceof HTMLElement)) {
  962. console.warn("\u67E5\u627E\u7279\u5B9A\u6761\u4EF6\u7684\u7236\u7EA7\u5143\u7D20\u51FD\u6570 findParentElement:\u53C2\u6570dom\u5FC5\u987B\u4E3Aelement\u5143\u7D20 ");
  963. return void 0;
  964. }
  965. while (dom) {
  966. if (callback(dom)) {
  967. break;
  968. }
  969. dom = dom.parentElement;
  970. }
  971. if (!dom || dom === document.body) {
  972. // 始终是 documentElement等同于window
  973. dom = defaultVal;
  974. }
  975. return dom;
  976. }
  977.  
  978. /** 原生横向滚动条 吸附 页面底部 */
  979. var StickyHorizontalNativeScrollBar = /*#__PURE__*/(/* unused pure expression or super */ null && (_createClass(function StickyHorizontalNativeScrollBar() {
  980. var _this = this;
  981. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  982. _classCallCheck(this, StickyHorizontalNativeScrollBar);
  983. /** 创建滚轴组件元素 */
  984. _defineProperty(this, "createScrollbar", function () {
  985. var style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  986. if (_this.scrollbar) return _this.scrollbar;
  987. var timer = Date.now();
  988. _this.thumbId = "thumb".concat(timer);
  989. _this.scrollbarId = "scrollbar".concat(timer);
  990. _this.scrollbar = document.createElement('div');
  991. _this.scrollbar.setAttribute('id', _this.scrollbarId);
  992. _this.scrollbar.innerHTML = "\n\t\t\t<style>\n\t\t\t\t#".concat(_this.scrollbarId, " {\n\t\t\t\t\tposition: sticky;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\tbox-shadow: 0 15px 0 0 #fff;\n\t\t\t\t\tbottom: 8px;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\theight: 17px;\n\t\t\t\t\toverflow-x: auto;\n\t\t\t\t\toverflow-y: hidden;\n\t\t\t\t\tmargin-top: -17px;\n\t\t\t\t\tz-index: 3;\n\t\t\t\t\t").concat(style, "\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<div id=\"").concat(_this.thumbId, "\" style=\"height: 1px;\"></div>\n\t\t");
  993. });
  994. /** 把滚轴组件元素插入目标元素的后面 */
  995. _defineProperty(this, "insertScrollbar", function (el) {
  996. _this.target = el;
  997. if (typeof el === 'string') {
  998. _this.target = document.querySelector(el);
  999. }
  1000. if (!_this.target) throw Error('el Dom do not exit');
  1001. _this.targetParentElement = document.querySelector(el).parentElement;
  1002. if (!_this.targetParentElement.querySelector("#".concat(_this.scrollbarId))) {
  1003. _this.targetParentElement.insertBefore(_this.scrollbar, _this.target.nextSibling);
  1004. }
  1005. return _this.target;
  1006. });
  1007. /** 设置 滚轴组件元素尺寸 */
  1008. _defineProperty(this, "setScrollbarSize", throttle(function () {
  1009. _this.scrollbar.style.width = _this.target.clientWidth + 'px';
  1010. _this.scrollbar.querySelector("#".concat(_this.thumbId)).style.width = _this.target.scrollWidth + 'px';
  1011. }, 100));
  1012. /** 监听目标元素和滚轴元素的scroll和页面resize事件 */
  1013. _defineProperty(this, "onEvent", function () {
  1014. _this.target.addEventListener('scroll', _this.onScrollTarget);
  1015. _this.scrollbar.addEventListener('scroll', _this.onScrollScrollbar);
  1016. window.addEventListener('resize', _this.setScrollbarSize);
  1017. });
  1018. /** 移除事件 */
  1019. _defineProperty(this, "removeEvent", function () {
  1020. _this.target.removeEventListener('scroll', _this.onScrollTarget);
  1021. _this.scrollbar.removeEventListener('scroll', _this.onScrollScrollbar);
  1022. window.removeEventListener('resize', _this.setScrollbarSize);
  1023. });
  1024. _defineProperty(this, "onScrollTarget", throttle(function (e) {
  1025. _this.scrollbar.scrollLeft = e.target.scrollLeft;
  1026. }, 100));
  1027. _defineProperty(this, "onScrollScrollbar", throttle(function (e) {
  1028. _this.target.scrollLeft = e.target.scrollLeft;
  1029. }, 100));
  1030. var _el = options.el,
  1031. _options$style = options.style,
  1032. _style = _options$style === void 0 ? '' : _options$style;
  1033. this.createScrollbar(_style);
  1034. this.insertScrollbar(_el);
  1035. this.setScrollbarSize();
  1036. this.onEvent();
  1037. })));
  1038.  
  1039. /** 插入横向滚动条 */
  1040. var HorizontalScrollBar = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  1041. function HorizontalScrollBar() {
  1042. var _this2 = this;
  1043. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1044. _classCallCheck(this, HorizontalScrollBar);
  1045. /** 创建滚轴组件元素 */
  1046. _defineProperty(this, "createScrollbar", function (setStyle) {
  1047. if (_this2.scrollbar) return _this2.scrollbar;
  1048. var timer = Date.now();
  1049. _this2.scrollbarId = "scrollbar".concat(timer);
  1050. _this2.scrollbar = document.createElement('div');
  1051. _this2.scrollbar.setAttribute('data-part', 'scrollbar');
  1052. _this2.scrollbar.setAttribute('id', _this2.scrollbarId);
  1053. _this2.scrollbar.innerHTML = "\n\t\t".concat(setStyle(_this2.scrollbarId) || _this2.setDefaultStyle(_this2.scrollbarId), "\n\t\t<div data-part=\"thumb\"></div>\n\t\t");
  1054. });
  1055. /** 把滚轴组件元素插入目标元素的后面 */
  1056. _defineProperty(this, "insertScrollbar", function (el) {
  1057. _this2.target = el;
  1058. if (typeof el === 'string') {
  1059. _this2.target = document.querySelector(el);
  1060. }
  1061. if (!_this2.target) throw Error('el Dom do not exit');
  1062. _this2.targetParentElement = document.querySelector(el).parentElement;
  1063. if (!_this2.targetParentElement.querySelector("#".concat(_this2.scrollbarId))) {
  1064. _this2.targetParentElement.insertBefore(_this2.scrollbar, _this2.target.nextSibling);
  1065. }
  1066. return _this2.target;
  1067. });
  1068. /** 根据目标元素 设置 滚轴组件元素尺寸 */
  1069. _defineProperty(this, "setScrollbarSize", function () {
  1070. _this2.scrollbar.style.width = _this2.target.clientWidth + 'px';
  1071. _this2.thumb = _this2.scrollbar.querySelector('[data-part="thumb"]');
  1072. _this2.thumb.style.width = _this2.scrollbar.clientWidth * _this2.target.clientWidth / _this2.target.scrollWidth + 'px';
  1073. _this2.offsetMax = _this2.scrollbar.clientWidth - _this2.thumb.clientWidth;
  1074. _this2.rate = (_this2.target.scrollWidth - _this2.target.clientWidth) / _this2.offsetMax;
  1075. });
  1076. /** */
  1077. _defineProperty(this, "onMouseDownOfThumb", function (e) {
  1078. console.log("mousedown => %O ");
  1079. _this2.prePageX = e.pageX;
  1080. _this2.isMousedown = true;
  1081. });
  1082. /** */
  1083. _defineProperty(this, "onMouseUpOfWindow", function (e) {
  1084. _this2.isMousedown = false;
  1085. });
  1086. /** */
  1087. _defineProperty(this, "requestAnimationFrameCallback", function (offsetLeft) {
  1088. _this2.thumb.style.left = offsetLeft + 'px';
  1089. _this2.target.scrollLeft = offsetLeft * _this2.rate;
  1090. });
  1091. /** */
  1092. _defineProperty(this, "onMousemoveOfWindow", function (e) {
  1093. if (_this2.isMousedown) {
  1094. var offsetLeft = Number(_this2.thumb.style.left.replace('px', '')) + Number(e.pageX - _this2.prePageX);
  1095. offsetLeft = Math.max(0, offsetLeft);
  1096. offsetLeft = Math.min(offsetLeft, _this2.offsetMax);
  1097. _this2.requestAnimationFrameCallback(offsetLeft);
  1098. _this2.prePageX = e.pageX;
  1099. }
  1100. });
  1101. /** 监听目标元素和滚轴元素的scroll和页面resize事件 */
  1102. _defineProperty(this, "onEvent", function () {
  1103. _this2.thumb.addEventListener('mousedown', _this2.onMouseDownOfThumb);
  1104. window.addEventListener('mouseup', _this2.onMouseUpOfWindow);
  1105. window.addEventListener('mousemove', _this2.onMousemoveOfWindow);
  1106. window.addEventListener('resize', _this2.setScrollbarSize);
  1107. });
  1108. /** 移除事件 */
  1109. _defineProperty(this, "removeEvent", function () {
  1110. _this2.thumb.removeEventListener('mousedown', _this2.onMouseDownOfThumb);
  1111. window.removeEventListener('mouseup', _this2.onMouseUpOfWindow);
  1112. window.removeEventListener('mousemove', _this2.onMousemoveOfWindow);
  1113. window.removeEventListener('resize', _this2.setScrollbarSize);
  1114. });
  1115. var _el2 = options.el,
  1116. _options$setStyle = options.setStyle,
  1117. _setStyle = _options$setStyle === void 0 ? function () {
  1118. return null;
  1119. } : _options$setStyle;
  1120. this.createScrollbar(_setStyle);
  1121. this.insertScrollbar(_el2);
  1122. this.setScrollbarSize();
  1123. this.onEvent();
  1124. }
  1125. return _createClass(HorizontalScrollBar, [{
  1126. key: "setDefaultStyle",
  1127. value: function setDefaultStyle(scrollbarId) {
  1128. return "\n\t\t<style>\n\t\t\t#".concat(scrollbarId, " {\n\t\t\t\theight: 17px;\n\t\t\t\tbackground-color: #f1f1f1;\n\t\t\t\tposition: relative;\n\t\t\t}\n\t\t\t#").concat(scrollbarId, ">[data-part=\"thumb\"] {\n\t\t\t\theight: 100%;\n\t\t\t\tbackground-color: #c1c1c1;\n\t\t\t\tposition: absolute;\n\t\t\t}\n\t\t\t#").concat(scrollbarId, ">[data-part=\"thumb\"]:active {\n\t\t\t\tbackground-color: #787878;\n\t\t\t}\n\t\t</style>\n\t");
  1129. }
  1130. }]);
  1131. }()));
  1132.  
  1133. /** 持久化数据状态 */
  1134. var PersistentStorage = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  1135. function PersistentStorage() {
  1136. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1137. _classCallCheck(this, PersistentStorage);
  1138. var _options$valKey = options.valKey,
  1139. valKey = _options$valKey === void 0 ? 'valKey' : _options$valKey,
  1140. _options$storageType = options.storageType,
  1141. storageType = _options$storageType === void 0 ? 'sessionStorage' : _options$storageType;
  1142. this.valKey = valKey;
  1143. this.storageType = storageType;
  1144. }
  1145. return _createClass(PersistentStorage, [{
  1146. key: "write",
  1147. value: function write(val) {
  1148. val = _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : val;
  1149. val && window[this.storageType].setItem(this.valKey, val);
  1150. }
  1151. }, {
  1152. key: "read",
  1153. value: function read() {
  1154. var val = window[this.storageType].getItem(this.valKey);
  1155. return val ? JSON.parse(val) : val;
  1156. }
  1157. }, {
  1158. key: "remove",
  1159. value: function remove() {
  1160. window[this.storageType].removeItem(this.valKey);
  1161. }
  1162. }]);
  1163. }()));
  1164.  
  1165. /**
  1166. * @description 节流函数
  1167. * @export
  1168. * @param {Function} func
  1169. * @param {Number} [wait=100]
  1170. * @returns {Function}
  1171. */
  1172. function throttle(func) {
  1173. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
  1174. var isDoing = false;
  1175. return function () {
  1176. if (isDoing) return;
  1177. isDoing = true;
  1178. func.apply(void 0, arguments);
  1179. setTimeout(function () {
  1180. isDoing = false;
  1181. }, wait);
  1182. };
  1183. }
  1184.  
  1185. /**
  1186. * @description 防抖函数
  1187. * @export
  1188. * @param {Function} func
  1189. * @param {Number} [wait=100]
  1190. * @param {'end'|'front'} type
  1191. * @returns {Function}
  1192. */
  1193. function debounce(func) {
  1194. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
  1195. var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'end';
  1196. var timer = 0;
  1197. return function () {
  1198. clearTimeout(timer);
  1199. for (var _len = arguments.length, rest = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
  1200. rest[_key2] = arguments[_key2];
  1201. }
  1202. timer = setTimeout.apply(void 0, [func, wait].concat(rest));
  1203. };
  1204. }
  1205.  
  1206. /**
  1207. * @description 等候
  1208. * @export
  1209. * @param {number} [interval=17]
  1210. * @returns {Promise}
  1211. */
  1212. function awaitTime() {
  1213. var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 17;
  1214. return new Promise(function (resolve) {
  1215. setTimeout(resolve, interval);
  1216. });
  1217. }
  1218.  
  1219. /**
  1220. * @description 打开已在窗口仅激活,不刷新
  1221. * @export
  1222. * @class OpenPlus
  1223. */
  1224. var OpenPlus = /*#__PURE__*/(/* unused pure expression or super */ null && (_createClass(function OpenPlus() {
  1225. var _this3 = this;
  1226. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1227. _classCallCheck(this, OpenPlus);
  1228. _defineProperty(this, "openPre", function () {
  1229. var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
  1230. return null;
  1231. };
  1232. for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
  1233. rest[_key3 - 1] = arguments[_key3];
  1234. }
  1235. var win = _this3.open.apply(_this3, rest);
  1236. callback === null || callback === void 0 || callback();
  1237. return win;
  1238. });
  1239. _defineProperty(this, "open", function (href) {
  1240. var willOpenTab = _this3.win.tabsCacheOfOpenPlus[href];
  1241. for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key4 = 1; _key4 < _len3; _key4++) {
  1242. rest[_key4 - 1] = arguments[_key4];
  1243. }
  1244. if (willOpenTab === undefined) {
  1245. var _this3$win;
  1246. willOpenTab = (_this3$win = _this3.win).open.apply(_this3$win, [href].concat(rest));
  1247. _this3.win.nextOfOpenPlus.forEach(function (item) {
  1248. return item === null || item === void 0 ? void 0 : item();
  1249. });
  1250. return _this3.win.tabsCacheOfOpenPlus[href] = willOpenTab;
  1251. } else if (willOpenTab.closed === true) {
  1252. var _this3$win2;
  1253. return (_this3$win2 = _this3.win).open.apply(_this3$win2, [href].concat(rest));
  1254. } else if (willOpenTab.closed === false) {
  1255. willOpenTab.focus();
  1256. return willOpenTab;
  1257. }
  1258. });
  1259. var _opt$win = opt.win,
  1260. _win = _opt$win === void 0 ? window : _opt$win,
  1261. _opt$next = opt.next,
  1262. next = _opt$next === void 0 ? function () {
  1263. return null;
  1264. } : _opt$next;
  1265. this.win = _win;
  1266. this.win.tabsCacheOfOpenPlus = this.win.tabsCacheOfOpenPlus || {};
  1267. this.win.nextOfOpenPlus = this.win.nextOfOpenPlus || [];
  1268. this.win.nextOfOpenPlus.push(next);
  1269. })));
  1270. function modifyStorage() {
  1271. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1272. var _opt$storageName = opt.storageName,
  1273. storageName = _opt$storageName === void 0 ? 'localStorage' : _opt$storageName,
  1274. chainKeys = opt.chainKeys,
  1275. _opt$doType = opt.doType,
  1276. doType = _opt$doType === void 0 ? 'get' : _opt$doType,
  1277. val = opt.val,
  1278. _opt$prefix = opt.prefix,
  1279. prefix = _opt$prefix === void 0 ? 'enjoy_setting' : _opt$prefix;
  1280. if (prefix) {
  1281. chainKeys = "".concat(prefix, ".").concat(chainKeys);
  1282. }
  1283. chainKeys = chainKeys.split('.');
  1284. var keyOfLevel1 = chainKeys.shift();
  1285. var keyOfEnd = chainKeys.pop();
  1286. var isObject = true;
  1287. var storage = null;
  1288. try {
  1289. storage = JSON.parse(window[storageName].getItem(keyOfLevel1));
  1290. } catch (error) {
  1291. isObject = false;
  1292. storage = window[storageName].getItem(keyOfLevel1);
  1293. console.error("".concat(storageName, " ").concat(chainKeys, " \u4E00\u7EA7\u5C5E\u6027\u503C\u4E3A\u57FA\u672C\u7C7B\u578B"));
  1294. return;
  1295. }
  1296. var obj = storage;
  1297. chainKeys.forEach(function (key) {
  1298. obj = obj[key];
  1299. });
  1300. if (doType === 'set') {
  1301. obj[keyOfEnd] = val;
  1302. window[storageName].setItem(keyOfLevel1, JSON.stringify(storage, null, 2));
  1303. } else {
  1304. return obj[keyOfEnd];
  1305. }
  1306. }
  1307.  
  1308. /**
  1309. * @description 简便的Storage SimpleStorage({ prefix: 'prefix' })
  1310. * @param {*} opt
  1311. */
  1312. function storagex() {
  1313. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1314. var Storage = /*#__PURE__*/createClass_createClass(function Storage() {
  1315. var _this4 = this;
  1316. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1317. classCallCheck_classCallCheck(this, Storage);
  1318. defineProperty_defineProperty(this, "storage", null);
  1319. defineProperty_defineProperty(this, "setItem", function (keys, val) {
  1320. _this4.formatChainKeys(keys);
  1321. _this4.getFirstLevelVal();
  1322. _this4.chainVal('set', val);
  1323. return void 0;
  1324. });
  1325. defineProperty_defineProperty(this, "getItem", function (keys) {
  1326. _this4.formatChainKeys(keys);
  1327. _this4.getFirstLevelVal();
  1328. return _this4.chainVal('get');
  1329. });
  1330. defineProperty_defineProperty(this, "removeItem", function (keys) {
  1331. _this4.formatChainKeys(keys);
  1332. _this4.getFirstLevelVal();
  1333. return _this4.chainVal('remove');
  1334. });
  1335. defineProperty_defineProperty(this, "clear", function () {
  1336. var keysWithPrefix = Object.keys(_this4.storage).filter(function (item) {
  1337. return item.startsWith(_this4.prefix);
  1338. });
  1339. keysWithPrefix.forEach(function (key) {
  1340. return _this4.storage.removeItem(key);
  1341. });
  1342. return void 0;
  1343. });
  1344. defineProperty_defineProperty(this, "getFirstLevelVal", function () {
  1345. var state = _this4.storage[_this4.prefix + _this4.startKey];
  1346. try {
  1347. state = JSON.parse(state);
  1348. } catch (error) {}
  1349. _this4.cache = state;
  1350. return state;
  1351. });
  1352. defineProperty_defineProperty(this, "formatChainKeys", function (keys) {
  1353. keys = keys.split('.');
  1354. _this4.startKey = keys.shift();
  1355. _this4.endKey = keys.pop();
  1356. _this4.middlekeys = keys;
  1357. return keys;
  1358. });
  1359. defineProperty_defineProperty(this, "chainVal", function (doType, val) {
  1360. var obj = _this4.cache;
  1361. _this4.middlekeys.forEach(function (key) {
  1362. obj = obj[key];
  1363. });
  1364. if (doType === 'set') {
  1365. if (_this4.endKey) {
  1366. obj[_this4.endKey] = val;
  1367. } else {
  1368. _this4.cache = val;
  1369. }
  1370. _this4.storage.setItem(_this4.prefix + _this4.startKey, _this4.isObject(_this4.cache) ? JSON.stringify(_this4.cache, null, 2) : _this4.cache);
  1371. } else if (doType === 'get') {
  1372. if (_this4.endKey) {
  1373. return obj[_this4.endKey];
  1374. }
  1375. return _this4.cache;
  1376. } else if (doType === 'remove') {
  1377. if (_this4.endKey) {
  1378. var isDeleted = delete obj[_this4.endKey];
  1379. isDeleted && _this4.setItem(_this4.startKey, _this4.cache);
  1380. return isDeleted;
  1381. }
  1382. _this4.storage.removeItem(_this4.prefix + _this4.startKey);
  1383. }
  1384. });
  1385. defineProperty_defineProperty(this, "isObject", function (value) {
  1386. var type = typeof_typeof(value);
  1387. return value != null && (type === 'object' || type === 'function');
  1388. });
  1389. var prefix = opt.prefix,
  1390. storage = opt.storage;
  1391. this.prefix = prefix ? "".concat(prefix, "_") : '';
  1392. this.storage = storage;
  1393. });
  1394. if (opt.storage && sessionStorage.__proto__.setItemX) return opt.storage;
  1395. var storage = new Storage(opt);
  1396. if (opt.storage) return storage;
  1397. if (sessionStorage.__proto__.setItemX) return;
  1398. sessionStorage.__proto__.setItemX = function (key, val) {
  1399. storage.storage = this;
  1400. storage.setItem(key, val);
  1401. };
  1402. sessionStorage.__proto__.getItemX = function (key) {
  1403. storage.storage = this;
  1404. return storage.getItem(key);
  1405. };
  1406. sessionStorage.__proto__.removeItemX = function (key) {
  1407. storage.storage = this;
  1408. return storage.removeItem(key);
  1409. };
  1410. sessionStorage.__proto__.clearX = function () {
  1411. storage.storage = this;
  1412. return storage.clear();
  1413. };
  1414. }
  1415.  
  1416. /**
  1417. * @description 处理标记内容
  1418. * @param {*} opt
  1419. * @returns {*}
  1420. */
  1421. function operateComment(opt) {
  1422. var _opt$text = opt.text,
  1423. text = _opt$text === void 0 ? '' : _opt$text,
  1424. _opt$S = opt.S,
  1425. S = _opt$S === void 0 ? '/*' : _opt$S,
  1426. _opt$E = opt.E,
  1427. E = _opt$E === void 0 ? '*/' : _opt$E,
  1428. _opt$modify = opt.modify,
  1429. modify = _opt$modify === void 0 ? function (val) {
  1430. return val;
  1431. } : _opt$modify;
  1432. var stack = [];
  1433. var index = text.indexOf(S);
  1434. if (index === -1) return text;
  1435. while (index <= text.length - 1) {
  1436. if (text[index] + text[index + 1] == S) {
  1437. stack.push(index);
  1438. } else if (text[index] + text[index + 1] == E) {
  1439. var latestIndex = stack.pop();
  1440. if (latestIndex !== undefined) {
  1441. var middle = modify(text.slice(latestIndex + S.length, index));
  1442. text = text.slice(0, latestIndex) + middle + text.slice(index + S.length);
  1443. index = latestIndex + middle.length;
  1444. }
  1445. }
  1446. index++;
  1447. }
  1448. return text;
  1449. }
  1450.  
  1451. /** 添加动画函数 */
  1452. function addAnimation(dom, className) {
  1453. if (!dom || !className) return;
  1454. if (!dom.animationend) {
  1455. dom.animationend = function () {
  1456. dom.classList.remove(className);
  1457. };
  1458. }
  1459. dom.removeEventListener('animationend', dom.animationend);
  1460. dom.addEventListener('animationend', dom.animationend);
  1461. dom.classList.add(className);
  1462. }
  1463.  
  1464. // 判断当前浏览器运行环境
  1465. function getBrowserEnv() {
  1466. var userAgent = window.navigator.userAgent.toLowerCase();
  1467. var agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
  1468. // 是否为支付宝环境
  1469. var isAliPay = /alipayclient/.test(userAgent);
  1470. // 是否为淘宝环境
  1471. var isTaoBao = /windvane/.test(userAgent);
  1472. // 是否为企业微信环境
  1473. var isWxWork = /wxwork/.test(userAgent);
  1474. // 是否为微信环境
  1475. var isWeChat = /micromessenger/.test(userAgent) && !isWxWork;
  1476. // 是否为移动端
  1477. var isPhone = agents.some(function (x) {
  1478. return new RegExp(x.toLocaleLowerCase()).test(userAgent);
  1479. });
  1480. return {
  1481. isAliPay: isAliPay,
  1482. isTaoBao: isTaoBao,
  1483. isWxWork: isWxWork,
  1484. isWeChat: isWeChat,
  1485. isPhone: isPhone
  1486. };
  1487. }
  1488. var RegisterDbltouchEvent = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  1489. function RegisterDbltouchEvent(el, fn) {
  1490. _classCallCheck(this, RegisterDbltouchEvent);
  1491. this.el = el || window;
  1492. this.callback = fn;
  1493. this.timer = null;
  1494. this.prevPosition = {};
  1495. this.isWaiting = false;
  1496.  
  1497. // 注册click事件,注意this指向
  1498. this.el.addEventListener('click', this.handleClick.bind(this), true);
  1499. }
  1500. return _createClass(RegisterDbltouchEvent, [{
  1501. key: "handleClick",
  1502. value: function handleClick(evt) {
  1503. var _this5 = this;
  1504. var pageX = evt.pageX;
  1505. var pageY = evt.pageY;
  1506. if (this.timer) {
  1507. clearTimeout(this.timer);
  1508. this.timer = null;
  1509. }
  1510. if (!evt.isTrusted) {
  1511. return;
  1512. }
  1513. if (this.isWaiting) {
  1514. this.isWaiting = false;
  1515. var diffX = Math.abs(pageX - this.prevPosition.pageX);
  1516. var diffY = Math.abs(pageY - this.prevPosition.pageY);
  1517. // 如果满足位移小于10,则是双击
  1518. if (diffX <= 10 && diffY <= 10) {
  1519. // 取消当前事件传递,并派发1个自定义双击事件
  1520. evt.stopPropagation();
  1521. evt.target.dispatchEvent(new PointerEvent('dbltouch', {
  1522. cancelable: false,
  1523. bubbles: true
  1524. }));
  1525. // 也可以采用回调函数的方式
  1526. this.callback && this.callback(evt);
  1527. }
  1528. } else {
  1529. this.prevPostion = {
  1530. pageX: pageX,
  1531. pageY: pageY
  1532. };
  1533. // 阻止冒泡,不让事件继续传播
  1534. evt.stopPropagation();
  1535. // 开始等待第2次点击
  1536. this.isWaiting = true;
  1537. // 设置200ms倒计时,200ms后重新派发当前事件
  1538. this.timer = setTimeout(function () {
  1539. _this5.isWaiting = false;
  1540. evt.target.dispatchEvent(evt);
  1541. }, 200);
  1542. }
  1543. }
  1544. }]);
  1545. }()));
  1546. /**移动端 双击 */
  1547. function addDbltouch() {
  1548. var dom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
  1549. var handle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (event) {
  1550. console.log('双击', event, Date.now());
  1551. };
  1552. var preTimestamp = 0;
  1553. dom.addEventListener('click', function (event) {
  1554. var currentTimestamp = Date.now();
  1555. if (currentTimestamp - preTimestamp < 200) handle(event);
  1556. preTimestamp = currentTimestamp;
  1557. });
  1558. }
  1559.  
  1560. /**
  1561. * @description 获取dom
  1562. * @export
  1563. * @param {*} element
  1564. * @param {*} selector
  1565. * @param {number} [timeout=80]
  1566. * @param {boolean} [isAlways=true]
  1567. * @returns {*}
  1568. */
  1569. function getElement(_x, _x2) {
  1570. return _getElement.apply(this, arguments);
  1571. }
  1572.  
  1573. /**
  1574. * @description 分隔dom分区
  1575. * @param {*} e
  1576. * @param {number} [divideX=3]
  1577. * @param {*} [divideY=divideX]
  1578. * @returns {*} string
  1579. */
  1580. function _getElement() {
  1581. _getElement = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(element, selector) {
  1582. var timeout,
  1583. isAlways,
  1584. count,
  1585. _args = arguments;
  1586. return _regeneratorRuntime.wrap(function _callee$(_context) {
  1587. while (1) switch (_context.prev = _context.next) {
  1588. case 0:
  1589. timeout = _args.length > 2 && _args[2] !== undefined ? _args[2] : 80;
  1590. isAlways = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
  1591. count = 0;
  1592. return _context.abrupt("return", new Promise(function (resolve, reject) {
  1593. var timeId = setInterval(function () {
  1594. if (timeout && count++ >= timeout) {
  1595. clearInterval(timeId);
  1596. console.warn('[utils.getElement] Element is not find.' + ' selector: ' + selector);
  1597. // 保持原生逻辑,即未找到时,返回null,便于之后执行埋点,比如错误上报
  1598. return resolve(null);
  1599. }
  1600. var node = element.querySelector(selector);
  1601. if (node) {
  1602. //node 总是返回 或 显示状态条件下,找到后即刻返回
  1603. if (isAlways || node.offsetParent) {
  1604. resolve(node);
  1605. clearInterval(timeId);
  1606. }
  1607. }
  1608. }, 200);
  1609. }));
  1610. case 4:
  1611. case "end":
  1612. return _context.stop();
  1613. }
  1614. }, _callee);
  1615. }));
  1616. return _getElement.apply(this, arguments);
  1617. }
  1618. function divideDom(e) {
  1619. var divideX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
  1620. var divideY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : divideX;
  1621. if (!divideX) {
  1622. throw new Error('divideDom 函数 divideX 参数不能为空');
  1623. }
  1624. if (!divideY) {
  1625. divideX = divideY;
  1626. console.warn("divideDom \u51FD\u6570 dom \u5206\u533A \u4E3A ".concat(divideX, "*").concat(divideY));
  1627. }
  1628. var resultStr = "".concat(getIdx(e.target.offsetWidth, divideX, e.offsetX), "-").concat(getIdx(e.target.offsetHeight, divideY, e.offsetY));
  1629. console.log("resultStr => %O ", resultStr);
  1630. return resultStr;
  1631.  
  1632. // 获取坐标
  1633. function getIdx(size, divide, offsetPosition) {
  1634. var size_step = Math.ceil(size / divide);
  1635. var posi_idx = Math.floor(offsetPosition / size_step);
  1636. if (offsetPosition % size_step) {
  1637. posi_idx++;
  1638. }
  1639. return posi_idx;
  1640. }
  1641. }
  1642. ;// CONCATENATED MODULE: ./src/tool/vimport.js
  1643.  
  1644.  
  1645.  
  1646. function run() {
  1647. return _run.apply(this, arguments);
  1648. }
  1649.  
  1650. /**
  1651. * @description
  1652. * @export
  1653. * @param {'dayjs@1.11.9'|dayjs} moduleAndVersion
  1654. */
  1655. function _run() {
  1656. _run = asyncToGenerator_asyncToGenerator(/*#__PURE__*/regenerator_default().mark(function _callee() {
  1657. var setting;
  1658. return regenerator_default().wrap(function _callee$(_context) {
  1659. while (1) switch (_context.prev = _context.next) {
  1660. case 0:
  1661. _context.prev = 0;
  1662. setting = codeIsNotExcutable('vimport', {
  1663. name: '快捷导入js模块cdn版本包',
  1664. feature: '快捷导入js模块cdn版本包',
  1665. importQueue: [],
  1666. // 单击时,按网站设计的方式跳转 ['dayjs','vue']
  1667. usage: "importQueue= ['dayjs','vue'],会一次导入dayjs,vue"
  1668. });
  1669. if (!setting.notExcutable) {
  1670. _context.next = 4;
  1671. break;
  1672. }
  1673. return _context.abrupt("return");
  1674. case 4:
  1675. window.vimport = bootcdn;
  1676. autoImport(setting.importQueue);
  1677. _context.next = 11;
  1678. break;
  1679. case 8:
  1680. _context.prev = 8;
  1681. _context.t0 = _context["catch"](0);
  1682. console.error(_context.t0);
  1683. case 11:
  1684. case "end":
  1685. return _context.stop();
  1686. }
  1687. }, _callee, null, [[0, 8]]);
  1688. }));
  1689. return _run.apply(this, arguments);
  1690. }
  1691. function bootcdn(_x) {
  1692. return _bootcdn.apply(this, arguments);
  1693. }
  1694. function _bootcdn() {
  1695. _bootcdn = asyncToGenerator_asyncToGenerator(/*#__PURE__*/regenerator_default().mark(function _callee2(moduleAndVersion) {
  1696. var setting, serializerOfDocument;
  1697. return regenerator_default().wrap(function _callee2$(_context2) {
  1698. while (1) switch (_context2.prev = _context2.next) {
  1699. case 0:
  1700. if (moduleAndVersion) {
  1701. _context2.next = 2;
  1702. break;
  1703. }
  1704. return _context2.abrupt("return");
  1705. case 2:
  1706. collectQueue(moduleAndVersion);
  1707. setting = formatParams(moduleAndVersion);
  1708. console.log("setting => %O ", setting);
  1709. _context2.next = 7;
  1710. return fetch("https://unpkg.com/".concat(moduleAndVersion), {
  1711. method: 'GET'
  1712. });
  1713. case 7:
  1714. _context2.next = 9;
  1715. return _context2.sent.text();
  1716. case 9:
  1717. serializerOfDocument = _context2.sent;
  1718. if (serializerOfDocument) {
  1719. _context2.next = 12;
  1720. break;
  1721. }
  1722. return _context2.abrupt("return", console.warn('${moduleAndVersion} 引入失败,未找到相应版'));
  1723. case 12:
  1724. console.warn('${moduleAndVersion} 引入成功');
  1725. console.warn("\u5F15\u5165\u5730\u5740\uFF1Ahttps://unpkg.com/".concat(moduleAndVersion));
  1726. console.warn('请用window.${setting.rename}访问');
  1727. createElement('script', {
  1728. randomType: 'new',
  1729. el: 'body',
  1730. src: "https://unpkg.com/".concat(moduleAndVersion)
  1731. });
  1732. case 16:
  1733. case "end":
  1734. return _context2.stop();
  1735. }
  1736. }, _callee2);
  1737. }));
  1738. return _bootcdn.apply(this, arguments);
  1739. }
  1740. function formatParams(moduleAndVersion) {
  1741. moduleAndVersion = moduleAndVersion.split('@');
  1742. return {
  1743. name: moduleAndVersion[0],
  1744. version: moduleAndVersion[1] || '',
  1745. url: moduleAndVersion.join('/') + '/',
  1746. rename: moduleAndVersion[0] + (moduleAndVersion[1] || '').replace(/\./g, '_')
  1747. };
  1748. }
  1749.  
  1750. // 栈 stack 队列 queue
  1751. function collectQueue(moduleAndVersion) {
  1752. var importQueue = JSON.parse(sessionStorage.importcdn || '[]');
  1753. var importQueueSet = new Set(importQueue);
  1754. console.log("moduleAndVersion => %O ", moduleAndVersion);
  1755. importQueueSet.add(moduleAndVersion);
  1756. importQueue = Array.from(importQueueSet);
  1757. console.log("importQueue => %O ", importQueue);
  1758. sessionStorage.importQueue = JSON.stringify(importQueue);
  1759. }
  1760. function autoImport(importQueue) {
  1761. var importQueueSet = new Set(importQueue);
  1762. importQueue = Array.from(importQueueSet);
  1763. importQueue.forEach(function (moduleName) {
  1764. window.importcdn(moduleName);
  1765. });
  1766. console.warn('当前tab页,一次导入包', importQueue);
  1767. }
  1768. ;// CONCATENATED MODULE: ./src/GlobalTools.js
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775. function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = GlobalTools_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
  1776. function GlobalTools_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return GlobalTools_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? GlobalTools_arrayLikeToArray(r, a) : void 0; } }
  1777. function GlobalTools_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
  1778. function GlobalTools_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
  1779. function GlobalTools_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? GlobalTools_ownKeys(Object(t), !0).forEach(function (r) { defineProperty_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : GlobalTools_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
  1780.  
  1781.  
  1782. run();
  1783. storagex();
  1784. GlobalTools_run(window);
  1785. function GlobalTools_run(win) {
  1786. // getLogObjectValue(['$0', 'temp1'])
  1787. // windowProxy()
  1788. var tools = {
  1789. backPrototype: backPrototype,
  1790. createPlainFile: createPlainFile,
  1791. getRegMobile: getRegMobile,
  1792. phoneFormat: phoneFormat,
  1793. getRegName: getRegName,
  1794. getRegEmail: getRegEmail,
  1795. getRegIDCard: getRegIDCard,
  1796. getQuery: getQuery,
  1797. toSearch: toSearch,
  1798. transformThousandth: transformThousandth,
  1799. deleteProperty: deleteProperty,
  1800. asyncRequire: asyncRequire,
  1801. transformData: transformData,
  1802. previewFile: previewFile,
  1803. dateUtil: dateUtil,
  1804. toWithOpener: toWithOpener,
  1805. downloadFile: downloadFile,
  1806. base64ToBlob: base64ToBlob,
  1807. base64ImgtoFile: base64ImgtoFile,
  1808. isHasBtnPower: isHasBtnPower,
  1809. getBrowerEnv: getBrowerEnv,
  1810. formatReportDataToStr: formatReportDataToStr,
  1811. copyStrToClipboard: copyStrToClipboard,
  1812. getPropertiesOfObj: getPropertiesOfObj,
  1813. lgd: lgd,
  1814. lgd0: lgd0,
  1815. lgdt1: lgdt1,
  1816. getPrototypeChainOfObject: getPrototypeChainOfObject,
  1817. getLogObjectValue: getLogObjectValue,
  1818. storagex: storagex,
  1819. pickFileDom: pickFileDom,
  1820. mockArr: mockArr,
  1821. getArr: mockArr,
  1822. getBasepath: getBasepath,
  1823. downloadFileByAElement: downloadFileByAElement
  1824. };
  1825. /** 获取静态资源的文件名 */
  1826. function getBasepath(fileUrl) {
  1827. var _a$pathname$match;
  1828. /** 获取静态资源的文件名 */
  1829. if (!fileUrl) {
  1830. console.error('getBasepath 函数 fileUrl参数不能为空');
  1831. return fileUrl;
  1832. }
  1833. var a = document.createElement('a');
  1834. a.href = fileUrl;
  1835. var basepath = ((_a$pathname$match = a.pathname.match(/[^/]*?$/)) === null || _a$pathname$match === void 0 ? void 0 : _a$pathname$match[0]) || '';
  1836. var filename = '';
  1837. var mimetype = '';
  1838. if (basepath) {
  1839. var mimeTypeMatch = basepath.match(/\.[^.]*$/);
  1840. if (mimeTypeMatch) {
  1841. mimetype = mimeTypeMatch[0];
  1842. filename = basepath.slice(0, mimeTypeMatch.index);
  1843. } else {
  1844. filename = basepath;
  1845. }
  1846. }
  1847. return {
  1848. basepath: basepath,
  1849. filename: filename,
  1850. mimetype: mimetype
  1851. };
  1852. }
  1853.  
  1854. /** @描述 通过 a标签下载文件 */
  1855. function downloadFileByAElement(url) {
  1856. var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  1857. /** @描述 通过 a标签下载文件 */
  1858. if (!url) {
  1859. throw new Error('downloadFileByAElement 函数中 url不能为空 ');
  1860. }
  1861. fetch(url, {
  1862. method: 'get',
  1863. responseType: 'blob'
  1864. }).then(function (res) {
  1865. return res.blob();
  1866. }).then(function (blob) {
  1867. var basePathObj = getBasepath(url);
  1868. if (filename) {
  1869. if (!filename.endsWith(basePathObj.mimetype)) {
  1870. filename += basePathObj.mimetype;
  1871. }
  1872. }
  1873. var link = document.createElement('a');
  1874. link.setAttribute('download', filename || basePathObj.basepath);
  1875. link.href = window.URL.createObjectURL(new Blob([blob]));
  1876. link.click();
  1877. window.URL.revokeObjectURL(link.href);
  1878. })["catch"](function (err) {
  1879. console.error(err);
  1880. // 报错时,跳转新页面
  1881. var link = document.createElement('a');
  1882. link.setAttribute('target', '_blank');
  1883. link.href = url;
  1884. link.click();
  1885. });
  1886. }
  1887.  
  1888. /** mock 生成数组 */
  1889. function mockArr() {
  1890. var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
  1891. var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (id) {
  1892. return {
  1893. id: id
  1894. };
  1895. };
  1896. /** mock 生成数组 */
  1897. // Array.from(new Array(10),item=>item)
  1898. return new Array(count).fill(undefined).map(function (item, index) {
  1899. return cb(index, index);
  1900. });
  1901. }
  1902. /** 获取文件 */
  1903. function pickFileDom() {
  1904. /** 获取文件 */
  1905. var pickFileDom = createElement('input', {
  1906. el: 'body',
  1907. id: 'pickFileDom',
  1908. addPrefix: false,
  1909. autoInsert: true,
  1910. type: 'file',
  1911. style: 'position:fixed;top:-100px'
  1912. });
  1913. pickFileDom.addEventListener('change', function (e) {
  1914. var _e$target;
  1915. if ((_e$target = e.target) !== null && _e$target !== void 0 && _e$target.files) {
  1916. console.log(e.target.files[0]);
  1917. }
  1918. });
  1919. pickFileDom.click();
  1920. }
  1921. function getPrototypeChainOfObject(Obj) {
  1922. /** @描述 对象原型链 */
  1923.  
  1924. var idx = 0;
  1925. var str = "".concat(Obj.name || '参数', "\u7684\u539F\u578B\u94FE\u662F\uFF1A ");
  1926. next(Obj);
  1927. return str;
  1928.  
  1929. /** @描述 递归 */
  1930. function next(obj) {
  1931. var _ObjType$match;
  1932. var ObjType = Object.toLocaleString.call(obj);
  1933. var ObjFlag = ((_ObjType$match = ObjType.match(/^\[object ([a-zA-Z]+)\]/)) === null || _ObjType$match === void 0 ? void 0 : _ObjType$match[1]) || typeof_typeof(ObjType);
  1934. str += "\u7B2C ".concat(idx, " \u7EA7\u3010").concat(ObjFlag, "\u3011.__proto__ \u25B6\uFE0F ");
  1935. idx++;
  1936. if (obj.__proto__) {
  1937. next(obj.__proto__);
  1938. } else {
  1939. str += "\u7B2C ".concat(idx, " \u7EA7\u3010null\u3011");
  1940. }
  1941. }
  1942. }
  1943. function lgdt1() {
  1944. var _console;
  1945. for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
  1946. rest[_key] = arguments[_key];
  1947. }
  1948. /** @描述 以对象形式打印 $0 */
  1949. (_console = console).log.apply(_console, ["temp1 ==%O", temp1].concat(rest));
  1950. }
  1951. function lgd() {
  1952. var _console3;
  1953. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1954. args[_key2] = arguments[_key2];
  1955. }
  1956. /** @描述 以对象形式打印 temp1 */
  1957.  
  1958. var desc = args[0],
  1959. rest = args.slice(1);
  1960. if (rest.length && typeof desc === 'string') {
  1961. var _console2;
  1962. return (_console2 = console).log.apply(_console2, ["".concat(desc, " %O")].concat(_toConsumableArray(rest)));
  1963. }
  1964. (_console3 = console).log.apply(_console3, ["%O"].concat(args));
  1965. }
  1966. function lgd0() {
  1967. var _console4;
  1968. for (var _len3 = arguments.length, rest = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1969. rest[_key3] = arguments[_key3];
  1970. }
  1971. /** @描述 以对象形式打印 $0 */
  1972. (_console4 = console).log.apply(_console4, ["$0 ==%O", $0].concat(rest));
  1973. }
  1974. function backPrototype(resourceObj) {
  1975. /**
  1976. * @description 对象原型链:继承谁的属性和方法
  1977. * @param {*} resourceObj
  1978. * @returns {*} string
  1979. */
  1980.  
  1981. var str = '';
  1982. next(resourceObj);
  1983. str = str + 'null';
  1984. console.log("%c \u8BE5\u5BF9\u8C61\u539F\u578B\u94FE\u662F\uFF1A", 'color:red', str);
  1985. return str;
  1986. function next(obj) {
  1987. var _ObjType$match2;
  1988. var ObjType = Object.toLocaleString.call(obj);
  1989. var ObjFlag = ((_ObjType$match2 = ObjType.match(/^\[object ([a-zA-Z]+)\]/)) === null || _ObjType$match2 === void 0 ? void 0 : _ObjType$match2[1]) || '无';
  1990. str = str + ObjFlag + ' + .__proto__ >> ';
  1991. if (obj.__proto__) {
  1992. next(obj.__proto__);
  1993. }
  1994. }
  1995. }
  1996. function createPlainFile() {
  1997. var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  1998. a: 'a'
  1999. };
  2000. var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'name';
  2001. /**
  2002. * @description 创建文本文件
  2003. * @param {string} [content={ a: 'a' }]
  2004. * @param {string} [name='name']
  2005. */
  2006.  
  2007. // 下载保存json文件
  2008. var eleLink = document.createElement('a');
  2009. eleLink.download = name + '.json';
  2010. // 字符内容转变成blob地址
  2011. var data = JSON.stringify(content, undefined, 4);
  2012. var blob = new Blob([data], {
  2013. type: 'text/json'
  2014. });
  2015. eleLink.href = URL.createObjectURL(blob);
  2016. // 触发点击
  2017. eleLink.click();
  2018. // 然后移除
  2019. }
  2020. function getRegMobile() {
  2021. /** @描述 正则 - 手机号 */
  2022. return /^1[2|3|4|5|6|7|8|9][\d]{9}$/;
  2023. }
  2024. function phoneFormat() {
  2025. var phone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  2026. /** @描述 格式化 - 手机号 */
  2027. if (!phone || !/^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(phone)) return;
  2028. phone = phone.replace(/\D/g, '').slice(0, 11);
  2029. phone = phone.replace(/^(\d{3})/, '$1 ').replace(/(\d{4})/, '$1 ').replace(/[\s]+$/, '');
  2030. return phone;
  2031. }
  2032. function getRegName() {
  2033. /** @描述 正则 - 姓名 */
  2034.  
  2035. return /^[0-9|A-Za-z|\u4e00-\u9fa5|\s]+$/;
  2036. }
  2037. function getRegEmail() {
  2038. /** @描述 正则 - 邮箱 */
  2039.  
  2040. return /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i;
  2041. }
  2042. function getRegIDCard() {
  2043. /** @描述 正则 - 大陆身份证号码 */
  2044. return /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
  2045. }
  2046. function getQuery() {
  2047. var search = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.search;
  2048. /** @描述 获取 url 参数 */
  2049.  
  2050. var query = {};
  2051. search.substr(1).split('&').forEach(function (str) {
  2052. var strArr = str.split('=');
  2053. var key = strArr[0];
  2054. if (!key) return;
  2055. var val = decodeURIComponent(strArr[1]);
  2056. try {
  2057. val = JSON.parse(val);
  2058. } catch (err) {}
  2059. query[key] = val;
  2060. });
  2061. return query;
  2062. }
  2063. function toSearch() {
  2064. var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2065. /** @描述 转换成 url search */
  2066. var arr = Object.keys(obj).map(function (key) {
  2067. var val = obj[key];
  2068. if (typeof val !== 'string') {
  2069. try {
  2070. val = JSON.stringify(val);
  2071. } catch (err) {
  2072. console.error(err);
  2073. }
  2074. }
  2075. return "".concat(key, "=").concat(encodeURIComponent(val));
  2076. });
  2077. return '?' + arr.join('&');
  2078. }
  2079. function transformThousandth(value, fixed) {
  2080. /**
  2081. * 格式化金额 千分符
  2082. * @param value
  2083. * @param fixed
  2084. */
  2085.  
  2086. var needFixed = fixed != null;
  2087. var num = Number(value);
  2088. if (isNaN(num)) {
  2089. return needFixed ? 0 .toFixed(fixed) : '0';
  2090. }
  2091. // return (needFixed ? num.toFixed(fixed) : num.toString()).replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,')
  2092. var str = needFixed ? num.toFixed(fixed) : num.toString();
  2093. var arr = str.split('.');
  2094. var result = arr[0] ? arr[0].replace(/(?=(?!\b)(\d{3})+$)/g, ',') : '0';
  2095. if (arr[1] != null) {
  2096. result += ".".concat(arr[1]);
  2097. }
  2098. return result;
  2099. }
  2100. function deleteProperty() {
  2101. var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2102. var v = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [undefined, null, ''];
  2103. /**
  2104. * 删除指定值的属性
  2105. * @param obj
  2106. */
  2107.  
  2108. var res = {};
  2109. var isArray = Array.isArray(v);
  2110. for (var key in obj) {
  2111. if (isArray) {
  2112. if (!v.includes(obj[key])) res[key] = obj[key];
  2113. } else {
  2114. if (obj[key] !== v) res[key] = obj[key];
  2115. }
  2116. }
  2117. return res;
  2118. }
  2119. function asyncRequire(url, name, type) {
  2120. /**
  2121. * 通过插入标签以加载 js/css 文件
  2122. * @param {String} url 需要载入的 js/css url
  2123. * @param {String} name 文件载入后挂载到 window 下的变量名
  2124. * @param {String} type 文件类型 默认取后缀名
  2125. */
  2126.  
  2127. return new Promise(function (resolve, reject) {
  2128. var head = document.head || document.getElementsByTagName('head')[0] || document.body;
  2129. var filePath = url.split('?')[0];
  2130. var ext = filePath.substring(filePath.lastIndexOf('.') + 1);
  2131. if (document.getElementById("async-require-".concat(name || 'unknown'))) {
  2132. return resolve(name ? window[name] : 'loaded');
  2133. }
  2134. var element;
  2135. if (ext == 'js' || type == 'js') {
  2136. element = document.createElement('script');
  2137. element.src = url;
  2138. element.onload = function (e) {
  2139. return resolve(name ? window[name] : e);
  2140. };
  2141. } else if (ext == 'css' || type == 'css') {
  2142. element = document.createElement('link');
  2143. element.rel = 'stylesheet';
  2144. element.type = 'text/css';
  2145. element.href = url;
  2146. element.onload = resolve;
  2147. } else {
  2148. return console.warn('好像有点不对劲...请指定文件类型: js | css');
  2149. }
  2150. element.id = "async-require-".concat(name);
  2151. element.onerror = reject;
  2152. head.appendChild(element);
  2153. });
  2154. }
  2155. function transformData(sourceData, relation) {
  2156. /**
  2157. * 返回数据
  2158. * @param {Array} sourceData 原数组
  2159. * @param {Array} 映射字段
  2160. */
  2161.  
  2162. return sourceData.map(function (item) {
  2163. var _relation = _slicedToArray(relation, 2),
  2164. key = _relation[0],
  2165. name = _relation[1];
  2166. return {
  2167. label: item[name],
  2168. value: item[key]
  2169. };
  2170. });
  2171. }
  2172. function previewFile(fileUrl) {
  2173. /**
  2174. * 在线预览文件
  2175. * @param {String} fileUrl 静态资源地址
  2176. */
  2177.  
  2178. var link = document.createElement('a');
  2179. link.href = fileUrl;
  2180. var ext = (link.pathname.split('.')[1] || '').toLowerCase();
  2181. var allowedExt = {
  2182. bmp: 1,
  2183. gif: 1,
  2184. jpg: 1,
  2185. jpeg: 1,
  2186. png: 1,
  2187. apng: 1,
  2188. webp: 1,
  2189. htm: 1,
  2190. html: 1,
  2191. pdf: 1
  2192. };
  2193. if (ext && allowedExt[ext]) {
  2194. var _window;
  2195. var url = "https://static.hrwork.com/tools/pdfviewer/index.html?file=".concat(encodeURIComponent(fileUrl));
  2196. if ((_window = window) !== null && _window !== void 0 && _window.__ZPA_CRX) {
  2197. return void dispatchEvent(new CustomEvent('$create_tab', {
  2198. detail: url
  2199. }));
  2200. }
  2201. window.open(url);
  2202. } else {
  2203. alert("\u4E0D\u652F\u6301\u5728\u7EBF\u9884\u89C8\u6B64\u7C7B\u578B(".concat(ext !== null && ext !== void 0 ? ext : '', ")\u6587\u4EF6"));
  2204. }
  2205. }
  2206. function dateUtil() {
  2207. var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
  2208. /**
  2209. * 获取特定格式日期
  2210. * date: 可以为日期字符串、日期对象,不传参数默认当前系统时间
  2211. * format: 输出日期时间格式, 不传参数默认 YYYY-MM-DD HH:mm:ss 格式
  2212. * 例:
  2213. * dateUtil().format()
  2214. * // 2022-06-16 11:56:02
  2215. *
  2216. * // 不传入日期,默认以当前日期,格式化为特定格式日期
  2217. * dateUtil().format('YYYY年MM月DD日 (周W) HH时mm分ss秒')
  2218. * // 2022年06月16日 (周四) 12时01分51秒
  2219. *
  2220. * // 传入指定日期(string | date),格式化为指定格式日期(string)
  2221. * dateUtil('2015.7.12').format('YYYY年MM月DD日 HH时mm秒ss分 星期W')
  2222. * // 2015年07月12日 00时00分00秒 星期三
  2223. */
  2224.  
  2225. time = typeof time === 'string' ? time.replace(/-/g, '/') : time;
  2226. var date = isNaN(new Date(time)) ? time : new Date(time);
  2227. return {
  2228. date: date,
  2229. format: format
  2230. };
  2231. function format() {
  2232. var rule = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
  2233. var weeks = ['日', '一', '二', '三', '四', '五', '六'];
  2234. var padStart = function padStart(d) {
  2235. return (d + '').padStart(2, '0');
  2236. };
  2237. var M = date.getMonth() + 1 + '';
  2238. var D = date.getDate() + '';
  2239. var H = date.getHours() + '';
  2240. var m = date.getMinutes() + '';
  2241. var s = date.getSeconds() + '';
  2242. return rule.replace('YYYY', date.getFullYear()).replace('MM', padStart(M)).replace('M', M).replace('DD', padStart(D)).replace('D', D).replace('HH', padStart(H)).replace('H', H).replace('mm', padStart(m)).replace('m', m).replace('ss', padStart(s)).replace('s', s).replace(/W/, weeks[date.getDay()]).replace(/w/, date.getDay());
  2243. }
  2244. }
  2245. function toWithOpener(href) {
  2246. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2247. /**
  2248. * 共享opener跳转
  2249. * @param { Object } router 如:
  2250. * @param { Object } options 如:
  2251. */
  2252.  
  2253. var _options$target = options.target,
  2254. target = _options$target === void 0 ? '_blank' : _options$target,
  2255. routes = options.routes;
  2256. var win = window.open(href, target);
  2257. // 设置新打开页面的面包屑
  2258. if (routes && Array.isArray(routes)) {
  2259. var cloneRoutes = _toConsumableArray(routes);
  2260. cloneRoutes.shift();
  2261. cloneRoutes[cloneRoutes.length - 1] = GlobalTools_objectSpread(GlobalTools_objectSpread({}, cloneRoutes[cloneRoutes.length - 1]), {}, {
  2262. a: true,
  2263. path: '/zhaopintong/' + location.hash
  2264. });
  2265. win.sessionStorage.parent_routes = JSON.stringify(cloneRoutes);
  2266. }
  2267. return win;
  2268. }
  2269. function downloadFile(href) {
  2270. var fileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2271. /**
  2272. * 通过url一键下载图片
  2273. * @param { String } href 如:
  2274. * @param { String } fileName 如:
  2275. */
  2276.  
  2277. if (!href) {
  2278. return;
  2279. }
  2280. var aLink = document.createElement('a');
  2281. aLink.download = fileName + Date.now();
  2282. aLink.href = href;
  2283. aLink.click();
  2284. }
  2285. function base64ToBlob(base64Code) {
  2286. /**
  2287. * base64转Blob对象
  2288. * @param { String } code 如:
  2289. */
  2290.  
  2291. var parts = base64Code.split(';base64,');
  2292. var contentType = parts[0].split(':')[1];
  2293. var raw = window.atob(parts[1]);
  2294. var rawLength = raw.length;
  2295. var uint8Array = new Uint8Array(rawLength);
  2296. for (var i = 0; i < rawLength; i++) {
  2297. uint8Array[i] = raw.charCodeAt(i);
  2298. }
  2299. return new Blob([uint8Array], {
  2300. type: contentType
  2301. });
  2302. }
  2303. function base64ImgtoFile(base64Code) {
  2304. var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'file';
  2305. /**
  2306. * base64转文件对象
  2307. * @param { String } base64Code 如:
  2308. * @param { String } filename 如:
  2309. */
  2310.  
  2311. var arr = base64Code.split(',');
  2312. var mime = arr[0].match(/:(.*?);/)[1];
  2313. var suffix = mime.split('/')[1];
  2314. var bstr = atob(arr[1]);
  2315. var n = bstr.length;
  2316. var u8arr = new Uint8Array(n);
  2317. while (n--) {
  2318. u8arr[n] = bstr.charCodeAt(n);
  2319. }
  2320. return new File([u8arr], "".concat(filename, ".").concat(suffix), {
  2321. type: mime
  2322. });
  2323. }
  2324. function isHasBtnPower() {
  2325. var powerList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  2326. var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2327. /**
  2328. * @description 判断角色是否有页面级按钮的权限
  2329. * @param {*} [powerList=[]]
  2330. * @param {string} [code='']
  2331. * @returns {*} {boolean}
  2332. */
  2333.  
  2334. if (!code) return false;
  2335. if (typeof code === 'string') code = [code];
  2336. var _iterator = _createForOfIteratorHelper(code),
  2337. _step;
  2338. try {
  2339. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  2340. var _powerList$includes;
  2341. var value = _step.value;
  2342. if (powerList !== null && powerList !== void 0 && (_powerList$includes = powerList.includes) !== null && _powerList$includes !== void 0 && _powerList$includes.call(powerList, value)) return true;
  2343. }
  2344. } catch (err) {
  2345. _iterator.e(err);
  2346. } finally {
  2347. _iterator.f();
  2348. }
  2349. return false;
  2350. }
  2351. function getBrowerEnv() {
  2352. /** @描述 判断当前浏览器运行环境 */
  2353.  
  2354. var userAgent = window.navigator.userAgent.toLowerCase();
  2355. var agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
  2356. // 是否为支付宝环境
  2357. var isAliPay = /alipayclient/.test(userAgent);
  2358. // 是否为淘宝环境
  2359. var isTaoBao = /windvane/.test(userAgent);
  2360. // 是否为企业微信环境
  2361. var isWxWork = /wxwork/.test(userAgent);
  2362. // 是否为微信环境
  2363. var isWeChat = /micromessenger/.test(userAgent) && !isWxWork;
  2364. // 是否为移动端
  2365. var isPhone = agents.some(function (x) {
  2366. return new RegExp(x.toLocaleLowerCase()).test(userAgent);
  2367. });
  2368. return {
  2369. isAliPay: isAliPay,
  2370. isTaoBao: isTaoBao,
  2371. isWxWork: isWxWork,
  2372. isWeChat: isWeChat,
  2373. isPhone: isPhone
  2374. };
  2375. }
  2376.  
  2377. //
  2378. function formatReportDataToStr() {
  2379. var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  2380. var headerLabel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  2381. /** @描述 格式化报表数据拼接成字符串,以便复制到剪贴板 */
  2382.  
  2383. return arr.reduce(function (pre, cur) {
  2384. return pre + headerLabel.reduceRight(function (pre2, cur2) {
  2385. return "".concat(cur[cur2.key], "\t").concat(pre2);
  2386. }, '\n');
  2387. }, headerLabel.reduceRight(function (pre, cur) {
  2388. return "".concat(cur.title, "\t").concat(pre);
  2389. }, '\n'));
  2390. }
  2391. function copyStrToClipboard(value) {
  2392. /** @描述 把字符串复制到剪贴板 */
  2393.  
  2394. var textarea = document.createElement('textarea');
  2395. textarea.value = value;
  2396. document.body.appendChild(textarea);
  2397. textarea.select();
  2398. document.execCommand('Copy');
  2399. document.body.removeChild(textarea);
  2400. }
  2401. function copyStrToClipboardOfNavigator(_x) {
  2402. return _copyStrToClipboardOfNavigator.apply(this, arguments);
  2403. }
  2404. function _copyStrToClipboardOfNavigator() {
  2405. _copyStrToClipboardOfNavigator = asyncToGenerator_asyncToGenerator(/*#__PURE__*/regenerator_default().mark(function _callee(value) {
  2406. return regenerator_default().wrap(function _callee$(_context) {
  2407. while (1) switch (_context.prev = _context.next) {
  2408. case 0:
  2409. _context.next = 2;
  2410. return navigator.clipboard.writeText(value);
  2411. case 2:
  2412. return _context.abrupt("return", _context.sent);
  2413. case 3:
  2414. case "end":
  2415. return _context.stop();
  2416. }
  2417. }, _callee);
  2418. }));
  2419. return _copyStrToClipboardOfNavigator.apply(this, arguments);
  2420. }
  2421. function getPropertiesOfObj(_ref) {
  2422. var _ref$obj = _ref.obj,
  2423. obj = _ref$obj === void 0 ? {} : _ref$obj,
  2424. _ref$keys = _ref.keys,
  2425. keys = _ref$keys === void 0 ? [] : _ref$keys;
  2426. /**
  2427. * @描述 获取对象的指定属性集合
  2428. * @param {*} { obj = {}, keys = [] }
  2429. * @returns {*}
  2430. */
  2431.  
  2432. var newObj = {};
  2433. keys.forEach(function (key) {
  2434. newObj[key] = obj[key];
  2435. });
  2436. return newObj;
  2437. }
  2438.  
  2439. /** @描述 定义以对象形式 获取window属性值 */
  2440. function getLogObjectValue(arr) {
  2441. var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2442. var suffix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '_o';
  2443. var win2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : win;
  2444. /** @描述 定义以对象形式 获取window属性值 */
  2445. arr.forEach(function (newKey) {
  2446. Object.defineProperty(win2, "".concat(newKey), {
  2447. get: function get() {
  2448. console.log('%O', win2[newKey]);
  2449. return win2[newKey];
  2450. }
  2451. });
  2452. });
  2453. }
  2454.  
  2455. /** @描述 代理window,读取属性时,即打印对象 */
  2456. function windowProxy() {
  2457. var win2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : win;
  2458. /** @描述 代理window,读取属性时,即打印对象 */
  2459. var result;
  2460. win2.enjoy_wp6 = new Proxy(win2, {
  2461. get: function get(obj, prop) {
  2462. result = obj[prop];
  2463. console.log("\uD83C\uDF8F ".concat(prop, "=%O"), result);
  2464. return result;
  2465. }
  2466. });
  2467. }
  2468. if (win.enjoy_tl6) {
  2469. // console.error('win.enjoy_tl已经存在,请使用win.enjoy_tls')
  2470. if (!win.enjoy_tls6) win.enjoy_tls6 = tools;
  2471. return;
  2472. }
  2473. win.enjoy_tl6 = tools;
  2474. Object.defineProperty(tools, 'fns', {
  2475. /** @描述 对象下的函数名列表 */get: function get() {
  2476. return Object.keys(tools);
  2477. }
  2478. });
  2479. }
  2480. })();
  2481.  
  2482. /******/ })()
  2483. ;