@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
@@ -0,0 +1,53 @@
1
+ import type { AdminModule } from "../modules";
2
+ import type { OptionLanguageResponse } from "../rpc/base/v1/language";
3
+ import { type GeneratedLocale } from "./generated";
4
+ /** 管理端已打包的语言区域;运行时可切换列表由 base_language 接口决定。 */
5
+ export declare const SUPPORTED_LOCALES: ("zh-CN" | "en-US" | "es-ES" | "fr-FR" | "ja-JP" | "ko-KR" | "zh-TW")[];
6
+ /** 管理端支持的语言区域类型。 */
7
+ export type SupportedLocale = GeneratedLocale;
8
+ /** 单个模块的扁平语言包。 */
9
+ export type LocaleMessages = Record<string, string>;
10
+ /** 翻译插值参数。 */
11
+ export type LocaleParams = Record<string, string | number>;
12
+ /** 运行时语言选项。 */
13
+ export interface LocaleOption {
14
+ /** 标准语言代码。 */
15
+ language_code: SupportedLocale;
16
+ /** 本地语言名称。 */
17
+ native_name: string;
18
+ }
19
+ export declare const DEFAULT_LOCALE: SupportedLocale;
20
+ export declare const LOCALE_STORAGE_KEY = "kratos-admin:locale";
21
+ /** 管理端 Vue I18n 实例。 */
22
+ export declare const adminI18n: import("vue-i18n").I18n<{}, {}, {}, "zh-CN" | "en-US" | "es-ES" | "fr-FR" | "ja-JP" | "ko-KR" | "zh-TW", false>;
23
+ /** 规范化任意语言输入到管理端白名单。 */
24
+ export declare function normalizeLocale(value?: string): SupportedLocale;
25
+ /** 注册模块语言包并校验语言键、占位符和命名空间。 */
26
+ export declare function registerLocaleMessages(modules: AdminModule[]): void;
27
+ /** 初始化持久化语言偏好并同步日期库。 */
28
+ export declare function initializeLocale(): SupportedLocale;
29
+ /** 应用后端语言配置,并在当前语言不可用时回退到接口第一项。 */
30
+ export declare function applyLanguageConfig(response: OptionLanguageResponse): void;
31
+ /** 获取当前接口配置的语言选项。 */
32
+ export declare function getLanguageOptions(): LocaleOption[];
33
+ /** 获取当前可切换的语言区域。 */
34
+ export declare function getSupportedLocales(): SupportedLocale[];
35
+ /** 获取当前规范语言区域。 */
36
+ export declare function getCurrentLocale(): SupportedLocale;
37
+ /** 获取非 Axios 请求统一使用的语言头。 */
38
+ export declare function getLocaleRequestHeaders(): Record<"Accept-Language", SupportedLocale>;
39
+ /** 切换语言并刷新动态本地化数据。 */
40
+ export declare function setCurrentLocale(value: SupportedLocale): Promise<void>;
41
+ /** 注册语言切换后的动态数据刷新处理器。 */
42
+ export declare function registerLocaleChangeHandler(handler: () => void | Promise<void>): () => void;
43
+ /** 在非组件代码中翻译稳定语言键。 */
44
+ export declare function t(key: string, params?: LocaleParams): string;
45
+ /** 管理端响应式语言状态。 */
46
+ export declare function useLocaleStore(): {
47
+ locale: Readonly<globalThis.Ref<"zh-CN" | "en-US" | "es-ES" | "fr-FR" | "ja-JP" | "ko-KR" | "zh-TW", "zh-CN" | "en-US" | "es-ES" | "fr-FR" | "ja-JP" | "ko-KR" | "zh-TW">>;
48
+ localeIndex: globalThis.ComputedRef<number>;
49
+ languageOptions: globalThis.ComputedRef<LocaleOption[]>;
50
+ supportedLocales: globalThis.ComputedRef<("zh-CN" | "en-US" | "es-ES" | "fr-FR" | "ja-JP" | "ko-KR" | "zh-TW")[]>;
51
+ setLocale: typeof setCurrentLocale;
52
+ t: typeof t;
53
+ };
@@ -1,5 +1,6 @@
1
1
  import type { Component } from "vue";
