Skip to content

Commit 998aed2

Browse files
committed
feat: support more languages for the guide page
1 parent e7d4967 commit 998aed2

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
"@crowdin/crowdin-api-client": "^1.51.1",
3232
"@emotion/babel-plugin": "^11.13.5",
3333
"@emotion/css": "^11.13.5",
34-
"@rsdoctor/rspack-plugin": "^1.4.0",
34+
"@rsdoctor/rspack-plugin": "^1.5.0",
3535
"@rspack/cli": "^1.7.2",
3636
"@rspack/core": "^1.7.2",
3737
"@swc/core": "^1.15.8",
3838
"@swc/jest": "^0.2.39",
3939
"@types/chrome": "0.1.33",
4040
"@types/decompress": "^4.2.7",
4141
"@types/jest": "^30.0.0",
42-
"@types/node": "^25.0.7",
42+
"@types/node": "^25.0.8",
4343
"@types/punycode": "^2.1.4",
4444
"@vue/babel-plugin-jsx": "^2.0.1",
4545
"babel-loader": "^10.0.0",

src/pages/app/Layout/menu/Nav.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Flex from '@pages/components/Flex'
1414
import { ElBreadcrumb, ElBreadcrumbItem, ElIcon, ElMenu, ElMenuItem, useNamespace } from "element-plus"
1515
import { defineComponent, h, onBeforeMount, ref, watch } from "vue"
1616
import { useRouter } from "vue-router"
17-
import { type MenuItem, NAV_MENUS } from "./item"
17+
import { type MenuItem, navMenus } from "./item"
1818
import { handleClick, initTitle } from "./route"
1919
import { colorMenu } from './style'
2020

@@ -42,12 +42,13 @@ const useStyle = () => {
4242
return { containerCls, menuWrapperCls }
4343
}
4444

45-
const findTitle = (routePath: string): string => {
46-
const title = NAV_MENUS.find(v => routePath === v.route)?.title
45+
const findTitle = (routePath: string, menus: MenuItem[]): string => {
46+
const title = menus.find(v => routePath === v.route)?.title
4747
return title ? t(title) : ''
4848
}
4949

5050
const _default = defineComponent<{}>(() => {
51+
const menus = navMenus()
5152
const router = useRouter()
5253
const title = ref('')
5354
const [showMenu, , closeMenu, toggleMenu] = useSwitch(false)
@@ -58,7 +59,7 @@ const _default = defineComponent<{}>(() => {
5859

5960
const syncRouter = () => {
6061
const route = router.currentRoute.value
61-
route && (title.value = findTitle(route.path))
62+
route && (title.value = findTitle(route.path, menus))
6263
}
6364

6465
watch(router.currentRoute, syncRouter)
@@ -86,7 +87,7 @@ const _default = defineComponent<{}>(() => {
8687
</Flex>
8788
<div class={menuWrapperCls} v-show={showMenu.value}>
8889
<ElMenu>
89-
{NAV_MENUS.map(item => (
90+
{menus.map(item => (
9091
<ElMenuItem
9192
index={item.index ?? item.route ?? item.href}
9293
onClick={() => handleItemClick(item)}

src/pages/app/Layout/menu/Side.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { colorVariant } from '@pages/util/style'
1616
import { ElCollapseTransition, ElIcon, ElMenu, ElMenuItem, ElMenuItemGroup, ElScrollbar, ElText, ElTooltip, useNamespace } from "element-plus"
1717
import { defineComponent, h, nextTick, onMounted, type Ref, ref, type StyleValue, watch } from "vue"
1818
import { type Router, useRouter } from "vue-router"
19-
import { MENU_GROUPS, type MenuItem } from "./item"
19+
import { menuGroups, type MenuItem } from "./item"
2020
import { handleClick, initTitle } from "./route"
2121
import { colorMenu } from './style'
2222

@@ -83,6 +83,7 @@ const _default = defineComponent(() => {
8383
tooltipVisible, setTooltipVisible,
8484
} = useCollapseState()
8585
const cls = useStyle()
86+
const menus = menuGroups()
8687

8788
return () => (
8889
<Flex
@@ -101,8 +102,8 @@ const _default = defineComponent(() => {
101102
} satisfies StyleValue}
102103
>
103104
{collapsed.value
104-
? MENU_GROUPS.flatMap(g => g.children).map(item => renderItem(item, router, curr))
105-
: MENU_GROUPS.map(({ children, title }) => (
105+
? menus.flatMap(g => g.children).map(item => renderItem(item, router, curr))
106+
: menus.map(({ children, title }) => (
106107
<ElMenuItemGroup title={t(title)}>
107108
{children.map(item => renderItem(item, router, curr))}
108109
</ElMenuItemGroup>

src/pages/app/Layout/menu/item.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type MenuGroup = Omit<MenuItem, 'href' | 'route'> & {
3939
/**
4040
* Menu items
4141
*/
42-
export const MENU_GROUPS: MenuGroup[] = [{
42+
export const menuGroups = (): MenuGroup[] => [{
4343
title: msg => msg.menu.data,
4444
index: 'data',
4545
icon: Histogram,
@@ -121,4 +121,4 @@ export const MENU_GROUPS: MenuGroup[] = [{
121121
}]
122122
}]
123123

124-
export const NAV_MENUS: MenuItem[] = MENU_GROUPS.flatMap(g => g.children || []).filter(m => m.mobile)
124+
export const navMenus = (): MenuItem[] => menuGroups().flatMap(g => g.children || []).filter(m => m.mobile)

src/pages/app/Layout/menu/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createTabAfterCurrent } from "@api/chrome/tab"
22
import { type I18nKey, t } from "@app/locale"
33
import { type Ref } from "vue"
44
import { type Router } from "vue-router"
5-
import { type MenuItem, MENU_GROUPS } from "./item"
5+
import { type MenuItem, menuGroups } from "./item"
66

77
function openMenu(route: string, title: I18nKey, router: Router) {
88
const currentPath = router.currentRoute.value?.path
@@ -27,7 +27,7 @@ export function handleClick(menuItem: MenuItem, router: Router, currentActive?:
2727
export async function initTitle(router: Router) {
2828
await router.isReady()
2929
const currentPath = router.currentRoute.value.path
30-
for (const group of MENU_GROUPS) {
30+
for (const group of menuGroups()) {
3131
for (const { route, title } of group.children) {
3232
const docTitle = route === currentPath && t(title)
3333
if (docTitle) {

src/util/constant/url.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ export function getAppPageUrl(route?: string, query?: any): string {
7878
}
7979

8080
export const HOMEPAGE = "https://www.wfhg.cc"
81-
const HOMEPAGE_LOCALES: timer.Locale[] = ["zh_CN", "zh_TW", "en"]
81+
const HOMEPAGE_LOCALES: timer.Locale[] = [
82+
"zh_CN", "zh_TW", "en",
83+
"ja", "de", "ru",
84+
"fr", "es", "pt_PT",
85+
]
8286

8387
export function getHomepageWithLocale(): string {
8488
const homepageLocale: timer.Locale = HOMEPAGE_LOCALES.includes(locale) ? locale : "en"

0 commit comments

Comments
 (0)