This commit is contained in:
恍兮惚兮 2024-07-19 12:52:46 +08:00
parent 341e57ae2d
commit f37f8c664c
4 changed files with 13 additions and 10 deletions

0
docs/README.md Normal file
View File

View File

@ -58,9 +58,9 @@
语言/Language 语言/Language
</span> </span>
<div class="dropdown-content "> <div class="dropdown-content ">
<a class="goodlink buttonsize" href="#/zh/">简体中文<br></a> <a class="goodlink buttonsize" onclick="switchlang(`zh`)">简体中文<br></a>
<a class="goodlink buttonsize" href="#/en/">English<br></a> <a class="goodlink buttonsize" onclick="switchlang(`en`)">English<br></a>
<a class="goodlink buttonsize" href="#/ru/">Русский язык<br></a> <a class="goodlink buttonsize" onclick="switchlang(`ru`)">Русский язык<br></a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,7 +4,7 @@ window.$docsify = {
requestHeaders: { requestHeaders: {
'cache-control': 'max-age=0', 'cache-control': 'max-age=0',
}, },
notFoundPage: 'redirect.html',
pagination: { pagination: {
previousText: '上一节', previousText: '上一节',
nextText: '下一节', nextText: '下一节',
@ -37,11 +37,10 @@ window.$docsify = {
} }
}, },
executeScript: true executeScript: true,
} }
let dropdowns = document.getElementsByClassName('dropdown') let dropdowns = document.getElementsByClassName('dropdown')
for (let i = 0; i < dropdowns.length; i++) { for (let i = 0; i < dropdowns.length; i++) {
@ -87,11 +86,14 @@ function getcurrlang(url) {
} }
return '' return ''
} }
function switchlang(lang) {
window.location.href = window.location.href.replace('/' + currentlang + '/', '/' + lang + '/')
}
window.onpopstate = function (event) { window.onpopstate = function (event) {
let url = window.location.href; let url = window.location.href;
console.log(url)
if (url.endsWith('/#/')) { if (url.endsWith('/#/')) {
window.location.href += 'zh/' let lang = window.localStorage.currentlang ? window.localStorage.currentlang : 'zh'
window.location.href += lang + '/'
return return
} }
for (let key in navitexts) { for (let key in navitexts) {
@ -101,9 +103,9 @@ window.onpopstate = function (event) {
} }
} }
let thislang = getcurrlang(url) let thislang = getcurrlang(url)
window.localStorage.currentlang = thislang
if (thislang != currentlang) { if (thislang != currentlang) {
currentlang = thislang currentlang = thislang
console.log(navitexts[currentlang])
for (let key in navitexts[currentlang]) { for (let key in navitexts[currentlang]) {
document.getElementById(key).innerText = navitexts[currentlang][key] document.getElementById(key).innerText = navitexts[currentlang][key]

1
docs/redirect.html Normal file
View File

@ -0,0 +1 @@
<meta http-equiv="refresh" content="0; URL=/#/">