2
2
  import type { RouteLocationNormalizedLoaded } from "vue-router";
3
+ import type { LocaleMessages, SupportedLocale } from "../locales";
3
4
  /**
4
5
  * 管理端视图加载器。
5
6
  */
@@ -35,8 +36,10 @@ export interface AdminHeaderTool {
35
36
  export interface AdminUserMenuAction {
36
37
  /** 操作唯一名称。 */
37
38
  name: string;
38
- /** 操作显示名称。 */
39
- label: string;
39
+ /** 操作显示名称对应的稳定语言键。 */
40
+ labelKey?: string;
41
+ /** 兼容未迁移模块的静态显示名称。 */
42
+ label?: string;
40
43
  /** 对应后端动态菜单名称,菜单不存在时不显示操作。 */
41
44
  menuName: string;
42
45
  /** 操作图标。 */
@@ -65,6 +68,8 @@ export interface AdminModule {
65
68
  routeOptions?: Record<string, AdminRouteOptions>;
66
69
  /** 模块提供的命名扩展,由扩展所属业务包定义具体类型。 */
67
70
  extensions?: Record<string, unknown>;
71
+ /** 模块按语言区域贡献的扁平语言包。 */
72
+ messages?: Partial<Record<SupportedLocale, LocaleMessages>>;
68
73
  }
69
74
  /**
70
75
  * 声明一个可被管理端宿主注册的模块。
@@ -1,2 +1,3 @@
1
1
  export { default } from "./utils/request";
2
2
  export { ensureAccessToken, getRequestAccessToken, handleAuthExpired, hasValidAccessToken, requestBaseURL } from "./utils/request";
3
+ export { getLocaleRequestHeaders } from "./locales";
@@ -14,6 +14,7 @@ export declare const errorRouter: ({
14
14
  }>;
15
15
  meta: {
16
16
  title: string;
17
+ titleKey: string;
17
18
  };
18
19
  } | {
19
20
  path: string;
@@ -1,4 +1,14 @@
1
- import type { BaseConfigSite } from "./enum";
1
+ /** 系统配置位置。 */
2
+ export declare enum BaseConfigSite {
3
+ /** BASE_CONFIG_SITE_UNSPECIFIED - 未指定系统配置位置。 */
4
+ BASE_CONFIG_SITE_UNSPECIFIED = 0,
5
+ /** BASE_CONFIG_SITE_SYSTEM - 系统内使用。 */
6
+ BASE_CONFIG_SITE_SYSTEM = 1,
7
+ /** BASE_CONFIG_SITE_ADMIN - 管理端。 */
8
+ BASE_CONFIG_SITE_ADMIN = 2,
9
+ /** BASE_CONFIG_SITE_APP - 移动端。 */
10
+ BASE_CONFIG_SITE_APP = 3
11
+ }
2
12
  /** 获取系统配置条件 */
3
13
  export interface GetConfigRequest {
4
14
  /** 位置:枚举【BaseConfigSite】 */
@@ -6,6 +16,8 @@ export interface GetConfigRequest {
6
16
  }
7
17
  /** 系统配置项 */
8
18
  export interface ConfigItem {
19
+ /** 配置ID */
20
+ id: number;
9
21
  /** 配置key */
10
22
  key: string;
11
23
  /** 配置value */
@@ -0,0 +1,20 @@
1
+ /** 查询语言选项请求参数。 */
2
+ export interface OptionLanguageRequest {
3
+ }
4
+ /** 语言选择项。 */
5
+ export interface LanguageItem {
6
+ /** 标准语言代码 */
7
+ language_code: string;
8
+ /** 本地语言名称 */
9
+ native_name: string;
10
+ }
11
+ /** 当前支持的语言选项查询结果。 */
12
+ export interface OptionLanguageResponse {
13
+ /** 当前支持的语言列表 */
14
+ languages: LanguageItem[];
15
+ }
16
+ /** 语言公共服务。 */
17
+ export interface LanguageService {
18
+ /** 查询当前支持的语言选项。 */
19
+ OptionLanguage(request: OptionLanguageRequest): Promise<OptionLanguageResponse>;
20
+ }
@@ -1,6 +1,18 @@
1
1
  import type { PasswordCrypto } from "../../common/v1/types";
2
2
  import type { Empty } from "../../google/protobuf/empty";
3
- import type { PasswordCryptoScene } from "./enum";
3
+ /** 密码加密场景枚举。 */
4
+ export declare enum PasswordCryptoScene {
5
+ /** PASSWORD_CRYPTO_SCENE_UNSPECIFIED - 未指定密码加密场景。 */
6
+ PASSWORD_CRYPTO_SCENE_UNSPECIFIED = 0,
7
+ /** PASSWORD_CRYPTO_SCENE_LOGIN - 登录密码加密场景。 */
8
+ PASSWORD_CRYPTO_SCENE_LOGIN = 1,
9
+ /** PASSWORD_CRYPTO_SCENE_CREATE_BASE_USER - 新增后台用户密码加密场景。 */
10
+ PASSWORD_CRYPTO_SCENE_CREATE_BASE_USER = 2,
11
+ /** PASSWORD_CRYPTO_SCENE_RESET_BASE_USER_PASSWORD - 重置后台用户密码加密场景。 */
12
+ PASSWORD_CRYPTO_SCENE_RESET_BASE_USER_PASSWORD = 3,
13
+ /** PASSWORD_CRYPTO_SCENE_UPDATE_USER_PASSWORD - 个人修改密码加密场景。 */
14
+ PASSWORD_CRYPTO_SCENE_UPDATE_USER_PASSWORD = 4
15
+ }
4
16
  /** 验证码获取条件 */
5
17
  export interface CaptchaRequest {
6
18
  /** 验证码类型,random 表示随机选择当前支持的验证码类型 */
@@ -1,6 +1,6 @@
1
1
  import type { PasswordCrypto, StringValues } from "../../../common/v1/types";
2
2
  import type { Empty } from "../../../google/protobuf/empty";
3
- import type { BaseMenuType } from "../../common/v1/enum";
3
+ import type { BaseMenuType } from "./common";
4
4
  /** 登录用户菜单树查询参数 */
5
5
  export interface TreeUserMenuRequest {
6
6
  }
@@ -1,5 +1,6 @@
1
1
  import type { Status } from "../../../common/v1/enum";
2
2
  import type { Empty } from "../../../google/protobuf/empty";
3
+ import type { BaseTranslation } from "./base_translation";
3
4
  /** 字典选项查询条件 */
4
5
  export interface OptionBaseDictRequest {
5
6
  }
@@ -79,6 +80,8 @@ export interface BaseDictForm {
79
80
  code: string;
80
81
  /** 字典名称 */
81
82
  name: string;
83
+ /** 非主语言翻译 */
84
+ translations: BaseTranslation[];
82
85
  /** 状态 */
83
86
  status: Status;
84
87
  }
@@ -101,6 +104,8 @@ export interface BaseDictItemForm {
101
104
  tag_type: string;
102
105
  /** 排序 */
103
106
  sort: number;
107
+ /** 非主语言翻译 */
108
+ translations: BaseTranslation[];
104
109
  /** 状态 */
105
110
  status: Status;
106
111
  }
@@ -162,6 +167,8 @@ export interface BaseDict {
162
167
  created_at: string;
163
168
  /** 更新时间 */
164
169
  updated_at: string;
170
+ /** 非主语言翻译 */
171
+ translations: BaseTranslation[];
165
172
  }
166
173
  /** 字典项 */
167
174
  export interface BaseDictItem {
@@ -183,6 +190,8 @@ export interface BaseDictItem {
183
190
  created_at: string;
184
191
  /** 更新时间 */
185
192
  updated_at: string;
193
+ /** 非主语言翻译 */
194
+ translations: BaseTranslation[];
186
195
  }
187
196
  /** Admin字典服务 */
188
197
  export interface BaseDictService {
@@ -0,0 +1,75 @@
1
+ import type { Empty } from "../../../google/protobuf/empty";
2
+ /** 统一翻译表目标类型,和 base_translation.target_type 的值一一对应。 */
3
+ export declare enum TranslationTargetType {
4
+ /** TRANSLATION_TARGET_TYPE_UNSPECIFIED - 未指定统一翻译表目标类型。 */
5
+ TRANSLATION_TARGET_TYPE_UNSPECIFIED = 0,
6
+ /** TRANSLATION_TARGET_TYPE_BASE_CONFIG_VALUE - 系统配置值。 */
7
+ TRANSLATION_TARGET_TYPE_BASE_CONFIG_VALUE = 1,
8
+ /** TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME - 系统配置名称。 */
9
+ TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME = 2,
10
+ /** TRANSLATION_TARGET_TYPE_BASE_DICT - 字典名称。 */
11
+ TRANSLATION_TARGET_TYPE_BASE_DICT = 3,
12
+ /** TRANSLATION_TARGET_TYPE_BASE_DICT_ITEM - 字典项标签。 */
13
+ TRANSLATION_TARGET_TYPE_BASE_DICT_ITEM = 4,
14
+ /** TRANSLATION_TARGET_TYPE_BASE_MENU - 菜单标题。 */
15
+ TRANSLATION_TARGET_TYPE_BASE_MENU = 5
16
+ }
17
+ /** 翻译单个文本请求。 */
18
+ export interface DraftBaseTranslationRequest {
19
+ /** 待翻译文本 */
20
+ source: string;
21
+ /** 目标语言区域,不传时翻译所有启用的非主语言 */
22
+ locale?: string | undefined;
23
+ }
24
+ /** 翻译单个文本响应。 */
25
+ export interface DraftBaseTranslationResponse {
26
+ /** 翻译结果 */
27
+ translations: DraftBaseTranslationItem[];
28
+ }
29
+ /** 翻译单个文本响应。 */
30
+ export interface DraftBaseTranslationItem {
31
+ /** 目标语言区域 */
32
+ locale: string;
33
+ /** 翻译文本 */
34
+ translation: string;
35
+ }
36
+ /** 修改单个翻译信息请求。 */
37
+ export interface UpdateBaseTranslationRequest {
38
+ /** 翻译记录ID,大于零时优先按ID更新;ID不存在时根据目标信息更新或新增 */
39
+ id: number;
40
+ /** 翻译目标类型,ID为零时用于查询或新增 */
41
+ target_type: TranslationTargetType;
42
+ /** 目标资源ID,ID为零时用于查询或新增 */
43
+ target_id: number;
44
+ /** 目标语言区域,ID为零时用于查询或新增 */
45
+ locale: string;
46
+ /** 翻译文本 */
47
+ name: string;
48
+ }
49
+ /** 国际化翻译信息 */
50
+ export interface BaseTranslation {
51
+ /** 翻译记录ID */
52
+ id: number;
53
+ /** 翻译目标类型 */
54
+ target_type: TranslationTargetType;
55
+ /** 目标资源ID */
56
+ target_id: number;
57
+ /** 语言区域 */
58
+ locale: string;
59
+ /** 翻译文本 */
60
+ name: string;
61
+ }
62
+ /** 代码生成单语言国际化配置 */
63
+ export interface CodeGenLocaleConfig {
64
+ /** 业务或字段描述 */
65
+ comment: string;
66
+ /** 左树描述 */
67
+ left_tree_comment: string;
68
+ }
69
+ /** 国际化翻译信息服务。 */
70
+ export interface BaseTranslationService {
71
+ /** 翻译单个文本。 */
72
+ DraftBaseTranslation(request: DraftBaseTranslationRequest): Promise<DraftBaseTranslationResponse>;
73
+ /** 修改国际化翻译信息 */
74
+ UpdateBaseTranslation(request: UpdateBaseTranslationRequest): Promise<Empty>;
75
+ }
@@ -0,0 +1,13 @@
1
+ /** 菜单类型。 */
2
+ export declare enum BaseMenuType {
3
+ /** BASE_MENU_TYPE_UNSPECIFIED - 未指定菜单类型。 */
4
+ BASE_MENU_TYPE_UNSPECIFIED = 0,
5
+ /** BASE_MENU_TYPE_FOLDER - 目录。 */
6
+ BASE_MENU_TYPE_FOLDER = 1,
7
+ /** BASE_MENU_TYPE_MENU - 菜单。 */
8
+ BASE_MENU_TYPE_MENU = 2,
9
+ /** BASE_MENU_TYPE_BUTTON - 按钮。 */
10
+ BASE_MENU_TYPE_BUTTON = 3,
11
+ /** BASE_MENU_TYPE_EXT_LINK - 外部链接。 */
12
+ BASE_MENU_TYPE_EXT_LINK = 4
13
+ }
@@ -87,4 +87,6 @@ export interface SiteConfigState {
87
87
  display: SiteDisplayConfig;
88
88
  /** 当前登录验证码配置 */
89
89
  captcha: LoginCaptchaConfig;
90
+ /** 是否允许显式生成机器翻译草稿。 */
91
+ translationDraftEnabled: boolean;
90
92
  }
@@ -24,7 +24,7 @@ export declare const useAuthStore: import("pinia").StoreDefinition<"admin-auth",
24
24
  value?: string | undefined | undefined;
25
25
  }[];
26
26
  } | undefined;
27
- type: import("../../rpc/system/common/v1/enum").BaseMenuType;
27
+ type: import("../../rpc/system/admin/v1/common").BaseMenuType;
28
28
  children: /*elided*/ any[];
29
29
  }[];
30
30
  } & import("pinia").PiniaCustomStateProperties<AuthState>) => {
@@ -53,7 +53,7 @@ export declare const useAuthStore: import("pinia").StoreDefinition<"admin-auth",
53
53
  value?: string | undefined | undefined;
54
54
  }[];
55
55
  } | undefined;
56
- type: import("../../rpc/system/common/v1/enum").BaseMenuType;
56
+ type: import("../../rpc/system/admin/v1/common").BaseMenuType;
57
57
  children: /*elided*/ any[];
58
58
  }[];
