@liujitcn/kratos-admin-system 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 (118) hide show
  1. package/README.md +51 -50
  2. package/dist/package/declarations/src/api/system/base_language.d.ts +52 -0
  3. package/dist/package/declarations/src/api/system/base_translation.d.ts +10 -0
  4. package/dist/package/declarations/src/api/system/code_gen_i18n.d.ts +8 -0
  5. package/dist/package/declarations/src/api/system/ops_monitoring.d.ts +19 -0
  6. package/dist/package/declarations/src/api/system/ops_monitoring_sse.d.ts +12 -0
  7. package/dist/package/declarations/src/components/DynamicTranslationCell.vue.d.ts +16 -0
  8. package/dist/package/declarations/src/components/DynamicTranslationEditor.vue.d.ts +20 -0
  9. package/dist/package/declarations/src/components/dynamicTranslation.d.ts +38 -0
  10. package/dist/package/declarations/src/locales/generated.d.ts +6536 -0
  11. package/dist/package/declarations/src/rpc/base/v1/ai_session.d.ts +12 -2
  12. package/dist/package/declarations/src/rpc/base/v1/ai_tool.d.ts +9 -1
  13. package/dist/package/declarations/src/rpc/base/v1/config.d.ts +35 -0
  14. package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +1 -1
  15. package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +23 -2
  16. package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +9 -0
  17. package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +9 -1
  18. package/dist/package/declarations/src/rpc/system/admin/v1/base_language.d.ts +119 -0
  19. package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +6 -1
  20. package/dist/package/declarations/src/rpc/system/admin/v1/base_migration.d.ts +6 -6
  21. package/dist/package/declarations/src/rpc/system/admin/v1/base_role.d.ts +13 -1
  22. package/dist/package/declarations/src/rpc/system/admin/v1/base_translation.d.ts +75 -0
  23. package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +11 -1
  24. package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +13 -11
  25. package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_column.d.ts +7 -0
  26. package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_table.d.ts +24 -1
  27. package/dist/package/declarations/src/rpc/system/admin/v1/common.d.ts +13 -0
  28. package/dist/package/declarations/src/rpc/system/admin/v1/ops_monitoring.d.ts +222 -0
  29. package/dist/package/declarations/src/views/base/language/index.vue.d.ts +3 -0
  30. package/dist/package/declarations/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue.d.ts +23 -0
  31. package/dist/package/declarations/src/views/tool/code-gen/config.d.ts +7 -7
  32. package/dist/package/declarations/src/views/tool/ops-monitoring/index.vue.d.ts +3 -0
  33. package/dist/package/src/api/base/ai_message.ts +7 -12
  34. package/dist/package/src/api/base/sse.ts +3 -1
  35. package/dist/package/src/api/system/base_language.ts +135 -0
  36. package/dist/package/src/api/system/base_translation.ts +33 -0
  37. package/dist/package/src/api/system/code_gen_column.ts +17 -3
  38. package/dist/package/src/api/system/code_gen_i18n.ts +18 -0
  39. package/dist/package/src/api/system/code_gen_table.ts +12 -4
  40. package/dist/package/src/api/system/ops_monitoring.ts +88 -0
  41. package/dist/package/src/api/system/ops_monitoring_sse.ts +49 -0
  42. package/dist/package/src/components/DynamicTranslationCell.vue +249 -0
  43. package/dist/package/src/components/DynamicTranslationEditor.vue +197 -0
  44. package/dist/package/src/components/dynamicTranslation.ts +66 -0
  45. package/dist/package/src/locales/README.md +30 -0
  46. package/dist/package/src/locales/en-US.json +933 -0
  47. package/dist/package/src/locales/es-ES.json +933 -0
  48. package/dist/package/src/locales/fr-FR.json +933 -0
  49. package/dist/package/src/locales/generated.ts +22 -0
  50. package/dist/package/src/locales/ja-JP.json +933 -0
  51. package/dist/package/src/locales/ko-KR.json +933 -0
  52. package/dist/package/src/locales/zh-CN.json +933 -0
  53. package/dist/package/src/locales/zh-TW.json +933 -0
  54. package/dist/package/src/module.ts +6 -2
  55. package/dist/package/src/rpc/base/v1/ai_session.ts +13 -2
  56. package/dist/package/src/rpc/base/v1/ai_tool.ts +10 -1
  57. package/dist/package/src/rpc/base/v1/config.ts +47 -0
  58. package/dist/package/src/rpc/system/admin/v1/auth.ts +1 -1
  59. package/dist/package/src/rpc/system/admin/v1/base_config.ts +24 -2
  60. package/dist/package/src/rpc/system/admin/v1/base_dict.ts +9 -0
  61. package/dist/package/src/rpc/system/admin/v1/base_job.ts +10 -1
  62. package/dist/package/src/rpc/system/admin/v1/base_language.ts +141 -0
  63. package/dist/package/src/rpc/system/admin/v1/base_menu.ts +6 -1
  64. package/dist/package/src/rpc/system/admin/v1/base_migration.ts +8 -8
  65. package/dist/package/src/rpc/system/admin/v1/base_role.ts +14 -1
  66. package/dist/package/src/rpc/system/admin/v1/base_translation.ts +90 -0
  67. package/dist/package/src/rpc/system/admin/v1/base_user.ts +12 -1
  68. package/dist/package/src/rpc/system/admin/v1/code_gen.ts +16 -12
  69. package/dist/package/src/rpc/system/admin/v1/code_gen_column.ts +8 -0
  70. package/dist/package/src/rpc/system/admin/v1/code_gen_table.ts +27 -1
  71. package/dist/package/src/rpc/system/admin/v1/common.ts +21 -0
  72. package/dist/package/src/rpc/system/admin/v1/ops_monitoring.ts +255 -0
  73. package/dist/package/src/views/ai/chat/components/AiMarkdown.vue +1 -6
  74. package/dist/package/src/views/ai/chat/components/ChatPanel.vue +75 -58
  75. package/dist/package/src/views/ai/chat/components/SessionPanel.vue +20 -9
  76. package/dist/package/src/views/ai/chat/components/XSender.vue +36 -23
  77. package/dist/package/src/views/ai/chat/index.vue +58 -41
  78. package/dist/package/src/views/ai/chat/message.ts +29 -27
  79. package/dist/package/src/views/base/api/index.vue +121 -84
  80. package/dist/package/src/views/base/area/index.vue +81 -32
  81. package/dist/package/src/views/base/config/index.vue +300 -96
  82. package/dist/package/src/views/base/dept/index.vue +110 -62
  83. package/dist/package/src/views/base/dict/index.vue +145 -62
  84. package/dist/package/src/views/base/dict/item.vue +155 -64
  85. package/dist/package/src/views/base/job/index.vue +134 -82
  86. package/dist/package/src/views/base/job/log.vue +24 -25
  87. package/dist/package/src/views/base/language/index.vue +260 -0
  88. package/dist/package/src/views/base/log/index.vue +68 -46
  89. package/dist/package/src/views/base/menu/index.vue +344 -200
  90. package/dist/package/src/views/base/migration/index.vue +49 -29
  91. package/dist/package/src/views/base/post/index.vue +128 -60
  92. package/dist/package/src/views/base/role/index.vue +145 -79
  93. package/dist/package/src/views/base/tenant/index.vue +132 -64
  94. package/dist/package/src/views/base/user/components/dept-tree.vue +2 -1
  95. package/dist/package/src/views/base/user/index.vue +194 -116
  96. package/dist/package/src/views/profile/components/base.vue +45 -28
  97. package/dist/package/src/views/profile/components/password.vue +45 -30
  98. package/dist/package/src/views/profile/components/security.vue +90 -54
  99. package/dist/package/src/views/profile/index.vue +10 -9
  100. package/dist/package/src/views/tool/api-doc/index.vue +6 -2
  101. package/dist/package/src/views/tool/code-gen/code-preview/index.vue +32 -16
  102. package/dist/package/src/views/tool/code-gen/columns/index.vue +382 -273
  103. package/dist/package/src/views/tool/code-gen/columns/option-copy.ts +1 -6
  104. package/dist/package/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue +118 -0
  105. package/dist/package/src/views/tool/code-gen/components/CodeGenProgressDialog.vue +65 -36
  106. package/dist/package/src/views/tool/code-gen/components/CodePreviewPane.vue +8 -5
  107. package/dist/package/src/views/tool/code-gen/config.ts +116 -79
  108. package/dist/package/src/views/tool/code-gen/preview/data.ts +19 -17
  109. package/dist/package/src/views/tool/code-gen/preview/index.vue +96 -59
  110. package/dist/package/src/views/tool/code-gen/proto/index.vue +110 -62
  111. package/dist/package/src/views/tool/code-gen/table/index.vue +201 -121
  112. package/dist/package/src/views/tool/ops-monitoring/index.vue +1175 -0
  113. package/dist/package/src/views/tool/project-doc/index.vue +17 -15
  114. package/package.json +6 -2
  115. package/dist/package/declarations/src/rpc/base/v1/enum.d.ts +0 -43
  116. package/dist/package/declarations/src/rpc/system/common/v1/enum.d.ts +0 -67
  117. package/dist/package/src/rpc/base/v1/enum.ts +0 -54
  118. package/dist/package/src/rpc/system/common/v1/enum.ts +0 -80
