@peng_kai/kit 0.1.17 → 0.2.0-beta.0
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/admin/adminPlugin.ts +47 -0
- package/admin/components/filter/src/FilterParam.vue +76 -78
- package/admin/components/filter/src/FilterReset.vue +2 -2
- package/admin/components/filter/src/useFilterParams.ts +75 -25
- package/admin/components/filter/src/useFilterQuery.ts +32 -16
- package/admin/components/rich-text/index.ts +2 -0
- package/admin/components/rich-text/src/RichText.vue +342 -0
- package/admin/components/rich-text/src/imageUploader.ts +34 -0
- package/admin/components/rich-text/src/type.d.ts +7 -0
- package/admin/components/text/src/Datetime.vue +47 -48
- package/admin/components/upload/index.ts +2 -0
- package/admin/components/upload/src/PictureCardUpload.vue +143 -0
- package/admin/components/upload/src/customRequests.ts +31 -0
- package/admin/defines/index.ts +1 -1
- package/admin/defines/route/helpers.ts +0 -1
- package/admin/defines/startup/defineStartup.ts +8 -1
- package/admin/defines/startup/index.ts +1 -1
- package/admin/defines/startup/{getStartups.ts → runStartup.ts} +16 -7
- package/admin/layout/large/Breadcrumb.vue +68 -69
- package/admin/layout/large/Content.vue +23 -24
- package/admin/layout/large/Menu.vue +68 -69
- package/admin/layout/large/PageTab.vue +70 -71
- package/admin/permission/index.ts +2 -4
- package/admin/permission/routerGuard.ts +41 -43
- package/admin/permission/vuePlugin.ts +46 -30
- package/admin/route-guards/collapseMenu.ts +3 -3
- package/admin/route-guards/pageTitle.ts +18 -19
- package/admin/{hooks/useMenu.ts → stores/createUseMenuStore.ts} +133 -128
- package/admin/{hooks/usePage.ts → stores/createUsePageStore.ts} +145 -141
- package/admin/stores/createUsePageTabStore.ts +43 -0
- package/admin/{permission/usePermission.ts → stores/createUsePermissionStore.ts} +57 -52
- package/admin/stores/index.ts +8 -0
- package/admin/styles/classCover.scss +8 -0
- package/antd/hooks/useAntdForm.helpers.ts +92 -8
- package/antd/hooks/useAntdForm.ts +55 -63
- package/antd/hooks/useAntdTable.ts +12 -0
- package/antd/index.ts +1 -1
- package/libs/a-calc.ts +1 -0
- package/libs/axios.ts +2 -0
- package/libs/bignumber.ts +2 -0
- package/libs/dayjs.ts +5 -0
- package/libs/echarts.ts +5 -0
- package/libs/localstorage-slim.ts +2 -0
- package/libs/lodash-es.ts +1 -0
- package/libs/pinia.ts +1 -0
- package/libs/vue-query.ts +1 -0
- package/libs/vueuse.ts +3 -0
- package/package.json +55 -16
- package/request/helpers.ts +20 -1
- package/request/queryClient.ts +34 -21
- package/utils/upload/AwsS3.ts +76 -0
- package/utils/upload/fileHandlers.ts +27 -0
- package/utils/upload/index.ts +2 -0
- package/vite/index.d.ts +1 -0
- package/vite/index.mjs +27 -0
- package/vue/components/echarts/index.ts +1 -0
- package/vue/components/echarts/src/ECharts.vue +48 -0
- package/vue/components/index.ts +1 -0
- package/vue/components/infinite-query/src/InfiniteQuery.vue +2 -8
- package/vue/components/test/KitTest.vue +9 -0
- package/vue/components/test/testStore.ts +11 -0
- package/admin/hooks/index.ts +0 -5
- package/admin/hooks/usePageTab.ts +0 -35
- package/kitDependencies.ts +0 -43
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
import type { App } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
import { watch } from 'vue';
|
|
3
|
+
import { adminPlugin } from '../adminPlugin';
|
|
4
|
+
|
|
5
|
+
type TCodes = string | string[];
|
|
6
|
+
|
|
7
|
+
const PLUGIN_NAME = 'has-permission';
|
|
8
|
+
const UNWATCH_NAME = `v-${PLUGIN_NAME}@unwatch`;
|
|
9
|
+
|
|
10
|
+
export function setupPermissionPlugin(app: App) {
|
|
11
|
+
app.directive<HTMLElement, TCodes>(PLUGIN_NAME, {
|
|
12
|
+
mounted(el, binding) {
|
|
13
|
+
const permissionStore = adminPlugin.deps.usePermissionStore();
|
|
14
|
+
|
|
15
|
+
function updateVisibility() {
|
|
16
|
+
const codes = binding.value;
|
|
17
|
+
el.style.display = permissionStore.hasPermission(codes) ? '' : 'none';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
(el as any)[UNWATCH_NAME] = watch(
|
|
21
|
+
() => permissionStore.permissionCodesStr,
|
|
22
|
+
updateVisibility,
|
|
23
|
+
{ immediate: true },
|
|
24
|
+
);
|
|
25
|
+
},
|
|
26
|
+
unmounted(el) {
|
|
27
|
+
(el as any)[UNWATCH_NAME]?.();
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
app.use({
|
|
32
|
+
install(app) {
|
|
33
|
+
app.config.globalProperties.$hasPermission = (codes: TCodes) => {
|
|
34
|
+
const permissionStore = adminPlugin.deps.usePermissionStore();
|
|
35
|
+
|
|
36
|
+
return permissionStore.hasPermission(codes);
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare module 'vue' {
|
|
43
|
+
interface ComponentCustomProperties {
|
|
44
|
+
$hasPermission: (code: string | string[]) => boolean
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Router } from 'vue-router';
|
|
2
|
-
import {
|
|
2
|
+
import { adminPlugin } from '../adminPlugin';
|
|
3
3
|
|
|
4
4
|
export function setupCollapseMenu(router: Router) {
|
|
5
|
-
const
|
|
5
|
+
const menuStore = adminPlugin.deps.useMenuStore();
|
|
6
6
|
|
|
7
7
|
router.beforeEach(() => {
|
|
8
|
-
|
|
8
|
+
menuStore.collapsed = false;
|
|
9
9
|
return true;
|
|
10
10
|
});
|
|
11
11
|
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import type { Router } from 'vue-router';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 用于在路由跳转后,同步修改 title
|
|
6
|
-
*/
|
|
7
|
-
export function setupPageTitle(router: Router) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
1
|
+
import type { Router } from 'vue-router';
|
|
2
|
+
import { adminPlugin } from '../adminPlugin';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 用于在路由跳转后,同步修改 title
|
|
6
|
+
*/
|
|
7
|
+
export function setupPageTitle(router: Router) {
|
|
8
|
+
router.afterEach((to, _, err) => {
|
|
9
|
+
const meta = adminPlugin.meta;
|
|
10
|
+
const title = to.meta.title;
|
|
11
|
+
|
|
12
|
+
if (!err) {
|
|
13
|
+
document.title = typeof title === 'function'
|
|
14
|
+
? title()
|
|
15
|
+
: title ?? meta.appName;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,128 +1,133 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
export type { TMenu };
|
|
7
|
-
|
|
8
|
-
interface IMenuConfig {
|
|
9
|
-
key: string
|
|
10
|
-
label: string | (() => string)
|
|
11
|
-
icon?: () => VNode
|
|
12
|
-
order: number
|
|
13
|
-
trigger: () => void
|
|
14
|
-
children?: IMenuConfig[]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface IMenuReactive {
|
|
18
|
-
key: string
|
|
19
|
-
label: Ref<string>
|
|
20
|
-
icon: Ref<VNode | null>
|
|
21
|
-
order: number
|
|
22
|
-
trigger: () => void
|
|
23
|
-
children?: IMenuReactive[]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type TMenu = UnwrapNestedRefs<IMenuReactive>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (menu.
|
|
63
|
-
path.push(menu);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
1
|
+
import { computed, reactive, ref } from 'vue';
|
|
2
|
+
import type { Ref, UnwrapNestedRefs, VNode } from 'vue';
|
|
3
|
+
import { defineStore } from 'pinia';
|
|
4
|
+
|
|
5
|
+
export { createUseMenuStore };
|
|
6
|
+
export type { TMenu, TUseMenuStore };
|
|
7
|
+
|
|
8
|
+
interface IMenuConfig {
|
|
9
|
+
key: string
|
|
10
|
+
label: string | (() => string)
|
|
11
|
+
icon?: () => VNode
|
|
12
|
+
order: number
|
|
13
|
+
trigger: () => void
|
|
14
|
+
children?: IMenuConfig[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface IMenuReactive {
|
|
18
|
+
key: string
|
|
19
|
+
label: Ref<string>
|
|
20
|
+
icon: Ref<VNode | null>
|
|
21
|
+
order: number
|
|
22
|
+
trigger: () => void
|
|
23
|
+
children?: IMenuReactive[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type TMenu = UnwrapNestedRefs<IMenuReactive>;
|
|
27
|
+
type TUseMenuStore = ReturnType<typeof createUseMenuStore>;
|
|
28
|
+
|
|
29
|
+
function createUseMenuStore() {
|
|
30
|
+
return defineStore('appMenu', () => storeSetup());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function storeSetup() {
|
|
34
|
+
const menus = reactive<TMenu[]>([]);
|
|
35
|
+
const collapsed = ref(false);
|
|
36
|
+
|
|
37
|
+
const findMenu = (menus: TMenu[], key: string) => {
|
|
38
|
+
const queue = [...menus];
|
|
39
|
+
|
|
40
|
+
while (queue.length > 0) {
|
|
41
|
+
const menu = queue.shift()!;
|
|
42
|
+
|
|
43
|
+
if (menu.key === key)
|
|
44
|
+
return menu;
|
|
45
|
+
|
|
46
|
+
if (menu.children)
|
|
47
|
+
queue.push(...menu.children);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return undefined;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 获取目标路由的路径
|
|
55
|
+
* @param key 目标路由
|
|
56
|
+
*/
|
|
57
|
+
const getMenuPath = (key: string) => {
|
|
58
|
+
const path: TMenu[] = [];
|
|
59
|
+
|
|
60
|
+
const _getMenuPath = (menus: TMenu[], key: string) => {
|
|
61
|
+
for (const menu of menus) {
|
|
62
|
+
if (menu.key === key) {
|
|
63
|
+
path.push(menu);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (menu.children) {
|
|
68
|
+
path.push(menu);
|
|
69
|
+
if (_getMenuPath(menu.children, key))
|
|
70
|
+
return true;
|
|
71
|
+
path.pop();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return false;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
_getMenuPath(menus, key);
|
|
79
|
+
|
|
80
|
+
return path;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const addMenu = (menuConfig: IMenuConfig, parentKey?: string) => {
|
|
84
|
+
const labelGetter = typeof menuConfig.label === 'function' ? menuConfig.label : (() => menuConfig.label) as (() => string);
|
|
85
|
+
const iconGetter = typeof menuConfig.icon === 'function' ? menuConfig.icon : () => null;
|
|
86
|
+
|
|
87
|
+
const _menu = reactive<IMenuReactive>({
|
|
88
|
+
key: menuConfig.key,
|
|
89
|
+
label: computed(labelGetter),
|
|
90
|
+
icon: computed(iconGetter),
|
|
91
|
+
trigger: menuConfig.trigger,
|
|
92
|
+
order: menuConfig.order,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (parentKey) {
|
|
96
|
+
const parentMenu = findMenu(menus, parentKey);
|
|
97
|
+
|
|
98
|
+
if (!parentMenu)
|
|
99
|
+
return;
|
|
100
|
+
|
|
101
|
+
const children = reactive(parentMenu.children ?? []);
|
|
102
|
+
children.push(_menu);
|
|
103
|
+
children.sort((a, b) => b.order - a.order);
|
|
104
|
+
parentMenu.children = children;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
menus.push(_menu);
|
|
108
|
+
menus.sort((a, b) => b.order - a.order);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const removeMenu = (key: string) => {
|
|
113
|
+
const _remove = (menus: TMenu[], key: string) => {
|
|
114
|
+
for (let i = 0; i < menus.length; i++) {
|
|
115
|
+
const menu = menus[i];
|
|
116
|
+
if (menu.key === key) {
|
|
117
|
+
menus.splice(i, 1);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (menu.children)
|
|
121
|
+
_remove(menu.children, key);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
return _remove(menus, key);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const getMenu = (key: string) => {
|
|
129
|
+
return findMenu(menus, key);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return { menus, collapsed, getMenuPath, addMenu, removeMenu, getMenu };
|
|
133
|
+
}
|