Skip to content

Commit c0ed7f4

Browse files
zhangpan-softzhangpan
andauthored
修复已知问题 (#13)
修改国际化布局, 更规范化 调整所有示例代码为国际化 Co-authored-by: zhangpan <zhangpan@uu898.com>
1 parent 9156a5b commit c0ed7f4

File tree

18 files changed

+506
-181
lines changed

18 files changed

+506
-181
lines changed

src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useStore } from 'vuex'
99
import { useI18n } from 'vue-i18n'
1010
import { useRoute } from 'vue-router'
1111
import getPageTitle from '@/utils/get-page-title'
12+
import { onMounted } from 'vue'
1213
const store = useStore()
1314
const i18n = useI18n()
1415
const route = useRoute()
@@ -19,7 +20,7 @@ store.watch(
1920
(value) => {
2021
i18n.locale.value = value
2122
if (route.meta && route.meta.title) {
22-
document.title = getPageTitle(i18n.t(route.meta.title as string))
23+
document.title = getPageTitle(i18n.t((route.meta.title as string) || ''))
2324
}
2425
}
2526
)

src/components/Breadcrumb/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ function getBreadcrumb() {
3333
let matched = currentRoute.matched.filter((item) => item.meta && item.meta.title)
3434
const first = matched[0]
3535
if (!isDashboard(first)) {
36-
matched = [{ path: '/dashboard', meta: { title: 'route.dashboard' } } as any].concat(matched)
36+
matched = [
37+
{ path: '/dashboard', meta: { title: 'routes.dashboard.dashboard.title' } } as any
38+
].concat(matched)
3739
}
3840
breadcrumbs.value = matched.filter((item) => {
3941
return item.meta && item.meta.title && item.meta.breadcrumb !== false

src/layout/components/Navbar.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,19 @@ function logout() {
7070
confirmButtonText: '确定',
7171
cancelButtonText: '取消',
7272
type: 'warning'
73-
}).then(() => {
74-
store.dispatch('user/logout').then(() => {
75-
router.push(`/login?redirect=${route.fullPath}`)
76-
})
7773
})
74+
.then(() => {
75+
store.dispatch('user/logout').then(() => {
76+
router.push(`/login?redirect=${route.fullPath}`)
77+
})
78+
})
79+
.catch(() => {
80+
// pass
81+
})
7882
}
7983
8084
function settings() {
81-
router.push('/settings')
85+
router.push('/system/settings')
8286
}
8387
</script>
8488

src/layout/components/Sidebar/SidebarItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const onlyOneChild = ref() // 临时变量,唯一子路由
3939
function hasOneShowingChild(children = [], parent: any) {
4040
// 需要显示的子路由数组
4141
const showingChildren = children.filter((item: any) => {
42-
if (item.meta?.hidden) {
42+
if (item?.hidden) {
4343
return false // 过滤不显示的子路由
4444
} else {
4545
onlyOneChild.value = item // 唯一子路由赋值(多个子路由情况 onlyOneChild 变量是用不上的)

src/permission.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export default {
1818
NProgress.start()
1919

2020
// set page title
21-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
22-
// @ts-ignore
23-
document.title = getPageTitle(i18n.global.t(to.meta.title))
21+
document.title = getPageTitle(i18n.global.t((to.meta.title as string) || ''))
2422

2523
// determine whether the user has logged in
2624
const hasToken = getToken()

src/plugins/lang/package/en.ts

Lines changed: 181 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,186 @@
11
export default {
22
// 路由国际化
3-
route: {
4-
dashboard: 'Dashboard',
5-
document: 'Document',
6-
example: 'Example',
7-
table: 'Table',
8-
tree: 'Tree',
9-
form: 'Form',
10-
nested: 'Nested',
11-
menu1: 'Menu1',
12-
menu1_1: 'Menu1-1',
13-
menu1_2: 'Menu1-2',
14-
menu1_2_1: 'Menu1-2-1',
15-
menu1_2_2: 'Menu1-2-2',
16-
menu1_3: 'Menu1-3',
17-
menu2: 'Menu2',
18-
externalLink: 'External Link',
19-
test1: 'Test1',
20-
system: 'System',
21-
settings: 'Settings'
3+
routes: {
4+
dashboard: {
5+
dashboard: {
6+
title: 'Dashboard'
7+
}
8+
},
9+
example: {
10+
title: 'Example',
11+
table: {
12+
title: 'Table'
13+
},
14+
tree: {
15+
title: 'Tree'
16+
}
17+
},
18+
form: {
19+
form: {
20+
title: 'Form'
21+
}
22+
},
23+
nested: {
24+
title: 'Nested',
25+
menu1: {
26+
title: 'Menu1',
27+
menu1_1: {
28+
title: 'Menu1-1'
29+
},
30+
menu1_2: {
31+
title: 'Menu1-2',
32+
menu1_2_1: {
33+
title: 'Menu1-2-1'
34+
},
35+
menu1_2_2: {
36+
title: 'Menu1-2-2'
37+
}
38+
},
39+
menu1_3: {
40+
title: 'Menu1-3'
41+
}
42+
},
43+
menu2: {
44+
title: 'Menu2'
45+
}
46+
},
47+
externalLink: {
48+
externalLink: {
49+
title: 'External Link'
50+
}
51+
},
52+
tests: {
53+
test1: {
54+
title: 'Test1'
55+
}
56+
},
57+
system: {
58+
title: 'System Management',
59+
settings: {
60+
title: 'System Settings'
61+
}
62+
}
63+
},
64+
// 页面国际化
65+
views: {
66+
dashboard: {},
67+
form: {
68+
activityName: 'Activity Name',
69+
activityType: 'Activity Type',
70+
activityTime: 'Activity Time',
71+
activityAddress: 'Activity Address',
72+
activityZone: 'Activity Zone',
73+
activityZoneOptions: [
74+
{
75+
value: 'beijing',
76+
label: 'Beijing'
77+
},
78+
{
79+
value: 'shanghai',
80+
label: 'Shanghai'
81+
}
82+
],
83+
activityZonePlaceholder: 'Please select your zone',
84+
activityTimePlaceholder: 'Pick a time',
85+
instantDelivery: 'Instant Delivery',
86+
activityTypeChecks: [
87+
{
88+
label: 'Online Activity',
89+
value: 1
90+
},
91+
{
92+
label: 'Promotion Activity',
93+
value: 2
94+
},
95+
{
96+
label: 'Offline Activity',
97+
value: 3
98+
},
99+
{
100+
label: 'Pure Brand Exposure',
101+
value: 4
102+
}
103+
],
104+
resources: 'Resources',
105+
resourcesOptions: [
106+
{
107+
value: 'Sponsor',
108+
label: 'Sponsor'
109+
},
110+
{
111+
value: 'Venue',
112+
label: 'Venue'
113+
}
114+
],
115+
activityDesc: 'Activity Description',
116+
btn: {
117+
submit: 'Create',
118+
cancel: 'Cancel'
119+
},
120+
elMessages: {
121+
submit: 'submit!',
122+
cancel: 'cancel!'
123+
}
124+
},
125+
login: {
126+
title: 'Login',
127+
usernamePlaceholder: 'Please enter your username',
128+
passwordPlaceholder: 'Please enter your password',
129+
btn: {
130+
login: 'Login'
131+
},
132+
tips: {
133+
username: 'Username:admin',
134+
password: 'Password:any'
135+
}
136+
},
137+
nested: {
138+
menu1: {
139+
menu1_1: {},
140+
menu1_2: {
141+
menu1_2_1: {},
142+
menu1_2_2: {}
143+
},
144+
menu1_3: {}
145+
},
146+
menu2: {}
147+
},
148+
system: {
149+
settings: {
150+
languageTitle: 'Language Preference',
151+
currentLanguage: 'Current Language',
152+
languageOptions: [
153+
{
154+
value: 'zh-cn',
155+
label: 'Chinese'
156+
},
157+
{
158+
value: 'en',
159+
label: 'English'
160+
}
161+
],
162+
changeLanguage: 'Change Language'
163+
}
164+
},
165+
// 表格
166+
table: {
167+
id: 'ID',
168+
title: 'Title',
169+
author: 'Author',
170+
pageviews: 'Pageviews',
171+
createdAt: 'Created At',
172+
status: 'Status'
173+
},
174+
tree: {
175+
filterTextPlaceholder: 'Filter keyword'
176+
},
177+
notFount: {
178+
// The webmaster said that you can not enter this page...
179+
message: 'The webmaster said that you can not enter this page...',
180+
bullshitInfo:
181+
'Please check that the URL you entered is correct, or click the button below to return to the homepage.',
182+
bullshitReturnHome: 'Back to home'
183+
}
22184
},
23185
// 登录页面国际化
24186
login: {
@@ -36,21 +198,6 @@ export default {
36198
github: 'Github',
37199
settings: 'Settings'
38200
},
39-
settings: {
40-
languageTitle: 'Language Preference',
41-
currentLanguage: 'Current Language',
42-
languageOptions: [
43-
{
44-
value: 'zh-cn',
45-
label: 'Chinese'
46-
},
47-
{
48-
value: 'en',
49-
label: 'English'
50-
}
51-
],
52-
changeLanguage: 'Change Language'
53-
},
54201
language: {
55202
'zh-cn': 'Chinese',
56203
en: 'English'

0 commit comments

Comments
 (0)