59
59
  } & import("pinia").PiniaCustomStateProperties<AuthState>) => {
@@ -74,7 +74,7 @@ export declare const useAuthStore: import("pinia").StoreDefinition<"admin-auth",
74
74
  value?: string | undefined | undefined;
75
75
  }[];
76
76
  } | undefined;
77
- type: import("../../rpc/system/common/v1/enum").BaseMenuType;
77
+ type: import("../../rpc/system/admin/v1/common").BaseMenuType;
78
78
  children: /*elided*/ any[];
79
79
  }[];
80
80
  showMenuListGet: (state: {
@@ -100,7 +100,7 @@ export declare const useAuthStore: import("pinia").StoreDefinition<"admin-auth",
100
100
  value?: string | undefined | undefined;
101
101
  }[];
102
102
  } | undefined;
103
- type: import("../../rpc/system/common/v1/enum").BaseMenuType;
103
+ type: import("../../rpc/system/admin/v1/common").BaseMenuType;
104
104
  children: /*elided*/ any[];
105
105
  }[];
106
106
  } & import("pinia").PiniaCustomStateProperties<AuthState>) => RouteItem[];
@@ -127,7 +127,7 @@ export declare const useAuthStore: import("pinia").StoreDefinition<"admin-auth",
127
127
  value?: string | undefined | undefined;
