mirror of
https://github.com/SuperManito/LinuxMirrors.git
synced 2026-05-06 21:53:02 +08:00
更新文档
This commit is contained in:
48
docs/assets/js/algolia-search/config.js
Normal file
48
docs/assets/js/algolia-search/config.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const AlgoliaI18nData = {
|
||||
'zh-Hans': {
|
||||
askAiText: '询问 AI',
|
||||
clearText: '清空',
|
||||
openText: '打开',
|
||||
navigateText: '导航',
|
||||
placeholder: '请输入要搜索的内容',
|
||||
},
|
||||
'zh-Hant': {
|
||||
askAiText: '詢問 AI',
|
||||
clearText: '清空',
|
||||
openText: '打開',
|
||||
navigateText: '導航',
|
||||
placeholder: '請輸入要搜索的內容',
|
||||
},
|
||||
en: {
|
||||
askAiText: 'Ask AI',
|
||||
clearText: 'Clear',
|
||||
openText: 'Open',
|
||||
navigateText: 'Navigate',
|
||||
placeholder: 'Enter your search query',
|
||||
},
|
||||
}
|
||||
|
||||
function getAlgoliaCurrentLang() {
|
||||
return __isZhHant ? 'zh-Hant' : __isEn ? 'en' : 'zh-Hans'
|
||||
}
|
||||
|
||||
function getAlgoliaSearchConfig() {
|
||||
const lang = getAlgoliaCurrentLang()
|
||||
return {
|
||||
container: '#search-container',
|
||||
applicationId: 'EQO6IPTEY8',
|
||||
apiKey: '353d0a78521edc905d38a27d479bc2ec',
|
||||
indexName: 'docs',
|
||||
assistantId: '967fa671-8a15-46d8-83cd-095bb3e3619a',
|
||||
agentStudio: true,
|
||||
placeholder: AlgoliaI18nData[lang].placeholder,
|
||||
attributes: {
|
||||
primaryText: 'title',
|
||||
secondaryText: 'description',
|
||||
tertiaryText: 'itunesAuthor',
|
||||
url: 'url',
|
||||
image: 'imageUrl',
|
||||
},
|
||||
insights: false,
|
||||
}
|
||||
}
|
||||
68
docs/assets/js/algolia-search/index.js
Normal file
68
docs/assets/js/algolia-search/index.js
Normal file
@@ -0,0 +1,68 @@
|
||||
function loadAlgoliaSearchComponent() {
|
||||
SiteSearchAskAI.init(getAlgoliaSearchConfig())
|
||||
|
||||
// SiteSearch uses 'modal-backdrop', SiteSearchAskAI uses 'modal-backdrop-askai'
|
||||
const bodyObserver = new MutationObserver((mutations) => {
|
||||
for (const mutation of mutations) {
|
||||
for (const node of mutation.addedNodes) {
|
||||
if (
|
||||
node.nodeType === Node.ELEMENT_NODE &&
|
||||
Array.from(node.classList).some((c) => c.startsWith('modal-backdrop'))
|
||||
) {
|
||||
localizationAlgoliaSearchModal(node)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
bodyObserver.observe(document.body, { childList: true })
|
||||
}
|
||||
|
||||
function localizationAlgoliaSearchModal(modal) {
|
||||
const lang = getAlgoliaCurrentLang()
|
||||
// English is the component default, no need to patch
|
||||
if (lang === 'en') return
|
||||
|
||||
const i18n = AlgoliaI18nData[lang]
|
||||
|
||||
const observer = new MutationObserver((mutations, obs) => {
|
||||
// "Clear" button
|
||||
const clearBtn = modal.querySelector('.ss-search-clear-button')
|
||||
if (clearBtn && clearBtn.textContent.trim() === 'Clear') {
|
||||
clearBtn.textContent = i18n.clearText
|
||||
}
|
||||
|
||||
// Footer kbd groups: first span = "Open", second span = "Navigate"
|
||||
const kbdGroups = modal.querySelectorAll('.ss-footer-kbd-group')
|
||||
kbdGroups.forEach((group) => {
|
||||
const span = group.querySelector('span')
|
||||
if (!span) return
|
||||
if (span.textContent.trim() === 'Open') {
|
||||
span.textContent = i18n.openText
|
||||
} else if (span.textContent.trim() === 'Navigate') {
|
||||
span.textContent = i18n.navigateText
|
||||
}
|
||||
})
|
||||
|
||||
// "Ask AI" entry in hits list: <article class="ss-ask-ai-btn">
|
||||
const askAiArticle = modal.querySelector('.ss-ask-ai-btn')
|
||||
if (askAiArticle) {
|
||||
const titleP = askAiArticle.querySelector('.ss-infinite-hits-item-title')
|
||||
if (titleP) {
|
||||
const firstText = titleP.childNodes[0]
|
||||
if (firstText && firstText.nodeType === Node.TEXT_NODE && firstText.textContent.startsWith('Ask AI')) {
|
||||
firstText.textContent = i18n.askAiText + ': '
|
||||
}
|
||||
}
|
||||
if (askAiArticle.getAttribute('aria-label') === 'Ask AI') {
|
||||
askAiArticle.setAttribute('aria-label', i18n.askAiText)
|
||||
}
|
||||
if (askAiArticle.getAttribute('title') === 'Ask AI') {
|
||||
askAiArticle.setAttribute('title', i18n.askAiText)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
observer.observe(modal, { childList: true, subtree: true })
|
||||
// Disconnect after the modal content has fully rendered
|
||||
setTimeout(() => observer.disconnect(), 2000)
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
// 使用 mkdocs-material 与第三方 JavaScript 库集成的方法
|
||||
document$.subscribe(function () {
|
||||
ComponentSystem.reinitializeAll()
|
||||
// Algolia 搜索
|
||||
loadAlgoliaSearchComponent()
|
||||
})
|
||||
|
||||
@@ -251,7 +251,7 @@ search:
|
||||
<button class="md-button" title="https://tool.chinaz.com" onclick="window.open('https://tool.chinaz.com')">Domain Lookup</button>
|
||||
<button class="md-button" title="https://tools.ipip.net/newping.php" onclick="window.open('https://tools.ipip.net/newping.php')">Ping Latency Test</button>
|
||||
<button class="md-button" title="https://tools.ipip.net/traceroute.php" onclick="window.open('https://tools.ipip.net/traceroute.php')">Tracert Route Trace Test</button>
|
||||
<button class="md-button" title="https://ipw.cn/ipv6webcheck" onclick="window.open('https://ipw.cn/ipv6webcheck')">IPv6 Access Test</button>
|
||||
<button class="md-button" title="https://www.guokeyun.com/ipv6Monitor.html" onclick="window.open('https://www.guokeyun.com/ipv6Monitor.html')">IPv6 Access Test</button>
|
||||
|
||||
!!! tip "This page displays only the default repository addresses provided by the script. If you can't find the one you want, don't worry—the script supports custom addresses via command options. See [Advanced Usage](../use/index.md#command-options-advanced-usage) for details."
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ search:
|
||||
<button class="md-button" title="https://tool.chinaz.com" onclick="window.open('https://tool.chinaz.com')">域名查询</button>
|
||||
<button class="md-button" title="https://tools.ipip.net/newping.php" onclick="window.open('https://tools.ipip.net/newping.php')">Ping 延迟测试</button>
|
||||
<button class="md-button" title="https://tools.ipip.net/traceroute.php" onclick="window.open('https://tools.ipip.net/traceroute.php')">Tracert 路由追踪测试</button>
|
||||
<button class="md-button" title="https://ipw.cn/ipv6webcheck" onclick="window.open('https://ipw.cn/ipv6webcheck')">IPv6 接入测试</button>
|
||||
<button class="md-button" title="https://www.guokeyun.com/ipv6Monitor.html" onclick="window.open('https://www.guokeyun.com/ipv6Monitor.html')">IPv6 接入测试</button>
|
||||
|
||||
!!! tip "该页面展示的均为脚本默认提供可供选择的软件源地址,如果没有找到你想使用的也没有关系,脚本支持命令选项可自定义使用,详见[高级用法](../use/index.md#命令选项高级用法)"
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ search:
|
||||
<button class="md-button" title="https://tool.chinaz.com" onclick="window.open('https://tool.chinaz.com')">域名查詢</button>
|
||||
<button class="md-button" title="https://tools.ipip.net/newping.php" onclick="window.open('https://tools.ipip.net/newping.php')">Ping 延遲測試</button>
|
||||
<button class="md-button" title="https://tools.ipip.net/traceroute.php" onclick="window.open('https://tools.ipip.net/traceroute.php')">Tracert 路由追蹤測試</button>
|
||||
<button class="md-button" title="https://ipw.cn/ipv6webcheck" onclick="window.open('https://ipw.cn/ipv6webcheck')">IPv6 接取測試</button>
|
||||
<button class="md-button" title="https://www.guokeyun.com/ipv6Monitor.html" onclick="window.open('https://www.guokeyun.com/ipv6Monitor.html')">IPv6 接取測試</button>
|
||||
|
||||
!!! tip "該頁面顯示的皆為腳本預設提供可供選擇的軟體源位址,如果沒有找到你想使用的也沒有關係,腳本支援命令選項可自定義使用,詳見[進階用法](../use/index.md#命令選項進階用法)"
|
||||
|
||||
|
||||
@@ -77,11 +77,11 @@
|
||||
<img src="/assets/images/sponsor/yuluyundun-dark.png#only-dark" alt="语鹿云盾" />
|
||||
</a>
|
||||
<a class="sponsor-item sponsor-item-flex" target="_blank" rel="noopener noreferrer" href="https://cb2.cn" title="国内外建站快响应服务器的不二之选">
|
||||
<!-- 26 4 15 -->
|
||||
<!-- 26 5 15 -->
|
||||
<img src="/assets/images/sponsor/bueryun.svg" alt="不二云" />
|
||||
</a>
|
||||
<a class="sponsor-item sponsor-item-flex" target="_blank" href="https://www.runxinyun.com" title="国内挂机宝海外云服务器低至9.9元/月">
|
||||
<!-- 26 4 14 -->
|
||||
<!-- 26 7 14 -->
|
||||
<img src="/assets/images/sponsor/runxinyun-light.png#only-light" alt="润信云" />
|
||||
<img src="/assets/images/sponsor/runxinyun-dark.png#only-dark" alt="润信云" />
|
||||
</a>
|
||||
|
||||
@@ -261,14 +261,13 @@
|
||||
}
|
||||
|
||||
.md-select__inner .md-select__list {
|
||||
padding: 6px !important;
|
||||
padding: 0.25rem !important;
|
||||
font-size: .75rem !important;
|
||||
border-radius: var(--component-border-radius) !important;
|
||||
}
|
||||
|
||||
.md-select__inner .md-select__list .md-select__item {
|
||||
margin: 1px;
|
||||
border-radius: var(--component-border-radius) !important;
|
||||
border-radius: calc(var(--component-border-radius) - 2px) !important;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
@@ -291,6 +290,20 @@
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
.hide-button {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.hide-button {
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
.md-header__title {
|
||||
margin-left: .4rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
.md-header__button {
|
||||
border-radius: 6px;
|
||||
|
||||
11
docs/theme/partials/header.html
vendored
11
docs/theme/partials/header.html
vendored
@@ -66,6 +66,17 @@
|
||||
{% include "partials/javascripts/palette.html" %}
|
||||
{% endif %}
|
||||
|
||||
{% if "material/search" in config.plugins %}
|
||||
{% set search = config.plugins["material/search"] | attr("config") %}
|
||||
{% if search.enabled %}
|
||||
<label class="md-header__button md-icon hide-button" onclick="OpenAlgoliaSearchComponent()">
|
||||
{% set icon = config.theme.icon.search or "octicons/search-16" %}
|
||||
{% include ".icons/" ~ icon ~ ".svg" %}
|
||||
</label>
|
||||
{% include "partials/search.html" %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if config.repo_url %}
|
||||
<div class="md-header__source">
|
||||
{% include "partials/source.html" %}
|
||||
|
||||
71
docs/theme/partials/search.html
vendored
Normal file
71
docs/theme/partials/search.html
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<div id="search-container">
|
||||
<div class="md-search__inner" role="search">
|
||||
<form class="md-search__form" name="search" onsubmit="return false;">
|
||||
<input type="text" class="md-search__input" name="query" aria-label="{{'AI Search' if i18n_page_locale == 'en' else 'AI 搜尋' if i18n_page_locale == 'zh-Hant' else 'AI 搜索'}}" placeholder="{{'AI Search' if i18n_page_locale == 'en' else 'AI 搜尋' if i18n_page_locale == 'zh-Hant' else 'AI 搜索'}}" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" readonly required onclick="OpenAlgoliaSearchComponent()" />
|
||||
<label class="md-search__icon md-icon" for="__search"> {% set icon = config.theme.icon.search or "material/magnify" %} {% include ".icons/" ~ icon ~ ".svg" %} {% set icon = config.theme.icon.previous or "material/arrow-left" %} {% include ".icons/" ~ icon ~ ".svg" %} </label>
|
||||
</form>
|
||||
<div class="md-search__output">
|
||||
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
|
||||
<div class="md-search-result" data-md-component="search-result">
|
||||
<div class="md-search-result__meta">{{ lang.t("search.result.initializer") }}</div>
|
||||
<ol class="md-search-result__list" role="presentation"></ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const __lang = "{{ i18n_page_locale }}";
|
||||
let __notReadyMsg = '';
|
||||
switch (__lang) {
|
||||
case 'en':
|
||||
__notReadyMsg = "The search component has not yet been loaded. Please try again later.";
|
||||
break;
|
||||
case 'zh-Hant':
|
||||
__notReadyMsg = "搜尋元件尚未載入完畢,請稍後再試。";
|
||||
break;
|
||||
default:
|
||||
__notReadyMsg = "搜索组件尚未加载完毕,请稍后再试。";
|
||||
}
|
||||
|
||||
function OpenAlgoliaSearchComponent() {
|
||||
const isMac = /Mac|iPhone|iPod|iPad/i.test(navigator.platform);
|
||||
const dispatched = document.dispatchEvent(new KeyboardEvent('keydown', {
|
||||
key: 'k',
|
||||
code: 'KeyK',
|
||||
ctrlKey: !isMac,
|
||||
metaKey: isMac,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.md-search__output {
|
||||
display: none !important;
|
||||
}
|
||||
.md-search__inner {
|
||||
padding-left: 8px;
|
||||
}
|
||||
.md-search__input {
|
||||
cursor: pointer !important;
|
||||
}
|
||||
.md-search__form {
|
||||
border-radius: 6px;
|
||||
}
|
||||
@media screen and (min-width: 60em) {
|
||||
.md-search-trigger {
|
||||
display: none;
|
||||
}
|
||||
.md-search__inner {
|
||||
width: 8.7rem;
|
||||
}
|
||||
}
|
||||
[class^="sitesearch-button"] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -16,14 +16,18 @@ nav:
|
||||
extra_javascript:
|
||||
- https://unpkg.com/vue/dist/vue.global.prod.js
|
||||
- https://unpkg.com/tdesign-vue-next/dist/tdesign.min.js
|
||||
- https://unpkg.com/@algolia/sitesearch@latest/dist/search-askai.min.js
|
||||
- assets/js/modules/tdesign-theme.js
|
||||
- assets/js/useThemeTransition.js
|
||||
- assets/js/common.js
|
||||
- assets/js/algolia-search/config.js
|
||||
- assets/js/algolia-search/index.js
|
||||
- assets/js/component.js
|
||||
- assets/js/components/mirrors-table/data.js
|
||||
- assets/js/components/mirrors-table/index.js
|
||||
extra_css:
|
||||
- https://unpkg.com/tdesign-vue-next/dist/tdesign.min.css
|
||||
- https://unpkg.com/@algolia/sitesearch@latest/dist/search-askai.min.css
|
||||
- stylesheets/extra.css
|
||||
|
||||
theme:
|
||||
|
||||
Reference in New Issue
Block a user