@peng_kai/kit 0.1.10 → 0.1.11

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.
Files changed (44) hide show
  1. package/admin/components/filter/src/FilterDrawer.vue +153 -153
  2. package/admin/components/filter/src/FilterParam.vue +78 -78
  3. package/admin/components/scroll-nav/index.ts +1 -1
  4. package/admin/components/scroll-nav/src/ScrollNav.vue +59 -59
  5. package/admin/components/text/index.ts +13 -13
  6. package/admin/components/text/src/Amount.vue +117 -117
  7. package/admin/components/text/src/Datetime.vue +48 -48
  8. package/admin/components/text/src/Duration.vue +26 -26
  9. package/admin/components/text/src/Hash.vue +51 -51
  10. package/admin/components/text/src/createTagGetter.ts +13 -13
  11. package/admin/hooks/useMenu.ts +128 -128
  12. package/admin/hooks/usePage.ts +141 -141
  13. package/admin/hooks/usePageTab.ts +35 -35
  14. package/admin/layout/large/Breadcrumb.vue +69 -69
  15. package/admin/layout/large/Content.vue +24 -24
  16. package/admin/layout/large/Menu.vue +69 -69
  17. package/admin/layout/large/PageTab.vue +71 -71
  18. package/admin/permission/index.ts +4 -4
  19. package/admin/permission/routerGuard.ts +43 -43
  20. package/admin/permission/usePermission.ts +52 -52
  21. package/admin/permission/vuePlugin.ts +30 -30
  22. package/admin/route-guards/index.ts +3 -3
  23. package/admin/route-guards/pageProgress.ts +27 -27
  24. package/admin/route-guards/pageTitle.ts +19 -19
  25. package/admin/styles/globalCover.scss +54 -54
  26. package/antd/components/InputNumberRange.vue +53 -53
  27. package/antd/directives/formLabelAlign.ts +36 -36
  28. package/antd/hooks/useAntdDrawer.ts +73 -73
  29. package/antd/hooks/useAntdTable.ts +115 -82
  30. package/package.json +55 -55
  31. package/pnpm-lock.yaml +5255 -0
  32. package/request/helpers.ts +49 -49
  33. package/request/interceptors/formatPaging.ts +3 -4
  34. package/request/interceptors/popupMessage.ts +5 -4
  35. package/request/interceptors/toLogin.ts +26 -15
  36. package/request/queryClient.ts +32 -8
  37. package/request/request.ts +0 -1
  38. package/request/type.d.ts +92 -92
  39. package/stylelint.config.cjs +7 -7
  40. package/tsconfig.json +50 -50
  41. package/utils/index.ts +1 -1
  42. package/vue/components/infinite-query/index.ts +1 -1
  43. package/vue/components/infinite-query/src/InfiniteQuery.vue +205 -205
  44. package/vue/components/infinite-query/src/useCreateTrigger.ts +39 -39