128
128
  }[];
129
129
  } | undefined;
130
- type: import("../../rpc/system/common/v1/enum").BaseMenuType;
130
+ type: import("../../rpc/system/admin/v1/common").BaseMenuType;
131
131
  children: /*elided*/ any[];
132
132
  }[];
133
133
  } & import("pinia").PiniaCustomStateProperties<AuthState>) => RouteItem[];
@@ -154,7 +154,7 @@ export declare const useAuthStore: import("pinia").StoreDefinition<"admin-auth",
154
154
  value?: string | undefined | undefined;
155
155
  }[];
156
156
  } | undefined;
157
- type: import("../../rpc/system/common/v1/enum").BaseMenuType;
157
+ type: import("../../rpc/system/admin/v1/common").BaseMenuType;
158
158
  children: /*elided*/ any[];
159
159
  }[];
160
160
  } & import("pinia").PiniaCustomStateProperties<AuthState>) => Record<string, RouteItem[]>;
@@ -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";
@@ -2,14 +2,14 @@
2
2
  * @description:用户性别
3
3
  */
4
4
  export declare const genderType: {
5
- label: string;
5
+ readonly label: string;
6
6
  value: number;
7
7
  }[];
8
8
  /**
9
9
  * @description:用户状态
10
10
  */
11
11
  export declare const userStatus: {
12
- label: string;
12
+ readonly label: string;
13
13
  value: number;
14
14
  tagType: string;
15
15
  }[];