@@ -12,17 +12,19 @@
12
12
  <FormDialog
13
13
  v-model="dialog.visible"
14
14
  ref="formDialogRef"
15
- :title="dialog.title"
15
+ :title="t(dialog.titleKey, { resource: t('system.base.config.resource') })"
16
16
  width="1200px"
17
17
  :model="formData"
18
18
  :fields="formFields"
19
19
  :rules="rules"
20
- label-width="100px"
21
20
  @confirm="handleSubmit"
22
21
  @close="handleCloseDialog"
23
22
  >
24
23
  <template #textValue>
25
- <el-input v-model="formData.value" placeholder="请输入配置值" />
24
+ <el-input
25
+ v-model="formData.value"
26
+ :placeholder="t('common.validation.required_input', { field: t('system.base.config.field.value') })"
27
+ />
26
28
  </template>
27
29
  <template #imageValue>
28
30
  <UploadImg v-model:image-url="formData.value" upload-type="config" />
@@ -31,8 +33,18 @@
31
33
  <WangEditor v-model:value="formData.value" />
32
34
  </template>
33
35
  <template #dictValue>
34
- <Dict v-if="dictValueCode" v-model="formData.value" :code="dictValueCode" code-type="string" placeholder="请选择字典配置值" />
35
- <el-input v-else v-model="formData.value" placeholder="请输入配置值" />
36
+ <Dict
37
+ v-if="dictValueCode"
38
+ v-model="formData.value"
39
+ :code="dictValueCode"
40
+ code-type="string"
41
+ :placeholder="t('common.validation.required_select', { field: t('system.base.config.field.value') })"
42
+ />
43
+ <el-input
44
+ v-else
45
+ v-model="formData.value"
46
+ :placeholder="t('common.validation.required_input', { field: t('system.base.config.field.value') })"
47
+ />
36
48
  </template>
