GlobalTools

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

当前为 2023-08-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GlobalTools
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.9
  5. // @description 挂载到window下一级属性集合-常用工具函数
  6. // @author Enjoy_li
  7. // @match *://*/*
  8. // @match 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/1671100286067517749/4867929_enjoy_li_1671100285.png!avatar60
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. /******/ (() => { // webpackBootstrap
  16. /******/ var __webpack_modules__ = ({
  17.  
  18. /***/ 728:
  19. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  20.  
  21. var _typeof = (__webpack_require__(202)["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 exports;
  26. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  27. var exports = {},
  28. Op = Object.prototype,
  29. hasOwn = Op.hasOwnProperty,
  30. defineProperty = Object.defineProperty || function (obj, key, desc) {
  31. obj[key] = desc.value;
  32. },
  33. $Symbol = "function" == typeof Symbol ? Symbol : {},
  34. iteratorSymbol = $Symbol.iterator || "@@iterator",
  35. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  36. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  37. function define(obj, key, value) {
  38. return Object.defineProperty(obj, key, {
  39. value: value,
  40. enumerable: !0,
  41. configurable: !0,
  42. writable: !0
  43. }), obj[key];
  44. }
  45. try {
  46. define({}, "");
  47. } catch (err) {
  48. define = function define(obj, key, value) {
  49. return obj[key] = value;
  50. };
  51. }
  52. function wrap(innerFn, outerFn, self, tryLocsList) {
  53. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  54. generator = Object.create(protoGenerator.prototype),
  55. context = new Context(tryLocsList || []);
  56. return defineProperty(generator, "_invoke", {
  57. value: makeInvokeMethod(innerFn, self, context)
  58. }), generator;
  59. }
  60. function tryCatch(fn, obj, arg) {
  61. try {
  62. return {
  63. type: "normal",
  64. arg: fn.call(obj, arg)
  65. };
  66. } catch (err) {
  67. return {
  68. type: "throw",
  69. arg: err
  70. };
  71. }
  72. }
  73. exports.wrap = wrap;
  74. var ContinueSentinel = {};
  75. function Generator() {}
  76. function GeneratorFunction() {}
  77. function GeneratorFunctionPrototype() {}
  78. var IteratorPrototype = {};
  79. define(IteratorPrototype, iteratorSymbol, function () {
  80. return this;
  81. });
  82. var getProto = Object.getPrototypeOf,
  83. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  84. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  85. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  86. function defineIteratorMethods(prototype) {
  87. ["next", "throw", "return"].forEach(function (method) {
  88. define(prototype, method, function (arg) {
  89. return this._invoke(method, arg);
  90. });
  91. });
  92. }
  93. function AsyncIterator(generator, PromiseImpl) {
  94. function invoke(method, arg, resolve, reject) {
  95. var record = tryCatch(generator[method], generator, arg);
  96. if ("throw" !== record.type) {
  97. var result = record.arg,
  98. value = result.value;
  99. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  100. invoke("next", value, resolve, reject);
  101. }, function (err) {
  102. invoke("throw", err, resolve, reject);
  103. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  104. result.value = unwrapped, resolve(result);
  105. }, function (error) {
  106. return invoke("throw", error, resolve, reject);
  107. });
  108. }
  109. reject(record.arg);
  110. }
  111. var previousPromise;
  112. defineProperty(this, "_invoke", {
  113. value: function value(method, arg) {
  114. function callInvokeWithMethodAndArg() {
  115. return new PromiseImpl(function (resolve, reject) {
  116. invoke(method, arg, resolve, reject);
  117. });
  118. }
  119. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  120. }
  121. });
  122. }
  123. function makeInvokeMethod(innerFn, self, context) {
  124. var state = "suspendedStart";
  125. return function (method, arg) {
  126. if ("executing" === state) throw new Error("Generator is already running");
  127. if ("completed" === state) {
  128. if ("throw" === method) throw arg;
  129. return {
  130. value: void 0,
  131. done: !0
  132. };
  133. }
  134. for (context.method = method, context.arg = arg;;) {
  135. var delegate = context.delegate;
  136. if (delegate) {
  137. var delegateResult = maybeInvokeDelegate(delegate, context);
  138. if (delegateResult) {
  139. if (delegateResult === ContinueSentinel) continue;
  140. return delegateResult;
  141. }
  142. }
  143. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  144. if ("suspendedStart" === state) throw state = "completed", context.arg;
  145. context.dispatchException(context.arg);
  146. } else "return" === context.method && context.abrupt("return", context.arg);
  147. state = "executing";
  148. var record = tryCatch(innerFn, self, context);
  149. if ("normal" === record.type) {
  150. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  151. return {
  152. value: record.arg,
  153. done: context.done
  154. };
  155. }
  156. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  157. }
  158. };
  159. }
  160. function maybeInvokeDelegate(delegate, context) {
  161. var methodName = context.method,
  162. method = delegate.iterator[methodName];
  163. if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
  164. var record = tryCatch(method, delegate.iterator, context.arg);
  165. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  166. var info = record.arg;
  167. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  168. }
  169. function pushTryEntry(locs) {
  170. var entry = {
  171. tryLoc: locs[0]
  172. };
  173. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  174. }
  175. function resetTryEntry(entry) {
  176. var record = entry.completion || {};
  177. record.type = "normal", delete record.arg, entry.completion = record;
  178. }
  179. function Context(tryLocsList) {
  180. this.tryEntries = [{
  181. tryLoc: "root"
  182. }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
  183. }
  184. function values(iterable) {
  185. if (iterable || "" === iterable) {
  186. var iteratorMethod = iterable[iteratorSymbol];
  187. if (iteratorMethod) return iteratorMethod.call(iterable);
  188. if ("function" == typeof iterable.next) return iterable;
  189. if (!isNaN(iterable.length)) {
  190. var i = -1,
  191. next = function next() {
  192. for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  193. return next.value = undefined, next.done = !0, next;
  194. };
  195. return next.next = next;
  196. }
  197. }
  198. throw new TypeError(_typeof(iterable) + " is not iterable");
  199. }
  200. return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
  201. value: GeneratorFunctionPrototype,
  202. configurable: !0
  203. }), defineProperty(GeneratorFunctionPrototype, "constructor", {
  204. value: GeneratorFunction,
  205. configurable: !0
  206. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  207. var ctor = "function" == typeof genFun && genFun.constructor;
  208. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  209. }, exports.mark = function (genFun) {
  210. return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
  211. }, exports.awrap = function (arg) {
  212. return {
  213. __await: arg
  214. };
  215. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  216. return this;
  217. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  218. void 0 === PromiseImpl && (PromiseImpl = Promise);
  219. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  220. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  221. return result.done ? result.value : iter.next();
  222. });
  223. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  224. return this;
  225. }), define(Gp, "toString", function () {
  226. return "[object Generator]";
  227. }), exports.keys = function (val) {
  228. var object = Object(val),
  229. keys = [];
  230. for (var key in object) keys.push(key);
  231. return keys.reverse(), function next() {
  232. for (; keys.length;) {
  233. var key = keys.pop();
  234. if (key in object) return next.value = key, next.done = !1, next;
  235. }
  236. return next.done = !0, next;
  237. };
  238. }, exports.values = values, Context.prototype = {
  239. constructor: Context,
  240. reset: function reset(skipTempReset) {
  241. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
  242. },
  243. stop: function stop() {
  244. this.done = !0;
  245. var rootRecord = this.tryEntries[0].completion;
  246. if ("throw" === rootRecord.type) throw rootRecord.arg;
  247. return this.rval;
  248. },
  249. dispatchException: function dispatchException(exception) {
  250. if (this.done) throw exception;
  251. var context = this;
  252. function handle(loc, caught) {
  253. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  254. }
  255. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  256. var entry = this.tryEntries[i],
  257. record = entry.completion;
  258. if ("root" === entry.tryLoc) return handle("end");
  259. if (entry.tryLoc <= this.prev) {
  260. var hasCatch = hasOwn.call(entry, "catchLoc"),
  261. hasFinally = hasOwn.call(entry, "finallyLoc");
  262. if (hasCatch && hasFinally) {
  263. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  264. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  265. } else if (hasCatch) {
  266. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  267. } else {
  268. if (!hasFinally) throw new Error("try statement without catch or finally");
  269. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  270. }
  271. }
  272. }
  273. },
  274. abrupt: function abrupt(type, arg) {
  275. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  276. var entry = this.tryEntries[i];
  277. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  278. var finallyEntry = entry;
  279. break;
  280. }
  281. }
  282. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  283. var record = finallyEntry ? finallyEntry.completion : {};
  284. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  285. },
  286. complete: function complete(record, afterLoc) {
  287. if ("throw" === record.type) throw record.arg;
  288. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  289. },
  290. finish: function finish(finallyLoc) {
  291. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  292. var entry = this.tryEntries[i];
  293. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  294. }
  295. },
  296. "catch": function _catch(tryLoc) {
  297. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  298. var entry = this.tryEntries[i];
  299. if (entry.tryLoc === tryLoc) {
  300. var record = entry.completion;
  301. if ("throw" === record.type) {
  302. var thrown = record.arg;
  303. resetTryEntry(entry);
  304. }
  305. return thrown;
  306. }
  307. }
  308. throw new Error("illegal catch attempt");
  309. },
  310. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  311. return this.delegate = {
  312. iterator: values(iterable),
  313. resultName: resultName,
  314. nextLoc: nextLoc
  315. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  316. }
  317. }, exports;
  318. }
  319. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
  320.  
  321. /***/ }),
  322.  
  323. /***/ 202:
  324. /***/ ((module) => {
  325.  
  326. function _typeof(obj) {
  327. "@babel/helpers - typeof";
  328.  
  329. return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  330. return typeof obj;
  331. } : function (obj) {
  332. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  333. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
  334. }
  335. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  336.  
  337. /***/ }),
  338.  
  339. /***/ 170:
  340. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  341.  
  342. // TODO(Babel 8): Remove this file.
  343.  
  344. var runtime = __webpack_require__(728)();
  345. module.exports = runtime;
  346.  
  347. // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
  348. try {
  349. regeneratorRuntime = runtime;
  350. } catch (accidentalStrictMode) {
  351. if (typeof globalThis === "object") {
  352. globalThis.regeneratorRuntime = runtime;
  353. } else {
  354. Function("r", "regeneratorRuntime = r")(runtime);
  355. }
  356. }
  357.  
  358.  
  359. /***/ })
  360.  
  361. /******/ });
  362. /************************************************************************/
  363. /******/ // The module cache
  364. /******/ var __webpack_module_cache__ = {};
  365. /******/
  366. /******/ // The require function
  367. /******/ function __webpack_require__(moduleId) {
  368. /******/ // Check if module is in cache
  369. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  370. /******/ if (cachedModule !== undefined) {
  371. /******/ return cachedModule.exports;
  372. /******/ }
  373. /******/ // Create a new module (and put it into the cache)
  374. /******/ var module = __webpack_module_cache__[moduleId] = {
  375. /******/ // no module.id needed
  376. /******/ // no module.loaded needed
  377. /******/ exports: {}
  378. /******/ };
  379. /******/
  380. /******/ // Execute the module function
  381. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  382. /******/
  383. /******/ // Return the exports of the module
  384. /******/ return module.exports;
  385. /******/ }
  386. /******/
  387. /************************************************************************/
  388. /******/ /* webpack/runtime/compat get default export */
  389. /******/ (() => {
  390. /******/ // getDefaultExport function for compatibility with non-harmony modules
  391. /******/ __webpack_require__.n = (module) => {
  392. /******/ var getter = module && module.__esModule ?
  393. /******/ () => (module['default']) :
  394. /******/ () => (module);
  395. /******/ __webpack_require__.d(getter, { a: getter });
  396. /******/ return getter;
  397. /******/ };
  398. /******/ })();
  399. /******/
  400. /******/ /* webpack/runtime/define property getters */
  401. /******/ (() => {
  402. /******/ // define getter functions for harmony exports
  403. /******/ __webpack_require__.d = (exports, definition) => {
  404. /******/ for(var key in definition) {
  405. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  406. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  407. /******/ }
  408. /******/ }
  409. /******/ };
  410. /******/ })();
  411. /******/
  412. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  413. /******/ (() => {
  414. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  415. /******/ })();
  416. /******/
  417. /************************************************************************/
  418. var __webpack_exports__ = {};
  419. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  420. (() => {
  421. "use strict";
  422.  
  423. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
  424. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  425. try {
  426. var info = gen[key](arg);
  427. var value = info.value;
  428. } catch (error) {
  429. reject(error);
  430. return;
  431. }
  432. if (info.done) {
  433. resolve(value);
  434. } else {
  435. Promise.resolve(value).then(_next, _throw);
  436. }
  437. }
  438. function _asyncToGenerator(fn) {
  439. return function () {
  440. var self = this,
  441. args = arguments;
  442. return new Promise(function (resolve, reject) {
  443. var gen = fn.apply(self, args);
  444. function _next(value) {
  445. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  446. }
  447. function _throw(err) {
  448. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  449. }
  450. _next(undefined);
  451. });
  452. };
  453. }
  454. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/typeof.js
  455. function _typeof(obj) {
  456. "@babel/helpers - typeof";
  457.  
  458. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  459. return typeof obj;
  460. } : function (obj) {
  461. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  462. }, _typeof(obj);
  463. }
  464. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/toPrimitive.js
  465.  
  466. function _toPrimitive(input, hint) {
  467. if (_typeof(input) !== "object" || input === null) return input;
  468. var prim = input[Symbol.toPrimitive];
  469. if (prim !== undefined) {
  470. var res = prim.call(input, hint || "default");
  471. if (_typeof(res) !== "object") return res;
  472. throw new TypeError("@@toPrimitive must return a primitive value.");
  473. }
  474. return (hint === "string" ? String : Number)(input);
  475. }
  476. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
  477.  
  478.  
  479. function _toPropertyKey(arg) {
  480. var key = _toPrimitive(arg, "string");
  481. return _typeof(key) === "symbol" ? key : String(key);
  482. }
  483. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/defineProperty.js
  484.  
  485. function _defineProperty(obj, key, value) {
  486. key = _toPropertyKey(key);
  487. if (key in obj) {
  488. Object.defineProperty(obj, key, {
  489. value: value,
  490. enumerable: true,
  491. configurable: true,
  492. writable: true
  493. });
  494. } else {
  495. obj[key] = value;
  496. }
  497. return obj;
  498. }
  499. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
  500. function _arrayWithHoles(arr) {
  501. if (Array.isArray(arr)) return arr;
  502. }
  503. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
  504. function _iterableToArrayLimit(arr, i) {
  505. var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
  506. if (null != _i) {
  507. var _s,
  508. _e,
  509. _x,
  510. _r,
  511. _arr = [],
  512. _n = !0,
  513. _d = !1;
  514. try {
  515. if (_x = (_i = _i.call(arr)).next, 0 === i) {
  516. if (Object(_i) !== _i) return;
  517. _n = !1;
  518. } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
  519. } catch (err) {
  520. _d = !0, _e = err;
  521. } finally {
  522. try {
  523. if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
  524. } finally {
  525. if (_d) throw _e;
  526. }
  527. }
  528. return _arr;
  529. }
  530. }
  531. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
  532. function _arrayLikeToArray(arr, len) {
  533. if (len == null || len > arr.length) len = arr.length;
  534. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  535. return arr2;
  536. }
  537. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
  538.  
  539. function _unsupportedIterableToArray(o, minLen) {
  540. if (!o) return;
  541. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  542. var n = Object.prototype.toString.call(o).slice(8, -1);
  543. if (n === "Object" && o.constructor) n = o.constructor.name;
  544. if (n === "Map" || n === "Set") return Array.from(o);
  545. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  546. }
  547. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
  548. function _nonIterableRest() {
  549. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  550. }
  551. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/slicedToArray.js
  552.  
  553.  
  554.  
  555.  
  556. function _slicedToArray(arr, i) {
  557. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  558. }
  559. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
  560.  
  561. function _arrayWithoutHoles(arr) {
  562. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  563. }
  564. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/iterableToArray.js
  565. function _iterableToArray(iter) {
  566. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  567. }
  568. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
  569. function _nonIterableSpread() {
  570. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  571. }
  572. ;// CONCATENATED MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
  573.  
  574.  
  575.  
  576.  
  577. function _toConsumableArray(arr) {
  578. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  579. }
  580. // EXTERNAL MODULE: ./node_modules/.pnpm/registry.npmjs.org+@babel+runtime@7.22.10/node_modules/@babel/runtime/regenerator/index.js
  581. var regenerator = __webpack_require__(170);
  582. var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);
  583. ;// CONCATENATED MODULE: ./src/GlobalTools.js
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = GlobalTools_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  591. function GlobalTools_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return GlobalTools_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return GlobalTools_arrayLikeToArray(o, minLen); }
  592. function GlobalTools_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
  593. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  594. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  595.  
  596. run(window);
  597. function run(win) {
  598. getLogObjectValue(['$0', 'temp1']);
  599. windowProxy();
  600. var tools = {
  601. backPrototype: backPrototype,
  602. createPlainFile: createPlainFile,
  603. getRegMobile: getRegMobile,
  604. phoneFormat: phoneFormat,
  605. getRegName: getRegName,
  606. getRegEmail: getRegEmail,
  607. getRegIDCard: getRegIDCard,
  608. getQuery: getQuery,
  609. toSearch: toSearch,
  610. transformThousandth: transformThousandth,
  611. deleteProperty: deleteProperty,
  612. asyncRequire: asyncRequire,
  613. transformData: transformData,
  614. previewFile: previewFile,
  615. dateUtil: dateUtil,
  616. toWithOpener: toWithOpener,
  617. downloadFile: downloadFile,
  618. base64ToBlob: base64ToBlob,
  619. base64ImgtoFile: base64ImgtoFile,
  620. isHasBtnPower: isHasBtnPower,
  621. getBrowerEnv: getBrowerEnv,
  622. formatReportDataToStr: formatReportDataToStr,
  623. copyStrToClipboard: copyStrToClipboard,
  624. getPropertiesOfObj: getPropertiesOfObj,
  625. lgd: lgd,
  626. lgd0: lgd0,
  627. lgdt1: lgdt1,
  628. getPrototypeChainOfObject: getPrototypeChainOfObject,
  629. getLogObjectValue: getLogObjectValue
  630. };
  631. function getPrototypeChainOfObject(Obj) {
  632. /** @描述 对象原型链 */
  633.  
  634. var idx = 0;
  635. var str = "".concat(Obj.name || '参数', "\u7684\u539F\u578B\u94FE\u662F\uFF1A ");
  636. next(Obj);
  637. return str;
  638.  
  639. /** @描述 递归 */
  640. function next(obj) {
  641. var _ObjType$match;
  642. var ObjType = Object.toLocaleString.call(obj);
  643. var ObjFlag = ((_ObjType$match = ObjType.match(/^\[object ([a-zA-Z]+)\]/)) === null || _ObjType$match === void 0 ? void 0 : _ObjType$match[1]) || _typeof(ObjType);
  644. str += "\u7B2C ".concat(idx, " \u7EA7\u3010").concat(ObjFlag, "\u3011.__proto__ \u25B6\uFE0F ");
  645. idx++;
  646. if (obj.__proto__) {
  647. next(obj.__proto__);
  648. } else {
  649. str += "\u7B2C ".concat(idx, " \u7EA7\u3010null\u3011");
  650. }
  651. }
  652. }
  653. function lgdt1() {
  654. var _console;
  655. for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
  656. rest[_key] = arguments[_key];
  657. }
  658. /** @描述 以对象形式打印 $0 */
  659. (_console = console).log.apply(_console, ["temp1 ==%O", temp1].concat(rest));
  660. }
  661. function lgd() {
  662. var _console3;
  663. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  664. args[_key2] = arguments[_key2];
  665. }
  666. /** @描述 以对象形式打印 temp1 */
  667.  
  668. var desc = args[0],
  669. rest = args.slice(1);
  670. if (rest.length && typeof desc === 'string') {
  671. var _console2;
  672. return (_console2 = console).log.apply(_console2, ["".concat(desc, " %O")].concat(_toConsumableArray(rest)));
  673. }
  674. (_console3 = console).log.apply(_console3, ["%O"].concat(args));
  675. }
  676. function lgd0() {
  677. var _console4;
  678. for (var _len3 = arguments.length, rest = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  679. rest[_key3] = arguments[_key3];
  680. }
  681. /** @描述 以对象形式打印 $0 */
  682. (_console4 = console).log.apply(_console4, ["$0 ==%O", $0].concat(rest));
  683. }
  684. function backPrototype(resourceObj) {
  685. /**
  686. * @description 对象原型链:继承谁的属性和方法
  687. * @param {*} resourceObj
  688. * @returns {*} string
  689. */
  690.  
  691. var str = '';
  692. next(resourceObj);
  693. str = str + 'null';
  694. console.log("%c \u8BE5\u5BF9\u8C61\u539F\u578B\u94FE\u662F\uFF1A", 'color:red', str);
  695. return str;
  696. function next(obj) {
  697. var _ObjType$match2;
  698. var ObjType = Object.toLocaleString.call(obj);
  699. var ObjFlag = ((_ObjType$match2 = ObjType.match(/^\[object ([a-zA-Z]+)\]/)) === null || _ObjType$match2 === void 0 ? void 0 : _ObjType$match2[1]) || '无';
  700. str = str + ObjFlag + ' + .__proto__ >> ';
  701. if (obj.__proto__) {
  702. next(obj.__proto__);
  703. }
  704. }
  705. }
  706. function createPlainFile() {
  707. var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  708. a: 'a'
  709. };
  710. var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'name';
  711. /**
  712. * @description 创建文本文件
  713. * @param {string} [content={ a: 'a' }]
  714. * @param {string} [name='name']
  715. */
  716.  
  717. // 下载保存json文件
  718. var eleLink = document.createElement("a");
  719. eleLink.download = name + '.json';
  720. // 字符内容转变成blob地址
  721. var data = JSON.stringify(content, undefined, 4);
  722. var blob = new Blob([data], {
  723. type: "text/json"
  724. });
  725. eleLink.href = URL.createObjectURL(blob);
  726. // 触发点击
  727. eleLink.click();
  728. // 然后移除
  729. }
  730.  
  731. function getRegMobile() {
  732. /** @描述 正则 - 手机号 */
  733. return /^1[2|3|4|5|6|7|8|9][\d]{9}$/;
  734. }
  735. function phoneFormat() {
  736. var phone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  737. /** @描述 格式化 - 手机号 */
  738. if (!phone || !/^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(phone)) return;
  739. phone = phone.replace(/\D/g, '').slice(0, 11);
  740. phone = phone.replace(/^(\d{3})/, '$1 ').replace(/(\d{4})/, '$1 ').replace(/[\s]+$/, '');
  741. return phone;
  742. }
  743. function getRegName() {
  744. /** @描述 正则 - 姓名 */
  745.  
  746. return /^[0-9|A-Za-z|\u4e00-\u9fa5|\s]+$/;
  747. }
  748. function getRegEmail() {
  749. /** @描述 正则 - 邮箱 */
  750.  
  751. return /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i;
  752. }
  753. function getRegIDCard() {
  754. /** @描述 正则 - 大陆身份证号码 */
  755. 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)$/;
  756. }
  757. function getQuery() {
  758. var search = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.search;
  759. /** @描述 获取 url 参数 */
  760.  
  761. var query = {};
  762. search.substr(1).split('&').forEach(function (str) {
  763. var strArr = str.split('=');
  764. var key = strArr[0];
  765. if (!key) return;
  766. var val = decodeURIComponent(strArr[1]);
  767. try {
  768. val = JSON.parse(val);
  769. } catch (err) {}
  770. query[key] = val;
  771. });
  772. return query;
  773. }
  774. function toSearch() {
  775. var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  776. /** @描述 转换成 url search */
  777. var arr = Object.keys(obj).map(function (key) {
  778. var val = obj[key];
  779. if (typeof val !== 'string') {
  780. try {
  781. val = JSON.stringify(val);
  782. } catch (err) {
  783. console.error(err);
  784. }
  785. }
  786. return "".concat(key, "=").concat(encodeURIComponent(val));
  787. });
  788. return '?' + arr.join('&');
  789. }
  790. function transformThousandth(value, fixed) {
  791. /**
  792. * 格式化金额 千分符
  793. * @param value
  794. * @param fixed
  795. */
  796.  
  797. var needFixed = fixed != null;
  798. var num = Number(value);
  799. if (isNaN(num)) {
  800. return needFixed ? 0 .toFixed(fixed) : '0';
  801. }
  802. // return (needFixed ? num.toFixed(fixed) : num.toString()).replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,')
  803. var str = needFixed ? num.toFixed(fixed) : num.toString();
  804. var arr = str.split('.');
  805. var result = arr[0] ? arr[0].replace(/(?=(?!\b)(\d{3})+$)/g, ',') : '0';
  806. if (arr[1] != null) {
  807. result += ".".concat(arr[1]);
  808. }
  809. return result;
  810. }
  811. function deleteProperty() {
  812. var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  813. var v = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [undefined, null, ''];
  814. /**
  815. * 删除指定值的属性
  816. * @param obj
  817. */
  818.  
  819. var res = {};
  820. var isArray = Array.isArray(v);
  821. for (var key in obj) {
  822. if (isArray) {
  823. if (!v.includes(obj[key])) res[key] = obj[key];
  824. } else {
  825. if (obj[key] !== v) res[key] = obj[key];
  826. }
  827. }
  828. return res;
  829. }
  830. function asyncRequire(url, name, type) {
  831. /**
  832. * 通过插入标签以加载 js/css 文件
  833. * @param {String} url 需要载入的 js/css url
  834. * @param {String} name 文件载入后挂载到 window 下的变量名
  835. * @param {String} type 文件类型 默认取后缀名
  836. */
  837.  
  838. return new Promise(function (resolve, reject) {
  839. var head = document.head || document.getElementsByTagName('head')[0] || document.body;
  840. var filePath = url.split('?')[0];
  841. var ext = filePath.substring(filePath.lastIndexOf('.') + 1);
  842. if (document.getElementById("async-require-".concat(name || 'unknown'))) {
  843. return resolve(name ? window[name] : 'loaded');
  844. }
  845. var element;
  846. if (ext == 'js' || type == 'js') {
  847. element = document.createElement('script');
  848. element.src = url;
  849. element.onload = function (e) {
  850. return resolve(name ? window[name] : e);
  851. };
  852. } else if (ext == 'css' || type == 'css') {
  853. element = document.createElement('link');
  854. element.rel = 'stylesheet';
  855. element.type = 'text/css';
  856. element.href = url;
  857. element.onload = resolve;
  858. } else {
  859. return console.warn('好像有点不对劲...请指定文件类型: js | css');
  860. }
  861. element.id = "async-require-".concat(name);
  862. element.onerror = reject;
  863. head.appendChild(element);
  864. });
  865. }
  866. function transformData(sourceData, relation) {
  867. /**
  868. * 返回数据
  869. * @param {Array} sourceData 原数组
  870. * @param {Array} 映射字段
  871. */
  872.  
  873. return sourceData.map(function (item) {
  874. var _relation = _slicedToArray(relation, 2),
  875. key = _relation[0],
  876. name = _relation[1];
  877. return {
  878. label: item[name],
  879. value: item[key]
  880. };
  881. });
  882. }
  883. function previewFile(fileUrl) {
  884. /**
  885. * 在线预览文件
  886. * @param {String} fileUrl 静态资源地址
  887. */
  888.  
  889. var link = document.createElement('a');
  890. link.href = fileUrl;
  891. var ext = (link.pathname.split('.')[1] || '').toLowerCase();
  892. var allowedExt = {
  893. bmp: 1,
  894. gif: 1,
  895. jpg: 1,
  896. jpeg: 1,
  897. png: 1,
  898. apng: 1,
  899. webp: 1,
  900. htm: 1,
  901. html: 1,
  902. pdf: 1
  903. };
  904. if (ext && allowedExt[ext]) {
  905. var _window;
  906. var url = "https://static.hrwork.com/tools/pdfviewer/index.html?file=".concat(encodeURIComponent(fileUrl));
  907. if ((_window = window) !== null && _window !== void 0 && _window.__ZPA_CRX) {
  908. return void dispatchEvent(new CustomEvent('$create_tab', {
  909. detail: url
  910. }));
  911. }
  912. window.open(url);
  913. } else {
  914. alert("\u4E0D\u652F\u6301\u5728\u7EBF\u9884\u89C8\u6B64\u7C7B\u578B(".concat(ext !== null && ext !== void 0 ? ext : '', ")\u6587\u4EF6"));
  915. }
  916. }
  917. function dateUtil() {
  918. var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
  919. /**
  920. * 获取特定格式日期
  921. * date: 可以为日期字符串、日期对象,不传参数默认当前系统时间
  922. * format: 输出日期时间格式, 不传参数默认 YYYY-MM-DD HH:mm:ss 格式
  923. * 例:
  924. * dateUtil().format()
  925. * // 2022-06-16 11:56:02
  926. *
  927. * // 不传入日期,默认以当前日期,格式化为特定格式日期
  928. * dateUtil().format('YYYY年MM月DD日 (周W) HH时mm分ss秒')
  929. * // 2022年06月16日 (周四) 12时01分51秒
  930. *
  931. * // 传入指定日期(string | date),格式化为指定格式日期(string)
  932. * dateUtil('2015.7.12').format('YYYY年MM月DD日 HH时mm秒ss分 星期W')
  933. * // 2015年07月12日 00时00分00秒 星期三
  934. */
  935.  
  936. time = typeof time === 'string' ? time.replace(/-/g, '/') : time;
  937. var date = isNaN(new Date(time)) ? time : new Date(time);
  938. return {
  939. date: date,
  940. format: format
  941. };
  942. function format() {
  943. var rule = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
  944. var weeks = ['日', '一', '二', '三', '四', '五', '六'];
  945. var padStart = function padStart(d) {
  946. return (d + '').padStart(2, '0');
  947. };
  948. var M = date.getMonth() + 1 + '';
  949. var D = date.getDate() + '';
  950. var H = date.getHours() + '';
  951. var m = date.getMinutes() + '';
  952. var s = date.getSeconds() + '';
  953. 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());
  954. }
  955. }
  956. function toWithOpener(href) {
  957. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  958. /**
  959. * 共享opener跳转
  960. * @param { Object } router 如:
  961. * @param { Object } options 如:
  962. */
  963.  
  964. var _options$target = options.target,
  965. target = _options$target === void 0 ? '_blank' : _options$target,
  966. routes = options.routes;
  967. var win = window.open(href, target);
  968. // 设置新打开页面的面包屑
  969. if (routes && Array.isArray(routes)) {
  970. var cloneRoutes = _toConsumableArray(routes);
  971. cloneRoutes.shift();
  972. cloneRoutes[cloneRoutes.length - 1] = _objectSpread(_objectSpread({}, cloneRoutes[cloneRoutes.length - 1]), {}, {
  973. a: true,
  974. path: '/zhaopintong/' + location.hash
  975. });
  976. win.sessionStorage.parent_routes = JSON.stringify(cloneRoutes);
  977. }
  978. return win;
  979. }
  980. function downloadFile(href) {
  981. var fileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  982. /**
  983. * 通过url一键下载图片
  984. * @param { String } href 如:
  985. * @param { String } fileName 如:
  986. */
  987.  
  988. if (!href) {
  989. return;
  990. }
  991. var aLink = document.createElement('a');
  992. aLink.download = fileName + Date.now();
  993. aLink.href = href;
  994. aLink.click();
  995. }
  996. function base64ToBlob(base64Code) {
  997. /**
  998. * base64转Blob对象
  999. * @param { String } code 如:
  1000. */
  1001.  
  1002. var parts = base64Code.split(';base64,');
  1003. var contentType = parts[0].split(':')[1];
  1004. var raw = window.atob(parts[1]);
  1005. var rawLength = raw.length;
  1006. var uint8Array = new Uint8Array(rawLength);
  1007. for (var i = 0; i < rawLength; i++) {
  1008. uint8Array[i] = raw.charCodeAt(i);
  1009. }
  1010. return new Blob([uint8Array], {
  1011. type: contentType
  1012. });
  1013. }
  1014. function base64ImgtoFile(base64Code) {
  1015. var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'file';
  1016. /**
  1017. * base64转文件对象
  1018. * @param { String } base64Code 如:
  1019. * @param { String } filename 如:
  1020. */
  1021.  
  1022. var arr = base64Code.split(',');
  1023. var mime = arr[0].match(/:(.*?);/)[1];
  1024. var suffix = mime.split('/')[1];
  1025. var bstr = atob(arr[1]);
  1026. var n = bstr.length;
  1027. var u8arr = new Uint8Array(n);
  1028. while (n--) {
  1029. u8arr[n] = bstr.charCodeAt(n);
  1030. }
  1031. return new File([u8arr], "".concat(filename, ".").concat(suffix), {
  1032. type: mime
  1033. });
  1034. }
  1035. function isHasBtnPower() {
  1036. var powerList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  1037. var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  1038. /**
  1039. * @description 判断角色是否有页面级按钮的权限
  1040. * @param {*} [powerList=[]]
  1041. * @param {string} [code='']
  1042. * @returns {*} {boolean}
  1043. */
  1044.  
  1045. if (!code) return false;
  1046. if (typeof code === 'string') code = [code];
  1047. var _iterator = _createForOfIteratorHelper(code),
  1048. _step;
  1049. try {
  1050. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1051. var _powerList$includes;
  1052. var value = _step.value;
  1053. if (powerList !== null && powerList !== void 0 && (_powerList$includes = powerList.includes) !== null && _powerList$includes !== void 0 && _powerList$includes.call(powerList, value)) return true;
  1054. }
  1055. } catch (err) {
  1056. _iterator.e(err);
  1057. } finally {
  1058. _iterator.f();
  1059. }
  1060. return false;
  1061. }
  1062. function getBrowerEnv() {
  1063. /** @描述 判断当前浏览器运行环境 */
  1064.  
  1065. var userAgent = window.navigator.userAgent.toLowerCase();
  1066. var agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
  1067. // 是否为支付宝环境
  1068. var isAliPay = /alipayclient/.test(userAgent);
  1069. // 是否为淘宝环境
  1070. var isTaoBao = /windvane/.test(userAgent);
  1071. // 是否为企业微信环境
  1072. var isWxWork = /wxwork/.test(userAgent);
  1073. // 是否为微信环境
  1074. var isWeChat = /micromessenger/.test(userAgent) && !isWxWork;
  1075. // 是否为移动端
  1076. var isPhone = agents.some(function (x) {
  1077. return new RegExp(x.toLocaleLowerCase()).test(userAgent);
  1078. });
  1079. return {
  1080. isAliPay: isAliPay,
  1081. isTaoBao: isTaoBao,
  1082. isWxWork: isWxWork,
  1083. isWeChat: isWeChat,
  1084. isPhone: isPhone
  1085. };
  1086. }
  1087.  
  1088. //
  1089. function formatReportDataToStr() {
  1090. var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  1091. var headerLabel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  1092. /** @描述 格式化报表数据拼接成字符串,以便复制到剪贴板 */
  1093.  
  1094. return arr.reduce(function (pre, cur) {
  1095. return pre + headerLabel.reduceRight(function (pre2, cur2) {
  1096. return "".concat(cur[cur2.key], "\t").concat(pre2);
  1097. }, '\n');
  1098. }, headerLabel.reduceRight(function (pre, cur) {
  1099. return "".concat(cur.title, "\t").concat(pre);
  1100. }, '\n'));
  1101. }
  1102. function copyStrToClipboard(value) {
  1103. /** @描述 把字符串复制到剪贴板 */
  1104.  
  1105. var textarea = document.createElement('textarea');
  1106. textarea.value = value;
  1107. document.body.appendChild(textarea);
  1108. textarea.select();
  1109. document.execCommand('Copy');
  1110. document.body.removeChild(textarea);
  1111. }
  1112. function copyStrToClipboardOfNavigator(_x) {
  1113. return _copyStrToClipboardOfNavigator.apply(this, arguments);
  1114. }
  1115. function _copyStrToClipboardOfNavigator() {
  1116. _copyStrToClipboardOfNavigator = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee(value) {
  1117. return regenerator_default().wrap(function _callee$(_context) {
  1118. while (1) switch (_context.prev = _context.next) {
  1119. case 0:
  1120. _context.next = 2;
  1121. return navigator.clipboard.writeText(value);
  1122. case 2:
  1123. return _context.abrupt("return", _context.sent);
  1124. case 3:
  1125. case "end":
  1126. return _context.stop();
  1127. }
  1128. }, _callee);
  1129. }));
  1130. return _copyStrToClipboardOfNavigator.apply(this, arguments);
  1131. }
  1132. function getPropertiesOfObj(_ref) {
  1133. var _ref$obj = _ref.obj,
  1134. obj = _ref$obj === void 0 ? {} : _ref$obj,
  1135. _ref$keys = _ref.keys,
  1136. keys = _ref$keys === void 0 ? [] : _ref$keys;
  1137. /**
  1138. * @描述 获取对象的指定属性集合
  1139. * @param {*} { obj = {}, keys = [] }
  1140. * @returns {*}
  1141. */
  1142.  
  1143. var newObj = {};
  1144. keys.forEach(function (key) {
  1145. newObj[key] = obj[key];
  1146. });
  1147. return newObj;
  1148. }
  1149.  
  1150. /** @描述 定义以对象形式 获取window属性值 */
  1151. function getLogObjectValue(arr) {
  1152. var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  1153. var suffix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '_o';
  1154. var win2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : win;
  1155. /** @描述 定义以对象形式 获取window属性值 */
  1156. arr.forEach(function (newKey) {
  1157. Object.defineProperty(win2, "".concat(prefix).concat(newKey).concat(suffix), {
  1158. get: function get() {
  1159. return console.log('%O', win2[newKey]);
  1160. }
  1161. });
  1162. });
  1163. }
  1164.  
  1165. /** @描述 代理window,读取属性时,即打印对象 */
  1166. function windowProxy() {
  1167. var win2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : win;
  1168. /** @描述 代理window,读取属性时,即打印对象 */
  1169. var result;
  1170. win2.enjoy_wp = new Proxy(win2, {
  1171. get: function get(obj, prop) {
  1172. result = obj[prop];
  1173. console.log("\uD83C\uDF8F ".concat(prop, "=%O"), result);
  1174. return result;
  1175. }
  1176. });
  1177. }
  1178. if (win.enjoy_tl) {
  1179. console.error('win.enjoy_tl已经存在,请使用win.enjoy_tls');
  1180. if (!win.enjoy_tls) win.enjoy_tls = tools;
  1181. return;
  1182. }
  1183. win.enjoy_tl = tools;
  1184. Object.defineProperty(tools, 'fns', {
  1185. /** @描述 对象下的函数名列表 */get: function get() {
  1186. return Object.keys(tools);
  1187. }
  1188. });
  1189. }
  1190. })();
  1191.  
  1192. /******/ })()
  1193. ;