@@ -90,7 +90,7 @@ export declare function randomNum(min: number, max: number): number;
90
90
  * @description 获取当前时间对应的提示语
91
91
  * @returns {String}
92
92
  */
93
- export declare function getTimeState(): "早上好 ⛅" | "中午好 🌞" | "下午好 🌞" | "晚上好 🌛" | "凌晨好 🌛" | undefined;
93
+ export declare function getTimeState(): string;
94
94
  /**
95
95
  * @description 获取不同路由模式所对应的 url + params
96
96
  * @returns {String}
@@ -3,6 +3,8 @@ import { type Component } from "vue";
3
3
  export interface OauthProviderDisplay {
4
4
  /** 登录方式名称。 */
5
5
  name: string;
6
+ /** 登录方式名称对应的稳定语言键。 */
7
+ nameKey: string;
6
8
  /** 登录方式图标标识。 */
7
9
  icon: string;
8
10
  }
@@ -1,4 +1,4 @@
1
- import { PasswordCryptoScene } from "../rpc/base/v1/enum";
1
+ import { PasswordCryptoScene } from "../rpc/base/v1/login";
2
2
  import type { PasswordCrypto } from "../rpc/common/v1/types";
3
3
  export declare const PASSWORD_CRYPTO_SCENE: typeof PasswordCryptoScene;
