Greasy Fork镜像 支持简体中文。

Element UI文档辅助

在Element UI文档中增加示例目录导航,同时支持v2与v3(element-plus)版本,类似于Ant右侧悬浮的导航

  1. // ==UserScript==
  2. // @name Element UI文档辅助
  3. // @version 1.0.4
  4. // @description 在Element UI文档中增加示例目录导航,同时支持v2与v3(element-plus)版本,类似于Ant右侧悬浮的导航
  5. // @author sakura-flutter
  6. // @namespace https://github.com/sakura-flutter/tampermonkey-scripts
  7. // @license GPL-3.0
  8. // @compatible chrome Latest
  9. // @compatible firefox Latest
  10. // @compatible edge Latest
  11. // @match https://element-plus.gitee.io/*
  12. // @match https://element-plus.org/*
  13. // @match https://element.eleme.cn/*
  14. // @match https://element.eleme.io/*
  15. // @require https://unpkg.com/vue@3/dist/vue.runtime.global.prod.min.js
  16. // ==/UserScript==
  17.  
  18. /******/ (() => { // webpackBootstrap
  19. /******/ "use strict";
  20. /******/ var __webpack_modules__ = ({
  21.  
  22. /***/ 4451:
  23. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  24.  
  25. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  26. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  27. /* harmony export */ });
  28. /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8081);
  29. /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  30. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  31. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  32. // Imports
  33.  
  34.  
  35. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  36. // Module
  37. ___CSS_LOADER_EXPORT___.push([module.id, "#catalogue-js{contain:content;position:fixed;right:20px;top:100px;z-index:1000}@media(min-width: 1500px){#catalogue-js{left:calc(50% + 1140px / 2 + 40px);right:auto}}#catalogue-js ul{border-left:1px solid #f0f0f0;font-size:12px;list-style:none;margin:0;padding-left:0}#catalogue-js li{border-left:1px solid rgba(0,0,0,0);color:rgba(0,0,0,.85);cursor:pointer;line-height:1.5;list-style:none;margin-left:-1px;overflow:hidden;padding:2px 0 2px 16px;text-overflow:ellipsis;transition:all .3s ease;white-space:nowrap;width:110px}#catalogue-js li:hover{border-left-color:#1890ff;color:#1890ff}", ""]);
  38. // Exports
  39. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  40.  
  41.  
  42. /***/ }),
  43.  
  44. /***/ 3645:
  45. /***/ ((module) => {
  46.  
  47.  
  48.  
  49. /*
  50. MIT License http://www.opensource.org/licenses/mit-license.php
  51. Author Tobias Koppers @sokra
  52. */
  53. module.exports = function (cssWithMappingToString) {
  54. var list = []; // return the list of modules as css string
  55.  
  56. list.toString = function toString() {
  57. return this.map(function (item) {
  58. var content = "";
  59. var needLayer = typeof item[5] !== "undefined";
  60.  
  61. if (item[4]) {
  62. content += "@supports (".concat(item[4], ") {");
  63. }
  64.  
  65. if (item[2]) {
  66. content += "@media ".concat(item[2], " {");
  67. }
  68.  
  69. if (needLayer) {
  70. content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
  71. }
  72.  
  73. content += cssWithMappingToString(item);
  74.  
  75. if (needLayer) {
  76. content += "}";
  77. }
  78.  
  79. if (item[2]) {
  80. content += "}";
  81. }
  82.  
  83. if (item[4]) {
  84. content += "}";
  85. }
  86.  
  87. return content;
  88. }).join("");
  89. }; // import a list of modules into the list
  90.  
  91.  
  92. list.i = function i(modules, media, dedupe, supports, layer) {
  93. if (typeof modules === "string") {
  94. modules = [[null, modules, undefined]];
  95. }
  96.  
  97. var alreadyImportedModules = {};
  98.  
  99. if (dedupe) {
  100. for (var k = 0; k < this.length; k++) {
  101. var id = this[k][0];
  102.  
  103. if (id != null) {
  104. alreadyImportedModules[id] = true;
  105. }
  106. }
  107. }
  108.  
  109. for (var _k = 0; _k < modules.length; _k++) {
  110. var item = [].concat(modules[_k]);
  111.  
  112. if (dedupe && alreadyImportedModules[item[0]]) {
  113. continue;
  114. }
  115.  
  116. if (typeof layer !== "undefined") {
  117. if (typeof item[5] === "undefined") {
  118. item[5] = layer;
  119. } else {
  120. item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
  121. item[5] = layer;
  122. }
  123. }
  124.  
  125. if (media) {
  126. if (!item[2]) {
  127. item[2] = media;
  128. } else {
  129. item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
  130. item[2] = media;
  131. }
  132. }
  133.  
  134. if (supports) {
  135. if (!item[4]) {
  136. item[4] = "".concat(supports);
  137. } else {
  138. item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
  139. item[4] = supports;
  140. }
  141. }
  142.  
  143. list.push(item);
  144. }
  145. };
  146.  
  147. return list;
  148. };
  149.  
  150. /***/ }),
  151.  
  152. /***/ 8081:
  153. /***/ ((module) => {
  154.  
  155.  
  156.  
  157. module.exports = function (i) {
  158. return i[1];
  159. };
  160.  
  161. /***/ }),
  162.  
  163. /***/ 3379:
  164. /***/ ((module) => {
  165.  
  166.  
  167.  
  168. var stylesInDOM = [];
  169.  
  170. function getIndexByIdentifier(identifier) {
  171. var result = -1;
  172.  
  173. for (var i = 0; i < stylesInDOM.length; i++) {
  174. if (stylesInDOM[i].identifier === identifier) {
  175. result = i;
  176. break;
  177. }
  178. }
  179.  
  180. return result;
  181. }
  182.  
  183. function modulesToDom(list, options) {
  184. var idCountMap = {};
  185. var identifiers = [];
  186.  
  187. for (var i = 0; i < list.length; i++) {
  188. var item = list[i];
  189. var id = options.base ? item[0] + options.base : item[0];
  190. var count = idCountMap[id] || 0;
  191. var identifier = "".concat(id, " ").concat(count);
  192. idCountMap[id] = count + 1;
  193. var indexByIdentifier = getIndexByIdentifier(identifier);
  194. var obj = {
  195. css: item[1],
  196. media: item[2],
  197. sourceMap: item[3],
  198. supports: item[4],
  199. layer: item[5]
  200. };
  201.  
  202. if (indexByIdentifier !== -1) {
  203. stylesInDOM[indexByIdentifier].references++;
  204. stylesInDOM[indexByIdentifier].updater(obj);
  205. } else {
  206. var updater = addElementStyle(obj, options);
  207. options.byIndex = i;
  208. stylesInDOM.splice(i, 0, {
  209. identifier: identifier,
  210. updater: updater,
  211. references: 1
  212. });
  213. }
  214.  
  215. identifiers.push(identifier);
  216. }
  217.  
  218. return identifiers;
  219. }
  220.  
  221. function addElementStyle(obj, options) {
  222. var api = options.domAPI(options);
  223. api.update(obj);
  224.  
  225. var updater = function updater(newObj) {
  226. if (newObj) {
  227. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
  228. return;
  229. }
  230.  
  231. api.update(obj = newObj);
  232. } else {
  233. api.remove();
  234. }
  235. };
  236.  
  237. return updater;
  238. }
  239.  
  240. module.exports = function (list, options) {
  241. options = options || {};
  242. list = list || [];
  243. var lastIdentifiers = modulesToDom(list, options);
  244. return function update(newList) {
  245. newList = newList || [];
  246.  
  247. for (var i = 0; i < lastIdentifiers.length; i++) {
  248. var identifier = lastIdentifiers[i];
  249. var index = getIndexByIdentifier(identifier);
  250. stylesInDOM[index].references--;
  251. }
  252.  
  253. var newLastIdentifiers = modulesToDom(newList, options);
  254.  
  255. for (var _i = 0; _i < lastIdentifiers.length; _i++) {
  256. var _identifier = lastIdentifiers[_i];
  257.  
  258. var _index = getIndexByIdentifier(_identifier);
  259.  
  260. if (stylesInDOM[_index].references === 0) {
  261. stylesInDOM[_index].updater();
  262.  
  263. stylesInDOM.splice(_index, 1);
  264. }
  265. }
  266.  
  267. lastIdentifiers = newLastIdentifiers;
  268. };
  269. };
  270.  
  271. /***/ }),
  272.  
  273. /***/ 569:
  274. /***/ ((module) => {
  275.  
  276.  
  277.  
  278. var memo = {};
  279. /* istanbul ignore next */
  280.  
  281. function getTarget(target) {
  282. if (typeof memo[target] === "undefined") {
  283. var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
  284.  
  285. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  286. try {
  287. // This will throw an exception if access to iframe is blocked
  288. // due to cross-origin restrictions
  289. styleTarget = styleTarget.contentDocument.head;
  290. } catch (e) {
  291. // istanbul ignore next
  292. styleTarget = null;
  293. }
  294. }
  295.  
  296. memo[target] = styleTarget;
  297. }
  298.  
  299. return memo[target];
  300. }
  301. /* istanbul ignore next */
  302.  
  303.  
  304. function insertBySelector(insert, style) {
  305. var target = getTarget(insert);
  306.  
  307. if (!target) {
  308. throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
  309. }
  310.  
  311. target.appendChild(style);
  312. }
  313.  
  314. module.exports = insertBySelector;
  315.  
  316. /***/ }),
  317.  
  318. /***/ 9216:
  319. /***/ ((module) => {
  320.  
  321.  
  322.  
  323. /* istanbul ignore next */
  324. function insertStyleElement(options) {
  325. var element = document.createElement("style");
  326. options.setAttributes(element, options.attributes);
  327. options.insert(element, options.options);
  328. return element;
  329. }
  330.  
  331. module.exports = insertStyleElement;
  332.  
  333. /***/ }),
  334.  
  335. /***/ 3565:
  336. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  337.  
  338.  
  339.  
  340. /* istanbul ignore next */
  341. function setAttributesWithoutAttributes(styleElement) {
  342. var nonce = true ? __webpack_require__.nc : 0;
  343.  
  344. if (nonce) {
  345. styleElement.setAttribute("nonce", nonce);
  346. }
  347. }
  348.  
  349. module.exports = setAttributesWithoutAttributes;
  350.  
  351. /***/ }),
  352.  
  353. /***/ 7795:
  354. /***/ ((module) => {
  355.  
  356.  
  357.  
  358. /* istanbul ignore next */
  359. function apply(styleElement, options, obj) {
  360. var css = "";
  361.  
  362. if (obj.supports) {
  363. css += "@supports (".concat(obj.supports, ") {");
  364. }
  365.  
  366. if (obj.media) {
  367. css += "@media ".concat(obj.media, " {");
  368. }
  369.  
  370. var needLayer = typeof obj.layer !== "undefined";
  371.  
  372. if (needLayer) {
  373. css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
  374. }
  375.  
  376. css += obj.css;
  377.  
  378. if (needLayer) {
  379. css += "}";
  380. }
  381.  
  382. if (obj.media) {
  383. css += "}";
  384. }
  385.  
  386. if (obj.supports) {
  387. css += "}";
  388. }
  389.  
  390. var sourceMap = obj.sourceMap;
  391.  
  392. if (sourceMap && typeof btoa !== "undefined") {
  393. css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
  394. } // For old IE
  395.  
  396. /* istanbul ignore if */
  397.  
  398.  
  399. options.styleTagTransform(css, styleElement, options.options);
  400. }
  401.  
  402. function removeStyleElement(styleElement) {
  403. // istanbul ignore if
  404. if (styleElement.parentNode === null) {
  405. return false;
  406. }
  407.  
  408. styleElement.parentNode.removeChild(styleElement);
  409. }
  410. /* istanbul ignore next */
  411.  
  412.  
  413. function domAPI(options) {
  414. var styleElement = options.insertStyleElement(options);
  415. return {
  416. update: function update(obj) {
  417. apply(styleElement, options, obj);
  418. },
  419. remove: function remove() {
  420. removeStyleElement(styleElement);
  421. }
  422. };
  423. }
  424.  
  425. module.exports = domAPI;
  426.  
  427. /***/ }),
  428.  
  429. /***/ 4589:
  430. /***/ ((module) => {
  431.  
  432.  
  433.  
  434. /* istanbul ignore next */
  435. function styleTagTransform(css, styleElement) {
  436. if (styleElement.styleSheet) {
  437. styleElement.styleSheet.cssText = css;
  438. } else {
  439. while (styleElement.firstChild) {
  440. styleElement.removeChild(styleElement.firstChild);
  441. }
  442.  
  443. styleElement.appendChild(document.createTextNode(css));
  444. }
  445. }
  446.  
  447. module.exports = styleTagTransform;
  448.  
  449. /***/ })
  450.  
  451. /******/ });
  452. /************************************************************************/
  453. /******/ // The module cache
  454. /******/ var __webpack_module_cache__ = {};
  455. /******/
  456. /******/ // The require function
  457. /******/ function __webpack_require__(moduleId) {
  458. /******/ // Check if module is in cache
  459. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  460. /******/ if (cachedModule !== undefined) {
  461. /******/ return cachedModule.exports;
  462. /******/ }
  463. /******/ // Create a new module (and put it into the cache)
  464. /******/ var module = __webpack_module_cache__[moduleId] = {
  465. /******/ id: moduleId,
  466. /******/ // no module.loaded needed
  467. /******/ exports: {}
  468. /******/ };
  469. /******/
  470. /******/ // Execute the module function
  471. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  472. /******/
  473. /******/ // Return the exports of the module
  474. /******/ return module.exports;
  475. /******/ }
  476. /******/
  477. /************************************************************************/
  478. /******/ /* webpack/runtime/compat get default export */
  479. /******/ (() => {
  480. /******/ // getDefaultExport function for compatibility with non-harmony modules
  481. /******/ __webpack_require__.n = (module) => {
  482. /******/ var getter = module && module.__esModule ?
  483. /******/ () => (module['default']) :
  484. /******/ () => (module);
  485. /******/ __webpack_require__.d(getter, { a: getter });
  486. /******/ return getter;
  487. /******/ };
  488. /******/ })();
  489. /******/
  490. /******/ /* webpack/runtime/define property getters */
  491. /******/ (() => {
  492. /******/ // define getter functions for harmony exports
  493. /******/ __webpack_require__.d = (exports, definition) => {
  494. /******/ for(var key in definition) {
  495. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  496. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  497. /******/ }
  498. /******/ }
  499. /******/ };
  500. /******/ })();
  501. /******/
  502. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  503. /******/ (() => {
  504. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  505. /******/ })();
  506. /******/
  507. /******/ /* webpack/runtime/nonce */
  508. /******/ (() => {
  509. /******/ __webpack_require__.nc = undefined;
  510. /******/ })();
  511. /******/
  512. /************************************************************************/
  513. var __webpack_exports__ = {};
  514. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  515. (() => {
  516.  
  517. ;// CONCATENATED MODULE: external "Vue"
  518. const external_Vue_namespaceObject = Vue;
  519. ;// CONCATENATED MODULE: ./src/utils/base.ts
  520. function throttle(fn, delay) {
  521. let timeoutId;
  522. let begin = Date.now();
  523. return function (...args) {
  524. // eslint-disable-next-line @typescript-eslint/no-this-alias
  525. const self = this;
  526. const cur = Date.now();
  527. clearTimeout(timeoutId);
  528.  
  529. if (cur - begin >= delay) {
  530. fn.apply(self, args);
  531. begin = cur;
  532. } else {
  533. timeoutId = setTimeout(function () {
  534. fn.apply(self, args);
  535. }, delay);
  536. }
  537. };
  538. }
  539. function once(fn) {
  540. let called = false;
  541. return function (...args) {
  542. if (!called) {
  543. called = true;
  544. fn.apply(this, args);
  545. }
  546. };
  547. }
  548. /**
  549. * 延时
  550. * @param ms 毫秒数
  551. */
  552.  
  553. const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
  554. function isFunction(value) {
  555. return typeof value === 'function';
  556. }
  557. ;// CONCATENATED MODULE: ./src/utils/selector.ts
  558. const $ = document.querySelector.bind(document);
  559. const $$ = document.querySelectorAll.bind(document);
  560. ;// CONCATENATED MODULE: ./src/utils/compatibility.ts
  561. /**
  562. * 兼容性检查,只是用来拦截低版本用户
  563. * @return 是否通过
  564. */
  565. function checker({
  566. firefox = 75,
  567. edge = 80,
  568. chrome = 80,
  569. safari = 14,
  570. notify = true
  571. } = {}) {
  572. const {
  573. userAgent
  574. } = window.navigator;
  575. const firefoxVersion = userAgent.match(/Firefox\/(\d+)/)?.[1];
  576. const edgeVersion = userAgent.match(/Edg\/(\d+)/)?.[1];
  577. const chromeVersion = userAgent.match(/Chrome\/(\d+)/)?.[1];
  578. const safariVersion = userAgent.match(/Version\/(\d+).*Safari/)?.[1]; // 不保证兼容
  579.  
  580. let pass = false;
  581.  
  582. if (firefoxVersion && Number(firefoxVersion) >= firefox || edgeVersion && Number(edgeVersion) >= edge || chromeVersion && Number(chromeVersion) >= chrome || safariVersion && Number(safariVersion) >= safari) {
  583. pass = true;
  584. }
  585.  
  586. if (!pass) {
  587. const {
  588. Toast
  589. } = window;
  590. notify && Toast && Toast.error(`哎呀!遇到错误:不支持的浏览器版本(需要Chrome${chrome}或Firefox${firefox}以上~),请更新浏览器版本 o(╥﹏╥)o`, 0);
  591. }
  592.  
  593. return pass;
  594. }
  595. ;// CONCATENATED MODULE: ./src/utils/vue-root.ts
  596. function getVueRoot(rootContainer) {
  597. if (isVue2(rootContainer)) return getVue2Instance(rootContainer);
  598. if (isVue3(rootContainer)) return getVue3Instance(rootContainer);
  599. return {};
  600. }
  601.  
  602. function isVue2(rootContainer) {
  603. return '__vue__' in rootContainer;
  604. }
  605.  
  606. function isVue3(rootContainer) {
  607. // https://github.com/vuejs/vue-next/blob/a66e53a24f445b688eef6812ecb872dc53cf2702/packages/runtime-core/src/apiCreateApp.ts#L252
  608. return '__vue_app__' in rootContainer;
  609. }
  610.  
  611. function getVue2Instance(rootContainer) {
  612. return {
  613. instance: rootContainer.__vue__
  614. };
  615. }
  616.  
  617. function getVue3Instance(rootContainer) {
  618. return {
  619. app: rootContainer.__vue_app__,
  620. // dev mode下组件el有__vueParentComponent __vnode属性
  621. // https://github.com/vuejs/vue-next/blob/3867bb4c14131ef94098a62bffba97a5b7d1fe66/packages/runtime-core/src/renderer.ts#L767
  622. // https://github.com/vuejs/vue-next/blob/3867bb4c14131ef94098a62bffba97a5b7d1fe66/packages/runtime-core/src/renderer.ts#L763
  623. // _vnode.component.proxy获取实例,应该就是app.mount返回的
  624. // https://github.com/vuejs/vue-next/blob/a66e53a24f445b688eef6812ecb872dc53cf2702/packages/runtime-core/src/apiCreateApp.ts#L258
  625. // https://github.com/vuejs/vue-next/blob/3867bb4c14131ef94098a62bffba97a5b7d1fe66/packages/runtime-core/src/renderer.ts#L2198
  626. instance: rootContainer._vnode && rootContainer._vnode.component.proxy
  627. };
  628. }
  629.  
  630.  
  631. ;// CONCATENATED MODULE: ./src/utils/log.ts
  632. const isDebug = "production" !== 'production';
  633.  
  634. function warn(...args) {
  635. isDebug && warn.force(...args);
  636. }
  637.  
  638. warn.force = function (...args) {
  639. console.warn('%c warn ', 'background: #ffa500; padding: 1px; color: #fff;', ...args);
  640. };
  641.  
  642. function error(...args) {
  643. isDebug && error.force(...args);
  644. }
  645.  
  646. error.force = function (...args) {
  647. console.error('%c error ', 'background: red; padding: 1px; color: #fff;', ...args);
  648. };
  649.  
  650. function table(...args) {
  651. isDebug && console.table(...args);
  652. }
  653.  
  654.  
  655. ;// CONCATENATED MODULE: ./src/utils/mount-component.ts
  656. /*
  657. 引用:https://github.com/youzan/vant/blob/dev/src/utils/mount-component.ts
  658. */
  659.  
  660.  
  661. function append(el) {
  662. document.body ? document.body.appendChild(el) : window.addEventListener('DOMContentLoaded', () => append(el));
  663. }
  664.  
  665. function mountComponent(RootComponent) {
  666. const app = (0,external_Vue_namespaceObject.createApp)(RootComponent);
  667. const root = document.createElement('div');
  668. append(root);
  669. return {
  670. instance: app.mount(root),
  671.  
  672. unmount() {
  673. app.unmount();
  674. document.body.removeChild(root);
  675. }
  676.  
  677. };
  678. }
  679. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
  680. var injectStylesIntoStyleTag = __webpack_require__(3379);
  681. var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
  682. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleDomAPI.js
  683. var styleDomAPI = __webpack_require__(7795);
  684. var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
  685. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertBySelector.js
  686. var insertBySelector = __webpack_require__(569);
  687. var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
  688. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
  689. var setAttributesWithoutAttributes = __webpack_require__(3565);
  690. var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
  691. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertStyleElement.js
  692. var insertStyleElement = __webpack_require__(9216);
  693. var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
  694. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleTagTransform.js
  695. var styleTagTransform = __webpack_require__(4589);
  696. var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
  697. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/scripts/element-ui/catalogue.scss
  698. var catalogue = __webpack_require__(4451);
  699. ;// CONCATENATED MODULE: ./src/scripts/element-ui/catalogue.scss
  700.  
  701.  
  702. var options = {};
  703.  
  704. options.styleTagTransform = (styleTagTransform_default());
  705. options.setAttributes = (setAttributesWithoutAttributes_default());
  706.  
  707. options.insert = insertBySelector_default().bind(null, "head");
  708. options.domAPI = (styleDomAPI_default());
  709. options.insertStyleElement = (insertStyleElement_default());
  710.  
  711. var update = injectStylesIntoStyleTag_default()(catalogue/* default */.Z, options);
  712.  
  713.  
  714.  
  715.  
  716. /* harmony default export */ const element_ui_catalogue = (catalogue/* default */.Z && catalogue/* default.locals */.Z.locals ? catalogue/* default.locals */.Z.locals : undefined);
  717.  
  718. ;// CONCATENATED MODULE: ./src/scripts/element-ui/catalogue.tsx
  719.  
  720.  
  721. function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
  722.  
  723. var id = 0;
  724.  
  725. function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733. var _scope = /*#__PURE__*/_classPrivateFieldLooseKey("scope");
  734.  
  735. var _cat = /*#__PURE__*/_classPrivateFieldLooseKey("cat");
  736.  
  737. var _getElements = /*#__PURE__*/_classPrivateFieldLooseKey("getElements");
  738.  
  739. var _createUI = /*#__PURE__*/_classPrivateFieldLooseKey("createUI");
  740.  
  741. class Catalogue {
  742. constructor({
  743. scope
  744. }) {
  745. Object.defineProperty(this, _createUI, {
  746. value: _createUI2
  747. });
  748. Object.defineProperty(this, _getElements, {
  749. value: _getElements2
  750. });
  751. Object.defineProperty(this, _scope, {
  752. writable: true,
  753. value: ''
  754. });
  755. Object.defineProperty(this, _cat, {
  756. writable: true,
  757. value: (0,external_Vue_namespaceObject.ref)([])
  758. });
  759. _classPrivateFieldLooseBase(this, _scope)[_scope] = scope;
  760.  
  761. _classPrivateFieldLooseBase(this, _createUI)[_createUI]();
  762. }
  763.  
  764. update() {
  765. const els = _classPrivateFieldLooseBase(this, _getElements)[_getElements]();
  766.  
  767. const cat = els.map(el => {
  768. const catItem = {
  769. id: el.id,
  770. text: ''
  771. }; // 仅显示文本节点内容
  772.  
  773. el.childNodes.forEach(node => {
  774. if (node.nodeName === '#text') {
  775. catItem.text += node.nodeValue;
  776. }
  777. });
  778. catItem.text = catItem.text.trim();
  779. return catItem;
  780. });
  781. warn(els, cat);
  782. _classPrivateFieldLooseBase(this, _cat)[_cat].value = cat;
  783. }
  784.  
  785. }
  786.  
  787. function _getElements2() {
  788. return [...$$(_classPrivateFieldLooseBase(this, _scope)[_scope])];
  789. }
  790.  
  791. function _createUI2() {
  792. // eslint-disable-next-line @typescript-eslint/no-this-alias
  793. const self = this;
  794. mountComponent({
  795. setup() {
  796. function intoView(item) {
  797. $('#' + item.id)?.scrollIntoView({
  798. block: 'center'
  799. });
  800. }
  801.  
  802. return () => (0,external_Vue_namespaceObject.createVNode)("div", {
  803. "id": "catalogue-js"
  804. }, [(0,external_Vue_namespaceObject.createVNode)("ul", null, [_classPrivateFieldLooseBase(self, _cat)[_cat].value.map(item => (0,external_Vue_namespaceObject.createVNode)("li", {
  805. "key": item.id,
  806. "title": item.text,
  807. "onClick": () => intoView(item)
  808. }, [item.text]))])]);
  809. }
  810.  
  811. });
  812. }
  813. ;// CONCATENATED MODULE: ./src/scripts/element-ui/index.ts
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822. async function main() {
  823. if (!checker()) return;
  824. let instance; // 非国内链接打开较慢,防止未完成加载
  825.  
  826. while (instance == null) {
  827. ({
  828. instance
  829. } = getVueRoot($('#app')));
  830. await sleep(500);
  831. }
  832.  
  833. warn(instance); // element-plus 已支持
  834.  
  835. if ($('#app').__vue_app__) return;
  836. const catalogue = new Catalogue({
  837. // 注意:选择器要同时兼容element与element plus文档
  838. scope: '.page-container .page-component__content section.element-doc > h3'
  839. });
  840. let unwatch;
  841. instance.$watch('$route', function () {
  842. (0,external_Vue_namespaceObject.nextTick)(() => {
  843. const target = $('.page-component__content');
  844.  
  845. if (target && unwatch == null) {
  846. unwatch = watchDocs(target);
  847. } else if (!target) {
  848. unwatch?.();
  849. unwatch = undefined;
  850. }
  851. });
  852. }, {
  853. immediate: true
  854. });
  855.  
  856. function watchDocs(target) {
  857. catalogue.update();
  858. const observer = new MutationObserver(() => catalogue.update());
  859. observer.observe(target, {
  860. subtree: true,
  861. childList: true
  862. });
  863. return () => {
  864. observer.disconnect();
  865. catalogue.update();
  866. };
  867. }
  868. }
  869.  
  870. main();
  871. })();
  872.  
  873. /******/ })()
  874. ;

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址