@oiij/naive-ui 0.0.75 → 0.0.76
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 +3 -3
- package/dist/components/config-providers/ConfigProviders.vue.d.ts +2 -2
- package/dist/components/copy-button/CopyButton.js +1 -1
- package/dist/components/copy-button/CopyButton.vue.d.ts +4 -4
- package/dist/components/data-table-plus/DataTablePlus.vue.d.ts +12 -12
- package/dist/components/loading-provider/LoadingProvider.vue.d.ts +2 -2
- package/dist/components/preset-form/PresetForm.vue.d.ts +10 -10
- package/dist/components/preset-input/PresetInput.vue.d.ts +3 -3
- package/dist/components/preset-picker/PresetPicker.vue.d.ts +4 -4
- package/dist/components/preset-select/PresetSelect.js +1 -1
- package/dist/components/preset-select/PresetSelect.vue.d.ts +5 -5
- package/dist/components/remote-request/RemoteRequest.vue.d.ts +5 -5
- package/dist/components/search-input/SearchInput.js +1 -1
- package/dist/components/search-input/SearchInput.vue.d.ts +4 -4
- package/dist/components/type-writer/TypeWriter.vue.d.ts +4 -4
- package/dist/composables/index.d.ts +1 -1
- package/dist/composables/use-data-request.d.ts +7 -7
- package/dist/composables/use-data-request.js +1 -1
- package/dist/composables/use-naive-form.d.ts +6 -6
- package/dist/composables/use-naive-form.js +1 -1
- package/dist/composables/use-naive-menu.d.ts +103 -0
- package/dist/composables/use-naive-menu.js +181 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +4 -4
- package/dist/composables/use-auto-menu.d.ts +0 -74
- package/dist/composables/use-auto-menu.js +0 -129
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ yarn add @oiij/naive-ui
|
|
|
60
60
|
```vue
|
|
61
61
|
<script setup>
|
|
62
62
|
import type { RouteRecordRaw } from 'vue-router'
|
|
63
|
-
import {
|
|
63
|
+
import { useNaiveMenu } from '@oiij/naive-ui'
|
|
64
64
|
|
|
65
65
|
// 模拟路由配置
|
|
66
66
|
const routes: RouteRecordRaw[] = [
|
|
@@ -80,7 +80,7 @@ const routes: RouteRecordRaw[] = [
|
|
|
80
80
|
}
|
|
81
81
|
]
|
|
82
82
|
|
|
83
|
-
const { menuOptions } =
|
|
83
|
+
const { menuOptions } = useNaiveMenu(routes)
|
|
84
84
|
</script>
|
|
85
85
|
|
|
86
86
|
<template>
|
|
@@ -94,7 +94,7 @@ const { menuOptions } = useAutoMenu(routes)
|
|
|
94
94
|
|
|
95
95
|
### 组合式 API
|
|
96
96
|
|
|
97
|
-
- **use-
|
|
97
|
+
- **use-naive-menu** 📋: 自动菜单生成
|
|
98
98
|
- **use-data-request** 📡: 数据请求管理
|
|
99
99
|
- **use-loading** ⏳: 加载状态管理
|
|
100
100
|
- **use-naive-form** 📝: 表单管理
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ConfigProvidersProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue20 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/config-providers/ConfigProviders.vue.d.ts
|
|
5
5
|
declare var __VLS_44: {};
|
|
6
6
|
type __VLS_Slots = {} & {
|
|
7
7
|
default?: (props: typeof __VLS_44) => any;
|
|
8
8
|
};
|
|
9
|
-
declare const __VLS_base:
|
|
9
|
+
declare const __VLS_base: vue20.DefineComponent<ConfigProvidersProps, {}, {}, {}, {}, vue20.ComponentOptionsMixin, vue20.ComponentOptionsMixin, {}, string, vue20.PublicProps, Readonly<ConfigProvidersProps> & Readonly<{}>, {}, {}, {}, {}, string, vue20.ComponentProvideOptions, false, {}, any>;
|
|
10
10
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
11
11
|
declare const _default: typeof __VLS_export;
|
|
12
12
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MageCopyFill_default from "../icons/MageCopyFill.js";
|
|
2
|
-
import { createBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderSlot, toDisplayString, unref, watch, withCtx } from "vue";
|
|
3
2
|
import { useClipboard } from "@vueuse/core";
|
|
3
|
+
import { createBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderSlot, toDisplayString, unref, watch, withCtx } from "vue";
|
|
4
4
|
import { NButton, NTooltip } from "naive-ui";
|
|
5
5
|
|
|
6
6
|
//#region src/components/copy-button/CopyButton.vue
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CopyButtonProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue54 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/copy-button/CopyButton.vue.d.ts
|
|
5
5
|
declare var __VLS_9: {}, __VLS_18: {}, __VLS_25: {};
|
|
@@ -10,11 +10,11 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
} & {
|
|
11
11
|
tooltip?: (props: typeof __VLS_25) => any;
|
|
12
12
|
};
|
|
13
|
-
declare const __VLS_base:
|
|
13
|
+
declare const __VLS_base: vue54.DefineComponent<CopyButtonProps, {}, {}, {}, {}, vue54.ComponentOptionsMixin, vue54.ComponentOptionsMixin, {} & {
|
|
14
14
|
copied: (v: string | undefined) => any;
|
|
15
|
-
}, string,
|
|
15
|
+
}, string, vue54.PublicProps, Readonly<CopyButtonProps> & Readonly<{
|
|
16
16
|
onCopied?: ((v: string | undefined) => any) | undefined;
|
|
17
|
-
}>, {}, {}, {}, {}, string,
|
|
17
|
+
}>, {}, {}, {}, {}, string, vue54.ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
19
19
|
declare const _default: typeof __VLS_export;
|
|
20
20
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { DataObject, UseDataRequestPagination } from "../../composables/use-data-request.js";
|
|
2
2
|
import { DataTablePlusEmits, DataTablePlusExpose, DataTablePlusProps } from "./index.js";
|
|
3
3
|
import "../../composables/index.js";
|
|
4
|
-
import * as vue65 from "vue";
|
|
5
4
|
import * as _vueuse_core31 from "@vueuse/core";
|
|
5
|
+
import * as vue70 from "vue";
|
|
6
6
|
import { DataTableBaseColumn, DataTableFilterState, DataTableInst, DataTableSortState } from "naive-ui";
|
|
7
7
|
|
|
8
8
|
//#region src/components/data-table-plus/DataTablePlus.vue.d.ts
|
|
9
9
|
declare const __VLS_export: <P extends DataObject, D extends DataObject, R extends DataObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
10
|
-
props:
|
|
11
|
-
onSuccess?: ((data: D, params: P[]) => any) | undefined;
|
|
10
|
+
props: vue70.PublicProps & __VLS_PrettifyLocal<DataTablePlusProps<P, D, R> & {
|
|
12
11
|
onError?: ((err: Error, params: P[]) => any) | undefined;
|
|
12
|
+
onSuccess?: ((data: D, params: P[]) => any) | undefined;
|
|
13
13
|
onLoad?: ((row: R) => any) | undefined;
|
|
14
14
|
onScroll?: ((ev: Event) => any) | undefined;
|
|
15
15
|
onFinally?: ((params: P[], data?: D | undefined, err?: Error | undefined) => any) | undefined;
|
|
@@ -29,7 +29,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
29
29
|
}> & (typeof globalThis extends {
|
|
30
30
|
__VLS_PROPS_FALLBACK: infer P_1;
|
|
31
31
|
} ? P_1 : {});
|
|
32
|
-
expose: (exposed:
|
|
32
|
+
expose: (exposed: vue70.ShallowUnwrapRef<DataTablePlusExpose<P, D, R>>) => void;
|
|
33
33
|
attrs: any;
|
|
34
34
|
slots: {
|
|
35
35
|
header?: (props: {
|
|
@@ -46,7 +46,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
46
46
|
filters: DataTableFilterState | undefined;
|
|
47
47
|
sorters: Record<string, DataTableSortState> | undefined;
|
|
48
48
|
dataTableInst: DataTableInst | null;
|
|
49
|
-
pagination:
|
|
49
|
+
pagination: vue70.Ref<{
|
|
50
50
|
page: number;
|
|
51
51
|
pageSize: number;
|
|
52
52
|
itemCount: number;
|
|
@@ -86,7 +86,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
86
86
|
filters: DataTableFilterState | undefined;
|
|
87
87
|
sorters: Record<string, DataTableSortState> | undefined;
|
|
88
88
|
dataTableInst: DataTableInst | null;
|
|
89
|
-
pagination:
|
|
89
|
+
pagination: vue70.Ref<{
|
|
90
90
|
page: number;
|
|
91
91
|
pageSize: number;
|
|
92
92
|
itemCount: number;
|
|
@@ -124,7 +124,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
124
124
|
filters: DataTableFilterState | undefined;
|
|
125
125
|
sorters: Record<string, DataTableSortState> | undefined;
|
|
126
126
|
dataTableInst: DataTableInst | null;
|
|
127
|
-
pagination:
|
|
127
|
+
pagination: vue70.Ref<{
|
|
128
128
|
page: number;
|
|
129
129
|
pageSize: number;
|
|
130
130
|
itemCount: number;
|
|
@@ -162,7 +162,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
162
162
|
filters: DataTableFilterState | undefined;
|
|
163
163
|
sorters: Record<string, DataTableSortState> | undefined;
|
|
164
164
|
dataTableInst: DataTableInst | null;
|
|
165
|
-
pagination:
|
|
165
|
+
pagination: vue70.Ref<{
|
|
166
166
|
page: number;
|
|
167
167
|
pageSize: number;
|
|
168
168
|
itemCount: number;
|
|
@@ -200,7 +200,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
200
200
|
filters: DataTableFilterState | undefined;
|
|
201
201
|
sorters: Record<string, DataTableSortState> | undefined;
|
|
202
202
|
dataTableInst: DataTableInst | null;
|
|
203
|
-
pagination:
|
|
203
|
+
pagination: vue70.Ref<{
|
|
204
204
|
page: number;
|
|
205
205
|
pageSize: number;
|
|
206
206
|
itemCount: number;
|
|
@@ -238,7 +238,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
238
238
|
filters: DataTableFilterState | undefined;
|
|
239
239
|
sorters: Record<string, DataTableSortState> | undefined;
|
|
240
240
|
dataTableInst: DataTableInst | null;
|
|
241
|
-
pagination:
|
|
241
|
+
pagination: vue70.Ref<{
|
|
242
242
|
page: number;
|
|
243
243
|
pageSize: number;
|
|
244
244
|
itemCount: number;
|
|
@@ -276,7 +276,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
276
276
|
filters: DataTableFilterState | undefined;
|
|
277
277
|
sorters: Record<string, DataTableSortState> | undefined;
|
|
278
278
|
dataTableInst: DataTableInst | null;
|
|
279
|
-
pagination:
|
|
279
|
+
pagination: vue70.Ref<{
|
|
280
280
|
page: number;
|
|
281
281
|
pageSize: number;
|
|
282
282
|
itemCount: number;
|
|
@@ -301,7 +301,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
301
301
|
}) => any;
|
|
302
302
|
};
|
|
303
303
|
emit: DataTablePlusEmits<P, D, R>;
|
|
304
|
-
}>) =>
|
|
304
|
+
}>) => vue70.VNode & {
|
|
305
305
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
306
306
|
};
|
|
307
307
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoadingProviderProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue35 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/loading-provider/LoadingProvider.vue.d.ts
|
|
5
5
|
declare var __VLS_26: {}, __VLS_29: {}, __VLS_31: {};
|
|
@@ -10,7 +10,7 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
} & {
|
|
11
11
|
default?: (props: typeof __VLS_31) => any;
|
|
12
12
|
};
|
|
13
|
-
declare const __VLS_base:
|
|
13
|
+
declare const __VLS_base: vue35.DefineComponent<LoadingProviderProps, {}, {}, {}, {}, vue35.ComponentOptionsMixin, vue35.ComponentOptionsMixin, {}, string, vue35.PublicProps, Readonly<LoadingProviderProps> & Readonly<{}>, {}, {}, {}, {}, string, vue35.ComponentProvideOptions, false, {}, any>;
|
|
14
14
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
15
15
|
declare const _default: typeof __VLS_export;
|
|
16
16
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { DataObject } from "../../composables/use-data-request.js";
|
|
2
2
|
import { PresetFormExpose, PresetFormProps } from "./index.js";
|
|
3
|
-
import * as vue35 from "vue";
|
|
4
3
|
import * as _vueuse_core8 from "@vueuse/core";
|
|
4
|
+
import * as vue40 from "vue";
|
|
5
5
|
import * as naive_ui0 from "naive-ui";
|
|
6
6
|
import { FormInst, FormRules } from "naive-ui";
|
|
7
7
|
import * as async_validator0 from "async-validator";
|
|
8
8
|
|
|
9
9
|
//#region src/components/preset-form/PresetForm.vue.d.ts
|
|
10
10
|
declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
11
|
-
props:
|
|
11
|
+
props: vue40.PublicProps & __VLS_PrettifyLocal<PresetFormProps<V> & {
|
|
12
12
|
onValidated?: ((val: V) => any) | undefined;
|
|
13
13
|
}> & (typeof globalThis extends {
|
|
14
14
|
__VLS_PROPS_FALLBACK: infer P;
|
|
15
15
|
} ? P : {});
|
|
16
|
-
expose: (exposed:
|
|
16
|
+
expose: (exposed: vue40.ShallowUnwrapRef<PresetFormExpose<V>>) => void;
|
|
17
17
|
attrs: any;
|
|
18
18
|
slots: {
|
|
19
19
|
header?: (props: {
|
|
@@ -21,8 +21,8 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
21
21
|
formValue: V;
|
|
22
22
|
formRules: Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>;
|
|
23
23
|
formProps: {
|
|
24
|
-
model:
|
|
25
|
-
rules:
|
|
24
|
+
model: vue40.Reactive<V>;
|
|
25
|
+
rules: vue40.Reactive<Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>>;
|
|
26
26
|
};
|
|
27
27
|
setValue: (_value: Partial<V>) => void;
|
|
28
28
|
validate: () => Promise<{
|
|
@@ -40,8 +40,8 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
40
40
|
formValue: V;
|
|
41
41
|
formRules: Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>;
|
|
42
42
|
formProps: {
|
|
43
|
-
model:
|
|
44
|
-
rules:
|
|
43
|
+
model: vue40.Reactive<V>;
|
|
44
|
+
rules: vue40.Reactive<Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>>;
|
|
45
45
|
};
|
|
46
46
|
setValue: (_value: Partial<V>) => void;
|
|
47
47
|
validate: () => Promise<{
|
|
@@ -59,8 +59,8 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
59
59
|
formValue: V;
|
|
60
60
|
formRules: Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>;
|
|
61
61
|
formProps: {
|
|
62
|
-
model:
|
|
63
|
-
rules:
|
|
62
|
+
model: vue40.Reactive<V>;
|
|
63
|
+
rules: vue40.Reactive<Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>>;
|
|
64
64
|
};
|
|
65
65
|
setValue: (_value: Partial<V>) => void;
|
|
66
66
|
validate: () => Promise<{
|
|
@@ -74,7 +74,7 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
74
74
|
}) => any;
|
|
75
75
|
};
|
|
76
76
|
emit: (e: "validated", val: V) => void;
|
|
77
|
-
}>) =>
|
|
77
|
+
}>) => vue40.VNode & {
|
|
78
78
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
79
79
|
};
|
|
80
80
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PresetInputProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue25 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/preset-input/PresetInput.vue.d.ts
|
|
5
5
|
declare const __VLS_export: <V>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
6
|
-
props:
|
|
6
|
+
props: vue25.PublicProps & __VLS_PrettifyLocal<PresetInputProps<V> & {
|
|
7
7
|
"onUpdate:value"?: ((val?: V | undefined) => any) | undefined;
|
|
8
8
|
}> & (typeof globalThis extends {
|
|
9
9
|
__VLS_PROPS_FALLBACK: infer P;
|
|
@@ -12,7 +12,7 @@ declare const __VLS_export: <V>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
12
12
|
attrs: any;
|
|
13
13
|
slots: {};
|
|
14
14
|
emit: (e: "update:value", val?: V) => void;
|
|
15
|
-
}>) =>
|
|
15
|
+
}>) => vue25.VNode & {
|
|
16
16
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
17
17
|
};
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DataObject } from "../../composables/use-data-request.js";
|
|
2
2
|
import { PresetPickerEmits, PresetPickerExpose, PresetPickerProps, PresetPickerValue } from "./index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as vue59 from "vue";
|
|
4
4
|
import { DataTableColumns } from "naive-ui";
|
|
5
5
|
|
|
6
6
|
//#region src/components/preset-picker/PresetPicker.vue.d.ts
|
|
7
7
|
declare const __VLS_export: <V extends PresetPickerValue, R extends DataObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
8
|
-
props:
|
|
8
|
+
props: vue59.PublicProps & __VLS_PrettifyLocal<PresetPickerProps<V, R> & {
|
|
9
9
|
onClose?: (() => any) | undefined;
|
|
10
10
|
"onUpdate:value"?: ((val: V | null, raw: R | R[] | null) => any) | undefined;
|
|
11
11
|
onAfterEnter?: (() => any) | undefined;
|
|
@@ -18,7 +18,7 @@ declare const __VLS_export: <V extends PresetPickerValue, R extends DataObject>(
|
|
|
18
18
|
}> & (typeof globalThis extends {
|
|
19
19
|
__VLS_PROPS_FALLBACK: infer P;
|
|
20
20
|
} ? P : {});
|
|
21
|
-
expose: (exposed:
|
|
21
|
+
expose: (exposed: vue59.ShallowUnwrapRef<PresetPickerExpose<R>>) => void;
|
|
22
22
|
attrs: any;
|
|
23
23
|
slots: {
|
|
24
24
|
'button-icon'?: (props: {}) => any;
|
|
@@ -54,7 +54,7 @@ declare const __VLS_export: <V extends PresetPickerValue, R extends DataObject>(
|
|
|
54
54
|
'modal-close'?: (props: {}) => any;
|
|
55
55
|
};
|
|
56
56
|
emit: PresetPickerEmits<V, R>;
|
|
57
|
-
}>) =>
|
|
57
|
+
}>) => vue59.VNode & {
|
|
58
58
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
59
59
|
};
|
|
60
60
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useDataRequest } from "../../composables/use-data-request.js";
|
|
2
|
-
import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, reactive, ref, renderSlot, toRaw, toValue, unref, useTemplateRef, withCtx } from "vue";
|
|
3
2
|
import { useDebounceFn } from "@vueuse/core";
|
|
3
|
+
import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, reactive, ref, renderSlot, toRaw, toValue, unref, useTemplateRef, withCtx } from "vue";
|
|
4
4
|
import { NFlex, NPagination, NSelect } from "naive-ui";
|
|
5
5
|
|
|
6
6
|
//#region src/components/preset-select/PresetSelect.vue
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { DataObject, UseDataRequestPagination } from "../../composables/use-data-request.js";
|
|
2
2
|
import { PresetSelectEmits, PresetSelectExpose, PresetSelectProps, PresetSelectValue } from "./index.js";
|
|
3
|
-
import * as vue49 from "vue";
|
|
4
3
|
import * as _vueuse_core11 from "@vueuse/core";
|
|
4
|
+
import * as vue62 from "vue";
|
|
5
5
|
import { SelectInst, SelectOption } from "naive-ui";
|
|
6
6
|
|
|
7
7
|
//#region src/components/preset-select/PresetSelect.vue.d.ts
|
|
8
8
|
declare const __VLS_export: <V extends PresetSelectValue, P extends DataObject, D extends DataObject, R extends DataObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
9
|
-
props:
|
|
10
|
-
onSuccess?: ((data: D, params: P[]) => any) | undefined;
|
|
9
|
+
props: vue62.PublicProps & __VLS_PrettifyLocal<PresetSelectProps<V, P, D, R> & {
|
|
11
10
|
onError?: ((err: Error, params: P[]) => any) | undefined;
|
|
11
|
+
onSuccess?: ((data: D, params: P[]) => any) | undefined;
|
|
12
12
|
onClear?: (() => any) | undefined;
|
|
13
13
|
onBlur?: ((ev: FocusEvent) => any) | undefined;
|
|
14
14
|
onFocus?: ((ev: FocusEvent) => any) | undefined;
|
|
@@ -23,7 +23,7 @@ declare const __VLS_export: <V extends PresetSelectValue, P extends DataObject,
|
|
|
23
23
|
}> & (typeof globalThis extends {
|
|
24
24
|
__VLS_PROPS_FALLBACK: infer P_1;
|
|
25
25
|
} ? P_1 : {});
|
|
26
|
-
expose: (exposed:
|
|
26
|
+
expose: (exposed: vue62.ShallowUnwrapRef<PresetSelectExpose<P, D, R>>) => void;
|
|
27
27
|
attrs: any;
|
|
28
28
|
slots: {
|
|
29
29
|
header?: (props: {
|
|
@@ -162,7 +162,7 @@ declare const __VLS_export: <V extends PresetSelectValue, P extends DataObject,
|
|
|
162
162
|
}) => any;
|
|
163
163
|
};
|
|
164
164
|
emit: PresetSelectEmits<V, P, D, R>;
|
|
165
|
-
}>) =>
|
|
165
|
+
}>) => vue62.VNode & {
|
|
166
166
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
167
167
|
};
|
|
168
168
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { DataObject, UseDataRequestPagination } from "../../composables/use-data-request.js";
|
|
2
2
|
import { RemoteRequestEmits, RemoteRequestExpose, RemoteRequestProps } from "./index.js";
|
|
3
|
-
import * as vue22 from "vue";
|
|
4
3
|
import * as _vueuse_core4 from "@vueuse/core";
|
|
4
|
+
import * as vue27 from "vue";
|
|
5
5
|
|
|
6
6
|
//#region src/components/remote-request/RemoteRequest.vue.d.ts
|
|
7
7
|
declare const __VLS_export: <P extends DataObject, D extends DataObject, R extends DataObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
8
|
-
props:
|
|
9
|
-
onSuccess?: ((data: D, params: P[]) => any) | undefined;
|
|
8
|
+
props: vue27.PublicProps & __VLS_PrettifyLocal<RemoteRequestProps<P, D> & {
|
|
10
9
|
onError?: ((err: Error, params: P[]) => any) | undefined;
|
|
10
|
+
onSuccess?: ((data: D, params: P[]) => any) | undefined;
|
|
11
11
|
onFinally?: ((params: P[], data?: D | undefined, err?: Error | undefined) => any) | undefined;
|
|
12
12
|
onBefore?: ((params: P[]) => any) | undefined;
|
|
13
13
|
}> & (typeof globalThis extends {
|
|
14
14
|
__VLS_PROPS_FALLBACK: infer P_1;
|
|
15
15
|
} ? P_1 : {});
|
|
16
|
-
expose: (exposed:
|
|
16
|
+
expose: (exposed: vue27.ShallowUnwrapRef<RemoteRequestExpose<P, D, R>>) => void;
|
|
17
17
|
attrs: any;
|
|
18
18
|
slots: {
|
|
19
19
|
default?: (props: {
|
|
@@ -43,7 +43,7 @@ declare const __VLS_export: <P extends DataObject, D extends DataObject, R exten
|
|
|
43
43
|
}) => any;
|
|
44
44
|
};
|
|
45
45
|
emit: RemoteRequestEmits<P, D>;
|
|
46
|
-
}>) =>
|
|
46
|
+
}>) => vue27.VNode & {
|
|
47
47
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
48
48
|
};
|
|
49
49
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MageSearch_default from "../icons/MageSearch.js";
|
|
2
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createSlots, createTextVNode, createVNode, defineComponent, mergeProps, openBlock, ref, renderSlot, unref, useTemplateRef, watch, watchEffect, withCtx } from "vue";
|
|
3
2
|
import { useDebounceFn, useTimeoutFn } from "@vueuse/core";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createSlots, createTextVNode, createVNode, defineComponent, mergeProps, openBlock, ref, renderSlot, unref, useTemplateRef, watch, watchEffect, withCtx } from "vue";
|
|
4
4
|
import { NButton, NInput, NInputGroup } from "naive-ui";
|
|
5
5
|
|
|
6
6
|
//#region src/components/search-input/SearchInput.vue
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SearchInputProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue49 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/search-input/SearchInput.vue.d.ts
|
|
5
5
|
declare var __VLS_19: {}, __VLS_21: {}, __VLS_28: {
|
|
@@ -15,11 +15,11 @@ type __VLS_Slots = {} & {
|
|
|
15
15
|
} & {
|
|
16
16
|
'button-icon'?: (props: typeof __VLS_39) => any;
|
|
17
17
|
};
|
|
18
|
-
declare const __VLS_base:
|
|
18
|
+
declare const __VLS_base: vue49.DefineComponent<SearchInputProps, {}, {}, {}, {}, vue49.ComponentOptionsMixin, vue49.ComponentOptionsMixin, {} & {
|
|
19
19
|
"update:value": (v: string | null | undefined) => any;
|
|
20
|
-
}, string,
|
|
20
|
+
}, string, vue49.PublicProps, Readonly<SearchInputProps> & Readonly<{
|
|
21
21
|
"onUpdate:value"?: ((v: string | null | undefined) => any) | undefined;
|
|
22
|
-
}>, {}, {}, {}, {}, string,
|
|
22
|
+
}>, {}, {}, {}, {}, string, vue49.ComponentProvideOptions, false, {}, any>;
|
|
23
23
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
24
24
|
declare const _default: typeof __VLS_export;
|
|
25
25
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { TypeWriterProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue65 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/type-writer/TypeWriter.vue.d.ts
|
|
5
|
-
declare const __VLS_export:
|
|
5
|
+
declare const __VLS_export: vue65.DefineComponent<TypeWriterProps, {}, {}, {}, {}, vue65.ComponentOptionsMixin, vue65.ComponentOptionsMixin, {} & {
|
|
6
6
|
start: () => any;
|
|
7
7
|
update: (v: {
|
|
8
8
|
index: number;
|
|
9
9
|
value: string;
|
|
10
10
|
}) => any;
|
|
11
11
|
stop: (v: string) => any;
|
|
12
|
-
}, string,
|
|
12
|
+
}, string, vue65.PublicProps, Readonly<TypeWriterProps> & Readonly<{
|
|
13
13
|
onStart?: (() => any) | undefined;
|
|
14
14
|
onUpdate?: ((v: {
|
|
15
15
|
index: number;
|
|
16
16
|
value: string;
|
|
17
17
|
}) => any) | undefined;
|
|
18
18
|
onStop?: ((v: string) => any) | undefined;
|
|
19
|
-
}>, {}, {}, {}, {}, string,
|
|
19
|
+
}>, {}, {}, {}, {}, string, vue65.ComponentProvideOptions, false, {}, any>;
|
|
20
20
|
declare const _default: typeof __VLS_export;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { _default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UseAutoMenuReturn, useAutoMenu } from "./use-auto-menu.js";
|
|
2
1
|
import { DataObject, DataRequestFields, UseDataRequestOptions, UseDataRequestPagination, UseDataRequestReturns, useDataRequest } from "./use-data-request.js";
|
|
3
2
|
import { useLoading } from "./use-loading.js";
|
|
4
3
|
import { UseNaiveFormClearRules, UseNaiveFormOptions, UseNaiveFormReturns, UseNaiveFormRules, useNaiveForm } from "./use-naive-form.js";
|
|
4
|
+
import { UseNaiveMenuOptions, UseNaiveMenuReturn, useNaiveMenu } from "./use-naive-menu.js";
|
|
5
5
|
import { UseNaiveThemeOptions, UseNaiveThemeReturns, useNaiveTheme } from "./use-naive-theme.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as vue4 from "vue";
|
|
2
1
|
import * as _vueuse_core0 from "@vueuse/core";
|
|
2
|
+
import * as vue0 from "vue";
|
|
3
3
|
import { UseRequestOptions, UseRequestPlugin } from "vue-hooks-plus/es/useRequest/types";
|
|
4
4
|
|
|
5
5
|
//#region src/composables/use-data-request.d.ts
|
|
@@ -48,12 +48,12 @@ type UseDataRequestPagination = {
|
|
|
48
48
|
* @returns 数据请求操作对象
|
|
49
49
|
*/
|
|
50
50
|
declare function useDataRequest<P extends DataObject = DataObject, D extends DataObject = DataObject, R extends DataObject = DataObject>(api: (...args: P[]) => Promise<D>, options?: UseDataRequestOptions<P, D>): {
|
|
51
|
-
/** 加载状态 */loading: Readonly<
|
|
52
|
-
data: Readonly<
|
|
53
|
-
error: Readonly<
|
|
54
|
-
params: Readonly<
|
|
55
|
-
list:
|
|
56
|
-
pagination:
|
|
51
|
+
/** 加载状态 */loading: Readonly<vue0.Ref<boolean, boolean>>; /** 响应数据 */
|
|
52
|
+
data: Readonly<vue0.Ref<D | undefined, D | undefined>>; /** 错误信息 */
|
|
53
|
+
error: Readonly<vue0.Ref<Error | undefined, Error | undefined>>; /** 请求参数 */
|
|
54
|
+
params: Readonly<vue0.Ref<P[] | [], P[] | []>>; /** 列表数据 */
|
|
55
|
+
list: vue0.ComputedRef<R[]>; /** 分页信息 */
|
|
56
|
+
pagination: vue0.Ref<{
|
|
57
57
|
page: number;
|
|
58
58
|
pageSize: number;
|
|
59
59
|
itemCount: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DataObject } from "./use-data-request.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _vueuse_core3 from "@vueuse/core";
|
|
3
|
+
import * as vue7 from "vue";
|
|
3
4
|
import { MaybeRefOrGetter, Ref, TemplateRef } from "vue";
|
|
4
|
-
import * as _vueuse_core0 from "@vueuse/core";
|
|
5
5
|
import { FormInst, FormItemRule, FormRules } from "naive-ui";
|
|
6
6
|
import { ValidateError } from "async-validator";
|
|
7
7
|
|
|
@@ -37,12 +37,12 @@ type UseNaiveFormOptions<T extends DataObject> = {
|
|
|
37
37
|
* @returns 表单操作对象
|
|
38
38
|
*/
|
|
39
39
|
declare function useNaiveForm<T extends DataObject = DataObject>(formInstRef: TemplateRef<FormInst>, options?: UseNaiveFormOptions<T>): {
|
|
40
|
-
/** 表单实例引用 */formInst: Readonly<
|
|
40
|
+
/** 表单实例引用 */formInst: Readonly<vue7.ShallowRef<FormInst | null>>; /** 表单值引用 */
|
|
41
41
|
formValue: Ref<T, T>; /** 表单规则引用 */
|
|
42
42
|
formRules: Ref<Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>, Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>>; /** 表单属性,用于绑定到表单组件 */
|
|
43
43
|
formProps: {
|
|
44
|
-
model:
|
|
45
|
-
rules:
|
|
44
|
+
model: vue7.Reactive<T>;
|
|
45
|
+
rules: vue7.Reactive<Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>>;
|
|
46
46
|
}; /** 设置表单值 */
|
|
47
47
|
setValue: (_value: Partial<T>) => void; /** 验证表单 */
|
|
48
48
|
validate: () => Promise<{
|
|
@@ -52,7 +52,7 @@ declare function useNaiveForm<T extends DataObject = DataObject>(formInstRef: Te
|
|
|
52
52
|
resetForm: () => void; /** 重置表单验证状态和值 */
|
|
53
53
|
reset: () => void; /** 清空表单值 */
|
|
54
54
|
clear: () => void; /** 验证成功事件 */
|
|
55
|
-
onValidated:
|
|
55
|
+
onValidated: _vueuse_core3.EventHookOn<[T]>;
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
58
58
|
* useNaiveForm 返回类型
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { reactive, ref, toRaw, toValue, watchEffect } from "vue";
|
|
2
1
|
import { createEventHook } from "@vueuse/core";
|
|
2
|
+
import { reactive, ref, toRaw, toValue, watchEffect } from "vue";
|
|
3
3
|
import { cloneDeep } from "es-toolkit/object";
|
|
4
4
|
|
|
5
5
|
//#region src/composables/use-naive-form.ts
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as vue5 from "vue";
|
|
2
|
+
import { MaybeRefOrGetter, VNodeChild } from "vue";
|
|
3
|
+
import { MenuOption } from "naive-ui";
|
|
4
|
+
import { RouteRecordRaw } from "vue-router";
|
|
5
|
+
|
|
6
|
+
//#region src/composables/use-naive-menu.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* 配置选项接口
|
|
9
|
+
* 用于定义 useNaiveMenu 组合函数的配置参数
|
|
10
|
+
*/
|
|
11
|
+
type UseNaiveMenuOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* 隐藏条件,可以是函数或字符串
|
|
14
|
+
* - 如果是函数,返回 true 时路由将不显示在菜单中
|
|
15
|
+
* - 如果是字符串,则从 route.meta 中获取对应属性的值
|
|
16
|
+
* @default 'hidden'
|
|
17
|
+
*/
|
|
18
|
+
hidden?: ((route: RouteRecordRaw) => boolean | string) | string;
|
|
19
|
+
/**
|
|
20
|
+
* 根路由判断,可以是函数或字符串
|
|
21
|
+
* - 如果是函数,返回 true 时路由将作为顶级菜单
|
|
22
|
+
* - 如果是字符串,则从 route.meta 中获取对应属性的值
|
|
23
|
+
* @default 'root'
|
|
24
|
+
*/
|
|
25
|
+
root?: ((route: RouteRecordRaw) => boolean | string) | string;
|
|
26
|
+
/**
|
|
27
|
+
* 标签字段名,从 route.meta 中获取对应属性的值作为菜单标签
|
|
28
|
+
* @default 'title'
|
|
29
|
+
*/
|
|
30
|
+
labelField?: string;
|
|
31
|
+
/**
|
|
32
|
+
* 键字段名,从 route 中获取对应属性的值作为菜单键
|
|
33
|
+
* @default 'name'
|
|
34
|
+
*/
|
|
35
|
+
keyField?: string;
|
|
36
|
+
/**
|
|
37
|
+
* 图标字段名,从 route.meta 中获取对应属性的值作为菜单图标
|
|
38
|
+
* @default 'icon'
|
|
39
|
+
*/
|
|
40
|
+
iconField?: string;
|
|
41
|
+
/**
|
|
42
|
+
* 图标渲染函数,用于自定义图标渲染
|
|
43
|
+
*/
|
|
44
|
+
renderIcon?: (icon: string) => VNodeChild;
|
|
45
|
+
/**
|
|
46
|
+
* 父路由元信息字段名
|
|
47
|
+
* @default 'parent'
|
|
48
|
+
*/
|
|
49
|
+
parentField?: string;
|
|
50
|
+
/**
|
|
51
|
+
* 父路由文件路径
|
|
52
|
+
* @default ''
|
|
53
|
+
*/
|
|
54
|
+
parentFilePath?: string;
|
|
55
|
+
/**
|
|
56
|
+
* 父路由元信息生成函数
|
|
57
|
+
*/
|
|
58
|
+
parent?: (route: RouteRecordRaw) => Record<string, unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* 自定义菜单选项创建函数
|
|
61
|
+
*/
|
|
62
|
+
createMenuOption?: (route: RouteRecordRaw) => MenuOption;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* 自动菜单组合函数
|
|
66
|
+
* 将路由配置转换为菜单配置,并提供扁平化的菜单选项
|
|
67
|
+
* @param routes 路由配置数组,可以是响应式或普通数组
|
|
68
|
+
* @param options 配置选项
|
|
69
|
+
* @returns 包含菜单选项和扁平化菜单选项的对象
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // 基本使用
|
|
73
|
+
* const { menuOptions, flattenedMenuOptions } = useNaiveMenu(routes)
|
|
74
|
+
*
|
|
75
|
+
* // 带配置选项(使用函数)
|
|
76
|
+
* const { menuOptions, flattenedMenuOptions } = useNaiveMenu(routes, {
|
|
77
|
+
* hidden: (route) => route.meta?.hidden,
|
|
78
|
+
* root: (route) => route.meta?.root,
|
|
79
|
+
* labelField: 'title',
|
|
80
|
+
* keyField: 'name',
|
|
81
|
+
* iconField: 'icon',
|
|
82
|
+
* renderIcon: (icon) => h('i', { class: icon })
|
|
83
|
+
* })
|
|
84
|
+
*
|
|
85
|
+
* // 带配置选项(使用字符串)
|
|
86
|
+
* const { menuOptions, flattenedMenuOptions } = useNaiveMenu(routes, {
|
|
87
|
+
* hidden: 'hidden',
|
|
88
|
+
* root: 'root',
|
|
89
|
+
* labelField: 'title',
|
|
90
|
+
* keyField: 'name',
|
|
91
|
+
* iconField: 'icon'
|
|
92
|
+
* })
|
|
93
|
+
*/
|
|
94
|
+
declare function useNaiveMenu(routes: MaybeRefOrGetter<RouteRecordRaw[]>, options?: UseNaiveMenuOptions): {
|
|
95
|
+
menuOptions: vue5.ComputedRef<MenuOption[]>;
|
|
96
|
+
flattenedMenuOptions: vue5.ComputedRef<MenuOption[]>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* useNaiveMenu 返回类型
|
|
100
|
+
*/
|
|
101
|
+
type UseNaiveMenuReturn = ReturnType<typeof useNaiveMenu>;
|
|
102
|
+
//#endregion
|
|
103
|
+
export { UseNaiveMenuOptions, UseNaiveMenuReturn, useNaiveMenu };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/composables/use-naive-menu.ts
|
|
4
|
+
/**
|
|
5
|
+
* 获取配置值
|
|
6
|
+
* @param route 路由配置
|
|
7
|
+
* @param config 配置项,可以是函数或字符串
|
|
8
|
+
* @param returnType 返回类型,'meta' 从 meta 中获取,'route' 从路由本身获取
|
|
9
|
+
* @param defaultValue 默认值
|
|
10
|
+
* @returns 配置值或默认值
|
|
11
|
+
*/
|
|
12
|
+
function getConfigValue(route, config, returnType, defaultValue) {
|
|
13
|
+
if (!config) return defaultValue;
|
|
14
|
+
if (typeof config === "function") return config(route);
|
|
15
|
+
if (returnType === "meta") return route.meta?.[config] ?? defaultValue;
|
|
16
|
+
return route?.[config] ?? defaultValue;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 创建单个菜单选项
|
|
20
|
+
* @param route 路由配置
|
|
21
|
+
* @param options 配置选项
|
|
22
|
+
* @returns 菜单选项
|
|
23
|
+
*/
|
|
24
|
+
function createConfigMenuOption(route, options) {
|
|
25
|
+
const { labelField, keyField, iconField, renderIcon } = options ?? {};
|
|
26
|
+
const labelValue = getConfigValue(route, labelField, "meta");
|
|
27
|
+
const keyValue = getConfigValue(route, keyField, "route");
|
|
28
|
+
const iconValue = getConfigValue(route, iconField, "meta");
|
|
29
|
+
return {
|
|
30
|
+
label: labelValue ?? route.meta?.title ?? route.name ?? route.path,
|
|
31
|
+
key: keyValue ?? route.name?.toString() ?? route.path?.toString(),
|
|
32
|
+
icon: iconValue ? () => renderIcon?.(iconValue) : void 0,
|
|
33
|
+
meta: route.meta
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 判断路由是否应该隐藏
|
|
38
|
+
* @param route 路由配置
|
|
39
|
+
* @param hidden 隐藏条件
|
|
40
|
+
* @returns 是否隐藏
|
|
41
|
+
*/
|
|
42
|
+
function shouldHide(route, hidden) {
|
|
43
|
+
if (!hidden) return false;
|
|
44
|
+
const result = getConfigValue(route, hidden, "meta");
|
|
45
|
+
return typeof result === "boolean" ? result : !!result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 判断路由是否为根路由
|
|
49
|
+
* @param route 路由配置
|
|
50
|
+
* @param root 根路由判断
|
|
51
|
+
* @returns 是否为根路由
|
|
52
|
+
*/
|
|
53
|
+
function isRoot(route, root) {
|
|
54
|
+
if (!root) return false;
|
|
55
|
+
const result = getConfigValue(route, root, "meta");
|
|
56
|
+
return typeof result === "boolean" ? result : !!result;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 将路由配置转换为菜单配置的递归函数
|
|
60
|
+
* @param routes 路由配置数组
|
|
61
|
+
* @param options 配置选项
|
|
62
|
+
* @returns 菜单配置数组
|
|
63
|
+
*/
|
|
64
|
+
function routes2menu(routes, options) {
|
|
65
|
+
const { hidden, root, createMenuOption } = options ?? {};
|
|
66
|
+
const menuOptions = [];
|
|
67
|
+
for (const route of routes ?? []) {
|
|
68
|
+
if (shouldHide(route, hidden)) continue;
|
|
69
|
+
const menu = typeof createMenuOption === "function" ? createMenuOption(route) : createConfigMenuOption(route, options);
|
|
70
|
+
if (route.children?.length) {
|
|
71
|
+
const rootChildren = route.children.filter((child) => isRoot(child, root));
|
|
72
|
+
const normalChildren = route.children.filter((child) => !isRoot(child, root));
|
|
73
|
+
if (normalChildren.length) menu.children = routes2menu(normalChildren, options);
|
|
74
|
+
if (rootChildren.length) {
|
|
75
|
+
const rootMenuOptions = rootChildren.filter((child) => !shouldHide(child, hidden)).map((child) => typeof createMenuOption === "function" ? createMenuOption(child) : createConfigMenuOption(child, options));
|
|
76
|
+
menuOptions.push(...rootMenuOptions);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
menuOptions.push(menu);
|
|
80
|
+
}
|
|
81
|
+
return menuOptions;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 深度扁平化菜单选项
|
|
85
|
+
* @param menuOptions 菜单选项数组
|
|
86
|
+
* @returns 扁平化的菜单选项数组
|
|
87
|
+
*/
|
|
88
|
+
function flattenDeepMenuOptions(menuOptions) {
|
|
89
|
+
return menuOptions.reduce((flattened, menu) => {
|
|
90
|
+
flattened.push(menu);
|
|
91
|
+
if (menu.children?.length) flattened.push(...flattenDeepMenuOptions(menu.children));
|
|
92
|
+
return flattened;
|
|
93
|
+
}, []);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 深度向上合并父路由元信息
|
|
97
|
+
* @param routes 路由配置数组
|
|
98
|
+
* @param parentField 父路由元信息字段名
|
|
99
|
+
* @param parentFilePath 父路由文件路径
|
|
100
|
+
* @param parent 父路由元信息生成函数
|
|
101
|
+
* @returns 处理后的路由配置数组
|
|
102
|
+
*/
|
|
103
|
+
function deepUpRouteParentMeta(routes, parentField, parentFilePath, parent) {
|
|
104
|
+
return routes.map((route) => {
|
|
105
|
+
const emptyPathChild = route.children?.find((f) => f.path === parentFilePath);
|
|
106
|
+
if (emptyPathChild) {
|
|
107
|
+
if (typeof parent === "function") {
|
|
108
|
+
const parentMeta = parent(route);
|
|
109
|
+
route.meta = {
|
|
110
|
+
...route.meta,
|
|
111
|
+
...parentMeta
|
|
112
|
+
};
|
|
113
|
+
} else if (parentField) {
|
|
114
|
+
const parentMeta = emptyPathChild.meta?.[parentField];
|
|
115
|
+
route.meta = {
|
|
116
|
+
...route.meta,
|
|
117
|
+
...parentMeta
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (route.children?.length) route.children = deepUpRouteParentMeta(route.children, parentField, parentFilePath, parent);
|
|
122
|
+
return route;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 自动菜单组合函数
|
|
127
|
+
* 将路由配置转换为菜单配置,并提供扁平化的菜单选项
|
|
128
|
+
* @param routes 路由配置数组,可以是响应式或普通数组
|
|
129
|
+
* @param options 配置选项
|
|
130
|
+
* @returns 包含菜单选项和扁平化菜单选项的对象
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* // 基本使用
|
|
134
|
+
* const { menuOptions, flattenedMenuOptions } = useNaiveMenu(routes)
|
|
135
|
+
*
|
|
136
|
+
* // 带配置选项(使用函数)
|
|
137
|
+
* const { menuOptions, flattenedMenuOptions } = useNaiveMenu(routes, {
|
|
138
|
+
* hidden: (route) => route.meta?.hidden,
|
|
139
|
+
* root: (route) => route.meta?.root,
|
|
140
|
+
* labelField: 'title',
|
|
141
|
+
* keyField: 'name',
|
|
142
|
+
* iconField: 'icon',
|
|
143
|
+
* renderIcon: (icon) => h('i', { class: icon })
|
|
144
|
+
* })
|
|
145
|
+
*
|
|
146
|
+
* // 带配置选项(使用字符串)
|
|
147
|
+
* const { menuOptions, flattenedMenuOptions } = useNaiveMenu(routes, {
|
|
148
|
+
* hidden: 'hidden',
|
|
149
|
+
* root: 'root',
|
|
150
|
+
* labelField: 'title',
|
|
151
|
+
* keyField: 'name',
|
|
152
|
+
* iconField: 'icon'
|
|
153
|
+
* })
|
|
154
|
+
*/
|
|
155
|
+
function useNaiveMenu(routes, options) {
|
|
156
|
+
const { hidden = "hidden", root = "root", labelField = "title", keyField = "name", iconField = "icon", renderIcon, createMenuOption, parentField = "parent", parentFilePath = "", parent } = options ?? {};
|
|
157
|
+
/**
|
|
158
|
+
* 菜单选项
|
|
159
|
+
* 响应式计算属性,当路由或配置变化时自动更新
|
|
160
|
+
*/
|
|
161
|
+
const menuOptions = computed(() => {
|
|
162
|
+
return routes2menu(deepUpRouteParentMeta(toValue(routes), parentField, parentFilePath, parent), {
|
|
163
|
+
hidden,
|
|
164
|
+
root,
|
|
165
|
+
labelField,
|
|
166
|
+
keyField,
|
|
167
|
+
iconField,
|
|
168
|
+
renderIcon,
|
|
169
|
+
createMenuOption
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
menuOptions,
|
|
174
|
+
flattenedMenuOptions: computed(() => {
|
|
175
|
+
return flattenDeepMenuOptions(menuOptions.value);
|
|
176
|
+
})
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
export { useNaiveMenu };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UseAutoMenuReturn, useAutoMenu } from "./composables/use-auto-menu.js";
|
|
2
1
|
import { DataObject, DataRequestFields, UseDataRequestOptions, UseDataRequestPagination, UseDataRequestReturns, useDataRequest } from "./composables/use-data-request.js";
|
|
3
2
|
import { useLoading } from "./composables/use-loading.js";
|
|
4
3
|
import { UseNaiveFormClearRules, UseNaiveFormOptions, UseNaiveFormReturns, UseNaiveFormRules, useNaiveForm } from "./composables/use-naive-form.js";
|
|
4
|
+
import { UseNaiveMenuOptions, UseNaiveMenuReturn, useNaiveMenu } from "./composables/use-naive-menu.js";
|
|
5
5
|
import { UseNaiveThemeOptions, UseNaiveThemeReturns, useNaiveTheme } from "./composables/use-naive-theme.js";
|
|
6
6
|
import "./composables/index.js";
|
|
7
|
-
export { DataObject, DataRequestFields,
|
|
7
|
+
export { DataObject, DataRequestFields, UseDataRequestOptions, UseDataRequestPagination, UseDataRequestReturns, UseNaiveFormClearRules, UseNaiveFormOptions, UseNaiveFormReturns, UseNaiveFormRules, UseNaiveMenuOptions, UseNaiveMenuReturn, UseNaiveThemeOptions, UseNaiveThemeReturns, useDataRequest, useLoading, useNaiveForm, useNaiveMenu, useNaiveTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useAutoMenu } from "./composables/use-auto-menu.js";
|
|
2
1
|
import { useDataRequest } from "./composables/use-data-request.js";
|
|
3
2
|
import { useLoading } from "./composables/use-loading.js";
|
|
4
3
|
import { useNaiveForm } from "./composables/use-naive-form.js";
|
|
4
|
+
import { useNaiveMenu } from "./composables/use-naive-menu.js";
|
|
5
5
|
import { useNaiveTheme } from "./composables/use-naive-theme.js";
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { useDataRequest, useLoading, useNaiveForm, useNaiveMenu, useNaiveTheme };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oiij/naive-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.76",
|
|
5
5
|
"description": "Some Composable Functions And Components for Vue 3",
|
|
6
6
|
"author": "oiij",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"vue-component-type-helpers": "^3.2.4",
|
|
47
47
|
"vue-hooks-plus": "^2.4.1",
|
|
48
48
|
"vue-router": "^5.0.2",
|
|
49
|
-
"@oiij/markdown-it": "0.0.12",
|
|
50
49
|
"@oiij/css-render": "0.0.10",
|
|
50
|
+
"@oiij/markdown-it": "0.0.12",
|
|
51
51
|
"@oiij/use": "0.0.44"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"vue-component-type-helpers": "^3.2.4",
|
|
63
63
|
"vue-hooks-plus": "^2.4.1",
|
|
64
64
|
"vue-router": "^5.0.2",
|
|
65
|
-
"@oiij/markdown-it": "0.0.12",
|
|
66
65
|
"@oiij/css-render": "0.0.10",
|
|
67
|
-
"@oiij/use": "0.0.44"
|
|
66
|
+
"@oiij/use": "0.0.44",
|
|
67
|
+
"@oiij/markdown-it": "0.0.12"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import * as vue0 from "vue";
|
|
2
|
-
import { MaybeRefOrGetter, VNode } from "vue";
|
|
3
|
-
import { MenuOption } from "naive-ui";
|
|
4
|
-
import { RouteRecordRaw } from "vue-router";
|
|
5
|
-
|
|
6
|
-
//#region src/composables/use-auto-menu.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* 配置选项接口
|
|
9
|
-
*/
|
|
10
|
-
type Options = {
|
|
11
|
-
/**
|
|
12
|
-
* 隐藏条件,可以是函数或字符串
|
|
13
|
-
* - 如果是函数,返回 true 时路由将不显示在菜单中
|
|
14
|
-
* - 如果是字符串,则从 route.meta 中获取对应属性的值
|
|
15
|
-
*/
|
|
16
|
-
hide?: ((route: RouteRecordRaw) => boolean | string) | string;
|
|
17
|
-
/**
|
|
18
|
-
* 根路由判断,可以是函数或字符串
|
|
19
|
-
* - 如果是函数,返回 true 时路由将作为顶级菜单
|
|
20
|
-
* - 如果是字符串,则从 route.meta 中获取对应属性的值
|
|
21
|
-
*/
|
|
22
|
-
root?: ((route: RouteRecordRaw) => boolean | string) | string;
|
|
23
|
-
/**
|
|
24
|
-
* 标签生成,可以是函数或字符串
|
|
25
|
-
* - 如果是函数,使用函数返回值作为菜单项的显示文本
|
|
26
|
-
* - 如果是字符串,则从 route.meta 中获取对应属性的值
|
|
27
|
-
*/
|
|
28
|
-
label?: ((route: RouteRecordRaw) => string) | string;
|
|
29
|
-
/**
|
|
30
|
-
* 键生成,可以是函数或字符串
|
|
31
|
-
* - 如果是函数,使用函数返回值作为菜单项的唯一标识
|
|
32
|
-
* - 如果是字符串,则从 route.meta 中获取对应属性的值
|
|
33
|
-
*/
|
|
34
|
-
key?: ((route: RouteRecordRaw) => string) | string;
|
|
35
|
-
/**
|
|
36
|
-
* 图标渲染函数,用于自定义路由图标
|
|
37
|
-
*/
|
|
38
|
-
icon?: (route: RouteRecordRaw) => VNode | string | undefined | null;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* 自动菜单组合函数
|
|
42
|
-
* @param routes 路由配置数组
|
|
43
|
-
* @param options 配置选项
|
|
44
|
-
* @returns 包含菜单选项和扁平化菜单选项的对象
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* // 基本使用
|
|
48
|
-
* const { menuOptions, flattenedMenuOptions } = useAutoMenu(routes)
|
|
49
|
-
*
|
|
50
|
-
* // 带配置选项(使用函数)
|
|
51
|
-
* const { menuOptions, flattenedMenuOptions } = useAutoMenu(routes, {
|
|
52
|
-
* hide: (route) => route.meta?.hidden,
|
|
53
|
-
* root: (route) => route.meta?.root,
|
|
54
|
-
* label: (route) => route.meta?.title ?? route.name,
|
|
55
|
-
* key: (route) => route.path,
|
|
56
|
-
* icon: (route) => route.meta?.icon
|
|
57
|
-
* })
|
|
58
|
-
*
|
|
59
|
-
* // 带配置选项(使用字符串)
|
|
60
|
-
* const { menuOptions, flattenedMenuOptions } = useAutoMenu(routes, {
|
|
61
|
-
* hide: 'hidden',
|
|
62
|
-
* root: 'root',
|
|
63
|
-
* label: 'title',
|
|
64
|
-
* key: 'path',
|
|
65
|
-
* icon: (route) => route.meta?.icon
|
|
66
|
-
* })
|
|
67
|
-
*/
|
|
68
|
-
declare function useAutoMenu(routes: MaybeRefOrGetter<RouteRecordRaw[]>, options?: Options): {
|
|
69
|
-
menuOptions: vue0.ComputedRef<MenuOption[]>;
|
|
70
|
-
flattenedMenuOptions: vue0.ComputedRef<MenuOption[]>;
|
|
71
|
-
};
|
|
72
|
-
type UseAutoMenuReturn = ReturnType<typeof useAutoMenu>;
|
|
73
|
-
//#endregion
|
|
74
|
-
export { UseAutoMenuReturn, useAutoMenu };
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { computed, toValue } from "vue";
|
|
2
|
-
|
|
3
|
-
//#region src/composables/use-auto-menu.ts
|
|
4
|
-
/**
|
|
5
|
-
* 获取配置值,支持函数和字符串两种类型
|
|
6
|
-
* @param route 路由配置
|
|
7
|
-
* @param config 配置项,可以是函数或字符串
|
|
8
|
-
* @param defaultValue 默认值
|
|
9
|
-
* @returns 配置值
|
|
10
|
-
*/
|
|
11
|
-
function getConfigValue(route, config, defaultValue) {
|
|
12
|
-
if (!config) return defaultValue;
|
|
13
|
-
if (typeof config === "function") return config(route);
|
|
14
|
-
return route.meta?.[config] ?? defaultValue;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 创建单个菜单选项
|
|
18
|
-
* @param route 路由配置
|
|
19
|
-
* @param options 配置选项
|
|
20
|
-
* @returns 菜单选项
|
|
21
|
-
*/
|
|
22
|
-
function createMenuOption(route, options) {
|
|
23
|
-
const { label, key, icon } = options ?? {};
|
|
24
|
-
return {
|
|
25
|
-
label: getConfigValue(route, label) ?? route.meta?.title ?? route.name ?? route.path,
|
|
26
|
-
key: getConfigValue(route, key) ?? route.name?.toString() ?? route.path?.toString(),
|
|
27
|
-
icon: icon ? () => icon(route) : void 0,
|
|
28
|
-
meta: route.meta
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 判断路由是否应该隐藏
|
|
33
|
-
* @param route 路由配置
|
|
34
|
-
* @param hide 隐藏条件
|
|
35
|
-
* @returns 是否隐藏
|
|
36
|
-
*/
|
|
37
|
-
function shouldHide(route, hide) {
|
|
38
|
-
if (!hide) return false;
|
|
39
|
-
const result = getConfigValue(route, hide);
|
|
40
|
-
return typeof result === "boolean" ? result : !!result;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 判断路由是否为根路由
|
|
44
|
-
* @param route 路由配置
|
|
45
|
-
* @param root 根路由判断
|
|
46
|
-
* @returns 是否为根路由
|
|
47
|
-
*/
|
|
48
|
-
function isRoot(route, root) {
|
|
49
|
-
if (!root) return !!route.meta?.root;
|
|
50
|
-
const result = getConfigValue(route, root);
|
|
51
|
-
return typeof result === "boolean" ? result : !!result;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* 将路由配置转换为菜单配置的递归函数
|
|
55
|
-
* @param routes 路由配置数组
|
|
56
|
-
* @param options 配置选项
|
|
57
|
-
* @returns 菜单配置数组
|
|
58
|
-
*/
|
|
59
|
-
function routes2menu(routes, options) {
|
|
60
|
-
const { hide, root } = options ?? {};
|
|
61
|
-
const menuOptions = [];
|
|
62
|
-
for (const route of routes ?? []) {
|
|
63
|
-
if (shouldHide(route, hide)) continue;
|
|
64
|
-
const menu = createMenuOption(route, options);
|
|
65
|
-
if (route.children?.length) {
|
|
66
|
-
const rootChildren = route.children.filter((child) => isRoot(child, root));
|
|
67
|
-
const normalChildren = route.children.filter((child) => !isRoot(child, root));
|
|
68
|
-
if (normalChildren.length) menu.children = routes2menu(normalChildren, options);
|
|
69
|
-
if (rootChildren.length) {
|
|
70
|
-
const rootMenuOptions = rootChildren.filter((child) => !shouldHide(child, hide)).map((child) => createMenuOption(child, options));
|
|
71
|
-
menuOptions.push(...rootMenuOptions);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
menuOptions.push(menu);
|
|
75
|
-
}
|
|
76
|
-
return menuOptions;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* 深度扁平化菜单选项
|
|
80
|
-
* @param menuOptions 菜单选项数组
|
|
81
|
-
* @returns 扁平化的菜单选项数组
|
|
82
|
-
*/
|
|
83
|
-
function flattenMenuOptions(menuOptions) {
|
|
84
|
-
const flattened = [];
|
|
85
|
-
function processMenu(menu) {
|
|
86
|
-
flattened.push(menu);
|
|
87
|
-
if (menu.children?.length) for (const child of menu.children) processMenu(child);
|
|
88
|
-
}
|
|
89
|
-
for (const menu of menuOptions) processMenu(menu);
|
|
90
|
-
return flattened;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* 自动菜单组合函数
|
|
94
|
-
* @param routes 路由配置数组
|
|
95
|
-
* @param options 配置选项
|
|
96
|
-
* @returns 包含菜单选项和扁平化菜单选项的对象
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* // 基本使用
|
|
100
|
-
* const { menuOptions, flattenedMenuOptions } = useAutoMenu(routes)
|
|
101
|
-
*
|
|
102
|
-
* // 带配置选项(使用函数)
|
|
103
|
-
* const { menuOptions, flattenedMenuOptions } = useAutoMenu(routes, {
|
|
104
|
-
* hide: (route) => route.meta?.hidden,
|
|
105
|
-
* root: (route) => route.meta?.root,
|
|
106
|
-
* label: (route) => route.meta?.title ?? route.name,
|
|
107
|
-
* key: (route) => route.path,
|
|
108
|
-
* icon: (route) => route.meta?.icon
|
|
109
|
-
* })
|
|
110
|
-
*
|
|
111
|
-
* // 带配置选项(使用字符串)
|
|
112
|
-
* const { menuOptions, flattenedMenuOptions } = useAutoMenu(routes, {
|
|
113
|
-
* hide: 'hidden',
|
|
114
|
-
* root: 'root',
|
|
115
|
-
* label: 'title',
|
|
116
|
-
* key: 'path',
|
|
117
|
-
* icon: (route) => route.meta?.icon
|
|
118
|
-
* })
|
|
119
|
-
*/
|
|
120
|
-
function useAutoMenu(routes, options) {
|
|
121
|
-
const menuOptions = computed(() => routes2menu(toValue(routes), options));
|
|
122
|
-
return {
|
|
123
|
-
menuOptions,
|
|
124
|
-
flattenedMenuOptions: computed(() => flattenMenuOptions(menuOptions.value))
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
export { useAutoMenu };
|