4
4
  export type { PasswordCryptoScene };
@@ -8,15 +8,9 @@ export interface PasswordStrengthResult {
8
8
  strengthScore: number;
9
9
  /** 强度等级。 */
10
10
  level: PasswordStrengthLevel;
11
- /** 强度文案。 */
12
- text: string;
13
11
  /** 是否达到允许提交的最高强度。 */
14
12
  isValid: boolean;
15
13
  }
16
- /** 密码强度错误提示。 */
17
- export declare const PASSWORD_STRENGTH_ERROR_MESSAGE = "\u5BC6\u7801\u9700\u540C\u65F6\u5305\u542B\u5927\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u7279\u6B8A\u5B57\u7B26\uFF0C\u4E14\u957F\u5EA6\u4E0D\u5C11\u4E8E 8 \u4F4D";
18
- /** 密码强度说明文案。 */
19
- export declare const PASSWORD_STRENGTH_TIP = "\u9700\u540C\u65F6\u5305\u542B\u5927\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u7279\u6B8A\u5B57\u7B26\uFF0C\u4E14\u957F\u5EA6\u4E0D\u5C11\u4E8E 8 \u4F4D\uFF0C\u8FBE\u5230\u6700\u9AD8\u5F3A\u5EA6\u540E\u624D\u53EF\u63D0\u4EA4\u3002";
20
14
  /**
21
15
  * 计算密码强度结果,供表单展示和校验统一复用。
22
16
  *
@@ -32,5 +26,4 @@ export declare function getPasswordStrength(password?: string): PasswordStrength
32
26
  */
