@peng_kai/kit 0.1.16 → 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/scripts/deploy.ts +67 -0
- 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 +97 -53
- package/request/helpers.ts +20 -1
- package/request/interceptors/checkCode.ts +3 -3
- package/request/interceptors/returnResultType.ts +2 -2
- 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
package/vite/index.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取 vite 的代理配置对象
|
|
3
|
+
* @param env 环境变量对象
|
|
4
|
+
* @returns 代理配置对象
|
|
5
|
+
*/
|
|
6
|
+
export function getProxy(env) {
|
|
7
|
+
const keyRE = /^VITE_(HTTP|WS)_PREFIX/;
|
|
8
|
+
const valueRE = /^.+? => .+?$/;
|
|
9
|
+
const proxys = {};
|
|
10
|
+
|
|
11
|
+
for (const [k, v] of Object.entries(env)) {
|
|
12
|
+
if (!(keyRE.test(k) && valueRE.test(v)))
|
|
13
|
+
continue;
|
|
14
|
+
|
|
15
|
+
const isWs = k.includes('_WS');
|
|
16
|
+
const [prefix, target] = v.split(' => ').map(i => i.trim());
|
|
17
|
+
|
|
18
|
+
proxys[prefix] = {
|
|
19
|
+
target,
|
|
20
|
+
changeOrigin: true,
|
|
21
|
+
ws: isWs,
|
|
22
|
+
rewrite: path => path.replace(new RegExp(`^${prefix}`), ''),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return proxys;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ECharts } from './src/ECharts.vue';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useResizeObserver } from '@vueuse/core';
|
|
3
|
+
import * as echarts from 'echarts';
|
|
4
|
+
import { ref, shallowRef, toRef, watchEffect } from 'vue';
|
|
5
|
+
import { useIsDark } from '../../../hooks/useIsDark';
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
echartOption: any
|
|
11
|
+
}>();
|
|
12
|
+
|
|
13
|
+
const $chartEle = ref<HTMLElement>();
|
|
14
|
+
const echartInst = shallowRef<echarts.ECharts>();
|
|
15
|
+
const isDark = useIsDark();
|
|
16
|
+
|
|
17
|
+
watchEffect(() => {
|
|
18
|
+
if (!$chartEle.value) {
|
|
19
|
+
echartInst.value = undefined;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
echartInst.value?.dispose();
|
|
24
|
+
echartInst.value = echarts.init($chartEle.value, isDark.value ? 'dark' : 'light');
|
|
25
|
+
echartInst.value.setOption(props.echartOption ?? {});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 当图表的尺寸变化时,图表响应式变化。
|
|
30
|
+
* 考虑到性能问题,所以当尺寸变化时隐藏图表,避免浏览器反复绘制。
|
|
31
|
+
*/
|
|
32
|
+
let sizeResponsiveTimer = 0;
|
|
33
|
+
useResizeObserver(toRef(() => $chartEle.value?.parentElement), () => {
|
|
34
|
+
$chartEle.value?.style.setProperty('width', '0px');
|
|
35
|
+
$chartEle.value?.style.setProperty('overflow', 'hidden');
|
|
36
|
+
clearTimeout(sizeResponsiveTimer);
|
|
37
|
+
|
|
38
|
+
sizeResponsiveTimer = window.setTimeout(() => {
|
|
39
|
+
$chartEle.value?.style.removeProperty('width');
|
|
40
|
+
$chartEle.value?.style.removeProperty('overflow');
|
|
41
|
+
echartInst.value?.resize({ width: 'auto' });
|
|
42
|
+
}, 200);
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<div ref="$chartEle" />
|
|
48
|
+
</template>
|
package/vue/components/index.ts
CHANGED
|
@@ -29,8 +29,7 @@ const props = withDefaults(defineProps<{
|
|
|
29
29
|
|
|
30
30
|
const { queryier } = props;
|
|
31
31
|
const pages = computed(() => queryier.data.value?.pages);
|
|
32
|
-
|
|
33
|
-
const isInitialLoading = computed(() => queryier.isInitialLoading.value);
|
|
32
|
+
const isInitialLoading = computed(() => queryier.isPending.value);
|
|
34
33
|
const isInitialLoadingError = computed(() => queryier.isLoadingError.value && !isInitialLoading.value);
|
|
35
34
|
const isMoreLoading = computed(
|
|
36
35
|
() => (queryier.isFetchingNextPage.value || queryier.isFetching.value) && !isInitialLoading.value,
|
|
@@ -60,12 +59,7 @@ const containerCssVars = computed(() => {
|
|
|
60
59
|
});
|
|
61
60
|
|
|
62
61
|
function refetchLastPage() {
|
|
63
|
-
queryier.refetch(
|
|
64
|
-
refetchPage(lastPage: any, _index, allPages: any[]) {
|
|
65
|
-
const lastIndex = allPages?.length - 1;
|
|
66
|
-
return lastPage?.pagination?.page === allPages?.[lastIndex]?.pagination?.page;
|
|
67
|
-
},
|
|
68
|
-
});
|
|
62
|
+
queryier.refetch();
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
function fetchNextPage() {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useQueryClient } from '@tanstack/vue-query';
|
|
2
|
+
import { defineStore } from 'pinia';
|
|
3
|
+
import { useRouter } from 'vue-router';
|
|
4
|
+
|
|
5
|
+
export const useTestStore = defineStore('test-store', () => {
|
|
6
|
+
const router = useRouter();
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
console.log('🤡 / router:', router);
|
|
9
|
+
console.log('🤡 / queryClient:', queryClient);
|
|
10
|
+
return {};
|
|
11
|
+
});
|
package/admin/hooks/index.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
});
|
package/kitDependencies.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type dayjs from 'dayjs';
|
|
2
|
-
import type { useRoute, useRouter } from 'vue-router';
|
|
3
|
-
import type { useMenu, usePage, usePageTab } from './admin/hooks';
|
|
4
|
-
import type { TRole, usePermission } from './admin/permission/usePermission';
|
|
5
|
-
|
|
6
|
-
const KEY = '__PK_KIT_DEPENDENCIES__';
|
|
7
|
-
|
|
8
|
-
interface Dependencies {
|
|
9
|
-
dayjs: typeof dayjs
|
|
10
|
-
appName: string
|
|
11
|
-
appId: string
|
|
12
|
-
roles: Record<string, TRole>
|
|
13
|
-
useRoute: typeof useRoute
|
|
14
|
-
useRouter: typeof useRouter
|
|
15
|
-
useMenu: typeof useMenu
|
|
16
|
-
usePage: typeof usePage
|
|
17
|
-
usePageTab: typeof usePageTab
|
|
18
|
-
usePermission: typeof usePermission
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function setDependencies(deps: Partial<Dependencies>) {
|
|
22
|
-
window[KEY] = { ...window[KEY], ...deps };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function getDependencies() {
|
|
26
|
-
if (window[KEY]) {
|
|
27
|
-
return new Proxy(window[KEY], {
|
|
28
|
-
get(target, prop: keyof Dependencies) {
|
|
29
|
-
if (prop in target)
|
|
30
|
-
return target[prop];
|
|
31
|
-
else
|
|
32
|
-
throw new Error(`未发现 kit 依赖 ${prop}`);
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
else { throw new Error('未发现 kit 依赖'); };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare global {
|
|
40
|
-
interface Window {
|
|
41
|
-
[KEY]: Dependencies
|
|
42
|
-
}
|
|
43
|
-
}
|