[v1] init commit for v1 docs (#10145)

Co-authored-by: frozenleaves <frozen@Mac.local>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: jiaqiw09 <jiaqiw960714@gmail.com>
Co-authored-by: jiaqiw09 <60021713+jiaqiw09@users.noreply.github.com>
Co-authored-by: Yaowei Zheng <hiyouga@buaa.edu.cn>
This commit is contained in:
浮梦
2026-02-09 19:43:55 +08:00
committed by GitHub
parent ea644d04ec
commit 1d5e8ebcd0
63 changed files with 2237 additions and 0 deletions

50
docs/_static/css/lang-switcher.css vendored Normal file
View File

@@ -0,0 +1,50 @@
.lang-switcher {
display: flex;
align-items: center;
justify-content: center;
}
.lang-switcher__select {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
padding: 6px 28px 6px 10px;
border-radius: 999px;
border: 1px solid rgba(0, 0, 0, 0.18);
background-color: #ffffff;
color: #333333;
font-size: 13px;
line-height: 18px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
cursor: pointer;
background-image: linear-gradient(45deg, transparent 50%, #667085 50%),
linear-gradient(135deg, #667085 50%, transparent 50%);
background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
background-size: 5px 5px, 5px 5px;
background-repeat: no-repeat;
}
.lang-switcher__select:focus {
outline: none;
border-color: rgba(41, 128, 185, 0.65);
box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.18);
}
.wy-side-nav-search .lang-switcher {
margin-top: 10px;
}
.wy-side-nav-search .lang-switcher__select {
border-color: rgba(255, 255, 255, 0.18);
background-color: rgba(255, 255, 255, 0.08);
color: #ffffff;
box-shadow: none;
background-image: linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.75) 50%),
linear-gradient(135deg, rgba(255, 255, 255, 0.75) 50%, transparent 50%);
}
.wy-side-nav-search .lang-switcher__select:focus {
border-color: rgba(255, 255, 255, 0.45);
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

93
docs/_static/js/switcher.js vendored Normal file
View File

@@ -0,0 +1,93 @@
document.addEventListener('DOMContentLoaded', function () {
var path = window.location.pathname || '';
var isZh = path.indexOf('/zh/') !== -1;
var isEn = path.indexOf('/en/') !== -1;
if (!isZh && !isEn) return;
var currentLang = isZh ? 'zh' : 'en';
function buildSwitcher() {
var container = document.createElement('div');
container.className = 'lang-switcher';
var select = document.createElement('select');
select.setAttribute('aria-label', 'Language');
select.className = 'lang-switcher__select';
var optionZh = document.createElement('option');
optionZh.value = 'zh';
optionZh.textContent = 'Simplified Chinese';
optionZh.selected = isZh;
var optionEn = document.createElement('option');
optionEn.value = 'en';
optionEn.textContent = 'English';
optionEn.selected = isEn;
select.appendChild(optionZh);
select.appendChild(optionEn);
select.addEventListener('change', function () {
var nextLang = select.value;
if (nextLang === currentLang) return;
var targetUrl = path.replace('/' + currentLang + '/', '/' + nextLang + '/');
window.location.href = targetUrl + window.location.search + window.location.hash;
});
container.appendChild(select);
return container;
}
function hideOtherLanguageToc() {
var captions = document.querySelectorAll('p.caption');
for (var i = 0; i < captions.length; i++) {
var caption = captions[i];
var textEl = caption.querySelector('.caption-text');
if (!textEl) continue;
var label = (textEl.textContent || '').trim().toLowerCase();
var isCaptionZh = label === '中文' || label === 'chinese' || label === 'zh';
var isCaptionEn = label === 'english' || label === 'en';
if (!isCaptionZh && !isCaptionEn) continue;
var shouldHide = (currentLang === 'zh' && isCaptionEn) || (currentLang === 'en' && isCaptionZh);
var shouldHideCaption = true;
var next = caption.nextElementSibling;
if (next && next.tagName && next.tagName.toLowerCase() === 'ul') {
if (shouldHide) {
caption.style.display = 'none';
next.style.display = 'none';
} else if (shouldHideCaption) {
caption.style.display = 'none';
}
} else if (shouldHide) {
caption.style.display = 'none';
} else if (shouldHideCaption) {
caption.style.display = 'none';
}
}
}
var side = document.querySelector('.wy-side-nav-search');
if (side) {
var sideSwitcher = buildSwitcher();
sideSwitcher.style.marginTop = '8px';
sideSwitcher.style.display = 'flex';
sideSwitcher.style.justifyContent = 'center';
side.appendChild(sideSwitcher);
} else {
var topRight = buildSwitcher();
topRight.style.position = 'fixed';
topRight.style.top = '12px';
topRight.style.right = '12px';
topRight.style.zIndex = '9999';
document.body.appendChild(topRight);
}
hideOtherLanguageToc();
window.addEventListener('load', hideOtherLanguageToc);
setTimeout(hideOtherLanguageToc, 50);
setTimeout(hideOtherLanguageToc, 300);
});