33
27
  export declare function validatePasswordStrengthValue(password?: string): {
34
28
  valid: boolean;
35
- message: string;
36
29
  };
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <el-config-provider :locale="zhCn" :size="assemblySize" :button="buttonConfig">
2
+ <el-config-provider :locale="elementLocale" :size="assemblySize" :button="buttonConfig">
3
3
  <router-view></router-view>
4
4
  </el-config-provider>
5
5
  </template>
@@ -9,9 +9,12 @@ import { reactive, computed } from "vue";
9
9
  import { useTheme } from "./hooks/useTheme";
10
10
  import { ElConfigProvider } from "element-plus";
11
11
  import { useGlobalStore } from "./stores/modules/global";
12
- import zhCn from "element-plus/es/locale/lang/zh-cn";
12
+ import { ELEMENT_LOCALES } from "./locales/generated";
13
+ import { useLocaleStore } from "./locales";
13
14
 
14
15
  const globalStore = useGlobalStore();
16
+ const { locale } = useLocaleStore();
17
+ const elementLocale = computed(() => ELEMENT_LOCALES[locale.value]);
15
18
 
16
19
  // init theme
17
20
  const { initTheme } = useTheme();
@@ -0,0 +1,20 @@
1
+ import service from "../../utils/request";
2
+ import type { LanguageService, OptionLanguageRequest, OptionLanguageResponse } from "../../rpc/base/v1/language";
3
+
4
+ const LANGUAGE_URL = "/v1/base/language";
5
+
6
+ /** 语言公共服务。 */
7
+ export class LanguageServiceImpl implements LanguageService {
8
+ /** 查询当前支持的语言选项。 */
9
+ OptionLanguage(request: OptionLanguageRequest): Promise<OptionLanguageResponse> {
10
+ return service<OptionLanguageRequest, OptionLanguageResponse>({
11
+ url: LANGUAGE_URL,
12
+ method: "get",
13
+ params: request,
14
+ headers: { Authorization: "no-auth" }
15
+ });
16
+ }
17
+ }
18
+
19
+ /** 主语言公共服务。 */
20
+ export const defLanguageService = new LanguageServiceImpl();
@@ -43,7 +43,6 @@ export class OauthServiceImpl {
43
43
  headers: { Authorization: "no-auth" }
44
44
  });
45
45
  }
46
-
47
46
  }
48
47
 
49
48
  /** defOauthService 三方登录服务实例。 */
@@ -38,7 +38,6 @@ export class AuthServiceImpl {
38
38
  params: request
39
39
  });
40
40
  }
41
-
42
41
  }
43
42
 
44
43
  /** defAuthService 管理端运行壳认证服务实例。 */
@@ -22,6 +22,13 @@ import { useConfigStore } from "./stores/modules/config";
22
22
  import { kratosAdminModule } from "./modules/kratosAdmin";
23
23
  import { registerAdminModules } from "./modules";
24
24
  import type { AdminModule } from "./modules";
25
+ import { adminI18n, applyLanguageConfig, initializeLocale, registerLocaleChangeHandler, registerLocaleMessages, t } from "./locales";
26
+ import { useAuthStore } from "./stores/modules/auth";
27
+ import { useDictStore } from "./stores/modules/dict";
28
+ import { useTabsStore } from "./stores/modules/tabs";
29
+ import { useUserStore } from "./stores/modules/user";
30
+ import { getRouteMetaTitle } from "./utils";
31
+ import { defLanguageService } from "./api/base/language";
25
32
 
