Files
theme-mdocs/templates/assets/main-BAX9Eehy.js
T
maoxiang d36050cff7 初始化仓库
初始化仓库
2026-09-09 13:19:09 +08:00

95 lines
25 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=`mdocs-theme`;function t(e){let t=window.themePluginPage?.[e];if(!t)return{};let n=`realNode`in t&&t.realNode?t.realNode:t;return e===`docs`?{nav_expanded_all:n.sidebar_default_expanded,nav_show_count:n.sidebar_show_count,toc_enabled:n.show_toc,toolbar_enabled:n.show_copy_markdown,toolbar_groups:n.toolbar_groups}:n}function n(){let e=document.body,t=(t,n)=>{let r=e.dataset[t];return r&&r!==`null`?r:n};e.style.setProperty(`--theme-bg-light`,t(`bgLight`,`#ffffff`)),e.style.setProperty(`--theme-bg-dark`,t(`bgDark`,`#0d1117`));let n=t(`bgImage`,``);e.style.setProperty(`--theme-bg-image`,n?`url("${n}")`:`none`)}function r(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.setAttribute(`data-color-scheme`,e),t.classList.toggle(`dark`,e===`dark`),t.classList.remove(`color-scheme-auto`,`color-scheme-dark`,`color-scheme-light`),t.classList.add(`color-scheme-${e}`),i(e)}function i(e){document.querySelectorAll(`img[data-logo-light]`).forEach(t=>{let n=t.dataset.logoLight??``,r=t.dataset.logoDark??n,i=e===`dark`&&r?r:n;i&&(t.src=i)})}function a(){let e=document.body,t=(e.dataset.primary??``).trim(),n=t.toLowerCase()===`#2563eb`;if(!/^#[0-9a-f]{6}$/i.test(t)||n){e.style.removeProperty(`--primary-color`);return}let r=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16);if(r===i&&i===a){e.style.removeProperty(`--primary-color`);return}e.style.setProperty(`--primary-color`,t)}function o(){let t=localStorage.getItem(e),n=window.matchMedia(`(prefers-color-scheme: dark)`).matches;r(t||(n?`dark`:`light`)),document.getElementById(`theme-toggle`)?.addEventListener(`click`,()=>{let t=document.documentElement.getAttribute(`data-theme`)===`dark`?`light`:`dark`;r(t),localStorage.setItem(e,t)})}function s(){let e=document.getElementById(`version-trigger`),t=e?.parentElement;!e||!t||(e.addEventListener(`click`,e=>{e.stopPropagation(),t.classList.toggle(`open`)}),document.addEventListener(`click`,()=>t.classList.remove(`open`)))}function c(){document.querySelectorAll(`[data-mdocs-version-trigger]`).forEach(e=>{let t=e.parentElement?.querySelector(`[data-mdocs-version-panel]`);if(!t)return;let n=()=>{t.hidden=!0,e.removeAttribute(`aria-expanded`)};e.addEventListener(`click`,r=>{r.stopPropagation();let i=t.hidden;n(),i&&(t.hidden=!1,e.setAttribute(`aria-expanded`,`true`))}),document.addEventListener(`click`,n),t.addEventListener(`click`,e=>e.stopPropagation())})}function l(){document.querySelectorAll(`.header-menu-item.has-dropdown`).forEach(e=>{e.querySelector(`.header-menu-trigger`)?.addEventListener(`click`,t=>{t.stopPropagation(),e.classList.toggle(`open`)})}),document.addEventListener(`click`,()=>{document.querySelectorAll(`.header-menu-item.open`).forEach(e=>e.classList.remove(`open`))})}function u(){let e=document.getElementById(`user-menu`);e&&(e.querySelector(`.user-avatar.user-authenticated`)?.addEventListener(`click`,t=>{t.stopPropagation(),e.classList.toggle(`open`)}),document.addEventListener(`click`,()=>e.classList.remove(`open`)))}function d(){let e=document.querySelector(`.site-header`),t=document.getElementById(`mobile-menu-toggle`),n=document.getElementById(`mobile-menu-backdrop`),r=document.getElementById(`header-menu-panel`);if(!e||!t)return;let i=()=>{e.classList.remove(`mobile-menu-open`),document.body.classList.remove(`mobile-menu-locked`),t.setAttribute(`aria-expanded`,`false`)},a=()=>{e.classList.add(`mobile-menu-open`),document.body.classList.add(`mobile-menu-locked`),t.setAttribute(`aria-expanded`,`true`)};t.addEventListener(`click`,()=>{e.classList.contains(`mobile-menu-open`)?i():a()}),n?.addEventListener(`click`,i),r?.addEventListener(`click`,e=>{e.target.closest(`a`)&&i()}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&i()})}function f(){document.querySelectorAll(`.hero-carousel`).forEach(e=>{let t=e.querySelector(`.hero-carousel-track`),n=e.querySelectorAll(`.hero-carousel-slide`),r=e.querySelectorAll(`.hero-carousel-dot`);if(!t||n.length===0)return;let i=0,a,o=e=>{let t=(e%n.length+n.length)%n.length;i=t,n.forEach((e,n)=>e.classList.toggle(`active`,t===n)),r.forEach((e,n)=>e.classList.toggle(`active`,t===n))},s=()=>{let t=parseInt(e.dataset.speed||`5000`,10);a=window.setInterval(()=>o(i+1),t)},c=()=>{a!==void 0&&(window.clearInterval(a),a=void 0)},l=!1,u=0,d=0,f=0,p=!1,m=e=>{Math.abs(e)<40||(p=!0,c(),o(e<0?i+1:i-1),s())};t.addEventListener(`pointerdown`,e=>{if(e.pointerType!==`mouse`||e.button===0){l=!0,u=e.clientX,d=e.clientY,f=0,p=!1,t.style.userSelect=`none`;try{t.setPointerCapture(e.pointerId)}catch{}}}),t.addEventListener(`pointermove`,e=>{if(!l)return;let t=e.clientX-u,n=e.clientY-d;Math.abs(t)>Math.abs(n)&&(f=t,e.preventDefault())}),t.addEventListener(`pointerup`,()=>{l&&(l=!1,m(f),f=0,t.style.removeProperty(`user-select`))}),t.addEventListener(`pointercancel`,()=>{l=!1,f=0,t.style.removeProperty(`user-select`)}),e.querySelectorAll(`a.hero-carousel-slide`).forEach(e=>{e.addEventListener(`click`,e=>{p&&=(e.preventDefault(),e.stopPropagation(),!1)})}),r.forEach((e,t)=>e.addEventListener(`click`,e=>{e.preventDefault(),c(),o(t),s()})),e.addEventListener(`mouseenter`,c),e.addEventListener(`mouseleave`,s),s()})}function p(){document.querySelectorAll(`.filter-input`).forEach(e=>{let t=e.dataset.filterTarget;if(!t)return;let n=document.querySelector(t);n&&e.addEventListener(`input`,()=>{let t=e.value.trim().toLowerCase();n.querySelectorAll(`.card-cell, .card-group`).forEach(e=>{let n=e.textContent?.toLowerCase()??``;e.classList.toggle(`filter-hidden`,t!==``&&!n.includes(t))})})})}function m(){document.querySelectorAll(`.overview-direct`).forEach(e=>{let t=e.querySelector(`.overview-grid`);(!t||t.querySelectorAll(`.card-cell`).length===0)&&e.remove()})}function h(){let e=document.getElementById(`toc-list`),t=document.querySelector(`.doc-article-body`);if(!e||!t)return;let n=t.querySelectorAll(`h2, h3`);if(n.length===0)return;let r=[];n.forEach((t,n)=>{t.id||=`heading-${n}`;let i=document.createElement(`a`);i.href=`#${t.id}`,i.textContent=t.textContent??``,i.classList.add(t.tagName===`H3`?`level-3`:`level-2`),e.appendChild(i),r.push({el:i,heading:t})});let i=new IntersectionObserver(e=>{e.forEach(e=>{if(!e.isIntersecting)return;let t=e.target.id;r.forEach(({el:e})=>{e.classList.toggle(`active`,e.getAttribute(`href`)===`#${t}`)})})},{rootMargin:`-80px 0px -70% 0px`,threshold:0});n.forEach(e=>i.observe(e))}function g(){let e=document.querySelector(`.doc-layout`);if(!e)return;let t=document.querySelectorAll(`.doc-nav-item.has-children`);if(t.forEach(e=>{let t=t=>{t.preventDefault(),t.stopPropagation(),e.classList.toggle(`collapsed`)};e.querySelector(`.doc-nav-toggle, .mdocs-nav-toggle`)?.addEventListener(`click`,t);let n=e.querySelector(`.doc-nav-link`);n?.addEventListener(`click`,e=>{n.classList.contains(`active`)&&t(e)})}),e.dataset.defaultExpanded===`true`)return;let n=document.querySelector(`.doc-nav-link.active, .doc-nav-post a.active`);if(!n)return;let r=new Set,i=n.closest(`.doc-nav-item`);for(;i;){let e=i.parentElement?.closest(`.doc-nav-item`);e&&r.add(e),i=e??null}t.forEach(e=>{r.has(e)||e.classList.add(`collapsed`)})}function _(){let e=document.querySelector(`.doc-layout`);if(!e)return;let t=document.querySelector(`.sidebar-toggle`),n=document.querySelector(`.sidebar-backdrop`);t?.addEventListener(`click`,()=>e.classList.toggle(`sidebar-open`)),n?.addEventListener(`click`,()=>e.classList.remove(`sidebar-open`))}function v(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function y(){return new URLSearchParams(window.location.search)}async function b(e,t){let n=await fetch(e,{credentials:`same-origin`,method:t?.method??`GET`,headers:{Accept:`application/json`}});if(!n.ok)throw n.status===401||n.status===403?Error(`没有阅读该知识库的权限,请先登录。`):Error(`MiniDocs 请求失败(${n.status}`);return n.json()}function x(e){let t=[];return e.forEach(e=>{e.slug&&t.push(e.slug),e.children&&e.children.length>0&&t.push(...x(e.children))}),t}function S(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}${n(t.getHours())}:${n(t.getMinutes())}`}function C(e){e.querySelectorAll(`.doc-nav-item.has-children`).forEach(e=>{e.querySelector(`.mdocs-nav-toggle`)?.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),e.classList.toggle(`collapsed`)});let n=e.querySelector(`:scope > .doc-nav-row > a.doc-nav-link`);n?.addEventListener(`click`,t=>{n.classList.contains(`active`)&&(t.preventDefault(),t.stopPropagation(),e.classList.toggle(`collapsed`))}),t(`minidocs`).nav_expanded_all!==!0&&e.querySelector(`.doc-nav-children .doc-nav-link.active`)===null&&e.classList.add(`collapsed`)})}function w(){let e=document.getElementById(`minidocs-toc-list`),t=document.querySelector(`.minidocs-doc-layout .doc-article-body`);if(!e||!t)return;e.innerHTML=``;let n=t.querySelectorAll(`h2, h3`);n.length!==0&&n.forEach((t,n)=>{t.id||=`minidocs-heading-${n}`;let r=document.createElement(`a`);r.href=`#${t.id}`,r.textContent=t.textContent??``,r.classList.add(t.tagName===`H3`?`level-3`:`level-2`),e.appendChild(r)})}async function T(e){if(!e)return!1;if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{return!1}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=!1;try{n=document.execCommand(`copy`)}catch{n=!1}return t.remove(),n}function E(e,t,n){let r=document.createElement(`a`);r.target=`_blank`,r.rel=`noopener noreferrer`;let i=`请阅读这篇文档并回答相关问题:${t}\n${n}`;return e===`chatgpt`?(r.href=`https://chatgpt.com/?q=${encodeURIComponent(i)}`,r.textContent=`在 ChatGPT 中打开`):(r.href=`https://claude.ai/new?q=${encodeURIComponent(i)}`,r.textContent=`在 Claude 中打开`),r}function D(e,t,n,r){let i=document.createElement(e===`custom`?`a`:`button`);if(e===`custom`){let e=i;e.href=t.url||`#`,e.target=`_blank`,e.rel=`noopener noreferrer`;let n=document.createElement(`span`);n.className=`mdocs-toolbar-item-icon`,t.icon&&(n.innerHTML=t.icon),e.appendChild(n),e.appendChild(document.createTextNode(t.title||`自定义`))}else if(e===`chatgpt`||e===`claude`)return E(e,n,r);else i.textContent=t.title||`自定义`;return i}function O(e){let n=t(e.plugin);if(n.toolbar_enabled===!1||e.container.querySelector(`.mdocs-content-toolbar`))return;let r=document.createElement(`div`);r.className=`mdocs-content-toolbar`;let i=document.querySelector(`.doc-article-title, .dm-content__body h1`)?.textContent??``;r.innerHTML=`
<button type="button" class="mdocs-toolbar-copy" data-mdocs-copy>
<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
<span>复制 Markdown</span>
</button>
<div class="mdocs-toolbar-menu">
<button type="button" class="mdocs-toolbar-menu-btn" data-mdocs-menu aria-label="更多操作">
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor"><circle cx="5" cy="12" r="2"></circle><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle></svg>
</button>
<div class="mdocs-toolbar-dropdown" data-mdocs-dropdown hidden></div>
</div>
`;let a=r.querySelector(`[data-mdocs-copy]`),o=a?.innerHTML??``,s;a?.addEventListener(`click`,async()=>{await T(e.getMarkdown())&&(a.classList.add(`mdocs-copied`),a.innerHTML=`
<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>
<span>复制 Markdown</span>
`,window.clearTimeout(s),s=window.setTimeout(()=>{a.classList.remove(`mdocs-copied`),a.innerHTML=o},500))});let c=r.querySelector(`[data-mdocs-menu]`),l=r.querySelector(`[data-mdocs-dropdown]`);if(!c||!l)return;let u=()=>{l.hidden=!0,c.removeAttribute(`aria-expanded`)};c.addEventListener(`click`,e=>{e.stopPropagation();let t=l.hidden;u(),t&&(l.hidden=!1,c.setAttribute(`aria-expanded`,`true`))}),document.addEventListener(`click`,u),l.addEventListener(`click`,e=>e.stopPropagation());let d=document.createElement(`div`);d.className=`mdocs-toolbar-group`;let f=document.createElement(`button`);if(f.type=`button`,f.textContent=`复制 Markdown 链接`,f.addEventListener(`click`,()=>T(`[${i}](${window.location.href})`)),d.appendChild(f),e.triggerLike){let t=document.createElement(`button`);t.type=`button`,t.textContent=`点赞`,t.addEventListener(`click`,()=>e.triggerLike?.()),d.appendChild(t)}let p=document.createElement(`button`);p.type=`button`,p.textContent=`分享`,p.addEventListener(`click`,()=>T(window.location.href)),d.appendChild(p),l.appendChild(d),(n.toolbar_groups??[]).forEach(e=>{if(!e.items||e.items.length===0)return;let t=document.createElement(`div`);if(t.className=`mdocs-toolbar-group`,e.title){let n=document.createElement(`div`);n.className=`mdocs-toolbar-group-title`,n.textContent=e.title,t.appendChild(n)}e.items.forEach(e=>{let n=D(e.type,e,i,window.location.href);n.classList.add(`mdocs-toolbar-item`),t.appendChild(n)}),l.appendChild(t)}),e.container.insertBefore(r,e.container.firstChild)}function k(){document.querySelectorAll(`.mdocs-docsme-page .dm-nav-tree details`).forEach(e=>{t(`docsme`).nav_expanded_all===!0&&(e.open=!0);let n=e.querySelector(`:scope > summary.dm-nav-tree__toggle`),r=e.querySelector(`:scope > ul.dm-nav-tree__nested`);if(!n||!r)return;if(n.classList.add(`mdocs-doc-nav-row`),!n.querySelector(`.mdocs-nav-toggle`)){let t=document.createElement(`span`);t.className=`mdocs-nav-toggle`,t.setAttribute(`role`,`button`),t.setAttribute(`aria-label`,`折叠/展开`),t.innerHTML=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>`,n.appendChild(t),t.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),e.open=!e.open})}let i=n.querySelector(`:scope > a.dm-nav-tree__link`);i?.addEventListener(`click`,t=>{i.classList.contains(`dm-nav-tree__link--active`)&&(t.preventDefault(),t.stopPropagation(),e.open=!e.open)})})}function A(e,t,n){return e.map(e=>{let r=e.children&&e.children.length>0,i=e.slug===t?` active`:``,a=e.slug?`<a class="doc-nav-link${i}" href="?kb=${encodeURIComponent(n)}&docSlug=${encodeURIComponent(e.slug)}" data-doc-slug="${v(e.slug)}">${v(e.title??``)}</a>`:`<span class="doc-nav-link doc-nav-folder">${v(e.title??``)}</span>`,o=r?`<button type="button" class="mdocs-nav-toggle" aria-label="折叠/展开"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg></button>`:``,s=r&&e.children?`<ul class="doc-nav-list doc-nav-children">${A(e.children,t,n)}</ul>`:``;return`<li class="doc-nav-item${r?` has-children`:``}"><div class="doc-nav-row">${a}${o}</div>${s}</li>`}).join(``)}function j(){let e=document.getElementById(`minidocs-archive`),n=document.getElementById(`minidocs-viewer-host`);if(!e||!n)return;let r=``,i=``,a=null,o=null,s=window.location.pathname,c=()=>{e.hidden=!1,n.hidden=!0,n.innerHTML=``},l=async(e,t)=>{if(!(!r||!e))try{let n=(await b(`/apis/api.minidocs.halo.run/v1alpha1/knowledgebases/${encodeURIComponent(r)}/docs/${encodeURIComponent(e)}`)).spec??{};i=n.raw??n.content??``;let c=document.querySelector(`.minidocs-viewer-title`),l=document.querySelector(`.minidocs-viewer-author`),u=document.querySelector(`.minidocs-viewer-time`);c&&(c.textContent=n.title??``),l&&(l.hidden=!n.author,l.textContent=n.author?` · ${n.author}`:``),u&&(u.hidden=!n.updateTime,u.textContent=n.updateTime?n.updateTime.slice(0,10):``),o&&(o.innerHTML=n.content??``),w(),a&&(a.querySelectorAll(`.doc-nav-link.active`).forEach(e=>{e.classList.remove(`active`)}),a.querySelectorAll(`a[data-doc-slug="${CSS.escape(e)}"]`).forEach(e=>e.classList.add(`active`))),t&&history.pushState({mdocsMinidocs:!0},``,`${s}?kb=${encodeURIComponent(r)}&docSlug=${encodeURIComponent(e)}`)}catch(e){let t=e instanceof Error?e.message:`加载文档失败`;o&&(o.innerHTML=`<p class="mdocs-plugin-empty">${v(t)}</p>`)}},u=async(u,d,f=!0)=>{e.hidden=!0,n.hidden=!1,n.innerHTML=`
<button class="sidebar-toggle" type="button" aria-label="切换目录">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg>
<span>目录</span>
</button>
<div class="sidebar-backdrop"></div>
<div class="doc-layout minidocs-doc-layout">
<aside class="doc-sidebar">
<div class="mdocs-docsme-sidebar-controls minidocs-toolbar">
<button type="button" class="mdocs-docsme-back minidocs-back-archive">
<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="19" y1="12" x2="5" y2="12"></line>
<polyline points="12 19 5 12 12 5"></polyline>
</svg>
<span>返回</span>
</button>
<div class="minidocs-toolbar-actions">
<a
href="#"
class="minidocs-toolbar-btn minidocs-share-btn"
title="分享"
>
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="18" cy="5" r="3"></circle>
<circle cx="6" cy="12" r="3"></circle>
<circle cx="18" cy="19" r="3"></circle>
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line>
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line>
</svg>
<span>分享</span>
</a>
<button
type="button"
class="minidocs-toolbar-btn minidocs-like-btn"
title="点赞"
>
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path>
</svg>
<span class="minidocs-like-count">0</span>
</button>
<span class="minidocs-view-count" title="浏览次数">
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
<circle cx="12" cy="12" r="3"></circle>
</svg>
<span class="minidocs-view-count-num">0</span>
<span>浏览</span>
</span>
</div>
</div>
<div class="minidocs-kb-heading">
<span class="minidocs-kb-cover"></span>
<div class="minidocs-kb-info">
<div class="doc-sidebar-kb-title minidocs-kb-name">加载中…</div>
<div class="minidocs-kb-stats">
<span class="minidocs-doc-count">共 0 篇</span>
<span class="minidocs-update-time"></span>
</div>
</div>
</div>
<nav class="doc-sidebar-nav">
<ul class="doc-nav-list" id="minidocs-tree"></ul>
</nav>
</aside>
<div class="doc-content">
<article class="doc-article">
<header class="doc-article-header">
<h1 class="doc-article-title minidocs-viewer-title"></h1>
</header>
<div class="doc-article-meta">
<time class="minidocs-viewer-time"></time>
<span class="minidocs-viewer-author"></span>
</div>
<div class="doc-article-body">
<p class="mdocs-plugin-empty">正在加载文档…</p>
</div>
</article>
</div>
${t(`minidocs`).toc_enabled===!1?``:`<aside class="doc-toc"><div class="toc-title">目录</div><nav class="toc-list" id="minidocs-toc-list"></nav></aside>`}
</div>`;let p=n.querySelector(`.doc-layout`),m=n.querySelector(`.sidebar-toggle`),h=n.querySelector(`.sidebar-backdrop`);m?.addEventListener(`click`,()=>{p?.classList.toggle(`sidebar-open`)}),h?.addEventListener(`click`,()=>{p?.classList.remove(`sidebar-open`)}),n.querySelector(`.minidocs-back-archive`)?.addEventListener(`click`,()=>{history.pushState({},``,s),c()});let g=n.querySelector(`.minidocs-share-btn`),_=n.querySelector(`.minidocs-like-btn`),y=n.querySelector(`.minidocs-view-count-num`),w=n.querySelector(`.minidocs-like-count`),T=(e,r)=>{let i=e.spec??{},a=n.querySelector(`.minidocs-kb-cover`);a&&(a.innerHTML=i.cover?`<img src="${v(i.cover)}" alt="" />`:`<span class="minidocs-kb-cover-fallback">${i.displayName?v(i.displayName.slice(0,1)):`库`}</span>`);let o=n.querySelector(`.minidocs-doc-count`);if(o){let n=t(`minidocs`).nav_show_count!==!1;o.hidden=!n,n&&(o.textContent=`共 ${e.status?.docCount??0} 篇`)}let s=n.querySelector(`.minidocs-update-time`);if(s){let e=S(i.updateTime);s.textContent=e?`更新于 ${e}`:``}let c=i.shareEnabled===!0&&i.shareToken?i.shareToken:``;g&&(c?(g.href=`/docs/share/${encodeURIComponent(c)}`,g.classList.remove(`is-disabled`),g.removeAttribute(`aria-disabled`)):(g.href=`#`,g.classList.add(`is-disabled`),g.setAttribute(`aria-disabled`,`true`)));let l=typeof r?.likeCount==`number`?r.likeCount:i.likeCount??0;w&&(w.textContent=String(l)),_&&r?.liked&&_.classList.add(`is-liked`);let u=typeof r?.accessCount==`number`?r.accessCount:i.accessCount??0;y&&(y.textContent=String(u))};g?.addEventListener(`click`,e=>{g.classList.contains(`is-disabled`)&&(e.preventDefault(),e.stopPropagation())}),_?.addEventListener(`click`,async()=>{if(r)try{let e=await b(`/apis/api.minidocs.halo.run/v1alpha1/knowledgebases/${encodeURIComponent(r)}/like`,{method:`POST`});typeof e.likeCount==`number`&&w&&(w.textContent=String(e.likeCount)),e.liked&&_.classList.add(`is-liked`)}catch{}});let E=n.querySelector(`.doc-content`);E&&O({plugin:`minidocs`,container:E,getMarkdown:()=>i,triggerLike:()=>_?.click()}),r=u,o=n.querySelector(`.doc-article-body`),a=document.getElementById(`minidocs-tree`);try{let e=await b(`/apis/api.minidocs.halo.run/v1alpha1/knowledgebases/${encodeURIComponent(u)}`),t=n.querySelector(`.minidocs-kb-name`);t&&(t.textContent=e.spec?.displayName??`MiniDocs 知识库`);let r=null;try{r=await b(`/apis/api.minidocs.halo.run/v1alpha1/knowledgebases/${encodeURIComponent(u)}/stats`)}catch{}T(e,r);let i=await b(`/apis/api.minidocs.halo.run/v1alpha1/knowledgebases/${encodeURIComponent(u)}/tree`),s=x(i??[]);if(s.length===0){o&&(o.innerHTML=`<p class="mdocs-plugin-empty">该知识库暂无已发布文档。</p>`);return}let c=d&&s.includes(d)?d:s[0];a&&(a.innerHTML=A(i??[],c,u),C(a),a.addEventListener(`click`,e=>{let t=e.target.closest(`a[data-doc-slug]`);if(!t)return;e.preventDefault();let n=t.dataset.docSlug;n&&l(n,!0)})),await l(c,f)}catch(e){let t=e instanceof Error?e.message:`加载知识库失败`;o&&(o.innerHTML=`<p class="mdocs-plugin-empty">${v(t)}</p>`)}};document.querySelectorAll(`.mdocs-kb-card[data-kb]`).forEach(e=>{e.addEventListener(`click`,t=>{t.preventDefault();let n=e.dataset.kb;n&&u(n)})}),window.addEventListener(`popstate`,()=>{let e=y().get(`kb`);e?u(e,y().get(`docSlug`)??void 0,!1):c()});let d=y().get(`kb`);d&&u(d,y().get(`docSlug`)??void 0,!1)}document.addEventListener(`DOMContentLoaded`,()=>{n(),o(),a(),s(),c(),l(),u(),d(),f(),p(),m(),h(),g(),_(),j(),k();let e=document.querySelector(`.mdocs-docsme-page .dm-content`),t=document.getElementById(`docsme-raw-markdown`);e&&t&&O({plugin:`docsme`,container:e,getMarkdown:()=>t.textContent?.trim()||`[${document.querySelector(`.dm-content__body h1`)?.textContent??``}](${window.location.href})`}),document.querySelectorAll(`.doc-content`).forEach(e=>{let t=e.closest(`.doc-layout`);if(!t||t.classList.contains(`minidocs-doc-layout`)||e.querySelector(`.mdocs-content-toolbar`))return;let n=document.getElementById(`page-md-data`);O({plugin:`docs`,container:e,getMarkdown:()=>n?.textContent?.trim()||`[${document.querySelector(`.doc-article-title`)?.textContent??``}](${window.location.href})`})}),document.querySelectorAll(`.minidocs-doc-layout`).forEach(e=>C(e))});