@liujitcn/kratos-admin-core 0.0.20 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +2 -2
  2. package/dist/package/declarations/src/api/base/language.d.ts +8 -0
  3. package/dist/package/declarations/src/components/Dialog/ProDialog.vue.d.ts +1 -0
  4. package/dist/package/declarations/src/components/Dict/index.vue.d.ts +4 -3
  5. package/dist/package/declarations/src/components/Dict/value.d.ts +11 -0
  6. package/dist/package/declarations/src/components/LocaleSwitch/index.vue.d.ts +3 -0
  7. package/dist/package/declarations/src/index.d.ts +2 -0
  8. package/dist/package/declarations/src/locales/generated.d.ts +3382 -0
  9. package/dist/package/declarations/src/locales/index.d.ts +53 -0
  10. package/dist/package/declarations/src/modules/index.d.ts +7 -2
  11. package/dist/package/declarations/src/request.d.ts +1 -0
  12. package/dist/package/declarations/src/routers/modules/staticRouter.d.ts +1 -0
  13. package/dist/package/declarations/src/rpc/base/v1/config.d.ts +13 -1
  14. package/dist/package/declarations/src/rpc/base/v1/language.d.ts +20 -0
  15. package/dist/package/declarations/src/rpc/base/v1/login.d.ts +13 -1
  16. package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +1 -1
  17. package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +9 -0
  18. package/dist/package/declarations/src/rpc/system/admin/v1/base_translation.d.ts +75 -0
  19. package/dist/package/declarations/src/rpc/system/admin/v1/common.d.ts +13 -0
  20. package/dist/package/declarations/src/stores/interface/index.d.ts +2 -0
  21. package/dist/package/declarations/src/stores/modules/auth.d.ts +6 -6
  22. package/dist/package/declarations/src/stores/runtime.d.ts +1 -0
  23. package/dist/package/declarations/src/utils/dict.d.ts +2 -2
  24. package/dist/package/declarations/src/utils/index.d.ts +1 -1
  25. package/dist/package/declarations/src/utils/oauthProvider.d.ts +2 -0
  26. package/dist/package/declarations/src/utils/passwordCrypto.d.ts +1 -1
  27. package/dist/package/declarations/src/utils/passwordStrength.d.ts +0 -7
  28. package/dist/package/src/App.vue +5 -2
  29. package/dist/package/src/api/base/language.ts +20 -0
  30. package/dist/package/src/api/base/oauth.ts +0 -1
  31. package/dist/package/src/api/system/auth.ts +0 -1
  32. package/dist/package/src/bootstrap.ts +57 -2
  33. package/dist/package/src/components/CronExpression/index.vue +80 -82
  34. package/dist/package/src/components/Dialog/FormDialog.vue +10 -5
  35. package/dist/package/src/components/Dialog/ProDialog.vue +10 -4
  36. package/dist/package/src/components/Dict/index.vue +26 -9
  37. package/dist/package/src/components/Dict/value.ts +18 -0
  38. package/dist/package/src/components/ECharts/config/index.ts +6 -1
  39. package/dist/package/src/components/ErrorMessage/index.vue +3 -1
  40. package/dist/package/src/components/ImportExcel/index.vue +29 -18
  41. package/dist/package/src/components/LocaleSwitch/index.vue +28 -0
  42. package/dist/package/src/components/PasswordStrength/index.vue +8 -5
  43. package/dist/package/src/components/ProForm/components/DynamicList.vue +8 -3
  44. package/dist/package/src/components/ProForm/components/KvList.vue +14 -6
  45. package/dist/package/src/components/ProForm/index.vue +2 -2
  46. package/dist/package/src/components/ProTable/components/ColSetting.vue +7 -5
  47. package/dist/package/src/components/ProTable/components/TableColumn.vue +2 -1
  48. package/dist/package/src/components/ProTable/index.vue +36 -11
  49. package/dist/package/src/components/SearchForm/components/SearchFormItem.vue +9 -4
  50. package/dist/package/src/components/SearchForm/index.vue +6 -3
  51. package/dist/package/src/components/SelectFilter/index.vue +4 -1
  52. package/dist/package/src/components/SelectIcon/index.vue +8 -4
  53. package/dist/package/src/components/TreeFilter/index.vue +14 -6
  54. package/dist/package/src/components/Upload/File.vue +18 -13
  55. package/dist/package/src/components/Upload/Files.vue +22 -15
  56. package/dist/package/src/components/Upload/Img.vue +14 -11
  57. package/dist/package/src/components/Upload/Imgs.vue +15 -12
  58. package/dist/package/src/components/WangEditor/index.vue +12 -4
  59. package/dist/package/src/directives/modules/copy.ts +2 -1
  60. package/dist/package/src/hooks/useDownload.ts +3 -2
  61. package/dist/package/src/hooks/useHandleData.ts +5 -4
  62. package/dist/package/src/hooks/useTheme.ts +2 -1
  63. package/dist/package/src/hooks/useTime.ts +11 -2
  64. package/dist/package/src/index.ts +2 -0
  65. package/dist/package/src/layouts/components/Header/ToolBarRight.vue +2 -0
  66. package/dist/package/src/layouts/components/Header/components/AssemblySize.vue +8 -6
  67. package/dist/package/src/layouts/components/Header/components/Avatar.vue +11 -9
  68. package/dist/package/src/layouts/components/Header/components/Breadcrumb.vue +11 -3
  69. package/dist/package/src/layouts/components/Header/components/Fullscreen.vue +4 -2
  70. package/dist/package/src/layouts/components/Header/components/InfoDialog.vue +6 -3
  71. package/dist/package/src/layouts/components/Header/components/PasswordDialog.vue +6 -3
  72. package/dist/package/src/layouts/components/Header/components/SearchMenu.vue +5 -3
  73. package/dist/package/src/layouts/components/Header/components/ThemeSetting.vue +3 -1
  74. package/dist/package/src/layouts/components/Main/index.vue +1 -0
  75. package/dist/package/src/layouts/components/Tabs/components/MoreButton.vue +9 -7
  76. package/dist/package/src/layouts/components/Tabs/index.vue +15 -1
  77. package/dist/package/src/layouts/components/ThemeDrawer/index.vue +27 -24
  78. package/dist/package/src/locales/README.md +15 -0
  79. package/dist/package/src/locales/en-US.json +283 -0
  80. package/dist/package/src/locales/es-ES.json +283 -0
  81. package/dist/package/src/locales/fr-FR.json +283 -0
  82. package/dist/package/src/locales/generated.ts +57 -0
  83. package/dist/package/src/locales/index.ts +222 -0
  84. package/dist/package/src/locales/ja-JP.json +283 -0
  85. package/dist/package/src/locales/ko-KR.json +283 -0
  86. package/dist/package/src/locales/zh-CN.json +283 -0
  87. package/dist/package/src/locales/zh-TW.json +283 -0
  88. package/dist/package/src/modules/index.ts +7 -2
  89. package/dist/package/src/modules/kratosAdmin.ts +5 -1
  90. package/dist/package/src/request.ts +8 -1
  91. package/dist/package/src/routers/index.ts +4 -1
  92. package/dist/package/src/routers/modules/dynamicRouter.ts +5 -4
  93. package/dist/package/src/routers/modules/staticRouter.ts +8 -4
  94. package/dist/package/src/rpc/base/v1/config.ts +14 -1
  95. package/dist/package/src/rpc/base/v1/language.ts +31 -0
  96. package/dist/package/src/rpc/base/v1/login.ts +14 -1
  97. package/dist/package/src/rpc/system/admin/v1/auth.ts +1 -1
  98. package/dist/package/src/rpc/system/admin/v1/base_dict.ts +9 -0
  99. package/dist/package/src/rpc/system/admin/v1/base_translation.ts +90 -0
  100. package/dist/package/src/rpc/system/admin/v1/common.ts +21 -0
  101. package/dist/package/src/stores/interface/index.ts +2 -0
  102. package/dist/package/src/stores/modules/config.ts +7 -3
  103. package/dist/package/src/stores/modules/user.ts +2 -1
  104. package/dist/package/src/stores/runtime.ts +1 -0
  105. package/dist/package/src/styles/element.scss +2 -0
  106. package/dist/package/src/utils/color.ts +5 -4
  107. package/dist/package/src/utils/dict.ts +27 -4
  108. package/dist/package/src/utils/eleValidate.ts +3 -2
  109. package/dist/package/src/utils/errorHandler.ts +9 -8
  110. package/dist/package/src/utils/index.ts +9 -8
  111. package/dist/package/src/utils/oauthProvider.ts +15 -10
  112. package/dist/package/src/utils/passwordCrypto.ts +4 -3
  113. package/dist/package/src/utils/passwordStrength.ts +1 -16
  114. package/dist/package/src/utils/request.ts +13 -8
  115. package/dist/package/src/views/error/403.vue +3 -1
  116. package/dist/package/src/views/error/404.vue +3 -1
  117. package/dist/package/src/views/error/500.vue +3 -1
  118. package/dist/package/src/views/error/pending.vue +5 -2
  119. package/dist/package/src/views/login/components/LoginForm.vue +58 -29
  120. package/dist/package/src/views/login/index.scss +6 -0
  121. package/dist/package/src/views/login/index.vue +2 -0
  122. package/dist/package/types/generated/auto-imports.d.ts +129 -111
  123. package/dist/package/types/generated/components.d.ts +67 -67
  124. package/package.json +4 -2
  125. package/types/generated/auto-imports.d.ts +129 -111
  126. package/types/generated/components.d.ts +67 -67
  127. package/vite.config.ts +12 -0
  128. package/dist/package/declarations/src/rpc/base/v1/enum.d.ts +0 -43
  129. package/dist/package/declarations/src/rpc/system/common/v1/enum.d.ts +0 -67
  130. package/dist/package/src/rpc/base/v1/enum.ts +0 -54
  131. package/dist/package/src/rpc/system/common/v1/enum.ts +0 -80