26
33
  /**
27
34
  * 管理端启动参数。
@@ -37,7 +44,15 @@ export interface AdminBootstrapOptions {
37
44
  * 创建并启动管理端应用,业务项目可通过 modules 注册自己的页面。
38
45
  */
39
46
  export async function bootstrapAdminApp(options: AdminBootstrapOptions = {}) {
40
- registerAdminModules([kratosAdminModule, ...(options.modules ?? [])]);
47
+ const modules = [kratosAdminModule, ...(options.modules ?? [])];
48
+ registerAdminModules(modules);
49
+ registerLocaleMessages(modules);
50
+ initializeLocale();
51
+ try {
52
+ applyLanguageConfig(await defLanguageService.OptionLanguage({}));
53
+ } catch {
54
+ // 语言公共接口失败时继续使用静态语言包和系统语言。
55
+ }
41
56
 
42
57
  const app = createApp(App);
43
58
 
@@ -56,7 +71,8 @@ export async function bootstrapAdminApp(options: AdminBootstrapOptions = {}) {
56
71
  // 按需加载模式不会自动注册 v-loading 指令,需要显式挂载。
57
72
  app.directive("loading", ElLoading.directive);
58
73
 
59
- app.use(directives).use(pinia).use(router);
74
+ app.use(directives).use(pinia).use(router).use(adminI18n);
75
+ registerLocaleChangeHandler(refreshLocalizedRuntimeData);
60
76
 
61
77
  try {
62
78
  await useConfigStore().loadDisplayConfig();
@@ -67,3 +83,42 @@ export async function bootstrapAdminApp(options: AdminBootstrapOptions = {}) {
67
83
  app.mount(options.mount ?? "#app");
68
84
  return app;
69
85
  }
86
+
87
+ /** 刷新当前语言对应的菜单、字典、页签和页面标题。 */
88
+ async function refreshLocalizedRuntimeData() {
89
+ const userStore = useUserStore(pinia);
90
+ const authStore = useAuthStore(pinia);
91
+ const dictStore = useDictStore(pinia);
92
+ const configStore = useConfigStore(pinia);
93
+ await Promise.allSettled([configStore.loadDisplayConfig()]);
94
+ if (userStore.token || userStore.refreshToken) {
95
+ await Promise.allSettled([authStore.getAuthMenuList(), dictStore.updateDictionaryCache()]);
96
+ syncLocalizedRouteState();
97
+ }
98
+ updateDocumentTitle();
99
+ }
100
+
101
+ function syncLocalizedRouteState() {
102
+ const authStore = useAuthStore(pinia);
103
+ const tabsStore = useTabsStore(pinia);
104
+ const menuMap = new Map(authStore.flatMenuListGet.flatMap(item => (item.name ? [[item.name, item] as const] : [])));
105
+
106
+ router.getRoutes().forEach(record => {
107
+ const menu = typeof record.name === "string" ? menuMap.get(record.name) : undefined;
108
+ if (menu?.meta) Object.assign(record.meta, menu.meta);
109
+ });
110
+ tabsStore.setTabs(
111
+ tabsStore.tabsMenuList.map(tab => {
112
+ const menu = menuMap.get(tab.name);
113
+ return menu ? { ...tab, title: getRouteMetaTitle(menu.meta) } : tab;
114
+ })
115
+ );
116
+ }
117
+
118
+ function updateDocumentTitle() {
119
+ const route = router.currentRoute.value;
120
+ const titleKey = typeof route.meta.titleKey === "string" ? route.meta.titleKey : "";
121
+ const routeTitle = titleKey ? t(titleKey) : String(route.meta.title ?? "");
122
+ const appTitle = import.meta.env.VITE_GLOB_APP_TITLE;
123
+ document.title = routeTitle ? `${routeTitle} - ${appTitle}` : appTitle;
124
+ }