@liujitcn/kratos-admin-system 0.0.19 → 0.0.21
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.
- package/README.md +51 -50
- package/dist/package/declarations/src/api/system/base_language.d.ts +51 -0
- package/dist/package/declarations/src/api/system/base_translation.d.ts +7 -0
- package/dist/package/declarations/src/api/system/code_gen_i18n.d.ts +8 -0
- package/dist/package/declarations/src/components/DynamicTranslationCell.vue.d.ts +39 -0
- package/dist/package/declarations/src/components/DynamicTranslationEditor.vue.d.ts +23 -0
- package/dist/package/declarations/src/components/dynamicTranslation.d.ts +44 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +5 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +79 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_language.d.ts +114 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +40 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_translation.d.ts +102 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +2 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_column.d.ts +7 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_table.d.ts +13 -0
- package/dist/package/declarations/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue.d.ts +23 -0
- package/dist/package/declarations/src/views/tool/code-gen/config.d.ts +7 -7
- package/dist/package/declarations/src/views/tool/language/index.vue.d.ts +3 -0
- package/dist/package/src/api/base/ai_message.ts +7 -12
- package/dist/package/src/api/base/sse.ts +3 -1
- package/dist/package/src/api/system/base_language.ts +137 -0
- package/dist/package/src/api/system/base_translation.ts +22 -0
- package/dist/package/src/api/system/code_gen_column.ts +17 -3
- package/dist/package/src/api/system/code_gen_i18n.ts +18 -0
- package/dist/package/src/api/system/code_gen_table.ts +12 -4
- package/dist/package/src/components/DynamicTranslationCell.vue +176 -0
- package/dist/package/src/components/DynamicTranslationEditor.vue +166 -0
- package/dist/package/src/components/dynamicTranslation.ts +86 -0
- package/dist/package/src/locales/README.md +28 -0
- package/dist/package/src/locales/en-US.json +929 -0
- package/dist/package/src/locales/es-ES.json +928 -0
- package/dist/package/src/locales/fr-FR.json +928 -0
- package/dist/package/src/locales/ja-JP.json +929 -0
- package/dist/package/src/locales/ko-KR.json +928 -0
- package/dist/package/src/locales/zh-CN.json +929 -0
- package/dist/package/src/locales/zh-TW.json +928 -0
- package/dist/package/src/module.ts +19 -1
- package/dist/package/src/rpc/system/admin/v1/base_config.ts +5 -0
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +81 -0
- package/dist/package/src/rpc/system/admin/v1/base_language.ts +135 -0
- package/dist/package/src/rpc/system/admin/v1/base_menu.ts +41 -0
- package/dist/package/src/rpc/system/admin/v1/base_translation.ts +117 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen.ts +5 -1
- package/dist/package/src/rpc/system/admin/v1/code_gen_column.ts +8 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_table.ts +15 -0
- package/dist/package/src/views/ai/chat/components/AiMarkdown.vue +1 -6
- package/dist/package/src/views/ai/chat/components/ChatPanel.vue +70 -53
- package/dist/package/src/views/ai/chat/components/SessionPanel.vue +20 -9
- package/dist/package/src/views/ai/chat/components/XSender.vue +36 -23
- package/dist/package/src/views/ai/chat/index.vue +55 -39
- package/dist/package/src/views/ai/chat/message.ts +18 -17
- package/dist/package/src/views/base/api/index.vue +121 -83
- package/dist/package/src/views/base/area/index.vue +81 -31
- package/dist/package/src/views/base/config/index.vue +272 -78
- package/dist/package/src/views/base/dept/index.vue +110 -61
- package/dist/package/src/views/base/dict/index.vue +137 -58
- package/dist/package/src/views/base/dict/item.vue +147 -61
- package/dist/package/src/views/base/job/index.vue +134 -81
- package/dist/package/src/views/base/job/log.vue +21 -22
- package/dist/package/src/views/base/log/index.vue +68 -46
- package/dist/package/src/views/base/menu/index.vue +257 -156
- package/dist/package/src/views/base/migration/index.vue +49 -29
- package/dist/package/src/views/base/post/index.vue +128 -59
- package/dist/package/src/views/base/role/index.vue +145 -78
- package/dist/package/src/views/base/tenant/index.vue +132 -63
- package/dist/package/src/views/base/user/components/dept-tree.vue +2 -1
- package/dist/package/src/views/base/user/index.vue +192 -112
- package/dist/package/src/views/profile/components/base.vue +44 -27
- package/dist/package/src/views/profile/components/password.vue +43 -27
- package/dist/package/src/views/profile/components/security.vue +89 -53
- package/dist/package/src/views/profile/index.vue +10 -9
- package/dist/package/src/views/tool/api-doc/index.vue +6 -2
- package/dist/package/src/views/tool/code-gen/code-preview/index.vue +30 -14
- package/dist/package/src/views/tool/code-gen/columns/index.vue +382 -273
- package/dist/package/src/views/tool/code-gen/columns/option-copy.ts +1 -6
- package/dist/package/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue +118 -0
- package/dist/package/src/views/tool/code-gen/components/CodeGenProgressDialog.vue +65 -36
- package/dist/package/src/views/tool/code-gen/components/CodePreviewPane.vue +8 -5
- package/dist/package/src/views/tool/code-gen/config.ts +114 -77
- package/dist/package/src/views/tool/code-gen/preview/data.ts +19 -17
- package/dist/package/src/views/tool/code-gen/preview/index.vue +96 -58
- package/dist/package/src/views/tool/code-gen/proto/index.vue +110 -62
- package/dist/package/src/views/tool/code-gen/table/index.vue +197 -117
- package/dist/package/src/views/tool/language/index.vue +256 -0
- package/dist/package/src/views/tool/project-doc/index.vue +17 -15
- package/package.json +6 -2
|
@@ -90,12 +90,7 @@ export function copyFirstMatchingCodeGenOption(column: CodeGenOptionCopyColumn,
|
|
|
90
90
|
const source = optionScopes
|
|
91
91
|
.filter(scope => scope !== targetScope)
|
|
92
92
|
.map(scope => getCodeGenOptionContainer(column, scope))
|
|
93
|
-
.find(
|
|
94
|
-
item =>
|
|
95
|
-
item.enabled &&
|
|
96
|
-
item.component === target.component &&
|
|
97
|
-
isCompleteCodeGenOptionConfig(item.option)
|
|
98
|
-
);
|
|
93
|
+
.find(item => item.enabled && item.component === target.component && isCompleteCodeGenOptionConfig(item.option));
|
|
99
94
|
if (!source) return false;
|
|
100
95
|
copyCodeGenOption(source, target);
|
|
101
96
|
return true;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="code-gen-locale-editor">
|
|
3
|
+
<el-alert
|
|
4
|
+
v-if="missingLocales.length"
|
|
5
|
+
:title="t('system.codegen.i18n.message.missing', { locales: missingLocales.join(', ') })"
|
|
6
|
+
type="warning"
|
|
7
|
+
:closable="false"
|
|
8
|
+
show-icon
|
|
9
|
+
/>
|
|
10
|
+
<div v-for="locale in editableLocales" :key="locale.value" class="code-gen-locale-editor__group">
|
|
11
|
+
<div class="code-gen-locale-editor__locale">
|
|
12
|
+
<span>{{ locale.label }}</span>
|
|
13
|
+
<el-tag v-if="hasComment(locale.value)" size="small" type="success" effect="plain">
|
|
14
|
+
{{ t("system.codegen.i18n.status.complete") }}
|
|
15
|
+
</el-tag>
|
|
16
|
+
<el-tag v-else size="small" type="warning" effect="plain">
|
|
17
|
+
{{ t("system.codegen.i18n.status.missing") }}
|
|
18
|
+
</el-tag>
|
|
19
|
+
</div>
|
|
20
|
+
<el-input
|
|
21
|
+
:model-value="localeValue(locale.value).comment"
|
|
22
|
+
:placeholder="t('system.codegen.i18n.placeholder.comment', { source: sourceComment || '-' })"
|
|
23
|
+
maxlength="255"
|
|
24
|
+
@update:model-value="value => updateLocale(locale.value, 'comment', value)"
|
|
25
|
+
/>
|
|
26
|
+
<el-input
|
|
27
|
+
v-if="showLeftTreeComment"
|
|
28
|
+
:model-value="localeValue(locale.value).left_tree_comment"
|
|
29
|
+
:placeholder="t('system.codegen.i18n.placeholder.leftTreeComment', { source: sourceLeftTreeComment || '-' })"
|
|
30
|
+
maxlength="255"
|
|
31
|
+
@update:model-value="value => updateLocale(locale.value, 'left_tree_comment', value)"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script setup lang="ts">
|
|
38
|
+
import { computed } from "vue";
|
|
39
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
40
|
+
import { loadEnabledBaseLanguages, useEnabledBaseLanguages } from "@liujitcn/kratos-admin-system/api/system/base_language";
|
|
41
|
+
import type { CodeGenLocaleConfig } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_translation";
|
|
42
|
+
|
|
43
|
+
/** 代码生成多语言编辑器属性。 */
|
|
44
|
+
interface CodeGenLocaleEditorProps {
|
|
45
|
+
/** 按语言区域索引的生成配置。 */
|
|
46
|
+
modelValue: Map<string, CodeGenLocaleConfig>;
|
|
47
|
+
/** 中文业务或字段描述。 */
|
|
48
|
+
sourceComment?: string;
|
|
49
|
+
/** 是否编辑左树标题。 */
|
|
50
|
+
showLeftTreeComment?: boolean;
|
|
51
|
+
/** 中文左树标题。 */
|
|
52
|
+
sourceLeftTreeComment?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const props = withDefaults(defineProps<CodeGenLocaleEditorProps>(), {
|
|
56
|
+
sourceComment: "",
|
|
57
|
+
showLeftTreeComment: false,
|
|
58
|
+
sourceLeftTreeComment: ""
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const emit = defineEmits<{
|
|
62
|
+
"update:modelValue": [value: Map<string, CodeGenLocaleConfig>];
|
|
63
|
+
}>();
|
|
64
|
+
|
|
65
|
+
const { languages } = useEnabledBaseLanguages();
|
|
66
|
+
void loadEnabledBaseLanguages();
|
|
67
|
+
|
|
68
|
+
const editableLocales = computed(() =>
|
|
69
|
+
languages.value
|
|
70
|
+
.filter(item => !item.is_primary)
|
|
71
|
+
.map(item => ({ value: item.language_code, label: item.native_name || item.language_name || item.language_code }))
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const missingLocales = computed(() =>
|
|
75
|
+
editableLocales.value.filter(locale => !hasComment(locale.value)).map(locale => locale.label)
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
/** 返回指定语言配置并补齐空字段。 */
|
|
79
|
+
function localeValue(locale: string): CodeGenLocaleConfig {
|
|
80
|
+
return props.modelValue?.get(locale) ?? { comment: "", left_tree_comment: "" };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 判断指定语言是否已填写业务或字段描述。 */
|
|
84
|
+
function hasComment(locale: string) {
|
|
85
|
+
const value = localeValue(locale);
|
|
86
|
+
return Boolean(value.comment && (!props.showLeftTreeComment || value.left_tree_comment));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** 更新单个语言字段并保持 Map 引用语义。 */
|
|
90
|
+
function updateLocale(locale: string, field: keyof CodeGenLocaleConfig, value: string) {
|
|
91
|
+
const next = new Map(props.modelValue ?? []);
|
|
92
|
+
next.set(locale, { ...localeValue(locale), [field]: value });
|
|
93
|
+
emit("update:modelValue", next);
|
|
94
|
+
}
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<style scoped lang="scss">
|
|
98
|
+
.code-gen-locale-editor {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
gap: 12px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.code-gen-locale-editor__group {
|
|
105
|
+
display: grid;
|
|
106
|
+
gap: 8px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.code-gen-locale-editor__locale {
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
justify-content: space-between;
|
|
113
|
+
min-height: 24px;
|
|
114
|
+
font-size: 13px;
|
|
115
|
+
font-weight: 600;
|
|
116
|
+
color: var(--el-text-color-primary);
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ProDialog
|
|
3
3
|
:model-value="modelValue"
|
|
4
|
-
title="
|
|
4
|
+
:title="t('system.codegen.progress.title')"
|
|
5
5
|
width="min(1080px, 94vw)"
|
|
6
6
|
top="4vh"
|
|
7
7
|
:close-on-click-modal="false"
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
<div class="task-heading">
|
|
14
14
|
<div>
|
|
15
15
|
<strong>{{ task.message }}</strong>
|
|
16
|
-
<span v-if="task.current_table_name"
|
|
16
|
+
<span v-if="task.current_table_name">
|
|
17
|
+
{{ t("system.codegen.progress.value.current", { table: task.current_table_name }) }}
|
|
18
|
+
</span>
|
|
17
19
|
</div>
|
|
18
20
|
<el-tag :type="statusMeta(task.status).type" effect="plain">{{ statusMeta(task.status).label }}</el-tag>
|
|
19
21
|
</div>
|
|
@@ -23,9 +25,13 @@
|
|
|
23
25
|
:stroke-width="12"
|
|
24
26
|
/>
|
|
25
27
|
<div class="task-meta">
|
|
26
|
-
<span>{{
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
<span>{{
|
|
29
|
+
t("system.codegen.progress.value.steps", { completed: task.completed_steps, total: task.total_steps })
|
|
30
|
+
}}</span>
|
|
31
|
+
<span>{{ t("system.codegen.progress.value.createdAt", { time: formatTime(task.created_at) }) }}</span>
|
|
32
|
+
<span v-if="task.finished_at">{{
|
|
33
|
+
t("system.codegen.progress.value.finishedAt", { time: formatTime(task.finished_at) })
|
|
34
|
+
}}</span>
|
|
29
35
|
</div>
|
|
30
36
|
|
|
31
37
|
<el-collapse v-model="expandedTables" class="table-progress-list">
|
|
@@ -41,12 +47,17 @@
|
|
|
41
47
|
</template>
|
|
42
48
|
<div v-if="table.message" class="table-message">
|
|
43
49
|
<span>{{ table.message }}</span>
|
|
44
|
-
<el-tooltip content="
|
|
45
|
-
<el-button
|
|
50
|
+
<el-tooltip :content="t('system.codegen.progress.action.copyError')" placement="top">
|
|
51
|
+
<el-button
|
|
52
|
+
:icon="CopyDocument"
|
|
53
|
+
link
|
|
54
|
+
:aria-label="t('system.codegen.progress.action.copyError')"
|
|
55
|
+
@click.stop="copyMessage(table.message)"
|
|
56
|
+
/>
|
|
46
57
|
</el-tooltip>
|
|
47
58
|
</div>
|
|
48
59
|
<el-table :data="table.steps" row-key="id" size="small" border>
|
|
49
|
-
<el-table-column label="
|
|
60
|
+
<el-table-column :label="t('system.codegen.table.field.status')" width="86" align="center">
|
|
50
61
|
<template #default="{ row }">
|
|
51
62
|
<el-icon :class="{ 'is-loading': row.status === CodeGenTaskStepStatus.CODE_GEN_TASK_STEP_STATUS_RUNNING }">
|
|
52
63
|
<Loading v-if="row.status === CodeGenTaskStepStatus.CODE_GEN_TASK_STEP_STATUS_RUNNING" />
|
|
@@ -57,10 +68,20 @@
|
|
|
57
68
|
</el-icon>
|
|
58
69
|
</template>
|
|
59
70
|
</el-table-column>
|
|
60
|
-
<el-table-column prop="label" label="
|
|
61
|
-
<el-table-column
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
<el-table-column prop="label" :label="t('system.codegen.progress.field.step')" min-width="130" />
|
|
72
|
+
<el-table-column
|
|
73
|
+
prop="path"
|
|
74
|
+
:label="t('system.codegen.preview.field.path')"
|
|
75
|
+
min-width="260"
|
|
76
|
+
show-overflow-tooltip
|
|
77
|
+
/>
|
|
78
|
+
<el-table-column
|
|
79
|
+
prop="message"
|
|
80
|
+
:label="t('system.codegen.progress.field.result')"
|
|
81
|
+
min-width="180"
|
|
82
|
+
show-overflow-tooltip
|
|
83
|
+
/>
|
|
84
|
+
<el-table-column :label="t('system.codegen.progress.field.output')" width="90" align="center">
|
|
64
85
|
<template #default="{ row }">
|
|
65
86
|
<el-button v-if="row.output" :icon="Document" link @click="showOutput(row.label, row.output)" />
|
|
66
87
|
</template>
|
|
@@ -69,19 +90,24 @@
|
|
|
69
90
|
</el-collapse-item>
|
|
70
91
|
</el-collapse>
|
|
71
92
|
</template>
|
|
72
|
-
<el-result
|
|
93
|
+
<el-result
|
|
94
|
+
v-else-if="errorMessage"
|
|
95
|
+
icon="error"
|
|
96
|
+
:title="t('system.codegen.progress.message.unavailableTitle')"
|
|
97
|
+
:sub-title="errorMessage"
|
|
98
|
+
>
|
|
73
99
|
<template #extra>
|
|
74
|
-
<el-button type="primary" @click="startTracking"
|
|
100
|
+
<el-button type="primary" @click="startTracking">{{ t("system.codegen.progress.action.reload") }}</el-button>
|
|
75
101
|
</template>
|
|
76
102
|
</el-result>
|
|
77
103
|
</div>
|
|
78
|
-
|
|
79
104
|
</ProDialog>
|
|
80
105
|
</template>
|
|
81
106
|
|
|
82
107
|
<script setup lang="ts">
|
|
83
108
|
import { onBeforeUnmount, ref, watch } from "vue";
|
|
84
109
|
import { Check, CircleClose, Clock, CopyDocument, Document, Loading, Minus } from "@element-plus/icons-vue";
|
|
110
|
+
import { getCurrentLocale, t } from "@liujitcn/kratos-admin-core";
|
|
85
111
|
import ProDialog from "@liujitcn/kratos-admin-core/components/Dialog/ProDialog.vue";
|
|
86
112
|
import { defCodeGenService } from "@liujitcn/kratos-admin-system/api/system/code_gen";
|
|
87
113
|
import { subscribeCodeGenProgress, type SseStop } from "@liujitcn/kratos-admin-system/api/system/code_gen_sse";
|
|
@@ -166,7 +192,7 @@ function applyTask(latest: CodeGenTask) {
|
|
|
166
192
|
function markUnavailable() {
|
|
167
193
|
stopTracking();
|
|
168
194
|
task.value = undefined;
|
|
169
|
-
errorMessage.value = "
|
|
195
|
+
errorMessage.value = t("system.codegen.progress.message.unavailable");
|
|
170
196
|
emit("unavailable");
|
|
171
197
|
}
|
|
172
198
|
|
|
@@ -180,10 +206,13 @@ function stopTracking() {
|
|
|
180
206
|
|
|
181
207
|
/** 返回状态标签配置。 */
|
|
182
208
|
function statusMeta(status: CodeGenTaskStatus): StatusMeta {
|
|
183
|
-
if (status === CodeGenTaskStatus.CODE_GEN_TASK_STATUS_RUNNING)
|
|
184
|
-
|
|
185
|
-
if (status === CodeGenTaskStatus.
|
|
186
|
-
|
|
209
|
+
if (status === CodeGenTaskStatus.CODE_GEN_TASK_STATUS_RUNNING)
|
|
210
|
+
return { label: t("system.codegen.progress.status.running"), type: "warning" };
|
|
211
|
+
if (status === CodeGenTaskStatus.CODE_GEN_TASK_STATUS_SUCCEEDED)
|
|
212
|
+
return { label: t("system.codegen.progress.status.succeeded"), type: "success" };
|
|
213
|
+
if (status === CodeGenTaskStatus.CODE_GEN_TASK_STATUS_FAILED)
|
|
214
|
+
return { label: t("system.codegen.progress.status.failed"), type: "danger" };
|
|
215
|
+
return { label: t("system.codegen.progress.status.pending"), type: "info" };
|
|
187
216
|
}
|
|
188
217
|
|
|
189
218
|
/** 返回进度条状态。 */
|
|
@@ -206,7 +235,7 @@ function isFinished(status: CodeGenTaskStatus) {
|
|
|
206
235
|
/** 格式化任务时间。 */
|
|
207
236
|
function formatTime(value: string) {
|
|
208
237
|
const date = new Date(value);
|
|
209
|
-
return !value || Number.isNaN(date.getTime()) ? "-" : date.toLocaleString();
|
|
238
|
+
return !value || Number.isNaN(date.getTime()) ? "-" : date.toLocaleString(getCurrentLocale());
|
|
210
239
|
}
|
|
211
240
|
|
|
212
241
|
/** 弹出展示命令输出。 */
|
|
@@ -214,18 +243,18 @@ function showOutput(title: string, output: string) {
|
|
|
214
243
|
ElMessageBox.alert(`<pre class="code-gen-command-output">${escapeHTML(output)}</pre>`, title, {
|
|
215
244
|
dangerouslyUseHTMLString: true,
|
|
216
245
|
customClass: "code-gen-output-dialog",
|
|
217
|
-
confirmButtonText: "
|
|
246
|
+
confirmButtonText: t("common.action.close")
|
|
218
247
|
});
|
|
219
248
|
}
|
|
220
249
|
|
|
221
250
|
/** 复制生成任务的错误信息,便于定位生成命令问题。 */
|
|
222
251
|
async function copyMessage(message: string) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
252
|
+
try {
|
|
253
|
+
await navigator.clipboard.writeText(message);
|
|
254
|
+
ElMessage.success(t("system.codegen.progress.message.copied"));
|
|
255
|
+
} catch {
|
|
256
|
+
ElMessage.error(t("system.codegen.progress.message.copyFailed"));
|
|
257
|
+
}
|
|
229
258
|
}
|
|
230
259
|
|
|
231
260
|
/** 转义命令输出中的HTML字符。 */
|
|
@@ -301,17 +330,17 @@ onBeforeUnmount(stopTracking);
|
|
|
301
330
|
}
|
|
302
331
|
|
|
303
332
|
.table-message {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
333
|
+
display: flex;
|
|
334
|
+
gap: 6px;
|
|
335
|
+
align-items: flex-start;
|
|
336
|
+
margin: 0 0 10px;
|
|
337
|
+
color: var(--el-text-color-secondary);
|
|
309
338
|
}
|
|
310
339
|
|
|
311
340
|
.table-message span {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
341
|
+
min-width: 0;
|
|
342
|
+
white-space: pre-wrap;
|
|
343
|
+
word-break: break-word;
|
|
315
344
|
}
|
|
316
345
|
</style>
|
|
317
346
|
|
|
@@ -5,18 +5,21 @@
|
|
|
5
5
|
<pre class="code-preview">{{ row.content || row.message }}</pre>
|
|
6
6
|
</template>
|
|
7
7
|
</el-table-column>
|
|
8
|
-
<el-table-column prop="path" label="
|
|
9
|
-
<el-table-column prop="action" label="
|
|
10
|
-
<el-table-column label="
|
|
8
|
+
<el-table-column prop="path" :label="t('system.codegen.preview.field.path')" min-width="320" show-overflow-tooltip />
|
|
9
|
+
<el-table-column prop="action" :label="t('system.codegen.preview.field.action')" width="100" />
|
|
10
|
+
<el-table-column :label="t('system.codegen.table.field.status')" width="100" align="center">
|
|
11
11
|
<template #default="{ row }">
|
|
12
|
-
<el-tag :type="row.exists ? 'info' : 'success'" effect="plain">
|
|
12
|
+
<el-tag :type="row.exists ? 'info' : 'success'" effect="plain">
|
|
13
|
+
{{ t(row.exists ? "system.codegen.preview.status.exists" : "system.codegen.preview.status.pendingCreate") }}
|
|
14
|
+
</el-tag>
|
|
13
15
|
</template>
|
|
14
16
|
</el-table-column>
|
|
15
|
-
<el-table-column prop="message" label="
|
|
17
|
+
<el-table-column prop="message" :label="t('system.codegen.preview.field.message')" min-width="220" show-overflow-tooltip />
|
|
16
18
|
</el-table>
|
|
17
19
|
</template>
|
|
18
20
|
|
|
19
21
|
<script setup lang="ts">
|
|
22
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
20
23
|
import type { CodeGenPreviewFile } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/code_gen";
|
|
21
24
|
|
|
22
25
|
/** 代码预览面板属性。 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FormRules } from "element-plus";
|
|
2
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
2
3
|
import type { ProFormComponentType, ProFormOption } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
|
|
3
4
|
import type {
|
|
4
5
|
CodeGenColumnFormConfig,
|
|
@@ -10,12 +11,14 @@ import type { CodeGenLeftTreeConfig, CodeGenTableForm } from "@liujitcn/kratos-a
|
|
|
10
11
|
import { CodeGenTableStatus } from "@liujitcn/kratos-admin-system/rpc/system/common/v1/enum";
|
|
11
12
|
|
|
12
13
|
/** 代码生成表配置页面类型选项。 */
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
export function codeGenPageTypeOptions(): ProFormOption[] {
|
|
15
|
+
return [
|
|
16
|
+
{ label: t("system.codegen.pageType.normal"), value: "normal" },
|
|
17
|
+
{ label: t("system.codegen.pageType.tree"), value: "tree" },
|
|
18
|
+
{ label: t("system.codegen.pageType.treeLazy"), value: "tree_lazy" },
|
|
19
|
+
{ label: t("system.codegen.pageType.leftTree"), value: "left_tree" }
|
|
20
|
+
];
|
|
21
|
+
}
|
|
19
22
|
|
|
20
23
|
/** 判断页面类型是否使用树形表格配置。 */
|
|
21
24
|
export function isCodeGenTreePageType(pageType?: string) {
|
|
@@ -23,89 +26,122 @@ export function isCodeGenTreePageType(pageType?: string) {
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/** 左树数据源类型选项。 */
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
export function codeGenSourceTypeOptions(): ProFormOption[] {
|
|
30
|
+
return [
|
|
31
|
+
{ label: t("system.codegen.source.static"), value: "static" },
|
|
32
|
+
{ label: t("system.codegen.source.dict"), value: "dict" },
|
|
33
|
+
{ label: t("system.codegen.source.table"), value: "table" }
|
|
34
|
+
];
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
/** 查询操作符选项。 */
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
export function codeGenQueryOperatorOptions(): ProFormOption[] {
|
|
39
|
+
return [
|
|
40
|
+
{ label: t("system.codegen.operator.eq"), value: "eq" },
|
|
41
|
+
{ label: t("system.codegen.operator.like"), value: "like" },
|
|
42
|
+
{ label: t("system.codegen.operator.between"), value: "between" }
|
|
43
|
+
];
|
|
44
|
+
}
|
|
38
45
|
|
|
39
46
|
/** 查询组件选项。 */
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
export function codeGenQueryComponentOptions(): ProFormOption[] {
|
|
48
|
+
return [
|
|
49
|
+
{ label: t("system.codegen.component.input"), value: "input" },
|
|
50
|
+
{ label: t("system.codegen.component.inputNumber"), value: "input-number" },
|
|
51
|
+
{ label: t("system.codegen.component.select"), value: "select" },
|
|
52
|
+
{ label: t("system.codegen.component.treeSelect"), value: "tree-select" },
|
|
53
|
+
{ label: t("system.codegen.component.datePicker"), value: "date-picker" }
|
|
54
|
+
];
|
|
55
|
+
}
|
|
47
56
|
|
|
48
57
|
/** 列表展示组件选项。 */
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
export function codeGenListComponentOptions(): ProFormOption[] {
|
|
59
|
+
return [
|
|
60
|
+
{ label: t("system.codegen.component.text"), value: "text" },
|
|
61
|
+
{ label: t("system.codegen.component.switch"), value: "switch" },
|
|
62
|
+
{ label: t("system.codegen.component.selectShort"), value: "select" },
|
|
63
|
+
{ label: t("system.codegen.component.tree"), value: "tree-select" },
|
|
64
|
+
{ label: t("system.codegen.component.image"), value: "image" },
|
|
65
|
+
{ label: t("system.codegen.component.money"), value: "money" },
|
|
66
|
+
{ label: t("system.codegen.component.date"), value: "date" }
|
|
67
|
+
];
|
|
68
|
+
}
|
|
58
69
|
|
|
59
70
|
/** ProForm 全量组件类型对应的中文名称。 */
|
|
60
|
-
const
|
|
61
|
-
input: "
|
|
62
|
-
password: "
|
|
63
|
-
textarea: "
|
|
64
|
-
"input-number": "
|
|
65
|
-
segmented: "
|
|
66
|
-
switch: "
|
|
67
|
-
checkbox: "
|
|
68
|
-
select: "
|
|
69
|
-
dict: "
|
|
70
|
-
"radio-group": "
|
|
71
|
-
"checkbox-group": "
|
|
72
|
-
"tree-select": "
|
|
73
|
-
"date-picker": "
|
|
74
|
-
"cron-expression": "
|
|
75
|
-
transfer: "
|
|
76
|
-
"image-upload": "
|
|
77
|
-
"images-upload": "
|
|
78
|
-
"file-upload": "
|
|
79
|
-
"files-upload": "
|
|
80
|
-
"rich-text": "
|
|
81
|
-
"dynamic-list": "
|
|
82
|
-
"kv-list": "
|
|
83
|
-
slot: "
|
|
71
|
+
const codeGenFormComponentLabelKeys: Record<ProFormComponentType, string> = {
|
|
72
|
+
input: "system.codegen.component.input",
|
|
73
|
+
password: "system.codegen.component.password",
|
|
74
|
+
textarea: "system.codegen.component.textarea",
|
|
75
|
+
"input-number": "system.codegen.component.inputNumber",
|
|
76
|
+
segmented: "system.codegen.component.segmented",
|
|
77
|
+
switch: "system.codegen.component.switch",
|
|
78
|
+
checkbox: "system.codegen.component.checkbox",
|
|
79
|
+
select: "system.codegen.component.select",
|
|
80
|
+
dict: "system.codegen.component.dict",
|
|
81
|
+
"radio-group": "system.codegen.component.radioGroup",
|
|
82
|
+
"checkbox-group": "system.codegen.component.checkboxGroup",
|
|
83
|
+
"tree-select": "system.codegen.component.treeSelect",
|
|
84
|
+
"date-picker": "system.codegen.component.datePicker",
|
|
85
|
+
"cron-expression": "system.codegen.component.cron",
|
|
86
|
+
transfer: "system.codegen.component.transfer",
|
|
87
|
+
"image-upload": "system.codegen.component.imageUpload",
|
|
88
|
+
"images-upload": "system.codegen.component.imagesUpload",
|
|
89
|
+
"file-upload": "system.codegen.component.fileUpload",
|
|
90
|
+
"files-upload": "system.codegen.component.filesUpload",
|
|
91
|
+
"rich-text": "system.codegen.component.richText",
|
|
92
|
+
"dynamic-list": "system.codegen.component.dynamicList",
|
|
93
|
+
"kv-list": "system.codegen.component.kvList",
|
|
94
|
+
slot: "system.codegen.component.slot"
|
|
84
95
|
};
|
|
85
96
|
|
|
86
97
|
/** 表单录入组件选项,保持与 ProForm 支持类型完整一致。 */
|
|
87
|
-
export
|
|
88
|
-
Object.entries(
|
|
89
|
-
|
|
98
|
+
export function codeGenFormComponentOptions(): ProFormOption[] {
|
|
99
|
+
return (Object.entries(codeGenFormComponentLabelKeys) as Array<[ProFormComponentType, string]>).map(([value, labelKey]) => ({
|
|
100
|
+
label: t(labelKey),
|
|
101
|
+
value
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
90
104
|
|
|
91
105
|
/** 代码生成表配置校验规则。 */
|
|
92
|
-
export
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
106
|
+
export function codeGenTableRules(): FormRules {
|
|
107
|
+
return {
|
|
108
|
+
name: [{ required: true, max: 128, message: t("system.codegen.validation.tableRequired"), trigger: "change" }],
|
|
109
|
+
business_module: [
|
|
110
|
+
{
|
|
111
|
+
required: true,
|
|
112
|
+
max: 64,
|
|
113
|
+
pattern: /^[a-z][a-z0-9_]*$/,
|
|
114
|
+
message: t("system.codegen.validation.moduleRequired"),
|
|
115
|
+
trigger: "change"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
comment: [{ max: 128, message: t("system.codegen.validation.commentLength"), trigger: "blur" }],
|
|
119
|
+
parent_menu_id: [
|
|
120
|
+
{ required: true, type: "number", min: 1, message: t("system.codegen.validation.parentMenuRequired"), trigger: "change" }
|
|
121
|
+
],
|
|
122
|
+
page_type: [{ required: true, max: 32, message: t("system.codegen.validation.pageTypeRequired"), trigger: "change" }],
|
|
123
|
+
parent_column: [{ required: true, max: 64, message: t("system.codegen.validation.parentColumnRequired"), trigger: "change" }],
|
|
124
|
+
tree_label_column: [
|
|
125
|
+
{ required: true, max: 64, message: t("system.codegen.validation.treeLabelRequired"), trigger: "change" }
|
|
126
|
+
],
|
|
127
|
+
remark: [{ max: 500, message: t("system.codegen.validation.remarkLength"), trigger: "blur" }],
|
|
128
|
+
"left_tree_config.table_name": [
|
|
129
|
+
{ required: true, message: t("system.codegen.validation.leftTreeTableRequired"), trigger: "change" }
|
|
130
|
+
],
|
|
131
|
+
"left_tree_config.filter_column": [
|
|
132
|
+
{ required: true, message: t("system.codegen.validation.filterColumnRequired"), trigger: "change" }
|
|
133
|
+
],
|
|
134
|
+
"left_tree_config.parent_column": [
|
|
135
|
+
{ required: true, message: t("system.codegen.validation.leftTreeParentRequired"), trigger: ["blur", "change"] }
|
|
136
|
+
],
|
|
137
|
+
"left_tree_config.label_column": [
|
|
138
|
+
{ required: true, message: t("system.codegen.validation.leftTreeLabelRequired"), trigger: ["blur", "change"] }
|
|
139
|
+
],
|
|
140
|
+
"left_tree_config.value_column": [
|
|
141
|
+
{ required: true, message: t("system.codegen.validation.leftTreeValueRequired"), trigger: ["blur", "change"] }
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
}
|
|
109
145
|
|
|
110
146
|
/** 创建默认左树右表页面配置。 */
|
|
111
147
|
export function createDefaultCodeGenLeftTreeConfig(): CodeGenLeftTreeConfig {
|
|
@@ -136,7 +172,8 @@ export function createDefaultCodeGenTableForm(): CodeGenTableForm {
|
|
|
136
172
|
gen_sql: true,
|
|
137
173
|
parent_menu_id: 0,
|
|
138
174
|
status: CodeGenTableStatus.DRAFT_CGTS,
|
|
139
|
-
remark: ""
|
|
175
|
+
remark: "",
|
|
176
|
+
i18n_config: new Map()
|
|
140
177
|
};
|
|
141
178
|
}
|
|
142
179
|
|