Skip to content

Commit 4674380

Browse files
committed
perf: optimize the naming of locale key
1 parent 25a1e93 commit 4674380

File tree

59 files changed

+662
-1251
lines changed

Some content is hidden

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

59 files changed

+662
-1251
lines changed

.tazerc.json

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

apps/backend-mock/src/modules/menu/menu.controller.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,31 @@ export class MenuController {
5050
const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
5151
const roleWithMenus = {
5252
admin: {
53-
component: '/demos/access/backend/access-test-2',
53+
component: '/demos/access/backend/admin-visible',
5454
meta: {
5555
icon: 'mdi:button-cursor',
56-
title: 'page.demos.access.access-test-2',
56+
title: 'page.demos.access.adminVisible',
5757
},
58-
name: 'AccessBackendTest2',
59-
path: 'access-test-2',
58+
name: 'AccessBackendAdminVisible',
59+
path: 'admin-visible',
6060
},
6161
super: {
62-
component: '/demos/access/backend/access-test-1',
62+
component: '/demos/access/backend/super-visible',
6363
meta: {
6464
icon: 'mdi:button-cursor',
65-
title: 'page.demos.access.access-test-1',
65+
title: 'page.demos.access.superVisible',
6666
},
67-
name: 'AccessBackendTest1',
68-
path: 'access-test-1',
67+
name: 'AccessBackendSuperVisible',
68+
path: 'super-visible',
6969
},
7070
user: {
71-
component: '/demos/access/backend/access-test-3',
71+
component: '/demos/access/backend/user-visible',
7272
meta: {
7373
icon: 'mdi:button-cursor',
74-
title: 'page.demos.access.access-test-3',
74+
title: 'page.demos.access.userVisible',
7575
},
76-
name: 'AccessBackendTest3',
77-
path: 'access-test-3',
76+
name: 'AccessBackendUserVisible',
77+
path: 'user-visible',
7878
},
7979
};
8080

@@ -105,7 +105,7 @@ export class MenuController {
105105
path: 'backend',
106106
meta: {
107107
icon: 'mdi:cloud-key-outline',
108-
title: 'page.demos.access.backend-control',
108+
title: 'page.demos.access.backendControl',
109109
},
110110
redirect: '/demos/access/backend/page-control',
111111
children: [
@@ -115,7 +115,7 @@ export class MenuController {
115115
component: '/demos/access/backend/index',
116116
meta: {
117117
icon: 'mdi:page-previous-outline',
118-
title: 'page.demos.access.page',
118+
title: 'page.demos.access.pageAccess',
119119
},
120120
},
121121
{
@@ -124,7 +124,7 @@ export class MenuController {
124124
component: '/demos/access/backend/button-control',
125125
meta: {
126126
icon: 'mdi:button-cursor',
127-
title: 'page.demos.access.button',
127+
title: 'page.demos.access.buttonControl',
128128
},
129129
},
130130
roleWithMenus[role],

apps/web-antd/src/apis/modules/user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { UserInfo } from '@vben/types';
22

3-
import type { UserApiType } from '../types';
3+
import type { UserApi } from '../types';
44

55
import { requestClient } from '#/forward';
66

77
/**
88
* 登录
99
*/
10-
async function userLogin(data: UserApiType.LoginParams) {
11-
return requestClient.post<UserApiType.LoginResult>('/auth/login', data);
10+
async function userLogin(data: UserApi.LoginParams) {
11+
return requestClient.post<UserApi.LoginResult>('/auth/login', data);
1212
}
1313

1414
/**

apps/web-antd/src/apis/types/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace UserApiType {
1+
namespace UserApi {
22
/** 登录接口参数 */
33
export interface LoginParams {
44
password: string;
@@ -16,4 +16,4 @@ namespace UserApiType {
1616
}
1717
}
1818

19-
export type { UserApiType };
19+
export type { UserApi };

apps/web-antd/src/bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function bootstrap(namespace: string) {
1717
await setupI18n(app, {
1818
defaultLocale: preferences.app.locale,
1919
loadMessages,
20-
missingWarn: import.meta.env.PROD,
20+
missingWarn: !import.meta.env.PROD,
2121
});
2222

2323
// 配置 pinia-store

apps/web-antd/src/forward/access.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async function generateAccess(options: GeneratorMenuAndRoutesOptions) {
2525
...options,
2626
fetchMenuListAsync: async () => {
2727
message.loading({
28-
content: `${$t('common.loading-menu')}...`,
28+
content: `${$t('common.loadingMenu')}...`,
2929
duration: 1.5,
3030
});
3131
return await getAllMenus();

apps/web-antd/src/locales/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const localesMap = loadLocalesMap(modules);
1616

1717
/**
1818
* 加载应用特有的语言包
19+
* 这里也可以改造为从服务端获取翻译数据
1920
* @param lang
2021
*/
2122
async function loadMessages(lang: SupportedLanguagesType) {

apps/web-antd/src/locales/langs/en-US.json

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,28 @@
44
"title": "Demos",
55
"access": {
66
"title": "Access Control",
7-
"frontend-control": "Front-end Control",
8-
"backend-control": "Backend Control",
9-
"page": "Page visit",
10-
"button": "Button control",
11-
"loading-menu": "In the loading menu",
12-
"access-test-1": "Super visit",
13-
"access-test-2": "Admin visit",
14-
"access-test-3": "User visit"
7+
"frontendControl": "Frontend Control",
8+
"backendControl": "Backend Control",
9+
"pageAccess": "Page Access",
10+
"buttonControl": "Button Control",
11+
"superVisible": "Visible to Super",
12+
"adminVisible": "Visible to Admin",
13+
"userVisible": "Visible to User"
1514
},
1615
"nested": {
1716
"title": "Nested Menu",
1817
"menu1": "Menu 1",
1918
"menu2": "Menu 2",
20-
"menu21": "Menu 2-1",
19+
"menu2_1": "Menu 2-1",
2120
"menu3": "Menu 3",
22-
"menu31": "Menu 3-1",
23-
"menu32": "Menu 3-2",
24-
"menu321": "Menu 3-2-1"
21+
"menu3_1": "Menu 3-1",
22+
"menu3_2": "Menu 3-2",
23+
"menu3_2_1": "Menu 3-2-1"
2524
},
2625
"outside": {
27-
"title": "External Page",
28-
"embedded": "embedded Page",
29-
"external-link": "External Link"
26+
"title": "External Pages",
27+
"embedded": "Embedded",
28+
"externalLink": "External Link"
3029
},
3130
"fallback": { "title": "Fallback Page" }
3231
}

apps/web-antd/src/locales/langs/zh-CN.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
"title": "演示",
55
"access": {
66
"title": "访问控制",
7-
"frontend-control": "前端控制",
8-
"backend-control": "后端控制",
9-
"page": "页面访问",
10-
"button": "按钮控制",
11-
"access-test-1": "Super 可见",
12-
"access-test-2": "Admin 可见",
13-
"access-test-3": "User 可见"
7+
"frontendControl": "前端控制",
8+
"backendControl": "后端控制",
9+
"pageAccess": "页面访问",
10+
"buttonControl": "按钮控制",
11+
"superVisible": "Super 可见",
12+
"adminVisible": "Admin 可见",
13+
"userVisible": "User 可见"
1414
},
1515
"nested": {
1616
"title": "嵌套菜单",
1717
"menu1": "菜单 1",
1818
"menu2": "菜单 2",
19-
"menu21": "菜单 2-1",
19+
"menu2_1": "菜单 2-1",
2020
"menu3": "菜单 3",
21-
"menu31": "菜单 3-1",
22-
"menu32": "菜单 3-2",
23-
"menu321": "菜单 3-2-1"
21+
"menu3_1": "菜单 3-1",
22+
"menu3_2": "菜单 3-2",
23+
"menu3_2_1": "菜单 3-2-1"
2424
},
2525
"outside": {
2626
"title": "外部页面",
2727
"embedded": "内嵌",
28-
"external-link": "外链"
28+
"externalLink": "外链"
2929
},
3030
"fallback": {
3131
"title": "缺省页"

apps/web-antd/src/router/routes/_essentials.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const essentialsRoutes: RouteRecordRaw[] = [
6060
component: () =>
6161
import('#/views/_essential/authentication/qrcode-login.vue'),
6262
meta: {
63-
title: $t('page.essentials.qrcode-login'),
63+
title: $t('page.essentials.qrcodeLogin'),
6464
},
6565
},
6666
{
@@ -69,7 +69,7 @@ const essentialsRoutes: RouteRecordRaw[] = [
6969
component: () =>
7070
import('#/views/_essential/authentication/forget-password.vue'),
7171
meta: {
72-
title: $t('page.essentials.forget-password'),
72+
title: $t('page.essentials.forgetPassword'),
7373
},
7474
},
7575
{

0 commit comments

Comments
 (0)