@@ -1,11 +1,12 @@
1
1
  import router from "../../routers/index";
2
2
  import { LOGIN_URL } from "../../config";
3
+ import { t } from "../../locales";
3
4
  import { RouteRecordRaw } from "vue-router";
4
5
  import { ElNotification } from "element-plus";
5
6
  import { useUserStore } from "../../stores/modules/user";
6
7
  import { useAuthStore } from "../../stores/modules/auth";
7
8
  import type { RouteItem } from "../../rpc/system/admin/v1/auth";
8
- import { BaseMenuType } from "../../rpc/system/common/v1/enum";
9
+ import { BaseMenuType } from "../../rpc/system/admin/v1/common";
9
10
  import { getRouteMetaFull } from "../../utils";
10
11
  import { ADMIN_STATIC_VIEWS, getAdminViewRegistry } from "../../modules";
11
12
 
@@ -121,8 +122,8 @@ export const initDynamicRouter = async () => {
121
122
  // 2.判断当前用户有没有菜单权限
122
123
  if (!authStore.authMenuListGet.length) {
123
124
  ElNotification({
124
- title: "无权限访问",
125
- message: "当前账号无任何菜单权限,请联系系统管理员!",
125
+ title: t("core.auth.no_permission"),
126
+ message: t("core.auth.no_menu_permission"),
126
127
  type: "warning",
127
128
  duration: 3000
128
129
  });
@@ -134,7 +135,7 @@ export const initDynamicRouter = async () => {
134
135
  // 3.添加动态路由
135
136
  const resolvedRouteItems = buildResolvedRouteItems(authStore.authMenuListGet);
136
137
  resolvedRouteItems.forEach(({ item, path, redirect }) => {
137
- if (item.type === BaseMenuType.EXT_LINK) return;
138
+ if (item.type === BaseMenuType.BASE_MENU_TYPE_EXT_LINK) return;
138
139
  const routeRecord = createRouteRecord(item, path, redirect);
139
140
 
140
141
  if (typeof routeRecord.component === "string") {
@@ -24,7 +24,8 @@ export const staticRouter: RouteRecordRaw[] = [
24
24
  name: "Login",
25
25
  component: createAdminStaticViewLoader(ADMIN_STATIC_VIEWS.LOGIN),
26
26
  meta: {
27
- title: "登录"
27
+ title: "",
28
+ titleKey: "core.route.login"
28
29
  }
29
30
  },
30
31
  {
@@ -46,7 +47,8 @@ export const errorRouter = [
46
47
  name: "403",
47
48
  component: createAdminStaticViewLoader(ADMIN_STATIC_VIEWS.FORBIDDEN),
48
49
  meta: {
49
- title: "403页面"
50
+ title: "",
51
+ titleKey: "core.route.forbidden"
50
52
  }
51
53
  },
52
54
  {
@@ -54,7 +56,8 @@ export const errorRouter = [
54
56
  name: "404",
55
57
  component: createAdminStaticViewLoader(ADMIN_STATIC_VIEWS.NOT_FOUND),
56
58
  meta: {
57
- title: "404页面"
59
+ title: "",
60
+ titleKey: "core.route.not_found"
58
61
  }
59
62
  },
60
63
  {
@@ -62,7 +65,8 @@ export const errorRouter = [
62
65
  name: "500",
63
66
  component: createAdminStaticViewLoader(ADMIN_STATIC_VIEWS.SERVER_ERROR),
64
67
  meta: {
65
- title: "500页面"
68
+ title: "",
69
+ titleKey: "core.route.server_error"
66
70
  }
67
71
  },
68
72
  // Resolve refresh page, route warnings
@@ -5,7 +5,18 @@
5
5
  // source: base/v1/config.proto
6
6
 
7
7
  /* eslint-disable */
8
- import type { BaseConfigSite } from "./enum";
8
+
9
+ /** 系统配置位置。 */
10
+ export enum BaseConfigSite {
11
+ /** BASE_CONFIG_SITE_UNSPECIFIED - 未指定系统配置位置。 */
12
+ BASE_CONFIG_SITE_UNSPECIFIED = 0,
13
+ /** BASE_CONFIG_SITE_SYSTEM - 系统内使用。 */
14
+ BASE_CONFIG_SITE_SYSTEM = 1,
15
+ /** BASE_CONFIG_SITE_ADMIN - 管理端。 */
16
+ BASE_CONFIG_SITE_ADMIN = 2,
17
+ /** BASE_CONFIG_SITE_APP - 移动端。 */
18
+ BASE_CONFIG_SITE_APP = 3,
19
+ }
9
20
 
10
21
  /** 获取系统配置条件 */
11
22
  export interface GetConfigRequest {
@@ -15,6 +26,8 @@ export interface GetConfigRequest {
15
26
 
16
27
  /** 系统配置项 */
17
28
  export interface ConfigItem {
29
+ /** 配置ID */
30
+ id: number;
18
31
  /** 配置key */
19
32
  key: string;
20
33
  /** 配置value */
@@ -0,0 +1,31 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.8
4
+ // protoc unknown
5
+ // source: base/v1/language.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ /** 查询语言选项请求参数。 */
10
+ export interface OptionLanguageRequest {
11
+ }
12
+
13
+ /** 语言选择项。 */
14
+ export interface LanguageItem {
15
+ /** 标准语言代码 */
16
+ language_code: string;
17
+ /** 本地语言名称 */
18
+ native_name: string;
19
+ }
20
+
21
+ /** 当前支持的语言选项查询结果。 */
22
+ export interface OptionLanguageResponse {
23
+ /** 当前支持的语言列表 */
24
+ languages: LanguageItem[];
25
+ }
26
+
27
+ /** 语言公共服务。 */
28
+ export interface LanguageService {
29
+ /** 查询当前支持的语言选项。 */
30
+ OptionLanguage(request: OptionLanguageRequest): Promise<OptionLanguageResponse>;
31
+ }
@@ -7,7 +7,20 @@
7
7
  /* eslint-disable */
8
8
  import type { PasswordCrypto } from "../../common/v1/types";
9
9
  import type { Empty } from "../../google/protobuf/empty";
10
- import type { PasswordCryptoScene } from "./enum";
10
+
11
+ /** 密码加密场景枚举。 */
12
+ export enum PasswordCryptoScene {
13
+ /** PASSWORD_CRYPTO_SCENE_UNSPECIFIED - 未指定密码加密场景。 */
14
+ PASSWORD_CRYPTO_SCENE_UNSPECIFIED = 0,
15
+ /** PASSWORD_CRYPTO_SCENE_LOGIN - 登录密码加密场景。 */
16
+ PASSWORD_CRYPTO_SCENE_LOGIN = 1,
17
+ /** PASSWORD_CRYPTO_SCENE_CREATE_BASE_USER - 新增后台用户密码加密场景。 */
18
+ PASSWORD_CRYPTO_SCENE_CREATE_BASE_USER = 2,
19
+ /** PASSWORD_CRYPTO_SCENE_RESET_BASE_USER_PASSWORD - 重置后台用户密码加密场景。 */
20
+ PASSWORD_CRYPTO_SCENE_RESET_BASE_USER_PASSWORD = 3,
21
+ /** PASSWORD_CRYPTO_SCENE_UPDATE_USER_PASSWORD - 个人修改密码加密场景。 */
22
+ PASSWORD_CRYPTO_SCENE_UPDATE_USER_PASSWORD = 4,
23
+ }
11
24
 
12
25
  /** 验证码获取条件 */
13
26
  export interface CaptchaRequest {
@@ -7,7 +7,7 @@
7
7
  /* eslint-disable */
8
8
  import type { PasswordCrypto, StringValues } from "../../../common/v1/types";
9
9
  import type { Empty } from "../../../google/protobuf/empty";
10
- import type { BaseMenuType } from "../../common/v1/enum";
10
+ import type { BaseMenuType } from "./common";
11
11
 
12
12
  /** 登录用户菜单树查询参数 */
13
13
  export interface TreeUserMenuRequest {
@@ -7,6 +7,7 @@
7
7
  /* eslint-disable */
8
8
  import type { Status } from "../../../common/v1/enum";
9
9
  import type { Empty } from "../../../google/protobuf/empty";
10
+ import type { BaseTranslation } from "./base_translation";
10
11
 
11
12
  /** 字典选项查询条件 */
12
13
  export interface OptionBaseDictRequest {
@@ -100,6 +101,8 @@ export interface BaseDictForm {
100
101
  code: string;
101
102
  /** 字典名称 */
102
103
  name: string;
104
+ /** 非主语言翻译 */
105
+ translations: BaseTranslation[];
103
106
  /** 状态 */
104
107
  status: Status;
105
108
  }
@@ -124,6 +127,8 @@ export interface BaseDictItemForm {
124
127
  tag_type: string;
125
128
  /** 排序 */
126
129
  sort: number;
130
+ /** 非主语言翻译 */
131
+ translations: BaseTranslation[];
127
132
  /** 状态 */
128
133
  status: Status;
129
134
  }
@@ -194,6 +199,8 @@ export interface BaseDict {
194
199
  created_at: string;
195
200
  /** 更新时间 */
196
201
  updated_at: string;
202
+ /** 非主语言翻译 */
203
+ translations: BaseTranslation[];
197
204
  }
198
205
 
199
206
  /** 字典项 */
@@ -216,6 +223,8 @@ export interface BaseDictItem {
216
223
  created_at: string;
217
224
  /** 更新时间 */
218
225
  updated_at: string;
226
+ /** 非主语言翻译 */
227
+ translations: BaseTranslation[];
219
228
  }
220
229
 
221
230
  /** Admin字典服务 */
@@ -0,0 +1,90 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.8
4
+ // protoc unknown
5
+ // source: system/admin/v1/base_translation.proto
6
+
7
+ /* eslint-disable */
8
+ import type { Empty } from "../../../google/protobuf/empty";
9
+
10
+ /** 统一翻译表目标类型,和 base_translation.target_type 的值一一对应。 */
11
+ export enum TranslationTargetType {
12
+ /** TRANSLATION_TARGET_TYPE_UNSPECIFIED - 未指定统一翻译表目标类型。 */
13
+ TRANSLATION_TARGET_TYPE_UNSPECIFIED = 0,
14
+ /** TRANSLATION_TARGET_TYPE_BASE_CONFIG_VALUE - 系统配置值。 */
15
+ TRANSLATION_TARGET_TYPE_BASE_CONFIG_VALUE = 1,
16
+ /** TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME - 系统配置名称。 */
17
+ TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME = 2,
18
+ /** TRANSLATION_TARGET_TYPE_BASE_DICT - 字典名称。 */
19
+ TRANSLATION_TARGET_TYPE_BASE_DICT = 3,
20
+ /** TRANSLATION_TARGET_TYPE_BASE_DICT_ITEM - 字典项标签。 */
21
+ TRANSLATION_TARGET_TYPE_BASE_DICT_ITEM = 4,
22
+ /** TRANSLATION_TARGET_TYPE_BASE_MENU - 菜单标题。 */
23
+ TRANSLATION_TARGET_TYPE_BASE_MENU = 5,
24
+ }
25
+
26
+ /** 翻译单个文本请求。 */
27
+ export interface DraftBaseTranslationRequest {
28
+ /** 待翻译文本 */
29
+ source: string;
30
+ /** 目标语言区域,不传时翻译所有启用的非主语言 */
31
+ locale?: string | undefined;
32
+ }
33
+
34
+ /** 翻译单个文本响应。 */
35
+ export interface DraftBaseTranslationResponse {
36
+ /** 翻译结果 */
37
+ translations: DraftBaseTranslationItem[];
38
+ }
39
+
40
+ /** 翻译单个文本响应。 */
41
+ export interface DraftBaseTranslationItem {
42
+ /** 目标语言区域 */
43
+ locale: string;
44
+ /** 翻译文本 */
45
+ translation: string;
46
+ }
47
+
48
+ /** 修改单个翻译信息请求。 */
49
+ export interface UpdateBaseTranslationRequest {
50
+ /** 翻译记录ID,大于零时优先按ID更新;ID不存在时根据目标信息更新或新增 */
51
+ id: number;
52
+ /** 翻译目标类型,ID为零时用于查询或新增 */
53
+ target_type: TranslationTargetType;
54
+ /** 目标资源ID,ID为零时用于查询或新增 */
55
+ target_id: number;
56
+ /** 目标语言区域,ID为零时用于查询或新增 */
57
+ locale: string;
58
+ /** 翻译文本 */
59
+ name: string;
60
+ }
61
+
62
+ /** 国际化翻译信息 */
63
+ export interface BaseTranslation {
64
+ /** 翻译记录ID */
65
+ id: number;
66
+ /** 翻译目标类型 */
67
+ target_type: TranslationTargetType;
68
+ /** 目标资源ID */
69
+ target_id: number;
70
+ /** 语言区域 */
71
+ locale: string;
72
+ /** 翻译文本 */
73
+ name: string;
74
+ }
75
+
76
+ /** 代码生成单语言国际化配置 */
77
+ export interface CodeGenLocaleConfig {
78
+ /** 业务或字段描述 */
79
+ comment: string;
80
+ /** 左树描述 */
81
+ left_tree_comment: string;
82
+ }
83
+
84
+ /** 国际化翻译信息服务。 */
85
+ export interface BaseTranslationService {
86
+ /** 翻译单个文本。 */
87
+ DraftBaseTranslation(request: DraftBaseTranslationRequest): Promise<DraftBaseTranslationResponse>;
88
+ /** 修改国际化翻译信息 */
89
+ UpdateBaseTranslation(request: UpdateBaseTranslationRequest): Promise<Empty>;
90
+ }
@@ -0,0 +1,21 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.8
4
+ // protoc unknown
5
+ // source: system/admin/v1/common.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ /** 菜单类型。 */
10
+ export enum BaseMenuType {
11
+ /** BASE_MENU_TYPE_UNSPECIFIED - 未指定菜单类型。 */
12
+ BASE_MENU_TYPE_UNSPECIFIED = 0,
13
+ /** BASE_MENU_TYPE_FOLDER - 目录。 */
14
+ BASE_MENU_TYPE_FOLDER = 1,
15
+ /** BASE_MENU_TYPE_MENU - 菜单。 */
16
+ BASE_MENU_TYPE_MENU = 2,
17
+ /** BASE_MENU_TYPE_BUTTON - 按钮。 */
18
+ BASE_MENU_TYPE_BUTTON = 3,
19
+ /** BASE_MENU_TYPE_EXT_LINK - 外部链接。 */
20
+ BASE_MENU_TYPE_EXT_LINK = 4,
21
+ }
@@ -99,4 +99,6 @@ export interface SiteConfigState {
99
99
  display: SiteDisplayConfig;
100
100
  /** 当前登录验证码配置 */
101
101
  captcha: LoginCaptchaConfig;
102
+ /** 是否允许显式生成机器翻译草稿。 */
103
+ translationDraftEnabled: boolean;
102
104
  }
@@ -1,11 +1,12 @@
1
1
  import { defineStore } from "pinia";
2
2
  import { defConfigService } from "../../api/base/config";
3
- import { BaseConfigSite } from "../../rpc/base/v1/enum";
3
+ import { BaseConfigSite } from "../../rpc/base/v1/config";
4
4
  import type { LoginCaptchaConfig, SiteConfigState, SiteDisplayConfig } from "../../stores/interface";
5
5
  import defaultLogoUrl from "../../assets/images/logo.svg";
6
6
  import defaultBackgroundUrl from "../../assets/images/login_left.png";
7
7
 
8
8
  const CAPTCHA_TYPE_KEY = "captchaType";
9
+ const TRANSLATION_DRAFT_ENABLED_KEY = "i18n.translation_draft.enabled";
9
10
 
10
11
  const DEFAULT_SITE_DISPLAY_CONFIG: SiteDisplayConfig = {
11
12
  sysName: "Admin",
@@ -76,7 +77,8 @@ function buildConfigMap(configs: Array<{ key?: string; value?: string }>) {
76
77
  export const useConfigStore = defineStore("admin-config", {
77
78
  state: (): SiteConfigState => ({
78
79
  display: { ...DEFAULT_SITE_DISPLAY_CONFIG },
79
- captcha: { ...DEFAULT_LOGIN_CAPTCHA_CONFIG }
80
+ captcha: { ...DEFAULT_LOGIN_CAPTCHA_CONFIG },
81
+ translationDraftEnabled: false
80
82
  }),
81
83
  getters: {},
82
84
  actions: {
@@ -101,18 +103,20 @@ export const useConfigStore = defineStore("admin-config", {
101
103
  resetDisplayConfig() {
102
104
  this.display = { ...DEFAULT_SITE_DISPLAY_CONFIG };
103
105
  this.captcha = { ...DEFAULT_LOGIN_CAPTCHA_CONFIG };
106
+ this.translationDraftEnabled = false;
104
107
  },
105
108
  /**
106
109
  * 加载管理端站点配置,并以服务端返回值覆盖本地默认值。
107
110
  */
108
111
  async loadDisplayConfig() {
109
112
  const configResponse = await defConfigService.GetConfig({
110
- site: BaseConfigSite.ADMIN
113
+ site: BaseConfigSite.BASE_CONFIG_SITE_ADMIN
111
114
  });
112
115
  const configMap = buildConfigMap(configResponse.configs ?? []);
113
116
 
114
117
  this.setDisplayConfig(normalizeSiteDisplayConfig(configMap));
115
118
  this.setLoginCaptchaConfig(normalizeLoginCaptchaConfig(configMap));
119
+ this.translationDraftEnabled = configMap[TRANSLATION_DRAFT_ENABLED_KEY] === "true";
116
120
  return this.display;
117
121
  }
118
122
  }
@@ -6,6 +6,7 @@ import type { UserInfoForm } from "../../rpc/system/admin/v1/auth";
6
6
  import { UserState } from "../../stores/interface";
7
7
  import piniaPersistConfig from "../../stores/helper/persist";
8
8
  import { useDictStoreHook } from "../../stores/modules/dict";
9
+ import { t } from "../../locales";
9
10
 
10
11
  const defaultUserInfo: UserInfoForm = {
11
12
  user_name: "",
@@ -71,7 +72,7 @@ export const useUserStore = defineStore("admin-user", {
71
72
  /** 刷新认证令牌 */
72
73
  async refreshAccessToken() {
73
74
  if (!this.refreshToken) {
74
- return Promise.reject(new Error("refresh token 不存在"));
75
+ return Promise.reject(new Error(t("core.auth.refresh_token_missing")));
75
76
  }
76
77
 
77
78
  const data = await defLoginService.RefreshToken({ refresh_token: this.refreshToken });
@@ -1,4 +1,5 @@
1
1
  export { useAuthStore } from "./modules/auth";
2
+ export { useConfigStore } from "./modules/config";
2
3
  export { useGlobalStore } from "./modules/global";
3
4
  export { useTabsStore } from "./modules/tabs";
4
5
  export { useUserStore } from "./modules/user";
@@ -310,6 +310,8 @@
310
310
 
311
311
  /* el-dialog */
312
312
  .el-dialog {
313
+ box-sizing: border-box;
314
+ max-width: calc(100vw - 32px);
313
315
  padding: 0;
314
316
  margin-top: 8vh;
315
317
  .el-dialog__header {
@@ -1,4 +1,5 @@
1
1
  import { ElMessage } from "element-plus";
2
+ import { t } from "../locales";
2
3
 
3
4
  /**
4
5
  * @description hex颜色转rgb颜色
@@ -8,7 +9,7 @@ import { ElMessage } from "element-plus";
8
9
  export function hexToRgb(str: any) {
9
10
  let hexs: any = "";
10
11
  let reg = /^#?[0-9A-Fa-f]{6}$/;
11
- if (!reg.test(str)) return ElMessage.warning("输入错误的hex");
12
+ if (!reg.test(str)) return ElMessage.warning(t("core.theme.color_hex_invalid"));
12
13
  str = str.replace("#", "");
13
14
  hexs = str.match(/../g);
14
15
  for (let i = 0; i < 3; i++) hexs[i] = parseInt(hexs[i], 16);
@@ -24,7 +25,7 @@ export function hexToRgb(str: any) {
24
25
  */
25
26
  export function rgbToHex(r: any, g: any, b: any) {
26
27
  let reg = /^\d{1,3}$/;
27
- if (!reg.test(r) || !reg.test(g) || !reg.test(b)) return ElMessage.warning("输入错误的rgb颜色值");
28
+ if (!reg.test(r) || !reg.test(g) || !reg.test(b)) return ElMessage.warning(t("core.theme.color_rgb_invalid"));
28
29
  let hexs = [r.toString(16), g.toString(16), b.toString(16)];
29
30
  for (let i = 0; i < 3; i++) if (hexs[i].length == 1) hexs[i] = `0${hexs[i]}`;
30
31
  return `#${hexs.join("")}`;
@@ -38,7 +39,7 @@ export function rgbToHex(r: any, g: any, b: any) {
38
39
  */
39
40
  export function getDarkColor(color: string, level: number) {
40
41
  let reg = /^#?[0-9A-Fa-f]{6}$/;
41
- if (!reg.test(color)) return ElMessage.warning("输入错误的hex颜色值");
42
+ if (!reg.test(color)) return ElMessage.warning(t("core.theme.color_hex_invalid"));
42
43
  let rgb = hexToRgb(color);
43
44
  for (let i = 0; i < 3; i++) rgb[i] = Math.round(20.5 * level + rgb[i] * (1 - level));
44
45
  return rgbToHex(rgb[0], rgb[1], rgb[2]);
@@ -52,7 +53,7 @@ export function getDarkColor(color: string, level: number) {
52
53
  */
53
54
  export function getLightColor(color: string, level: number) {
54
55
  let reg = /^#?[0-9A-Fa-f]{6}$/;
55
- if (!reg.test(color)) return ElMessage.warning("输入错误的hex颜色值");
56
+ if (!reg.test(color)) return ElMessage.warning(t("core.theme.color_hex_invalid"));
56
57
  let rgb = hexToRgb(color);
57
58
  for (let i = 0; i < 3; i++) rgb[i] = Math.round(255 * level + rgb[i] * (1 - level));
58
59
  return rgbToHex(rgb[0], rgb[1], rgb[2]);
@@ -1,17 +1,40 @@
1
1
  // ? 系统全局字典
2
+ import { t } from "../locales";
2
3
 
3
4
  /**
4
5
  * @description:用户性别
5
6
  */
6
7
  export const genderType = [
7
- { label: "男", value: 1 },
8
- { label: "女", value: 2 }
8
+ {
9
+ get label() {
10
+ return t("common.value.male");
11
+ },
12
+ value: 1
13
+ },
14
+ {
15
+ get label() {
16
+ return t("common.value.female");
17
+ },
18
+ value: 2
19
+ }
9
20
  ];
10
21
 
11
22
  /**
12
23
  * @description:用户状态
13
24
  */
14
25
  export const userStatus = [
15
- { label: "启用", value: 1, tagType: "success" },
16
- { label: "禁用", value: 0, tagType: "danger" }
26
+ {
27
+ get label() {
28
+ return t("common.status.enabled");
29
+ },
30
+ value: 1,
31
+ tagType: "success"
32
+ },
33
+ {
34
+ get label() {
35
+ return t("common.status.disabled");
36
+ },
37
+ value: 0,
38
+ tagType: "danger"
39
+ }
17
40
  ];
@@ -1,13 +1,14 @@
1
1
  // ? Element 常用表单校验规则
2
+ import { t } from "../locales";
2
3
 
3
4
  /**
4
5
  * @rule 手机号
5
6
  */
6
7
  export function checkPhoneNumber(rule: any, value: any, callback: any) {
7
8
  const regexp = /^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[3-8]{1})|(18[0-9]{1})|(19[0-9]{1})|(14[5-7]{1}))+\d{8})$/;
8
- if (value === "") callback("请输入手机号码");
9
+ if (value === "") callback(t("common.validation.phone_required"));
9
10
  if (!regexp.test(value)) {
10
- callback(new Error("请输入正确的手机号码"));
11
+ callback(new Error(t("common.validation.phone_invalid")));
11
12
  } else {
12
13
  return callback();
13
14
  }
@@ -1,4 +1,5 @@
1
1
  import { ElNotification } from "element-plus";
2
+ import { t } from "../locales";
2
3
 
3
4
  /**
4
5
  * @description 全局代码错误捕捉
@@ -7,15 +8,15 @@ const errorHandler = (error: any) => {
7
8
  // 过滤 HTTP 请求错误
8
9
  if (error.status || error.status == 0) return false;
9
10
  let errorMap: { [key: string]: string } = {
10
- InternalError: "Javascript引擎内部错误",
11
- ReferenceError: "未找到对象",
12
- TypeError: "使用了错误的类型或对象",
13
- RangeError: "使用内置对象时,参数超范围",
14
- SyntaxError: "语法错误",
15
- EvalError: "错误的使用了Eval",
16
- URIError: "URI错误"
11
+ InternalError: t("core.error.javascript.internal"),
12
+ ReferenceError: t("core.error.javascript.reference"),
13
+ TypeError: t("core.error.javascript.type"),
14
+ RangeError: t("core.error.javascript.range"),
15
+ SyntaxError: t("core.error.javascript.syntax"),
16
+ EvalError: t("core.error.javascript.eval"),
17
+ URIError: t("core.error.javascript.uri")
17
18
  };
18
- let errorName = errorMap[error.name] || "未知错误";
19
+ let errorName = errorMap[error.name] || t("core.error.javascript.unknown");
19
20
  ElNotification({
20
21
  title: errorName,
21
22
  message: error,
@@ -1,6 +1,7 @@
1
1
  import { isArray } from "../utils/is";
2
2
  import type { RouteItem, RouteMeta } from "../rpc/system/admin/v1/auth";
3
- import { BaseMenuType } from "../rpc/system/common/v1/enum";
3
+ import { BaseMenuType } from "../rpc/system/admin/v1/common";
4
+ import { t } from "../locales";
4
5
 
5
6
  const mode = import.meta.env.VITE_ROUTER_MODE;
6
7
 
@@ -22,7 +23,7 @@ export function getRouteMetaIcon(meta?: RouteMeta) {
22
23
  * 获取菜单标题。
23
24
  */
24
25
  export function getRouteMetaTitle(meta?: RouteMeta) {
25
- return meta?.title ?? "未命名菜单";
26
+ return meta?.title ?? t("core.layout.unnamed_menu");
26
27
  }
27
28
 
28
29
  /**
@@ -169,11 +170,11 @@ export function randomNum(min: number, max: number): number {
169
170
  export function getTimeState() {
170
171
  let timeNow = new Date();
171
172
  let hours = timeNow.getHours();
172
- if (hours >= 6 && hours <= 10) return `早上好 ⛅`;
173
- if (hours >= 10 && hours <= 14) return `中午好 🌞`;
174
- if (hours >= 14 && hours <= 18) return `下午好 🌞`;
175
- if (hours >= 18 && hours <= 24) return `晚上好 🌛`;
176
- if (hours >= 0 && hours <= 6) return `凌晨好 🌛`;
173
+ if (hours >= 6 && hours <= 10) return t("core.login.greeting.morning");
174
+ if (hours >= 10 && hours <= 14) return t("core.login.greeting.noon");
175
+ if (hours >= 14 && hours <= 18) return t("core.login.greeting.afternoon");
176
+ if (hours >= 18 && hours <= 24) return t("core.login.greeting.evening");
177
+ return t("core.login.greeting.night");
177
178
  }
178
179
 
179
180
  /**
@@ -198,7 +199,7 @@ export function isExternalPath(path?: string) {
198
199
 
199
200
  /** 获取菜单项实际跳转目标,外链优先使用 redirect。 */
200
201
  export function getRouteTarget(item: RouteItem): string {
201
- if (item.type === BaseMenuType.EXT_LINK) return item.redirect || item.path || "";
202
+ if (item.type === BaseMenuType.BASE_MENU_TYPE_EXT_LINK) return item.redirect || item.path || "";
202
203
  return item.path ?? "";
203
204
  }
204
205
 
@@ -6,11 +6,14 @@ import githubIconUrl from "../assets/images/oauth/github.png";
6
6
  import googleIconUrl from "../assets/images/oauth/google.png";
7
7
  import wechatIconUrl from "../assets/images/oauth/wechat.png";
8
8
  import wechatworkIconUrl from "../assets/images/oauth/wechatwork.png";
9
+ import { t } from "../locales";
9
10
 
10
11
  /** 三方登录展示信息。 */
11
12
  export interface OauthProviderDisplay {
12
13
  /** 登录方式名称。 */
13
14
  name: string;
15
+ /** 登录方式名称对应的稳定语言键。 */
16
+ nameKey: string;
14
17
  /** 登录方式图标标识。 */
15
18
  icon: string;
16
19
  }
@@ -21,15 +24,15 @@ export interface OauthProviderSource {
21
24
  provider: string;
22
25
  }
23
26
 
24
- const oauthProviderDisplayMap: Record<string, OauthProviderDisplay> = {
25
- github: { name: "GitHub", icon: "github" },
26
- wechat: { name: "微信", icon: "wechat" },
27
- wechatmp: { name: "微信公众号", icon: "wechat" },
28
- gitee: { name: "Gitee", icon: "gitee" },
29
- google: { name: "Google", icon: "google" },
30
- dingtalk: { name: "钉钉", icon: "dingtalk" },
31
- feishu: { name: "飞书", icon: "feishu" },
32
- wechatwork: { name: "企业微信", icon: "wechatwork" }
27
+ const oauthProviderDisplayMap: Record<string, Omit<OauthProviderDisplay, "name">> = {
28
+ github: { nameKey: "GitHub", icon: "github" },
29
+ wechat: { nameKey: "core.oauth.wechat", icon: "wechat" },
30
+ wechatmp: { nameKey: "core.oauth.wechatmp", icon: "wechat" },
31
+ gitee: { nameKey: "Gitee", icon: "gitee" },
32
+ google: { nameKey: "Google", icon: "google" },
33
+ dingtalk: { nameKey: "core.oauth.dingtalk", icon: "dingtalk" },
34
+ feishu: { nameKey: "core.oauth.feishu", icon: "feishu" },
35
+ wechatwork: { nameKey: "core.oauth.wechatwork", icon: "wechatwork" }
33
36
  };
34
37
 
35
38
  /** 创建本地官方图标图片组件。 */
@@ -56,7 +59,9 @@ const oauthIconMap: Record<string, Component> = {
56
59
 
57
60
  /** 根据 provider 标识获取前端展示信息。 */
58
61
  export function getOauthProviderDisplay(provider: string): OauthProviderDisplay {
59
- return oauthProviderDisplayMap[provider] || { name: provider || "未知方式", icon: provider };
62
+ const display = oauthProviderDisplayMap[provider] ?? { nameKey: "core.oauth.unknown", icon: provider };
63
+ const name = display.nameKey.includes(".") ? t(display.nameKey) : display.nameKey;
64
+ return { ...display, name: provider ? name : t("core.oauth.unknown") };
60
65
  }
61
66
 
62
67
  /** 创建未知 provider 的文字兜底图标。 */