Skip to content

Commit 5bc58dd

Browse files
committed
♻️ 对整个文档进行了彻底的重构,修复了中文的各种问题
1. 现在 sildbar 导航自动生成 1. 现在 search 能正确显示标定语言 1. 现在 config 中的多语言全部提取到 i18n/*.json 来配置 1. 暂时移除了原有的en 1. 现在dev模式下,默认禁用 local-search
1 parent ae5bc2d commit 5bc58dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+450
-4206
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ __pycache__
1515

1616
package-lock.json
1717
pnpm-lock.yaml
18+
en.bak

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@jsr:registry=https://npm.jsr.io

docs/.vitepress/components/DownloadLink.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const findQuery = (key: string) => {
5353
return (query.get(key) ?? query.get(key.toLowerCase())) || undefined;
5454
};
5555
const releaseAssets = latestReleaseAssets();
56-
console.log("latestReleaseAssets", releaseAssets);
56+
// console.log("latestReleaseAssets", releaseAssets);
5757
5858
const download_channels = [
5959
{ name: "原始", transfer: (url: string) => url },

docs/.vitepress/components/IncFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const beian = getBeianCode();
1010
<a href="https://github.com/BioforestChain/dweb_browser">BioforestChain</a>
1111
</footer>
1212
</template>
13-
<style lang="scss">
13+
<style lang="scss" scoped>
1414
footer {
1515
margin-top: 8em;
1616
font-size: 12px;

docs/.vitepress/components/IncFooterScript.vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
2-
export function getBeianCode(hostname = location.hostname) {
2+
const location_hostname = typeof location!=='undefined'?location.hostname:''
3+
export function getBeianCode(hostname = location_hostname) {
34
if (
45
hostname === "dweb-browser.com" ||
56
hostname.endsWith("dweb-browser.com")
@@ -14,18 +15,19 @@ export function getBeianCode(hostname = location.hostname) {
1415
}
1516
</script>
1617
<script setup lang="ts">
17-
const hook = () => {
18-
const beian = document.getElementById("beian");
19-
if (beian) {
20-
beian.innerHTML = getBeianCode();
21-
return true;
18+
if (typeof document !== "undefined") {
19+
const hook = () => {
20+
const beian = document.getElementById("beian");
21+
if (beian) {
22+
beian.innerHTML = getBeianCode();
23+
return true;
24+
}
25+
return false;
26+
};
27+
document.addEventListener("DOMContentLoaded", hook);
28+
if (!hook()) {
29+
requestAnimationFrame(hook);
2230
}
23-
return false;
24-
};
25-
document.addEventListener("DOMContentLoaded", hook);
26-
if (!hook()) {
27-
requestAnimationFrame(hook);
2831
}
2932
</script>
3033
<template></template>
31-
<style lang="css"></style>

docs/.vitepress/config.mts

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import {
22
defaultHoverInfoProcessor,
33
transformerTwoslash,
44
} from "@shikijs/vitepress-twoslash";
5-
import {
6-
groupIconMdPlugin,
7-
groupIconVitePlugin,
8-
} from "vitepress-plugin-group-icons";
95
import { defineConfig } from "vitepress";
10-
// import { ar, arSearch } from "./ar.mts";
11-
import { en, enSearch } from "./en.mts";
6+
import { groupIconMdPlugin } from "vitepress-plugin-group-icons";
127
// import { es, esSearch } from "./es.mts";
8+
import { getAllLocaleConfig, i18n, rootLang } from "./i18n.mts";
139
import vite from "./vite.config.mts";
14-
import { zh, zhSearch } from "./zh.mts";
1510

16-
const js = String.raw;
11+
const all = getAllLocaleConfig();
12+
13+
/**
14+
* 开发模式下,默认禁用搜索能力,如果有需要,手动开启
15+
*/
16+
const enableSearch = process.env.npm_lifecycle_event === "build";
17+
1718
// https://vitepress.dev/reference/site-config
1819
export default defineConfig({
1920
title: "DwebBrowser",
20-
description: "一个提供分布式网络 | 应用附着的浏览器。",
2121
lastUpdated: true,
2222
cleanUrls: false,
2323
markdown: {
@@ -39,17 +39,16 @@ export default defineConfig({
3939
},
4040
// errorRendering: 'hover',
4141
processHoverInfo(info) {
42-
return defaultHoverInfoProcessor(info)
43-
// Remove shiki_core namespace
44-
.replace(/_shikijs_core\w*\./g, "");
42+
return (
43+
defaultHoverInfoProcessor(info)
44+
// Remove shiki_core namespace
45+
.replace(/_shikijs_core\w*\./g, "")
46+
);
4547
},
4648
}),
47-
],
49+
] as any,
4850
},
49-
head: [
50-
["link", { rel: "icon", type: "image/svg+xml", href: "/logo.svg" }],
51-
["link", { rel: "icon", type: "image/png", href: "/logo.png" }],
52-
],
51+
head: [["link", { rel: "icon", type: "image/svg+xml", href: "/logo.svg" }]],
5352
themeConfig: {
5453
logo: "/logo.svg",
5554

@@ -60,20 +59,23 @@ export default defineConfig({
6059
},
6160
],
6261

63-
search: {
64-
provider: "local",
65-
options: {
66-
locales: { ...zhSearch, ...enSearch }, // ...arSearch, ...esSearch
67-
},
68-
},
69-
},
70-
locales: {
71-
root: { label: "简体中文", ...zh },
72-
en: { label: "English", ...en },
73-
// es: { label: "Spanish", ...es },
74-
// ar: { label: "Arabic", ...ar },
62+
search: enableSearch
63+
? {
64+
provider: "local",
65+
options: {
66+
locales: Object.keys(all).reduce((locales, key) => {
67+
locales[key === rootLang ? "root" : key] = all[key].search;
68+
return locales;
69+
}, {}),
70+
},
71+
}
72+
: undefined,
7573
},
76-
vite,
74+
locales: Object.keys(all).reduce((locales, key) => {
75+
locales[key === rootLang ? "root" : key] = i18n(key, all[key]);
76+
return locales;
77+
}, {}),
78+
vite: vite as any,
7779
vue: {
7880
template: {
7981
compilerOptions: {

docs/.vitepress/en.mts

Lines changed: 0 additions & 235 deletions
This file was deleted.

0 commit comments

Comments
 (0)