@liujitcn/kratos-admin-system 0.0.28 → 0.0.31
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 +19 -2
- package/dist/package/declarations/src/api/base/notification.d.ts +24 -0
- package/dist/package/declarations/src/api/system/base_audit_log.d.ts +55 -0
- package/dist/package/declarations/src/api/system/base_dashboard.d.ts +14 -0
- package/dist/package/declarations/src/api/system/base_file.d.ts +13 -0
- package/dist/package/declarations/src/api/system/base_i18n.d.ts +5 -5
- package/dist/package/declarations/src/api/system/base_login_policy.d.ts +10 -0
- package/dist/package/declarations/src/api/system/base_message.d.ts +24 -0
- package/dist/package/declarations/src/api/system/base_message_category.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_session.d.ts +11 -0
- package/dist/package/declarations/src/api/system/oauth_client.d.ts +24 -0
- package/dist/package/declarations/src/components/AuditLogTable.vue.d.ts +45 -0
- package/dist/package/declarations/src/components/DynamicI18nCell.vue.d.ts +16 -0
- package/dist/package/declarations/src/components/DynamicI18nEditor.vue.d.ts +20 -0
- package/dist/package/declarations/src/components/auditLog.d.ts +9 -0
- package/dist/package/declarations/src/components/dynamicI18n.d.ts +38 -0
- package/dist/package/declarations/src/locales/generated.d.ts +1364 -68
- package/dist/package/declarations/src/rpc/base/v1/login.d.ts +149 -0
- package/dist/package/declarations/src/rpc/base/v1/notification.d.ts +281 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth.d.ts +25 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth_client.d.ts +23 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_audit_log.d.ts +640 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +3 -3
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dashboard.d.ts +60 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +4 -4
- package/dist/package/declarations/src/rpc/system/admin/v1/base_file.d.ts +73 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_i18n.d.ts +27 -23
- package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +5 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_login_policy.d.ts +51 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +2 -2
- package/dist/package/declarations/src/rpc/system/admin/v1/base_message.d.ts +193 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_message_category.d.ts +125 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_session.d.ts +33 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +3 -3
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +1 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/oauth_client.d.ts +145 -0
- package/dist/package/declarations/src/views/base/api-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dashboard/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/data-access-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/file/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/login-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/login-policy/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/message/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/message-category/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/oauth-client/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/operation-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/permission-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/policy-evaluation-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/message/inbox/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/session.vue.d.ts +3 -0
- package/dist/package/src/api/base/notification.ts +69 -0
- package/dist/package/src/api/base/sse.ts +4 -4
- package/dist/package/src/api/system/auth.ts +1 -0
- package/dist/package/src/api/system/base_audit_log.ts +168 -0
- package/dist/package/src/api/system/base_dashboard.ts +55 -0
- package/dist/package/src/api/system/base_file.ts +43 -0
- package/dist/package/src/api/system/base_i18n.ts +12 -12
- package/dist/package/src/api/system/base_login_policy.ts +32 -0
- package/dist/package/src/api/system/base_message.ts +70 -0
- package/dist/package/src/api/system/base_message_category.ts +57 -0
- package/dist/package/src/api/system/base_session.ts +33 -0
- package/dist/package/src/api/system/oauth_client.ts +102 -0
- package/dist/package/src/components/AuditLogTable.vue +105 -0
- package/dist/package/src/components/{DynamicTranslationCell.vue → DynamicI18nCell.vue} +50 -50
- package/dist/package/src/components/{DynamicTranslationEditor.vue → DynamicI18nEditor.vue} +45 -45
- package/dist/package/src/components/Notification.vue +196 -0
- package/dist/package/src/components/auditLog.ts +46 -0
- package/dist/package/src/components/{dynamicTranslation.ts → dynamicI18n.ts} +15 -15
- package/dist/package/src/locales/README.md +5 -3
- package/dist/package/src/locales/en-US.json +345 -21
- package/dist/package/src/locales/ja-JP.json +347 -23
- package/dist/package/src/locales/zh-CN.json +343 -19
- package/dist/package/src/locales/zh-TW.json +346 -22
- package/dist/package/src/module.ts +5 -2
- package/dist/package/src/rpc/base/v1/login.ts +172 -0
- package/dist/package/src/rpc/base/v1/notification.ts +315 -0
- package/dist/package/src/rpc/base/v1/oauth.ts +25 -0
- package/dist/package/src/rpc/base/v1/oauth_client.ts +33 -0
- package/dist/package/src/rpc/system/admin/v1/base_audit_log.ts +737 -0
- package/dist/package/src/rpc/system/admin/v1/base_config.ts +3 -3
- package/dist/package/src/rpc/system/admin/v1/base_dashboard.ts +81 -0
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +4 -4
- package/dist/package/src/rpc/system/admin/v1/base_file.ts +88 -0
- package/dist/package/src/rpc/system/admin/v1/base_i18n.ts +27 -23
- package/dist/package/src/rpc/system/admin/v1/base_job.ts +5 -0
- package/dist/package/src/rpc/system/admin/v1/base_login_policy.ts +63 -0
- package/dist/package/src/rpc/system/admin/v1/base_menu.ts +2 -2
- package/dist/package/src/rpc/system/admin/v1/base_message.ts +236 -0
- package/dist/package/src/rpc/system/admin/v1/base_message_category.ts +149 -0
- package/dist/package/src/rpc/system/admin/v1/base_session.ts +44 -0
- package/dist/package/src/rpc/system/admin/v1/base_user.ts +3 -3
- package/dist/package/src/rpc/system/admin/v1/code_gen.ts +1 -1
- package/dist/package/src/rpc/system/admin/v1/oauth_client.ts +174 -0
- package/dist/package/src/views/ai/chat/components/ChatPanel.vue +2 -2
- package/dist/package/src/views/ai/chat/message.ts +7 -3
- package/dist/package/src/views/base/api-log/index.vue +83 -0
- package/dist/package/src/views/base/config/index.vue +41 -41
- package/dist/package/src/views/base/dashboard/index.vue +200 -0
- package/dist/package/src/views/base/data-access-log/index.vue +84 -0
- package/dist/package/src/views/base/dict/index.vue +23 -23
- package/dist/package/src/views/base/dict/item.vue +25 -25
- package/dist/package/src/views/base/file/index.vue +119 -0
- package/dist/package/src/views/base/job/index.vue +62 -7
- package/dist/package/src/views/base/language/index.vue +2 -1
- package/dist/package/src/views/base/login-log/index.vue +92 -0
- package/dist/package/src/views/base/login-policy/index.vue +219 -0
- package/dist/package/src/views/base/menu/index.vue +23 -23
- package/dist/package/src/views/base/message/index.vue +582 -0
- package/dist/package/src/views/base/message-category/index.vue +356 -0
- package/dist/package/src/views/base/oauth-client/index.vue +411 -0
- package/dist/package/src/views/base/operation-log/index.vue +82 -0
- package/dist/package/src/views/base/permission-log/index.vue +85 -0
- package/dist/package/src/views/base/policy-evaluation-log/index.vue +82 -0
- package/dist/package/src/views/message/inbox/index.vue +249 -0
- package/dist/package/src/views/profile/components/base.vue +6 -5
- package/dist/package/src/views/profile/components/password.vue +2 -2
- package/dist/package/src/views/profile/components/security.vue +475 -62
- package/dist/package/src/views/profile/components/session.vue +153 -0
- package/dist/package/src/views/profile/index.vue +35 -22
- package/dist/package/src/views/tool/code-gen/code-preview/index.vue +9 -9
- package/dist/package/src/views/tool/code-gen/columns/index.vue +1 -1
- package/dist/package/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue +8 -8
- package/dist/package/src/views/tool/code-gen/config.ts +1 -0
- package/dist/package/src/views/tool/code-gen/table/index.vue +7 -7
- package/dist/package/src/views/tool/ops-monitoring/index.vue +25 -21
- package/package.json +2 -2
- package/dist/package/declarations/src/api/system/base_log.d.ts +0 -9
- package/dist/package/declarations/src/components/DynamicTranslationCell.vue.d.ts +0 -16
- package/dist/package/declarations/src/components/DynamicTranslationEditor.vue.d.ts +0 -20
- package/dist/package/declarations/src/components/dynamicTranslation.d.ts +0 -38
- package/dist/package/declarations/src/rpc/system/admin/v1/base_log.d.ts +0 -87
- package/dist/package/src/api/system/base_log.ts +0 -32
- package/dist/package/src/rpc/system/admin/v1/base_log.ts +0 -101
- package/dist/package/src/views/base/log/index.vue +0 -339
- /package/dist/package/declarations/src/{views/base/log/index.vue.d.ts → components/Notification.vue.d.ts} +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="login-policy-page">
|
|
3
|
+
<el-card shadow="never">
|
|
4
|
+
<template #header>
|
|
5
|
+
<div class="policy-header">
|
|
6
|
+
<div>
|
|
7
|
+
<h3>{{ t("system.base.login_policy.title") }}</h3>
|
|
8
|
+
<p>{{ t("system.base.login_policy.description") }}</p>
|
|
9
|
+
</div>
|
|
10
|
+
<el-switch v-model="form.enabled" :active-text="t('system.base.login_policy.enabled')" />
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<el-alert :title="t('system.base.login_policy.hint')" type="info" :closable="false" show-icon />
|
|
15
|
+
<el-form label-position="top" class="policy-form" @submit.prevent="save">
|
|
16
|
+
<el-form-item :label="t('system.base.login_policy.field.ip_blacklist')">
|
|
17
|
+
<el-input v-model="form.ip_blacklist" type="textarea" :rows="3" :placeholder="t('system.base.login_policy.placeholder.ip')" />
|
|
18
|
+
</el-form-item>
|
|
19
|
+
<el-form-item :label="t('system.base.login_policy.field.ip_whitelist')">
|
|
20
|
+
<el-input v-model="form.ip_whitelist" type="textarea" :rows="3" :placeholder="t('system.base.login_policy.placeholder.ip')" />
|
|
21
|
+
</el-form-item>
|
|
22
|
+
<el-form-item :label="t('system.base.login_policy.field.time_windows')">
|
|
23
|
+
<el-input v-model="form.time_windows" type="textarea" :rows="2" :placeholder="t('system.base.login_policy.placeholder.time')" />
|
|
24
|
+
</el-form-item>
|
|
25
|
+
<el-form-item :label="t('system.base.login_policy.field.device_blacklist')">
|
|
26
|
+
<el-input v-model="form.device_blacklist" type="textarea" :rows="2" :placeholder="t('system.base.login_policy.placeholder.device')" />
|
|
27
|
+
</el-form-item>
|
|
28
|
+
<el-form-item :label="t('system.base.login_policy.field.device_whitelist')">
|
|
29
|
+
<el-input v-model="form.device_whitelist" type="textarea" :rows="2" :placeholder="t('system.base.login_policy.placeholder.device')" />
|
|
30
|
+
</el-form-item>
|
|
31
|
+
<el-divider />
|
|
32
|
+
<div class="rules-header">
|
|
33
|
+
<div>
|
|
34
|
+
<h4>{{ t("system.base.login_policy.rules.title") }}</h4>
|
|
35
|
+
<p>{{ t("system.base.login_policy.rules.description") }}</p>
|
|
36
|
+
</div>
|
|
37
|
+
<el-button type="primary" plain @click="addRule">{{ t("system.base.login_policy.rules.add") }}</el-button>
|
|
38
|
+
</div>
|
|
39
|
+
<el-table v-if="form.rules.length" :data="form.rules" border class="rules-table">
|
|
40
|
+
<el-table-column :label="t('system.base.login_policy.rules.target_type')" width="130">
|
|
41
|
+
<template #default="{ row }">
|
|
42
|
+
<el-select v-model="row.target_type" class="rule-control">
|
|
43
|
+
<el-option label="TENANT" value="TENANT" />
|
|
44
|
+
<el-option label="USER" value="USER" />
|
|
45
|
+
</el-select>
|
|
46
|
+
</template>
|
|
47
|
+
</el-table-column>
|
|
48
|
+
<el-table-column :label="t('system.base.login_policy.rules.target_value')" min-width="160">
|
|
49
|
+
<template #default="{ row }"><el-input v-model="row.target_value" class="rule-control" /></template>
|
|
50
|
+
</el-table-column>
|
|
51
|
+
<el-table-column :label="t('system.base.login_policy.field.ip_blacklist')" min-width="180">
|
|
52
|
+
<template #default="{ row }"><el-input v-model="row.ip_blacklist" :placeholder="t('system.base.login_policy.placeholder.ip')" class="rule-control" /></template>
|
|
53
|
+
</el-table-column>
|
|
54
|
+
<el-table-column :label="t('system.base.login_policy.field.ip_whitelist')" min-width="180">
|
|
55
|
+
<template #default="{ row }"><el-input v-model="row.ip_whitelist" :placeholder="t('system.base.login_policy.placeholder.ip')" class="rule-control" /></template>
|
|
56
|
+
</el-table-column>
|
|
57
|
+
<el-table-column :label="t('system.base.login_policy.field.time_windows')" min-width="160">
|
|
58
|
+
<template #default="{ row }"><el-input v-model="row.time_windows" :placeholder="t('system.base.login_policy.placeholder.time')" class="rule-control" /></template>
|
|
59
|
+
</el-table-column>
|
|
60
|
+
<el-table-column :label="t('system.base.login_policy.rules.enabled')" width="90">
|
|
61
|
+
<template #default="{ row }"><el-switch v-model="row.enabled" /></template>
|
|
62
|
+
</el-table-column>
|
|
63
|
+
<el-table-column :label="t('common.field.operation')" width="90" fixed="right">
|
|
64
|
+
<template #default="{ $index }"><el-button link type="danger" @click="removeRule($index)">{{ t("common.action.delete") }}</el-button></template>
|
|
65
|
+
</el-table-column>
|
|
66
|
+
</el-table>
|
|
67
|
+
<div class="policy-actions">
|
|
68
|
+
<el-button type="primary" :loading="saving" @click="save">{{ t("common.action.save") }}</el-button>
|
|
69
|
+
</div>
|
|
70
|
+
</el-form>
|
|
71
|
+
</el-card>
|
|
72
|
+
</div>
|
|
73
|
+
</template>
|
|
74
|
+
|
|
75
|
+
<script setup lang="ts">
|
|
76
|
+
import { onMounted, reactive, ref } from "vue";
|
|
77
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
78
|
+
import { defBaseLoginPolicyService } from "@liujitcn/kratos-admin-system/api/system/base_login_policy";
|
|
79
|
+
import type { BaseLoginPolicy, BaseLoginPolicyRule } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_login_policy";
|
|
80
|
+
|
|
81
|
+
const saving = ref(false);
|
|
82
|
+
/** 登录来源定向规则表单。 */
|
|
83
|
+
type RuleForm = { target_type: string; target_value: string; enabled: boolean; ip_blacklist: string; ip_whitelist: string; time_windows: string; device_blacklist: string; device_whitelist: string };
|
|
84
|
+
const form = reactive({
|
|
85
|
+
enabled: false,
|
|
86
|
+
ip_blacklist: "",
|
|
87
|
+
ip_whitelist: "",
|
|
88
|
+
time_windows: "",
|
|
89
|
+
device_blacklist: "",
|
|
90
|
+
device_whitelist: "",
|
|
91
|
+
rules: [] as RuleForm[]
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/** 将接口数组转换为逐行编辑文本。 */
|
|
95
|
+
function assignForm(policy: BaseLoginPolicy) {
|
|
96
|
+
form.enabled = policy.enabled;
|
|
97
|
+
form.ip_blacklist = policy.ip_blacklist.join("\n");
|
|
98
|
+
form.ip_whitelist = policy.ip_whitelist.join("\n");
|
|
99
|
+
form.time_windows = policy.time_windows.join("\n");
|
|
100
|
+
form.device_blacklist = policy.device_blacklist.join("\n");
|
|
101
|
+
form.device_whitelist = policy.device_whitelist.join("\n");
|
|
102
|
+
form.rules = (policy.rules ?? []).map(rule => ({
|
|
103
|
+
target_type: rule.target_type,
|
|
104
|
+
target_value: rule.target_value,
|
|
105
|
+
enabled: rule.enabled,
|
|
106
|
+
ip_blacklist: rule.ip_blacklist.join(","),
|
|
107
|
+
ip_whitelist: rule.ip_whitelist.join(","),
|
|
108
|
+
time_windows: rule.time_windows.join(","),
|
|
109
|
+
device_blacklist: rule.device_blacklist.join(","),
|
|
110
|
+
device_whitelist: rule.device_whitelist.join(",")
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** 将逐行编辑文本转换为接口数组。 */
|
|
115
|
+
function splitLines(value: string) {
|
|
116
|
+
return value.split(/[\n,]/).map(item => item.trim()).filter(Boolean);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** 加载登录来源策略。 */
|
|
120
|
+
async function load() {
|
|
121
|
+
assignForm(await defBaseLoginPolicyService.GetBaseLoginPolicy({}));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** 保存登录来源策略。 */
|
|
125
|
+
async function save() {
|
|
126
|
+
saving.value = true;
|
|
127
|
+
try {
|
|
128
|
+
const policy = await defBaseLoginPolicyService.UpdateBaseLoginPolicy({
|
|
129
|
+
policy: {
|
|
130
|
+
enabled: form.enabled,
|
|
131
|
+
ip_blacklist: splitLines(form.ip_blacklist),
|
|
132
|
+
ip_whitelist: splitLines(form.ip_whitelist),
|
|
133
|
+
time_windows: splitLines(form.time_windows),
|
|
134
|
+
device_blacklist: splitLines(form.device_blacklist),
|
|
135
|
+
device_whitelist: splitLines(form.device_whitelist),
|
|
136
|
+
rules: form.rules.map(rule => ({
|
|
137
|
+
target_type: rule.target_type,
|
|
138
|
+
target_value: rule.target_value,
|
|
139
|
+
enabled: rule.enabled,
|
|
140
|
+
ip_blacklist: splitLines(rule.ip_blacklist),
|
|
141
|
+
ip_whitelist: splitLines(rule.ip_whitelist),
|
|
142
|
+
time_windows: splitLines(rule.time_windows),
|
|
143
|
+
device_blacklist: splitLines(rule.device_blacklist),
|
|
144
|
+
device_whitelist: splitLines(rule.device_whitelist)
|
|
145
|
+
} as BaseLoginPolicyRule))
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
assignForm(policy);
|
|
149
|
+
ElMessage.success(t("common.message.update_success", { resource: t("system.base.login_policy.title") }));
|
|
150
|
+
} finally {
|
|
151
|
+
saving.value = false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** 新增一条定向登录策略。 */
|
|
156
|
+
function addRule() {
|
|
157
|
+
form.rules.push({ target_type: "TENANT", target_value: "", enabled: true, ip_blacklist: "", ip_whitelist: "", time_windows: "", device_blacklist: "", device_whitelist: "" });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** 删除一条定向登录策略。 */
|
|
161
|
+
function removeRule(index: number) {
|
|
162
|
+
form.rules.splice(index, 1);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
onMounted(load);
|
|
166
|
+
</script>
|
|
167
|
+
|
|
168
|
+
<style scoped lang="scss">
|
|
169
|
+
.login-policy-page {
|
|
170
|
+
padding: 20px;
|
|
171
|
+
}
|
|
172
|
+
.policy-header {
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: center;
|
|
175
|
+
justify-content: space-between;
|
|
176
|
+
gap: 16px;
|
|
177
|
+
}
|
|
178
|
+
.policy-header h3 {
|
|
179
|
+
margin: 0;
|
|
180
|
+
color: var(--el-text-color-primary);
|
|
181
|
+
font-size: 18px;
|
|
182
|
+
}
|
|
183
|
+
.policy-header p {
|
|
184
|
+
margin: 6px 0 0;
|
|
185
|
+
color: var(--el-text-color-secondary);
|
|
186
|
+
font-size: 13px;
|
|
187
|
+
}
|
|
188
|
+
.policy-form {
|
|
189
|
+
max-width: 920px;
|
|
190
|
+
margin-top: 20px;
|
|
191
|
+
}
|
|
192
|
+
.policy-actions {
|
|
193
|
+
display: flex;
|
|
194
|
+
justify-content: flex-end;
|
|
195
|
+
}
|
|
196
|
+
.rules-header {
|
|
197
|
+
display: flex;
|
|
198
|
+
align-items: center;
|
|
199
|
+
justify-content: space-between;
|
|
200
|
+
gap: 16px;
|
|
201
|
+
margin: 20px 0 12px;
|
|
202
|
+
}
|
|
203
|
+
.rules-header h4 {
|
|
204
|
+
margin: 0;
|
|
205
|
+
color: var(--el-text-color-primary);
|
|
206
|
+
font-size: 15px;
|
|
207
|
+
}
|
|
208
|
+
.rules-header p {
|
|
209
|
+
margin: 4px 0 0;
|
|
210
|
+
color: var(--el-text-color-secondary);
|
|
211
|
+
font-size: 12px;
|
|
212
|
+
}
|
|
213
|
+
.rules-table {
|
|
214
|
+
width: 100%;
|
|
215
|
+
}
|
|
216
|
+
.rule-control {
|
|
217
|
+
width: 100%;
|
|
218
|
+
}
|
|
219
|
+
</style>
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
<SelectIcon v-model:icon-value="menuIconValue" :placeholder="t('system.base.menu.placeholder.icon')" />
|
|
32
32
|
</template>
|
|
33
33
|
|
|
34
|
-
<template #
|
|
35
|
-
<
|
|
36
|
-
v-model="
|
|
34
|
+
<template #i18ns>
|
|
35
|
+
<DynamicI18nEditor
|
|
36
|
+
v-model="i18nValues"
|
|
37
37
|
:source="formData.meta.title"
|
|
38
38
|
:maxlength="100"
|
|
39
39
|
/>
|
|
@@ -79,17 +79,17 @@ import type {
|
|
|
79
79
|
} from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_menu";
|
|
80
80
|
import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
|
|
81
81
|
import { BaseMenuType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/common";
|
|
82
|
-
import {
|
|
82
|
+
import { I18nTargetType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_i18n";
|
|
83
83
|
import { normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
|
|
84
84
|
import { t } from "@liujitcn/kratos-admin-core";
|
|
85
|
-
import
|
|
86
|
-
import
|
|
85
|
+
import DynamicI18nEditor from "@liujitcn/kratos-admin-system/components/DynamicI18nEditor.vue";
|
|
86
|
+
import DynamicI18nCell from "@liujitcn/kratos-admin-system/components/DynamicI18nCell.vue";
|
|
87
87
|
import {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
type
|
|
91
|
-
type
|
|
92
|
-
} from "@liujitcn/kratos-admin-system/components/
|
|
88
|
+
normalizeDynamicI18ns,
|
|
89
|
+
serializeDynamicI18ns,
|
|
90
|
+
type DynamicI18nRecord,
|
|
91
|
+
type DynamicI18nValue
|
|
92
|
+
} from "@liujitcn/kratos-admin-system/components/dynamicI18n";
|
|
93
93
|
|
|
94
94
|
defineOptions({
|
|
95
95
|
name: "BaseMenu",
|
|
@@ -113,7 +113,7 @@ const menuOptions = ref<ProFormOption[]>([]);
|
|
|
113
113
|
const parentMenuTypeMap = ref(new Map<number, BaseMenuType>());
|
|
114
114
|
const appMenuIds = ref(new Set<number>([APP_MENU_ROOT_ID]));
|
|
115
115
|
const apiList = ref<BaseApi[]>([]);
|
|
116
|
-
const
|
|
116
|
+
const i18nValues = ref<DynamicI18nValue[]>(normalizeDynamicI18ns(undefined, "title"));
|
|
117
117
|
|
|
118
118
|
const dialog = reactive({
|
|
119
119
|
editing: false,
|
|
@@ -159,7 +159,7 @@ function createDefaultMenuForm(): MenuFormState {
|
|
|
159
159
|
redirect: "",
|
|
160
160
|
meta: createDefaultMenuMeta(),
|
|
161
161
|
api: [],
|
|
162
|
-
|
|
162
|
+
i18ns: [],
|
|
163
163
|
sort: 1,
|
|
164
164
|
status: Status.STATUS_ENABLE
|
|
165
165
|
};
|
|
@@ -294,11 +294,11 @@ function renderHiddenCell(scope: RenderScope<BaseMenu>) {
|
|
|
294
294
|
/** 渲染菜单标题翻译预览,并复用当前页面的编辑弹窗。 */
|
|
295
295
|
function renderMenuTitleCell(scope: RenderScope<BaseMenu>) {
|
|
296
296
|
const row = scope.row;
|
|
297
|
-
return h(
|
|
297
|
+
return h(DynamicI18nCell, {
|
|
298
298
|
source: row.meta?.title ?? "",
|
|
299
|
-
targetType:
|
|
299
|
+
targetType: I18nTargetType.I18N_TARGET_TYPE_BASE_MENU_META_TITLE,
|
|
300
300
|
targetId: row.id,
|
|
301
|
-
|
|
301
|
+
i18ns: row.i18ns
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
304
|
|
|
@@ -468,10 +468,10 @@ const formFields = computed<ProFormField[]>(() => [
|
|
|
468
468
|
})
|
|
469
469
|
},
|
|
470
470
|
{
|
|
471
|
-
prop: "
|
|
472
|
-
label: t("system.base.
|
|
471
|
+
prop: "i18ns",
|
|
472
|
+
label: t("system.base.i18n.field.i18ns"),
|
|
473
473
|
component: "slot",
|
|
474
|
-
slotName: "
|
|
474
|
+
slotName: "i18ns",
|
|
475
475
|
colSpan: 24
|
|
476
476
|
},
|
|
477
477
|
{
|
|
@@ -999,9 +999,9 @@ function buildMenuOptions(menuList: BaseMenu[] = []) {
|
|
|
999
999
|
/** 根据菜单类型清理无效字段,避免提交脏数据。 */
|
|
1000
1000
|
function buildSubmitPayload(): BaseMenuForm {
|
|
1001
1001
|
const payload = normalizeMenuForm(formData);
|
|
1002
|
-
payload.
|
|
1003
|
-
|
|
1004
|
-
|
|
1002
|
+
payload.i18ns = serializeDynamicI18ns(
|
|
1003
|
+
i18nValues.value,
|
|
1004
|
+
I18nTargetType.I18N_TARGET_TYPE_BASE_MENU_META_TITLE,
|
|
1005
1005
|
payload.id
|
|
1006
1006
|
);
|
|
1007
1007
|
// 一级菜单在表单中保持空白,提交时仍按接口约定传回根节点标识。
|
|
@@ -1145,7 +1145,7 @@ function resetForm(data?: Partial<BaseMenuForm>) {
|
|
|
1145
1145
|
formDialogRef.value?.resetFields();
|
|
1146
1146
|
formDialogRef.value?.clearValidate();
|
|
1147
1147
|
Object.assign(formData, normalizeMenuForm(data));
|
|
1148
|
-
|
|
1148
|
+
i18nValues.value = normalizeDynamicI18ns(data?.i18ns as DynamicI18nRecord[] | undefined, "title");
|
|
1149
1149
|
}
|
|
1150
1150
|
|
|
1151
1151
|
/** 提交菜单表单,并在成功后关闭弹窗、刷新表格。 */
|