@@ -1,128 +1,128 @@
1
- import { createGlobalState } from '@vueuse/core';
2
- import { computed, reactive, ref } from 'vue';
3
- import type { Ref, UnwrapNestedRefs, VNode } from 'vue';
4
-
5
- export { useMenu };
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
- const useMenu = createGlobalState(() => {
29
- const menus = reactive<TMenu[]>([]);
30
- const collapsed = ref(false);
31
-
32
- const findMenu = (menus: TMenu[], key: string) => {
33
- const queue = [...menus];
34
-
35
- while (queue.length > 0) {
36
- const menu = queue.shift()!;
37
-
38
- if (menu.key === key)
39
- return menu;
40
-
41
- if (menu.children)
42
- queue.push(...menu.children);
43
- }
44
-
45
- return undefined;
46
- };
47
-
48
- /**
49
- * 获取目标路由的路径
50
- * @param key 目标路由
51
- */
52
- const getMenuPath = (key: string) => {
53
- const path: TMenu[] = [];
54
-
55
- const _getMenuPath = (menus: TMenu[], key: string) => {
56
- for (const menu of menus) {
57
- if (menu.key === key) {
58
- path.push(menu);
59
- return true;
60
- }
61
-
62
- if (menu.children) {
63
- path.push(menu);
64
- if (_getMenuPath(menu.children, key))
65
- return true;
66
- path.pop();
67
- }
68
- }
69
-
70
- return false;
71
- };
72
-
73
- _getMenuPath(menus, key);
74
-
75
- return path;
76
- };
77
-
78
- const addMenu = (menuConfig: IMenuConfig, parentKey?: string) => {
79
- const labelGetter = typeof menuConfig.label === 'function' ? menuConfig.label : (() => menuConfig.label) as (() => string);
80
- const iconGetter = typeof menuConfig.icon === 'function' ? menuConfig.icon : () => null;
81
-
82
- const _menu = reactive<IMenuReactive>({
83
- key: menuConfig.key,
84
- label: computed(labelGetter),
85
- icon: computed(iconGetter),
86
- trigger: menuConfig.trigger,
87
- order: menuConfig.order,
88
- });
89
-
90
- if (parentKey) {
91
- const parentMenu = findMenu(menus, parentKey);
92
-
93
- if (!parentMenu)
94
- return;
95
-
96
- const children = reactive(parentMenu.children ?? []);
97
- children.push(_menu);
98
- children.sort((a, b) => b.order - a.order);
99
- parentMenu.children = children;
100
- }
101
- else {
102
- menus.push(_menu);
103
- menus.sort((a, b) => b.order - a.order);
104
- }
105
- };
106
-
107
- const removeMenu = (key: string) => {
108
- const _remove = (menus: TMenu[], key: string) => {
109
- for (let i = 0; i < menus.length; i++) {
110
- const menu = menus[i];
111
- if (menu.key === key) {
112
- menus.splice(i, 1);
113
- return;
114
- }
115
- if (menu.children)
116
- _remove(menu.children, key);
117
- }
118
- };
119
-
120
- return _remove(menus, key);
121
- };
122
-
123
- const getMenu = (key: string) => {
124
- return findMenu(menus, key);
125
- };
126
-
127
- return { menus, collapsed, getMenuPath, addMenu, removeMenu, getMenu };
128
- });
1
+ import { createGlobalState } from '@vueuse/core';
2
+ import { computed, reactive, ref } from 'vue';
3
+ import type { Ref, UnwrapNestedRefs, VNode } from 'vue';
4
+
5
+ export { useMenu };
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
+ const useMenu = createGlobalState(() => {
29
+ const menus = reactive<TMenu[]>([]);
30
+ const collapsed = ref(false);
31
+
32
+ const findMenu = (menus: TMenu[], key: string) => {
33
+ const queue = [...menus];
34
+
35
+ while (queue.length > 0) {
36
+ const menu = queue.shift()!;
37
+
38
+ if (menu.key === key)
39
+ return menu;
40
+
41
+ if (menu.children)
42
+ queue.push(...menu.children);
43
+ }
44
+
45
+ return undefined;
46
+ };
47
+
48
+ /**
49
+ * 获取目标路由的路径
50
+ * @param key 目标路由
51
+ */
52
+ const getMenuPath = (key: string) => {
53
+ const path: TMenu[] = [];
54
+
55
+ const _getMenuPath = (menus: TMenu[], key: string) => {
56
+ for (const menu of menus) {
57
+ if (menu.key === key) {
58
+ path.push(menu);
59
+ return true;
60
+ }
61
+
62
+ if (menu.children) {
63
+ path.push(menu);
64
+ if (_getMenuPath(menu.children, key))
65
+ return true;
66
+ path.pop();
67
+ }
68
+ }
69
+
70
+ return false;
71
+ };
72
+
73
+ _getMenuPath(menus, key);
74
+
75
+ return path;
76
+ };
77
+
78
+ const addMenu = (menuConfig: IMenuConfig, parentKey?: string) => {
79
+ const labelGetter = typeof menuConfig.label === 'function' ? menuConfig.label : (() => menuConfig.label) as (() => string);
80
+ const iconGetter = typeof menuConfig.icon === 'function' ? menuConfig.icon : () => null;
81
+
82
+ const _menu = reactive<IMenuReactive>({
83
+ key: menuConfig.key,
84
+ label: computed(labelGetter),
85
+ icon: computed(iconGetter),
86
+ trigger: menuConfig.trigger,
87
+ order: menuConfig.order,
88
+ });
89
+
90
+ if (parentKey) {
91
+ const parentMenu = findMenu(menus, parentKey);
92
+
93
+ if (!parentMenu)
94
+ return;
95
+
96
+ const children = reactive(parentMenu.children ?? []);
97
+ children.push(_menu);
98
+ children.sort((a, b) => b.order - a.order);
99
+ parentMenu.children = children;
100
+ }
101
+ else {
102
+ menus.push(_menu);
103
+ menus.sort((a, b) => b.order - a.order);
104
+ }
105
+ };
106
+
107
+ const removeMenu = (key: string) => {
108
+ const _remove = (menus: TMenu[], key: string) => {
109
+ for (let i = 0; i < menus.length; i++) {
110
+ const menu = menus[i];
111
+ if (menu.key === key) {
112
+ menus.splice(i, 1);
113
+ return;
114
+ }
115
+ if (menu.children)
116
+ _remove(menu.children, key);
117
+ }
118
+ };
119
+
120
+ return _remove(menus, key);
121
+ };
122
+
123
+ const getMenu = (key: string) => {
124
+ return findMenu(menus, key);
125
+ };
126
+
127
+ return { menus, collapsed, getMenuPath, addMenu, removeMenu, getMenu };
128
+ });
@@ -1,141 +1,141 @@
1
- import { createGlobalState, usePrevious } from '@vueuse/core';
2
- import type { RouteLocationNormalizedLoaded } from 'vue-router';
3
- import { computed, reactive, readonly, ref, shallowRef, watch } from 'vue';
4
- import type { VNode } from 'vue';
5
- import { getTitle } from '../defines/route';
6
- import { getDependencies } from '../../kitDependencies';
7
- import { useMenu } from './useMenu';
8
- import type { TMenu } from './useMenu';
9
-
10
- export { usePage };
11
- export type { TPageState, IBreadcrumb };
12
-
13
- type TPageState = ReturnType<typeof getPageState>;
14
-
15
- interface IBreadcrumb {
16
- title: string
17
- icon?: VNode | null
18
- trigger?: () => void
19
- children?: IBreadcrumb[]
20
- }
21
-
22
- const usePage = createGlobalState(() => {
23
- const { useRouter } = getDependencies();
24
- const router = useRouter();
25
- const currentPageNode = shallowRef<VNode>();
26
- const currentPageKey = ref('');
27
- const pageCacheList = reactive<string[]>([]);
28
- const pageStateMap = new Map<string, TPageState>();
29
- const currentPageState = computed(() => pageStateMap.get(currentPageKey.value));
30
- const previousPageState = usePrevious(currentPageState);
31
-
32
- const openPage = (key: string) => {
33
- const route = pageStateMap.get(key)?.route;
34
-
35
- if (!route)
36
- return;
37
-
38
- router.push(route.fullPath);
39
- };
40
-
41
- const closePage = (key: string) => {
42
- if (!pageStateMap.has(key))
43
- return;
44
-
45
- const cacheIndex = pageCacheList.indexOf(key);
46
- cacheIndex >= 0 && pageCacheList.splice(cacheIndex, 1);
47
- // 关闭当前页面则返回上一个路由
48
- currentPageKey.value === key && router.go(-1);
49
- pageStateMap.delete(key);
50
- };
51
-
52
- const setPage = (pageNode: VNode, route: RouteLocationNormalizedLoaded) => {
53
- const pageKey = route?.meta?.pageKeyFn?.(route) ?? route.fullPath;
54
- const pageInfo = getPageState(route);
55
- const canKeepAlive = route.meta.keepAlive && !pageCacheList.includes(pageKey);
56
-
57
- canKeepAlive && pageCacheList.push(pageKey);
58
- pageStateMap.has(pageKey) || pageStateMap.set(pageKey, pageInfo)
59
-
60
- ;(pageNode as any).type.name = pageKey;
61
- currentPageKey.value = pageKey;
62
- currentPageNode.value = pageNode;
63
-
64
- return pageNode;
65
- };
66
-
67
- const getCurrentPageState = () => {
68
- return pageStateMap.get(currentPageKey.value);
69
- };
70
-
71
- // 监听 title 变化
72
- watch(() => currentPageState.value?.title, (title) => {
73
- let _title = title;
74
-
75
- if (!_title) {
76
- const pageState = currentPageState.value;
77
-
78
- // 当前 title 为空时,使用路由 title
79
- if (pageState) {
80
- _title = getTitle(pageState?.route);
81
- pageState.title = _title!;
82
- }
83
- }
84
-
85
- document.title = _title!;
86
- });
87
-
88
- return {
89
- currentPageNode,
90
- pageCacheList,
91
- pageStateMap,
92
- currentPageKey,
93
- currentPageState,
94
- getCurrentPageState,
95
- previousPageState,
96
- setPage,
97
- openPage,
98
- closePage,
99
- };
100
- });
101
-
102
- function getPageState(route: RouteLocationNormalizedLoaded) {
103
- const deps = getDependencies();
104
- const appName = deps.appName as string;
105
- const { getMenuPath } = useMenu();
106
- const menuPath = getMenuPath(route.name as string);
107
- const currentMenu = menuPath.pop();
108
- const { icon: mIcon } = route.meta;
109
- const title = currentMenu?.label ?? getTitle(route) ?? appName;
110
- const icon = currentMenu?.icon ?? mIcon?.();
111
- const state = reactive({
112
- title,
113
- icon,
114
- breadcrumbs: menuPath.map(menuToBreadcrumb),
115
- route: readonly(route),
116
- refresh() {
117
- const menuKey = this.route.name as string;
118
- const { getMenu, getMenuPath } = useMenu();
119
- const menu = getMenu(menuKey);
120
- const menuPath = getMenuPath(menuKey);
121
-
122
- menuPath.pop();
123
-
124
- this.title = menu?.label ?? getTitle(this.route) ?? appName;
125
- this.breadcrumbs = menuPath.map(menuToBreadcrumb);
126
- },
127
- });
128
-
129
- return state;
130
- }
131
-
132
- function menuToBreadcrumb(menu: TMenu) {
133
- const ret: IBreadcrumb = reactive({
134
- title: menu.label,
135
- icon: menu.icon,
136
- trigger: menu.trigger,
137
- children: menu.children?.map(menuToBreadcrumb),
138
- });
139
-
140
- return ret;
141
- }
1
+ import { createGlobalState, usePrevious } from '@vueuse/core';
2
+ import type { RouteLocationNormalizedLoaded } from 'vue-router';
3
+ import { computed, reactive, readonly, ref, shallowRef, watch } from 'vue';
4
+ import type { VNode } from 'vue';
5
+ import { getTitle } from '../defines/route';
6
+ import { getDependencies } from '../../kitDependencies';
7
+ import { useMenu } from './useMenu';
8
+ import type { TMenu } from './useMenu';
9
+
10
+ export { usePage };
11
+ export type { TPageState, IBreadcrumb };
12
+
13
+ type TPageState = ReturnType<typeof getPageState>;
14
+
15
+ interface IBreadcrumb {
16
+ title: string
17
+ icon?: VNode | null
18
+ trigger?: () => void
19
+ children?: IBreadcrumb[]
20
+ }
21
+
22
+ const usePage = createGlobalState(() => {
23
+ const { useRouter } = getDependencies();
24
+ const router = useRouter();
25
+ const currentPageNode = shallowRef<VNode>();
26
+ const currentPageKey = ref('');
27
+ const pageCacheList = reactive<string[]>([]);
28
+ const pageStateMap = new Map<string, TPageState>();
29
+ const currentPageState = computed(() => pageStateMap.get(currentPageKey.value));
30
+ const previousPageState = usePrevious(currentPageState);
31
+
32
+ const openPage = (key: string) => {
33
+ const route = pageStateMap.get(key)?.route;
34
+
35
+ if (!route)
36
+ return;
37
+
38
+ router.push(route.fullPath);
39
+ };
40
+
41
+ const closePage = (key: string) => {
42
+ if (!pageStateMap.has(key))
43
+ return;
44
+
45
+ const cacheIndex = pageCacheList.indexOf(key);
46
+ cacheIndex >= 0 && pageCacheList.splice(cacheIndex, 1);
47
+ // 关闭当前页面则返回上一个路由
48
+ currentPageKey.value === key && router.go(-1);
49
+ pageStateMap.delete(key);
50
+ };
51
+
52
+ const setPage = (pageNode: VNode, route: RouteLocationNormalizedLoaded) => {
53
+ const pageKey = route?.meta?.pageKeyFn?.(route) ?? route.fullPath;
54
+ const pageInfo = getPageState(route);
55
+ const canKeepAlive = route.meta.keepAlive && !pageCacheList.includes(pageKey);
56
+
57
+ canKeepAlive && pageCacheList.push(pageKey);
58
+ pageStateMap.has(pageKey) || pageStateMap.set(pageKey, pageInfo)
59
+
60
+ ;(pageNode as any).type.name = pageKey;
61
+ currentPageKey.value = pageKey;
62
+ currentPageNode.value = pageNode;
63
+
64
+ return pageNode;
65
+ };
66
+
67
+ const getCurrentPageState = () => {
68
+ return pageStateMap.get(currentPageKey.value);
69
+ };
70
+
71
+ // 监听 title 变化
72
+ watch(() => currentPageState.value?.title, (title) => {
73
+ let _title = title;
74
+
75
+ if (!_title) {
76
+ const pageState = currentPageState.value;
77
+
78
+ // 当前 title 为空时,使用路由 title
79
+ if (pageState) {
80
+ _title = getTitle(pageState?.route);
81
+ pageState.title = _title!;
82
+ }
83
+ }
84
+
85
+ document.title = _title!;
86
+ });
87
+
88
+ return {
89
+ currentPageNode,
90
+ pageCacheList,
91
+ pageStateMap,
92
+ currentPageKey,
93
+ currentPageState,
94
+ getCurrentPageState,
95
+ previousPageState,
96
+ setPage,
97
+ openPage,
98
+ closePage,
99
+ };
100
+ });
101
+
102
+ function getPageState(route: RouteLocationNormalizedLoaded) {
103
+ const deps = getDependencies();
104
+ const appName = deps.appName as string;
105
+ const { getMenuPath } = useMenu();
106
+ const menuPath = getMenuPath(route.name as string);
107
+ const currentMenu = menuPath.pop();
108
+ const { icon: mIcon } = route.meta;
109
+ const title = currentMenu?.label ?? getTitle(route) ?? appName;
110
+ const icon = currentMenu?.icon ?? mIcon?.();
111
+ const state = reactive({
112
+ title,
113
+ icon,
114
+ breadcrumbs: menuPath.map(menuToBreadcrumb),
115
+ route: readonly(route),
116
+ refresh() {
117
+ const menuKey = this.route.name as string;
118
+ const { getMenu, getMenuPath } = useMenu();
119
+ const menu = getMenu(menuKey);
120
+ const menuPath = getMenuPath(menuKey);
121
+
122
+ menuPath.pop();
123
+
124
+ this.title = menu?.label ?? getTitle(this.route) ?? appName;
125
+ this.breadcrumbs = menuPath.map(menuToBreadcrumb);
126
+ },
127
+ });
128
+
129
+ return state;
130
+ }
131
+
132
+ function menuToBreadcrumb(menu: TMenu) {
133
+ const ret: IBreadcrumb = reactive({
134
+ title: menu.label,
135
+ icon: menu.icon,
136
+ trigger: menu.trigger,
137
+ children: menu.children?.map(menuToBreadcrumb),
138
+ });
139
+
140
+ return ret;
141
+ }
@@ -1,35 +1,35 @@
1
- import { createGlobalState } from '@vueuse/core';
2
- import { computed, ref, watch } from 'vue';
3
- import { usePage } from './usePage';
4
-
5
- export { usePageTab };
6
-
7
- const usePageTab = createGlobalState(() => {
8
- const { currentPageKey, pageStateMap, openPage, closePage } = usePage();
9
- const tabKeyList = ref<string[]>([]);
10
- const tabList = computed(() => tabKeyList.value.map((key) => {
11
- const state = pageStateMap.get(key);
12
-
13
- return state ? { key, title: state.title, icon: state.icon } : undefined!;
14
- }).filter(tab => !!tab));
15
-
16
- const closeTab = (key: string) => {
17
- const i = tabKeyList.value.indexOf(key);
18
-
19
- if (i > -1) {
20
- closePage(key);
21
- setTimeout(() => tabKeyList.value.splice(i, 1));
22
- }
23
- };
24
-
25
- watch(
26
- currentPageKey,
27
- (key) => {
28
- if (!tabKeyList.value.includes(key))
29
- tabKeyList.value.push(key);
30
- },
31
- { immediate: true },
32
- );
33
-
34
- return { activeTab: currentPageKey, tabList, closeTab, openTab: openPage };
35
- });
1
+ import { createGlobalState } from '@vueuse/core';
2
+ import { computed, ref, watch } from 'vue';
3
+ import { usePage } from './usePage';
4
+
5
+ export { usePageTab };
6
+
7
+ const usePageTab = createGlobalState(() => {
8
+ const { currentPageKey, pageStateMap, openPage, closePage } = usePage();
9
+ const tabKeyList = ref<string[]>([]);
10
+ const tabList = computed(() => tabKeyList.value.map((key) => {
11
+ const state = pageStateMap.get(key);
12
+
13
+ return state ? { key, title: state.title, icon: state.icon } : undefined!;
14
+ }).filter(tab => !!tab));
15
+
16
+ const closeTab = (key: string) => {
17
+ const i = tabKeyList.value.indexOf(key);
18
+
19
+ if (i > -1) {
20
+ closePage(key);
21
+ setTimeout(() => tabKeyList.value.splice(i, 1));
22
+ }
23
+ };
24
+
25
+ watch(
26
+ currentPageKey,
27
+ (key) => {
28
+ if (!tabKeyList.value.includes(key))
29
+ tabKeyList.value.push(key);
30
+ },
31
+ { immediate: true },
32
+ );
33
+
34
+ return { activeTab: currentPageKey, tabList, closeTab, openTab: openPage };
35
+ });