@liujitcn/kratos-admin-core 0.0.43 → 0.0.45
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/dist/package/declarations/src/components/ProForm/index.vue.d.ts +3 -1
- package/dist/package/declarations/src/components/ProForm/interface/index.d.ts +2 -0
- package/dist/package/declarations/src/rpc/base/v1/config.d.ts +2 -0
- package/dist/package/declarations/src/stores/interface/index.d.ts +2 -0
- package/dist/package/src/components/ProForm/index.vue +12 -2
- package/dist/package/src/components/ProForm/interface/index.ts +3 -0
- package/dist/package/src/routers/index.ts +4 -0
- package/dist/package/src/routers/modules/dynamicRouter.ts +3 -0
- package/dist/package/src/rpc/base/v1/config.ts +2 -0
- package/dist/package/src/stores/interface/index.ts +2 -0
- package/dist/package/src/stores/modules/config.ts +3 -1
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { FormRules } from "element-plus";
|
|
2
|
-
import type { ProFormField } from "../../components/ProForm/interface";
|
|
2
|
+
import type { ProFormField, ProFormLabelPosition } from "../../components/ProForm/interface";
|
|
3
3
|
/** ProForm 组件属性。 */
|
|
4
4
|
interface ProFormProps {
|
|
5
5
|
model: Record<string, any>;
|
|
6
6
|
fields: ProFormField[];
|
|
7
7
|
rules?: FormRules;
|
|
8
8
|
labelWidth?: string;
|
|
9
|
+
labelPosition?: ProFormLabelPosition;
|
|
9
10
|
gutter?: number;
|
|
10
11
|
colSpan?: number;
|
|
11
12
|
}
|
|
@@ -23,6 +24,7 @@ declare const __VLS_base: import("vue").DefineComponent<ProFormProps, {
|
|
|
23
24
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ProFormProps> & Readonly<{}>, {
|
|
24
25
|
rules: FormRules;
|
|
25
26
|
labelWidth: string;
|
|
27
|
+
labelPosition: ProFormLabelPosition;
|
|
26
28
|
gutter: number;
|
|
27
29
|
colSpan: number;
|
|
28
30
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -2,6 +2,8 @@ import type { FormItemRule } from "element-plus";
|
|
|
2
2
|
import type { Component } from "vue";
|
|
3
3
|
/** ProForm 支持的字段组件类型。 */
|
|
4
4
|
export type ProFormComponentType = "input" | "password" | "textarea" | "input-number" | "color-picker" | "segmented" | "switch" | "checkbox" | "select" | "dict" | "radio-group" | "checkbox-group" | "tree-select" | "date-picker" | "cron-expression" | "transfer" | "image-upload" | "images-upload" | "file-upload" | "files-upload" | "rich-text" | "dynamic-list" | "kv-list" | "slot";
|
|
5
|
+
/** ProForm 标签布局方向。 */
|
|
6
|
+
export type ProFormLabelPosition = "left" | "right" | "top";
|
|
5
7
|
/** ProForm 选择型字段选项。 */
|
|
6
8
|
export interface ProFormOption {
|
|
7
9
|
label: string;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-form
|
|
2
|
+
<el-form
|
|
3
|
+
class="pro-form"
|
|
4
|
+
ref="formRef"
|
|
5
|
+
:model="model"
|
|
6
|
+
:rules="formRules"
|
|
7
|
+
:label-width="labelWidth"
|
|
8
|
+
:label-position="labelPosition"
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
>
|
|
3
11
|
<el-row :gutter="gutter">
|
|
4
12
|
<template v-for="field in visibleFields" :key="field.prop">
|
|
5
13
|
<span v-if="field.rowBreakBefore" class="pro-form__row-break" aria-hidden="true" />
|
|
@@ -42,7 +50,7 @@
|
|
|
42
50
|
import { computed, ref, useSlots } from "vue";
|
|
43
51
|
import { QuestionFilled } from "@element-plus/icons-vue";
|
|
44
52
|
import type { FormInstance, FormRules } from "element-plus";
|
|
45
|
-
import type { ProFormField } from "../../components/ProForm/interface";
|
|
53
|
+
import type { ProFormField, ProFormLabelPosition } from "../../components/ProForm/interface";
|
|
46
54
|
import ProFormItem from "./components/ProFormItem.vue";
|
|
47
55
|
|
|
48
56
|
/** ProForm 组件属性。 */
|
|
@@ -51,6 +59,7 @@ interface ProFormProps {
|
|
|
51
59
|
fields: ProFormField[];
|
|
52
60
|
rules?: FormRules;
|
|
53
61
|
labelWidth?: string;
|
|
62
|
+
labelPosition?: ProFormLabelPosition;
|
|
54
63
|
gutter?: number;
|
|
55
64
|
colSpan?: number;
|
|
56
65
|
}
|
|
@@ -58,6 +67,7 @@ interface ProFormProps {
|
|
|
58
67
|
const props = withDefaults(defineProps<ProFormProps>(), {
|
|
59
68
|
rules: () => ({}),
|
|
60
69
|
labelWidth: "180px",
|
|
70
|
+
labelPosition: "top",
|
|
61
71
|
gutter: 20,
|
|
62
72
|
colSpan: 24
|
|
63
73
|
});
|
|
@@ -9,6 +9,7 @@ import { ensureAccessToken } from "../utils/request";
|
|
|
9
9
|
import { t } from "../locales";
|
|
10
10
|
import { useUserStore } from "../stores/modules/user";
|
|
11
11
|
import { setAdminDocumentTitle } from "../documentTitle";
|
|
12
|
+
import { useConfigStore } from "../stores/modules/config";
|
|
12
13
|
|
|
13
14
|
const mode = import.meta.env.VITE_ROUTER_MODE;
|
|
14
15
|
|
|
@@ -45,6 +46,7 @@ const router = createRouter({
|
|
|
45
46
|
router.beforeEach(async to => {
|
|
46
47
|
const authStore = useAuthStore();
|
|
47
48
|
const userStore = useUserStore();
|
|
49
|
+
const configStore = useConfigStore();
|
|
48
50
|
const redirectQuery = typeof to.query.redirect === "string" ? to.query.redirect : "";
|
|
49
51
|
|
|
50
52
|
// 1.NProgress 开始
|
|
@@ -81,6 +83,8 @@ router.beforeEach(async to => {
|
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
if (to.name === "AiChat" && !configStore.aiEnabled) return { path: "/404", replace: true };
|
|
87
|
+
|
|
84
88
|
// 5.如果没有菜单列表,就重新请求菜单列表并添加动态路由
|
|
85
89
|
if (!authStore.authMenuListGet.length) {
|
|
86
90
|
await userStore.getUserInfo();
|
|
@@ -9,6 +9,7 @@ import type { RouteItem } from "../../rpc/system/admin/v1/auth";
|
|
|
9
9
|
import { BaseMenuType } from "../../rpc/system/admin/v1/common";
|
|
10
10
|
import { getRouteMetaFull } from "../../utils";
|
|
11
11
|
import { ADMIN_STATIC_VIEWS, getAdminViewRegistry } from "../../modules";
|
|
12
|
+
import { useConfigStore } from "../../stores/modules/config";
|
|
12
13
|
|
|
13
14
|
/** 解析后的后端路由项,补齐完整路径和重定向。 */
|
|
14
15
|
type ResolvedRouteItem = {
|
|
@@ -113,6 +114,7 @@ function createRouteRecord(item: RouteItem, path: string, redirect?: string) {
|
|
|
113
114
|
export const initDynamicRouter = async () => {
|
|
114
115
|
const userStore = useUserStore();
|
|
115
116
|
const authStore = useAuthStore();
|
|
117
|
+
const configStore = useConfigStore();
|
|
116
118
|
|
|
117
119
|
try {
|
|
118
120
|
// 1.获取菜单列表 && 按钮权限列表
|
|
@@ -135,6 +137,7 @@ export const initDynamicRouter = async () => {
|
|
|
135
137
|
// 3.添加动态路由
|
|
136
138
|
const resolvedRouteItems = buildResolvedRouteItems(authStore.authMenuListGet);
|
|
137
139
|
resolvedRouteItems.forEach(({ item, path, redirect }) => {
|
|
140
|
+
if (item.name === "AiChat" && !configStore.aiEnabled) return;
|
|
138
141
|
if (item.type === BaseMenuType.BASE_MENU_TYPE_EXT_LINK) return;
|
|
139
142
|
const routeRecord = createRouteRecord(item, path, redirect);
|
|
140
143
|
|
|
@@ -80,7 +80,8 @@ export const useConfigStore = defineStore("admin-config", {
|
|
|
80
80
|
display: { ...DEFAULT_SITE_DISPLAY_CONFIG },
|
|
81
81
|
captcha: { ...DEFAULT_LOGIN_CAPTCHA_CONFIG },
|
|
82
82
|
showTenantCode: true,
|
|
83
|
-
i18nDraftEnabled: false
|
|
83
|
+
i18nDraftEnabled: false,
|
|
84
|
+
aiEnabled: false
|
|
84
85
|
}),
|
|
85
86
|
getters: {},
|
|
86
87
|
actions: {
|
|
@@ -120,6 +121,7 @@ export const useConfigStore = defineStore("admin-config", {
|
|
|
120
121
|
this.setLoginCaptchaConfig(normalizeLoginCaptchaConfig(configMap));
|
|
121
122
|
this.showTenantCode = !["false", "0"].includes((configMap[SHOW_TENANT_CODE_KEY] ?? "true").toLowerCase());
|
|
122
123
|
this.i18nDraftEnabled = configMap[I18N_DRAFT_ENABLED_KEY] === "true";
|
|
124
|
+
this.aiEnabled = configResponse.ai_enabled === true;
|
|
123
125
|
return this.display;
|
|
124
126
|
}
|
|
125
127
|
}
|