37
49
  <template #booleanValue>
38
50
  <el-switch
@@ -44,6 +56,21 @@
44
56
  inline-prompt
45
57
  />
46
58
  </template>
59
+ <template #nameTranslations>
60
+ <DynamicTranslationEditor
61
+ v-model="nameTranslationValues"
62
+ :source="formData.name"
63
+ :maxlength="100"
64
+ />
65
+ </template>
66
+ <template #valueTranslations>
67
+ <DynamicTranslationEditor
68
+ v-model="valueTranslationValues"
69
+ :source="formData.value"
70
+ :maxlength="10000"
71
+ multiline
72
+ />
73
+ </template>
47
74
  </FormDialog>
48
75
  </div>
49
76
  </template>
@@ -62,11 +89,33 @@ import UploadImg from "@liujitcn/kratos-admin-core/components/Upload/Img.vue";
62
89
  import WangEditor from "@liujitcn/kratos-admin-core/components/WangEditor/index.vue";
63
90
  import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
64
91
  import { defBaseConfigService } from "@liujitcn/kratos-admin-system/api/system/base_config";
65
- import type { BaseConfig, BaseConfigForm, PageBaseConfigRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_config";
66
- import { BaseConfigSite } from "@liujitcn/kratos-admin-system/rpc/base/v1/enum";
92
+ import { loadEnabledBaseLanguages } from "@liujitcn/kratos-admin-system/api/system/base_language";
93
+ import type {
94
+ BaseConfig,
95
+ BaseConfigForm,
96
+ PageBaseConfigRequest
97
+ } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_config";
98
+ import type { BaseTranslation } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_translation";
99
+ import { BaseConfigSite } from "@liujitcn/kratos-admin-system/rpc/base/v1/config";
67
100
  import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
68
- import { BaseConfigType } from "@liujitcn/kratos-admin-system/rpc/system/common/v1/enum";
101
+ import { BaseConfigType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_config";
102
+ import { TranslationTargetType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_translation";
69
103
  import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
104
+ import { t } from "@liujitcn/kratos-admin-core";
105
+ import DynamicTranslationEditor from "@liujitcn/kratos-admin-system/components/DynamicTranslationEditor.vue";
106
+ import DynamicTranslationCell from "@liujitcn/kratos-admin-system/components/DynamicTranslationCell.vue";
107
+ import {
108
+ getEditableLanguageOptions,
109
+ type DynamicTranslationValue
110
+ } from "@liujitcn/kratos-admin-system/components/dynamicTranslation";
111
+
112
+ /** 系统配置编辑表单状态,新增时枚举字段保持为空,避免把未知值 0 显示为下拉文本。 */
113
+ type BaseConfigFormState = Omit<BaseConfigForm, "site" | "type"> & {
114
+ /** 配置位置。 */
115
+ site?: BaseConfigSite;
116
+ /** 配置类型。 */
117
+ type?: BaseConfigType;
118
+ };
70
119
 
71
120
  defineOptions({
72
121
  name: "BaseConfig",
@@ -78,46 +127,135 @@ const proTable = ref<ProTableInstance>();
78
127
  const formDialogRef = ref<InstanceType<typeof FormDialog>>();
79
128
 
80
129
  const dialog = reactive({
81
- title: "",
130
+ titleKey: "common.action.create_resource",
82
131
  visible: false
83
132
  });
84
133
 
85
- const formData = reactive<BaseConfigForm>({
134
+ const formData = reactive<BaseConfigFormState>({
86
135
  /** 配置ID */
87
136
  id: 0,
88
137
  /** 位置:枚举【BaseConfigSite】 */
89
- site: BaseConfigSite.UNKNOWN_BCS,
138
+ site: undefined,
90
139
  /** 配置名称 */
91
140
  name: "",
92
141
  /** 配置类型:枚举【BaseConfigType】 */
93
- type: BaseConfigType.UNKNOWN_BCT,
142
+ type: undefined,
94
143
  /** 配置key */
95
144
  key: "",
96
145
  /** 配置value */
97
146
  value: "",
98
147
  /** 状态 */
99
- status: Status.ENABLE
148
+ status: Status.ENABLE,
149
+ /** 配置名称非主语言翻译。 */
150
+ name_translations: [],
151
+ /** 配置文本或富文本值的非主语言翻译。 */
152
+ value_translations: []
100
153
  });
101
154
 
102
- const rules = reactive({
103
- site: [{ required: true, message: "请选择系统配置位置", trigger: "change" }],
155
+ /** 将配置值翻译记录转换为编辑器值,缺少记录时保留可编辑的空行。 */
156
+ function normalizeConfigTranslations(targetType: TranslationTargetType): DynamicTranslationValue[] {
157
+ const records = targetType === TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME
158
+ ? formData.name_translations
159
+ : formData.value_translations;
160
+ return getEditableLanguageOptions()
161
+ .map(item => item.value)
162
+ .map(locale => {
163
+ const record = records?.find(item => item.locale === locale);
164
+ return {
165
+ id: record?.id ?? 0,
166
+ locale,
167
+ text: record?.name ?? ""
168
+ };
169
+ });
170
+ }
171
+
172
+ /** 保存指定目标类型的编辑器值,并保留其他字段的翻译。 */
173
+ function updateConfigTranslations(targetType: TranslationTargetType, values: DynamicTranslationValue[]) {
174
+ const next = values.map(
175
+ item =>
176
+ ({
177
+ ...item,
178
+ target_type: targetType,
179
+ target_id: formData.id,
180
+ name: item.text
181
+ }) as BaseTranslation
182
+ );
183
+ if (targetType === TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME) {
184
+ formData.name_translations = next;
185
+ } else {
186
+ formData.value_translations = next;
187
+ }
188
+ }
189
+
190
+ const nameTranslationValues = computed<DynamicTranslationValue[]>({
191
+ get: () => normalizeConfigTranslations(TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME),
192
+ set: values => updateConfigTranslations(TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME, values)
193
+ });
194
+
195
+ const valueTranslationValues = computed<DynamicTranslationValue[]>({
196
+ get: () => normalizeConfigTranslations(TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_CONFIG_VALUE),
197
+ set: values => updateConfigTranslations(TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_CONFIG_VALUE, values)
198
+ });
199
+
200
+ const rules = computed(() => ({
201
+ site: [
202
+ {
203
+ required: true,
204
+ message: t("common.validation.required_select", { field: t("system.base.config.field.site") }),
205
+ trigger: "change"
206
+ }
207
+ ],
104
208
  name: [
105
- { required: true, message: "请输入系统配置名称", trigger: "blur" },
106
- { max: 50, message: "配置名称不能超过 50 个字符", trigger: "blur" }
209
+ {
210
+ required: true,
211
+ message: t("common.validation.required_input", { field: t("system.base.config.field.name") }),
212
+ trigger: "blur"
213
+ },
214
+ {
215
+ max: 50,
216
+ message: t("common.validation.max_length", { field: t("system.base.config.field.name"), max: 50 }),
217
+ trigger: "blur"
218
+ }
219
+ ],
220
+ type: [
221
+ {
222
+ required: true,
223
+ message: t("common.validation.required_select", { field: t("system.base.config.field.type") }),
224
+ trigger: "change"
225
+ }
107
226
  ],
108
- type: [{ required: true, message: "请选择系统配置类型", trigger: "change" }],
109
227
  key: [
110
- { required: true, message: "请输入系统配置编码", trigger: "blur" },
111
- { max: 50, message: "配置key不能超过 50 个字符", trigger: "blur" }
228
+ {
229
+ required: true,
230
+ message: t("common.validation.required_input", { field: t("system.base.config.field.key") }),
231
+ trigger: "blur"
232
+ },
233
+ {
234
+ max: 50,
235
+ message: t("common.validation.max_length", { field: t("system.base.config.field.key"), max: 50 }),
236
+ trigger: "blur"
237
+ }
112
238
  ],
113
- value: [{ required: true, message: "配置值不能为空", trigger: "blur" }],
114
- status: [{ required: true, message: "请选择状态", trigger: "change" }]
115
- });
239
+ value: [
240
+ {
241
+ required: true,
242
+ message: t("common.validation.required_input", { field: t("system.base.config.field.value") }),
243
+ trigger: "blur"
244
+ }
245
+ ],
246
+ status: [
247
+ {
248
+ required: true,
249
+ message: t("common.validation.required_select", { field: t("common.field.status") }),
250
+ trigger: "change"
251
+ }
252
+ ]
253
+ }));
116
254
 
117
- const statusOptions: ProFormOption[] = [
118
- { label: "启用", value: Status.ENABLE },
119
- { label: "禁用", value: Status.DISABLE }
120
- ];
255
+ const statusOptions = computed<ProFormOption[]>(() => [
256
+ { label: t("common.status.enabled"), value: Status.ENABLE },
257
+ { label: t("common.status.disabled"), value: Status.DISABLE }
258
+ ]);
121
259
 
122
260
  /** 字典类系统配置与字典编码的映射关系。 */
123
261
  const BASE_CONFIG_DICT_CODE_MAP: Record<string, string> = {
@@ -131,106 +269,147 @@ const dictValueCode = computed(() => BASE_CONFIG_DICT_CODE_MAP[formData.key] ??
131
269
  const formFields = computed<ProFormField[]>(() => [
132
270
  {
133
271
  prop: "name",
134
- label: "配置名称",
272
+ label: t("system.base.config.field.name"),
135
273
  component: "input",
136
- props: { placeholder: "请输入配置名称", disabled: formData.id > 0 }
274
+ props: {
275
+ placeholder: t("common.validation.required_input", { field: t("system.base.config.field.name") }),
276
+ disabled: formData.id > 0
277
+ }
137
278
  },
138
279
  {
139
280
  prop: "site",
140
- label: "配置位置",
281
+ label: t("system.base.config.field.site"),
141
282
  component: "dict",
142
283
  props: { code: "base_config_site", disabled: formData.id > 0 }
143
284
  },
144
285
  {
145
286
  prop: "key",
146
- label: "配置键",
287
+ label: t("system.base.config.field.key"),
147
288
  component: "input",
148
- props: { placeholder: "请输入配置键", disabled: formData.id > 0 }
289
+ props: {
290
+ placeholder: t("common.validation.required_input", { field: t("system.base.config.field.key") }),
291
+ disabled: formData.id > 0
292
+ }
149
293
  },
150
294
  {
151
295
  prop: "type",
152
- label: "配置类型",
296
+ label: t("system.base.config.field.type"),
153
297
  component: "dict",
154
298
  props: { code: "base_config_type", disabled: formData.id > 0 }
155
299
  },
156
300
  {
157
301
  prop: "value",
158
- label: "配置值",
302
+ label: t("system.base.config.field.value"),
159
303
  component: "slot",
160
304
  slotName: "textValue",
161
- visible: model => model.type == BaseConfigType.TEXT
305
+ visible: model => model.type == BaseConfigType.BASE_CONFIG_TYPE_TEXT
162
306
  },
163
307
  {
164
308
  prop: "value",
165
- label: "配置值",
309
+ label: t("system.base.config.field.value"),
166
310
  component: "slot",
167
311
  slotName: "imageValue",
168
- visible: model => model.type == BaseConfigType.IMAGE
312
+ visible: model => model.type == BaseConfigType.BASE_CONFIG_TYPE_IMAGE
169
313
  },
170
314
  {
171
315
  prop: "value",
172
- label: "配置值",
316
+ label: t("system.base.config.field.value"),
173
317
  component: "slot",
174
318
  slotName: "richTextValue",
175
- visible: model => model.type == BaseConfigType.RICH_TEXT,
319
+ visible: model => model.type == BaseConfigType.BASE_CONFIG_TYPE_RICH_TEXT,
176
320
  colSpan: 24
177
321
  },
178
322
  {
179
323
  prop: "value",
180
- label: "配置值",
324
+ label: t("system.base.config.field.value"),
181
325
  component: "slot",
182
326
  slotName: "dictValue",
183
- visible: model => model.type == BaseConfigType.DICT
327
+ visible: model => model.type == BaseConfigType.BASE_CONFIG_TYPE_DICT
184
328
  },
185
329
  {
186
330
  prop: "value",
187
- label: "配置值",
331
+ label: t("system.base.config.field.value"),
188
332
  component: "slot",
189
333
  slotName: "booleanValue",
190
- visible: model => model.type == BaseConfigType.BOOLEAN
334
+ visible: model => model.type == BaseConfigType.BASE_CONFIG_TYPE_BOOLEAN
335
+ },
336
+ {
337
+ prop: "translations",
338
+ label: t("system.base.translation.field.name_translations"),
339
+ component: "slot",
340
+ slotName: "nameTranslations",
341
+ colSpan: 24
191
342
  },
192
- { prop: "status", label: "状态", component: "radio-group", options: statusOptions }
343
+ {
344
+ prop: "translations",
345
+ label: t("system.base.translation.field.value_translations"),
346
+ component: "slot",
347
+ slotName: "valueTranslations",
348
+ visible: model =>
349
+ model.type == BaseConfigType.BASE_CONFIG_TYPE_TEXT || model.type == BaseConfigType.BASE_CONFIG_TYPE_RICH_TEXT,
350
+ colSpan: 24
351
+ },
352
+ { prop: "status", label: t("common.field.status"), component: "radio-group", options: statusOptions.value }
193
353
  ]);
194
354
 
195
355
  /** 系统配置表格列配置。 */
196
- const columns: ColumnProps[] = [
356
+ const columns = computed<ColumnProps[]>(() => [
197
357
  { type: "selection", width: 55 },
198
- { prop: "site", label: "配置位置", minWidth: 120, dictCode: "base_config_site", search: { el: "select" } },
199
- { prop: "name", label: "配置名称", minWidth: 140, search: { el: "input" } },
200
- { prop: "type", label: "配置类型", minWidth: 120, dictCode: "base_config_type", search: { el: "select" } },
358
+ {
359
+ prop: "site",
360
+ label: t("system.base.config.field.site"),
361
+ minWidth: 120,
362
+ dictCode: "base_config_site",
363
+ search: { el: "select" }
364
+ },
365
+ {
366
+ prop: "name",
367
+ label: t("system.base.config.field.name"),
368
+ minWidth: 140,
369
+ search: { el: "input" },
370
+ showOverflowTooltip: false,
371
+ render: scope => renderConfigNameCell(scope.row as BaseConfig)
372
+ },
373
+ {
374
+ prop: "type",
375
+ label: t("system.base.config.field.type"),
376
+ minWidth: 120,
377
+ dictCode: "base_config_type",
378
+ search: { el: "select" }
379
+ },
201
380
  {
202
381
  prop: "key",
203
- label: "配置键",
382
+ label: t("system.base.config.field.key"),
204
383
  minWidth: 160,
205
384
  search: { el: "input" },
206
385
  render: scope => renderConfigKeyCell(scope.row as BaseConfig)
207
386
  },
208
387
  {
209
388
  prop: "status",
210
- label: "状态",
389
+ label: t("common.field.status"),
211
390
  minWidth: 100,
212
391
  search: { el: "select" },
213
392
  cellType: "status",
214
393
  statusProps: {
215
394
  activeValue: Status.ENABLE,
216
395
  inactiveValue: Status.DISABLE,
217
- activeText: "启用",
218
- inactiveText: "禁用",
396
+ activeText: t("common.status.enabled"),
397
+ inactiveText: t("common.status.disabled"),
219
398
  disabled: () => !BUTTONS.value["base:config:status"],
220
399
  beforeChange: scope => handleBeforeSetStatus(scope.row as BaseConfig)
221
400
  }
222
401
  },
223
- { prop: "created_at", label: "创建时间", minWidth: 180 },
224
- { prop: "updated_at", label: "更新时间", minWidth: 180 },
402
+ { prop: "created_at", label: t("common.field.created_at"), minWidth: 180 },
403
+ { prop: "updated_at", label: t("common.field.updated_at"), minWidth: 180 },
225
404
  {
226
405
  prop: "operation",
227
- label: "操作",
406
+ label: t("common.field.operation"),
228
407
  width: 150,
229
408
  fixed: "right",
230
409
  cellType: "actions",
231
410
  actions: [
232
411
  {
233
- label: "编辑",
412
+ label: t("common.action.edit"),
234
413
  type: "primary",
235
414
  link: true,
236
415
  icon: EditPen,
@@ -239,7 +418,7 @@ const columns: ColumnProps[] = [
239
418
  onClick: (scope, params) => handleOpenDialog((params?.configId as number | undefined) ?? (scope.row as BaseConfig).id)
240
419
  },
241
420
  {
242
- label: "删除",
421
+ label: t("common.action.delete"),
243
422
  type: "danger",
244
423
  link: true,
245
424
  icon: Delete,
@@ -248,7 +427,17 @@ const columns: ColumnProps[] = [
248
427
  }
249
428
  ]
250
429
  }
251
- ];
430
+ ]);
431
+
432
+ /** 渲染系统配置名称翻译预览。 */
433
+ function renderConfigNameCell(row: BaseConfig) {
434
+ return h(DynamicTranslationCell, {
435
+ source: row.name,
436
+ targetType: TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_CONFIG_NAME,
437
+ targetId: row.id,
438
+ translations: row.translations
439
+ });
440
+ }
252
441
 
253
442
  /**
254
443
  * 将配置键渲染为可悬停查看配置值的单元格。
@@ -274,7 +463,7 @@ function renderConfigKeyCell(row: BaseConfig) {
274
463
  * 根据配置类型渲染悬停预览内容。
275
464
  */
276
465
  function renderConfigValuePreview(row: BaseConfig) {
277
- if (row.type === BaseConfigType.IMAGE) {
466
+ if (row.type === BaseConfigType.BASE_CONFIG_TYPE_IMAGE) {
278
467
  return row.value
279
468
  ? h(ElImage, {
280
469
  src: row.value,
@@ -283,15 +472,15 @@ function renderConfigValuePreview(row: BaseConfig) {
283
472
  fit: "contain",
284
473
  style: { width: "180px", height: "120px", borderRadius: "4px" }
285
474
  })
286
- : h("span", { class: "config-value-preview" }, "未配置图片");
475
+ : h("span", { class: "config-value-preview" }, t("system.base.config.message.image_missing"));
287
476
  }
288
477
 
289
- if (row.type === BaseConfigType.BOOLEAN) {
478
+ if (row.type === BaseConfigType.BASE_CONFIG_TYPE_BOOLEAN) {
290
479
  const value = row.value === "true" ? "true" : "false";
291
480
  return h(ElTag, { type: value === "true" ? "success" : "info" }, () => value);
292
481
  }
293
482
 
294
- if (row.type === BaseConfigType.DICT && BASE_CONFIG_DICT_CODE_MAP[row.key]) {
483
+ if (row.type === BaseConfigType.BASE_CONFIG_TYPE_DICT && BASE_CONFIG_DICT_CODE_MAP[row.key]) {
295
484
  return h(DictLabel, {
296
485
  code: BASE_CONFIG_DICT_CODE_MAP[row.key],
297
486
  modelValue: row.value,
@@ -299,27 +488,27 @@ function renderConfigValuePreview(row: BaseConfig) {
299
488
  });
300
489
  }
301
490
 
302
- if (row.type === BaseConfigType.RICH_TEXT) {
491
+ if (row.type === BaseConfigType.BASE_CONFIG_TYPE_RICH_TEXT) {
303
492
  return row.value
304
493
  ? h("div", { class: "config-rich-text-preview", innerHTML: row.value })
305
- : h("span", { class: "config-value-preview" }, "未配置富文本");
494
+ : h("span", { class: "config-value-preview" }, t("system.base.config.message.rich_text_missing"));
306
495
  }
307
496
 
308
497
  const value = row.value;
309
- return h("span", { class: "config-value-preview" }, value || "未配置");
498
+ return h("span", { class: "config-value-preview" }, value || t("system.base.config.message.value_missing"));
310
499
  }
311
500
 
312
501
  /** 系统配置顶部按钮配置。 */
313
- const headerActions: HeaderActionProps[] = [
502
+ const headerActions = computed<HeaderActionProps[]>(() => [
314
503
  {
315
- label: "新增",
504
+ label: t("common.action.create"),
316
505
  type: "success",
317
506
  icon: CirclePlus,
318
507
  hidden: () => !BUTTONS.value["base:config:create"],
319
508
  onClick: () => handleOpenDialog()
320
509
  },
321
510
  {
322
- label: "删除",
511
+ label: t("common.action.delete"),
323
512
  type: "danger",
324
513
  icon: Delete,
325
514
  hidden: () => !BUTTONS.value["base:config:delete"],
@@ -327,18 +516,19 @@ const headerActions: HeaderActionProps[] = [
327
516
  onClick: scope => handleDelete(scope.selectedList as BaseConfig[])
328
517
  },
329
518
  {
330
- label: "刷新缓存",
519
+ label: t("common.action.refresh_cache"),
331
520
  type: "primary",
332
521
  icon: RefreshLeft,
333
522
  hidden: () => !BUTTONS.value["base:config:refresh"],
334
523
  onClick: () => handleRefreshCache()
335
524
  }
336
- ];
525
+ ]);
337
526
 
338
527
  /**
339
528
  * 请求系统配置列表,并由 ProTable 统一维护分页与搜索参数。
340
529
  */
341
530
  async function requestBaseConfigTable(params: PageBaseConfigRequest) {
531
+ await loadEnabledBaseLanguages();
342
532
  const data = await defBaseConfigService.PageBaseConfig(buildPageRequest(params));
343
533
  return { data: { list: data.base_configs ?? [], total: data.total } };
344
534
  }
@@ -353,15 +543,14 @@ function refreshTable() {
353
543
  /**
354
544
  * 打开系统配置弹窗。
355
545
  */
356
- function handleOpenDialog(configId?: number) {
546
+ async function handleOpenDialog(configId?: number) {
547
+ await loadEnabledBaseLanguages();
357
548
  resetForm();
358
- dialog.title = configId ? "修改系统配置" : "新增系统配置";
549
+ dialog.titleKey = configId ? "common.action.edit_resource" : "common.action.create_resource";
359
550
  dialog.visible = true;
360
551
  if (!configId) return;
361
552
 
362
- defBaseConfigService.GetBaseConfig({ id: configId }).then(data => {
363
- Object.assign(formData, data);
364
- });
553
+ Object.assign(formData, await defBaseConfigService.GetBaseConfig({ id: configId }));
365
554
  }
366
555
 
367
556
  /**
@@ -379,11 +568,13 @@ function resetForm() {
379
568
  formDialogRef.value?.resetFields();
380
569
  formDialogRef.value?.clearValidate();
381
570
  formData.id = 0;
382
- formData.site = BaseConfigSite.UNKNOWN_BCS;
571
+ formData.site = undefined;
383
572
  formData.name = "";
384
- formData.type = BaseConfigType.UNKNOWN_BCT;
573
+ formData.type = undefined;
385
574
  formData.key = "";
386
575
  formData.value = "";
576
+ formData.name_translations = [];
577
+ formData.value_translations = [];
387
578
  formData.status = Status.ENABLE;
388
579
  }
389
580
 
@@ -391,7 +582,7 @@ function resetForm() {
391
582
  * 提交系统配置表单。
392
583
  */
393
584
  function handleSubmit() {
394
- if (formData.type === BaseConfigType.BOOLEAN) {
585
+ if (formData.type === BaseConfigType.BASE_CONFIG_TYPE_BOOLEAN) {
395
586
  formData.value = formData.value === "true" ? "true" : "false";
396
587
  }
397
588
  formDialogRef.value?.validate()?.then(valid => {
@@ -402,7 +593,11 @@ function handleSubmit() {
402
593
  ? defBaseConfigService.UpdateBaseConfig({ base_config: submitData })
403
594
  : defBaseConfigService.CreateBaseConfig({ base_config: submitData });
404
595
  request.then(() => {
405
- ElMessage.success(submitData.id ? "修改系统配置成功" : "新增系统配置成功");
596
+ ElMessage.success(
597
+ t(submitData.id ? "common.message.update_success" : "common.message.create_success", {
598
+ resource: t("system.base.config.resource")
599
+ })
600
+ );
406
601
  handleCloseDialog();
407
602
  refreshTable();
408
603
  });
@@ -414,7 +609,7 @@ function handleSubmit() {
414
609
  */
415
610
  const handleRefreshCache = useDebounceFn(() => {
416
611
  defBaseConfigService.RefreshBaseConfigCache({}).then(() => {
417
- ElMessage.success("刷新成功");
612
+ ElMessage.success(t("common.message.refresh_success"));
418
613
  });
419
614
  }, 1000);
420
615
 
@@ -423,16 +618,25 @@ const handleRefreshCache = useDebounceFn(() => {
423
618
  */
424
619
  async function handleBeforeSetStatus(row: BaseConfig) {
425
620
  const nextStatus = row.status === Status.ENABLE ? Status.DISABLE : Status.ENABLE;
426
- const text = nextStatus === Status.ENABLE ? "启用" : "禁用";
621
+ const text = t(nextStatus === Status.ENABLE ? "common.status.enabled" : "common.status.disabled");
427
622
  const configName = row.name || row.key || `ID:${row.id}`;
428
623
  try {
429
- await ElMessageBox.confirm(`是否确定${text}配置?\n配置名称:${configName}`, "提示", {
430
- confirmButtonText: "确认",
431
- cancelButtonText: "取消",
432
- type: "warning"
433
- });
624
+ await ElMessageBox.confirm(
625
+ t("common.dialog.status_change", {
626
+ action: text,
627
+ resource: t("system.base.config.resource"),
628
+ field: t("system.base.config.field.name"),
629
+ value: configName
630
+ }),
631
+ t("common.title.notice"),
632
+ {
633
+ confirmButtonText: t("common.action.confirm"),
634
+ cancelButtonText: t("common.action.cancel"),
635
+ type: "warning"
636
+ }
637
+ );
434
638
  await defBaseConfigService.SetBaseConfigStatus({ id: row.id, status: nextStatus });
435
- ElMessage.success(`${text}成功`);
639
+ ElMessage.success(t("common.message.status_success", { action: text }));
436
640
  refreshTable();
437
641
  return true;
438
642
  } catch {
@@ -455,29 +659,29 @@ function handleDelete(selected?: number | string | Array<number | string> | Base
455
659
  : normalizeSelectedIds(selected as number | string | Array<number | string>)
456
660
  ).join(",");
457
661
  if (!configIds) {
458
- ElMessage.warning("请勾选删除项");
662
+ ElMessage.warning(t("common.message.select_delete_item"));
459
663
  return;
460
664
  }
461
665
 
462
666
  const confirmMessage = configList.length
463
667
  ? configList.length === 1
464
- ? `是否确定删除配置?\n配置名称:${configList[0].name || configList[0].key || `ID:${configList[0].id}`}`
465
- : `确认删除已选中的 ${configList.length} 项系统配置吗?`
466
- : "确认删除已选中的系统配置吗?";
668
+ ? `${t("common.dialog.delete_single", { resource: t("system.base.config.resource") })}\n${t("common.dialog.resource_field", { field: t("system.base.config.field.name"), value: configList[0].name || configList[0].key || `ID:${configList[0].id}` })}`
669
+ : t("common.dialog.delete_batch", { count: configList.length, unit: "", resource: t("system.base.config.resource") })
670
+ : t("common.dialog.delete_selected", { resource: t("system.base.config.resource") });
467
671
 
468
- ElMessageBox.confirm(confirmMessage, "警告", {
469
- confirmButtonText: "确定",
470
- cancelButtonText: "取消",
672
+ ElMessageBox.confirm(confirmMessage, t("common.title.warning"), {
673
+ confirmButtonText: t("common.action.confirm"),
674
+ cancelButtonText: t("common.action.cancel"),
471
675
  type: "warning"
472
676
  }).then(
473
677
  () => {
474
678
  defBaseConfigService.DeleteBaseConfig({ id: configIds }).then(() => {
475
- ElMessage.success("删除系统配置成功");
679
+ ElMessage.success(t("common.message.delete_success", { resource: t("system.base.config.resource") }));
476
680
  refreshTable();
477
681
  });
478
682
  },
479
683
  () => {
480
- ElMessage.info("已取消删除系统配置");
684
+ ElMessage.info(t("common.dialog.cancel_delete", { resource: t("system.base.config.resource") }));
481
685
  }
482
686
  );
483
687
  }