@peng_kai/kit 0.1.17 → 0.2.0-beta.1

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 (84) hide show
  1. package/admin/adminPlugin.ts +47 -0
  2. package/admin/components/filter/src/FilterDrawer.vue +153 -153
  3. package/admin/components/filter/src/FilterParam.vue +76 -78
  4. package/admin/components/filter/src/FilterReset.vue +2 -2
  5. package/admin/components/filter/src/useFilterParams.ts +75 -25
  6. package/admin/components/filter/src/useFilterQuery.ts +32 -16
  7. package/admin/components/rich-text/index.ts +2 -0
  8. package/admin/components/rich-text/src/RichText.vue +342 -0
  9. package/admin/components/rich-text/src/imageUploader.ts +34 -0
  10. package/admin/components/rich-text/src/type.d.ts +7 -0
  11. package/admin/components/scroll-nav/index.ts +1 -1
  12. package/admin/components/scroll-nav/src/ScrollNav.vue +59 -59
  13. package/admin/components/text/index.ts +13 -13
  14. package/admin/components/text/src/Amount.vue +121 -121
  15. package/admin/components/text/src/Datetime.vue +47 -48
  16. package/admin/components/text/src/Duration.vue +26 -26
  17. package/admin/components/text/src/Hash.vue +51 -51
  18. package/admin/components/text/src/createTagGetter.ts +13 -13
  19. package/admin/components/upload/index.ts +2 -0
  20. package/admin/components/upload/src/PictureCardUpload.vue +143 -0
  21. package/admin/components/upload/src/customRequests.ts +31 -0
  22. package/admin/defines/index.ts +1 -1
  23. package/admin/defines/route/helpers.ts +0 -1
  24. package/admin/defines/startup/defineStartup.ts +8 -1
  25. package/admin/defines/startup/index.ts +1 -1
  26. package/admin/defines/startup/{getStartups.ts → runStartup.ts} +16 -7
  27. package/admin/layout/large/Breadcrumb.vue +68 -69
  28. package/admin/layout/large/Content.vue +23 -24
  29. package/admin/layout/large/Menu.vue +68 -69
  30. package/admin/layout/large/PageTab.vue +70 -71
  31. package/admin/permission/index.ts +2 -4
  32. package/admin/permission/routerGuard.ts +41 -43
  33. package/admin/permission/vuePlugin.ts +46 -30
  34. package/admin/route-guards/collapseMenu.ts +3 -3
  35. package/admin/route-guards/index.ts +3 -3
  36. package/admin/route-guards/pageProgress.ts +27 -27
  37. package/admin/route-guards/pageTitle.ts +18 -19
  38. package/admin/{hooks/useMenu.ts → stores/createUseMenuStore.ts} +133 -128
  39. package/admin/{hooks/usePage.ts → stores/createUsePageStore.ts} +145 -141
  40. package/admin/stores/createUsePageTabStore.ts +43 -0
  41. package/admin/{permission/usePermission.ts → stores/createUsePermissionStore.ts} +57 -52
  42. package/admin/stores/index.ts +8 -0
  43. package/admin/styles/classCover.scss +8 -0
  44. package/admin/styles/globalCover.scss +54 -54
  45. package/antd/components/InputNumberRange.vue +59 -59
  46. package/antd/directives/formLabelAlign.ts +36 -36
  47. package/antd/hooks/useAntdDrawer.ts +73 -73
  48. package/antd/hooks/useAntdForm.helpers.ts +92 -8
  49. package/antd/hooks/useAntdForm.ts +55 -63
  50. package/antd/hooks/useAntdTable.ts +127 -115
  51. package/antd/index.ts +1 -1
  52. package/libs/a-calc.ts +1 -0
  53. package/libs/axios.ts +2 -0
  54. package/libs/bignumber.ts +2 -0
  55. package/libs/dayjs.ts +5 -0
  56. package/libs/echarts.ts +5 -0
  57. package/libs/localstorage-slim.ts +2 -0
  58. package/libs/lodash-es.ts +1 -0
  59. package/libs/pinia.ts +1 -0
  60. package/libs/vue-query.ts +1 -0
  61. package/libs/vueuse.ts +3 -0
  62. package/package.json +91 -58
  63. package/request/helpers.ts +68 -49
  64. package/request/interceptors/toLogin.ts +26 -26
  65. package/request/queryClient.ts +34 -21
  66. package/request/type.d.ts +92 -92
  67. package/stylelint.config.cjs +7 -7
  68. package/tsconfig.json +50 -50
  69. package/utils/upload/AwsS3.ts +68 -0
  70. package/utils/upload/fileHandlers.ts +27 -0
  71. package/utils/upload/index.ts +2 -0
  72. package/vite/index.d.ts +1 -0
  73. package/vite/index.mjs +27 -0
  74. package/vue/components/echarts/index.ts +1 -0
  75. package/vue/components/echarts/src/ECharts.vue +48 -0
  76. package/vue/components/index.ts +1 -0
  77. package/vue/components/infinite-query/index.ts +1 -1
  78. package/vue/components/infinite-query/src/InfiniteQuery.vue +199 -205
  79. package/vue/components/infinite-query/src/useCreateTrigger.ts +39 -39
  80. package/vue/components/test/KitTest.vue +9 -0
  81. package/vue/components/test/testStore.ts +11 -0
  82. package/admin/hooks/index.ts +0 -5
  83. package/admin/hooks/usePageTab.ts +0 -35
  84. package/kitDependencies.ts +0 -43
@@ -1,8 +1,11 @@
1
1
  import type { QueryClientConfig, QueryObserverOptions } from '@tanstack/vue-query';
2
2
  import { ApiCode } from './helpers';
3
3
 
4
+ export { keepPreviousData } from '@tanstack/vue-query';
5
+ export { ignoreRetryCodes, buildRetryFn, presetOptions, getNextPageParam, getPreviousPageParam };
6
+
4
7
  /** 不需要重试的 api code */
5
- export const ignoreRetryCodes = [
8
+ const ignoreRetryCodes = [
6
9
  ApiCode.UNKNOWN,
7
10
  11000, // 操作失败
8
11
  11001, // 操作过于频繁
@@ -21,7 +24,7 @@ export const ignoreRetryCodes = [
21
24
  * @param additionPresetIgnore 一个布尔值,指示是否包括额外的预设忽略代码。默认为 true。
22
25
  * @returns 根据失败计数和错误代码确定是否重试的重试函数。
23
26
  */
24
- export function buildRetryFn(ignoreList: Array<number | string | RegExp>, additionPresetIgnore = true): NonNullable<QueryObserverOptions['retry']> {
27
+ function buildRetryFn(ignoreList: Array<number | string | RegExp>, additionPresetIgnore = true): NonNullable<QueryObserverOptions['retry']> {
25
28
  const _ignoreList = [...ignoreList, ...(additionPresetIgnore ? ignoreRetryCodes : [])];
26
29
  return (failureCount, error: any) => {
27
30
  if (error?.code === undefined)
@@ -38,29 +41,39 @@ export function buildRetryFn(ignoreList: Array<number | string | RegExp>, additi
38
41
  };
39
42
  }
40
43
 
41
- export const presetOptions: QueryClientConfig = {
44
+ const presetOptions: QueryClientConfig = {
42
45
  defaultOptions: {
43
46
  queries: {
44
47
  refetchOnWindowFocus: false,
45
48
  retry: buildRetryFn(ignoreRetryCodes),
46
- getNextPageParam: (lastPage: any) => {
47
- const { pagination } = lastPage ?? {};
48
-
49
- if (pagination?.has_more) {
50
- return {
51
- page: (pagination.page ?? 0) + 1,
52
- page_size: pagination?.page_size ?? 10,
53
- };
54
- }
55
- },
56
- getPreviousPageParam: (lastPage: any) => {
57
- const { pagination } = lastPage ?? {};
58
-
59
- return {
60
- page: (pagination.page ?? 1) - 1,
61
- page_size: pagination?.page_size ?? 10,
62
- };
63
- },
64
49
  },
65
50
  },
66
51
  };
52
+
53
+ /**
54
+ * useInfiniteQuery 中的 getNextPageParam 预设
55
+ */
56
+ function getNextPageParam(lastPage: any) {
57
+ const { pagination } = lastPage ?? {};
58
+
59
+ if (pagination?.has_more) {
60
+ return {
61
+ page: (pagination.page ?? 0) + 1,
62
+ page_size: pagination?.page_size ?? 10,
63
+ };
64
+ }
65
+ }
66
+
67
+ /**
68
+ * useInfiniteQuery 中的 getPreviousPageParam 预设
69
+ */
70
+ function getPreviousPageParam(firstPage: any) {
71
+ const { pagination } = firstPage ?? {};
72
+
73
+ if (pagination?.has_more) {
74
+ return {
75
+ page: (pagination.page ?? 0) + 1,
76
+ page_size: pagination?.page_size ?? 10,
77
+ };
78
+ }
79
+ }
package/request/type.d.ts CHANGED
@@ -1,92 +1,92 @@
1
- declare namespace Api {
2
- type Request = ((reqData: any, options?: Options) => Promise<any>) & {
3
- id: string
4
- setDefaultConfig: (config: Partial<import('axios').AxiosRequestConfig>) => Request
5
- };
6
- // type RequestPagination = (reqData: Partial<PageParam>, options?: Options) => Promise<PaginationData<any>>;
7
- interface PageParam {
8
- page: number
9
- page_size: number
10
- }
11
- interface PageInfo {
12
- has_more: boolean
13
- page: number
14
- page_size: number
15
- total: number
16
- }
17
- interface PageData<T = any> {
18
- list: T[] | null
19
- pagination: PaginationInfo
20
- [k in string]: any
21
- }
22
- interface Result<T = any | PageData<any>> {
23
- code: number
24
- msg: string
25
- data: T
26
- }
27
- type GetParam<A extends Request> = A extends (reqData: infer R) => any ? R : any;
28
- type GetData<A extends Request> = ReturnType<A> extends Promise<infer D> ? D : any;
29
- type GetDataItem<A extends Request> = NonNullable<GetData<A>> extends { list: infer L }
30
- ? NonNullable<L> extends Array<infer I>
31
- ? I
32
- : any
33
- : any;
34
- type GetDataField<R> = R extends { data: infer D } ? (D extends { list: any, pagination: any } ? D : D) : any;
35
-
36
- /**
37
- * 将api返回的分页数据转换成前端使用的分页数据格式,将分页数据格式统一
38
- *
39
- * ```
40
- * {
41
- * code: number,
42
- * msg: string,
43
- * data: {
44
- * list: [],
45
- * pagination: {},
46
- * ...
47
- * }
48
- * }
49
- * ```
50
- */
51
- type TransformPageResult<R> = R extends { pagination: infer P, data: infer D }
52
- ? D extends Record<string, any>
53
- ? D extends { list: any }
54
- ? {
55
- [Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
56
- } & {
57
- data: D & { pagination: P }
58
- }
59
- : {
60
- [Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
61
- } & {
62
- data: {
63
- list: D
64
- pagination: P
65
- }
66
- }
67
- : R
68
- : R;
69
- }
70
-
71
- // 测试用例 ----------------------------
72
- // type DDD1 = Api.TransformPageResult<{
73
- // code: number
74
- // msg: string
75
- // data: {
76
- // name: string
77
- // }[]
78
- // pagination: {
79
- // page: number
80
- // }
81
- // }>
82
- // type DDD2 = Api.TransformPageResult<{
83
- // code: number
84
- // msg: string
85
- // data: {
86
- // list: { name: string }[]
87
- // total: {}
88
- // }
89
- // pagination: {
90
- // page: number
91
- // }
92
- // }>
1
+ declare namespace Api {
2
+ type Request = ((reqData: any, options?: Options) => Promise<any>) & {
3
+ id: string
4
+ setDefaultConfig: (config: Partial<import('axios').AxiosRequestConfig>) => Request
5
+ };
6
+ // type RequestPagination = (reqData: Partial<PageParam>, options?: Options) => Promise<PaginationData<any>>;
7
+ interface PageParam {
8
+ page: number
9
+ page_size: number
10
+ }
11
+ interface PageInfo {
12
+ has_more: boolean
13
+ page: number
14
+ page_size: number
15
+ total: number
16
+ }
17
+ interface PageData<T = any> {
18
+ list: T[] | null
19
+ pagination: PaginationInfo
20
+ [k in string]: any
21
+ }
22
+ interface Result<T = any | PageData<any>> {
23
+ code: number
24
+ msg: string
25
+ data: T
26
+ }
27
+ type GetParam<A extends Request> = A extends (reqData: infer R) => any ? R : any;
28
+ type GetData<A extends Request> = ReturnType<A> extends Promise<infer D> ? D : any;
29
+ type GetDataItem<A extends Request> = NonNullable<GetData<A>> extends { list: infer L }
30
+ ? NonNullable<L> extends Array<infer I>
31
+ ? I
32
+ : any
33
+ : any;
34
+ type GetDataField<R> = R extends { data: infer D } ? (D extends { list: any, pagination: any } ? D : D) : any;
35
+
36
+ /**
37
+ * 将api返回的分页数据转换成前端使用的分页数据格式,将分页数据格式统一
38
+ *
39
+ * ```
40
+ * {
41
+ * code: number,
42
+ * msg: string,
43
+ * data: {
44
+ * list: [],
45
+ * pagination: {},
46
+ * ...
47
+ * }
48
+ * }
49
+ * ```
50
+ */
51
+ type TransformPageResult<R> = R extends { pagination: infer P, data: infer D }
52
+ ? D extends Record<string, any>
53
+ ? D extends { list: any }
54
+ ? {
55
+ [Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
56
+ } & {
57
+ data: D & { pagination: P }
58
+ }
59
+ : {
60
+ [Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
61
+ } & {
62
+ data: {
63
+ list: D
64
+ pagination: P
65
+ }
66
+ }
67
+ : R
68
+ : R;
69
+ }
70
+
71
+ // 测试用例 ----------------------------
72
+ // type DDD1 = Api.TransformPageResult<{
73
+ // code: number
74
+ // msg: string
75
+ // data: {
76
+ // name: string
77
+ // }[]
78
+ // pagination: {
79
+ // page: number
80
+ // }
81
+ // }>
82
+ // type DDD2 = Api.TransformPageResult<{
83
+ // code: number
84
+ // msg: string
85
+ // data: {
86
+ // list: { name: string }[]
87
+ // total: {}
88
+ // }
89
+ // pagination: {
90
+ // page: number
91
+ // }
92
+ // }>
@@ -1,7 +1,7 @@
1
- module.exports = {
2
- // root: true,
3
- extends: ['@peng_kai/lint/vue/stylelint_v2'],
4
- rules: {
5
- 'custom-property-pattern': '(antd-([a-z][a-zA-Z0-9]+)*)|(([a-z][a-z0-9]*)(-[a-z0-9]+)*)',
6
- },
7
- };
1
+ module.exports = {
2
+ // root: true,
3
+ extends: ['@peng_kai/lint/vue/stylelint_v2'],
4
+ rules: {
5
+ 'custom-property-pattern': '(antd-([a-z][a-zA-Z0-9]+)*)|(([a-z][a-z0-9]*)(-[a-z0-9]+)*)',
6
+ },
7
+ };
package/tsconfig.json CHANGED
@@ -1,50 +1,50 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "jsx": "preserve",
5
- "jsxFactory": "h",
6
- "jsxFragmentFactory": "Fragment",
7
- "lib": [
8
- "ESNext",
9
- "DOM",
10
- "DOM.Iterable"
11
- ],
12
- "useDefineForClassFields": true,
13
- "module": "ESNext",
14
-
15
- /* Bundler mode */
16
- "moduleResolution": "bundler",
17
- "resolveJsonModule": true,
18
- "allowImportingTsExtensions": true,
19
-
20
- /* Linting */
21
- "strict": true,
22
- "noFallthroughCasesInSwitch": true,
23
- "noImplicitAny": false,
24
- "noUnusedLocals": true,
25
- "noUnusedParameters": true,
26
- "noEmit": true,
27
- "allowSyntheticDefaultImports": true,
28
- "esModuleInterop": true,
29
- "isolatedModules": true,
30
- "skipLibCheck": true
31
- },
32
- "include": [
33
- "admin/**/*.ts",
34
- "admin/**/*.d.ts",
35
- "admin/**/*.tsx",
36
- "admin/**/*.vue",
37
- "antd/**/*.ts",
38
- "antd/**/*.d.ts",
39
- "antd/**/*.tsx",
40
- "antd/**/*.vue",
41
- "request/**/*.ts",
42
- "request/**/*.d.ts",
43
- "utils/**/*.ts",
44
- "utils/**/*.d.ts",
45
- "vue/**/*.ts",
46
- "vue/**/*.d.ts",
47
- "vue/**/*.tsx",
48
- "vue/**/*.vue"
49
- ]
50
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "jsx": "preserve",
5
+ "jsxFactory": "h",
6
+ "jsxFragmentFactory": "Fragment",
7
+ "lib": [
8
+ "ESNext",
9
+ "DOM",
10
+ "DOM.Iterable"
11
+ ],
12
+ "useDefineForClassFields": true,
13
+ "module": "ESNext",
14
+
15
+ /* Bundler mode */
16
+ "moduleResolution": "bundler",
17
+ "resolveJsonModule": true,
18
+ "allowImportingTsExtensions": true,
19
+
20
+ /* Linting */
21
+ "strict": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "noImplicitAny": false,
24
+ "noUnusedLocals": true,
25
+ "noUnusedParameters": true,
26
+ "noEmit": true,
27
+ "allowSyntheticDefaultImports": true,
28
+ "esModuleInterop": true,
29
+ "isolatedModules": true,
30
+ "skipLibCheck": true
31
+ },
32
+ "include": [
33
+ "admin/**/*.ts",
34
+ "admin/**/*.d.ts",
35
+ "admin/**/*.tsx",
36
+ "admin/**/*.vue",
37
+ "antd/**/*.ts",
38
+ "antd/**/*.d.ts",
39
+ "antd/**/*.tsx",
40
+ "antd/**/*.vue",
41
+ "request/**/*.ts",
42
+ "request/**/*.d.ts",
43
+ "utils/**/*.ts",
44
+ "utils/**/*.d.ts",
45
+ "vue/**/*.ts",
46
+ "vue/**/*.d.ts",
47
+ "vue/**/*.tsx",
48
+ "vue/**/*.vue"
49
+ ]
50
+ }
@@ -0,0 +1,68 @@
1
+ import { S3Client } from '@aws-sdk/client-s3';
2
+ import { Upload } from '@aws-sdk/lib-storage';
3
+ import type { FileHandler } from './fileHandlers';
4
+
5
+ export type TGetParams = () => Promise<{
6
+ domain: string
7
+ bucket: string
8
+ region: string
9
+ accessKeyId: string
10
+ secretAccessKey: string
11
+ sessionToken: string
12
+ }>;
13
+
14
+ export class AwsS3 {
15
+ public domain = '';
16
+ public bucket = '';
17
+ public region = '';
18
+ private s3Client: S3Client | undefined = undefined;
19
+
20
+ public constructor(private getParams: TGetParams, private fileHandler?: FileHandler) {
21
+ }
22
+
23
+ public async upload(file: File, root?: string) {
24
+ const s3Client = await this.refreshClient();
25
+ const filePath = await this.genFilePath(root || 'unclassified');
26
+ const fileName = await (this.fileHandler?.genFileName(file) ?? this.genFileName(file));
27
+ const fullPath = `${filePath}/${fileName}`;
28
+
29
+ const uploader = new Upload({
30
+ client: s3Client!,
31
+ params: { Bucket: this.bucket, Key: fullPath, Body: file },
32
+ leavePartsOnError: false,
33
+ });
34
+
35
+ return { uploader, fileURL: `${this.domain}/${fullPath}` };
36
+ }
37
+
38
+ private genFilePath(root: string) {
39
+ const now = new Date();
40
+ const year = now.getFullYear();
41
+ const month = (now.getMonth() + 1).toString().padStart(2, '0');
42
+ const day = now.getDate().toString().padStart(2, '0');
43
+ const filePath = `${root}/${year}/${month}/${day}`;
44
+
45
+ return filePath;
46
+ }
47
+
48
+ private genFileName(file: File) {
49
+ return file.name;
50
+ }
51
+
52
+ private async refreshClient() {
53
+ const params = await this.getParams();
54
+ this.domain = params.domain;
55
+ this.bucket = params.bucket;
56
+ this.region = params.region;
57
+ this.s3Client = new S3Client({
58
+ region: this.region,
59
+ credentials: {
60
+ accessKeyId: params.accessKeyId,
61
+ secretAccessKey: params.secretAccessKey,
62
+ sessionToken: params.sessionToken,
63
+ },
64
+ });
65
+
66
+ return this.s3Client;
67
+ }
68
+ }
@@ -0,0 +1,27 @@
1
+ export abstract class FileHandler {
2
+ abstract genFileName(file: File): Promise<string>;
3
+ }
4
+
5
+ export class ImageHandler implements FileHandler {
6
+ public genFileName(file: File) {
7
+ const fileNameParts = file.name.split('.');
8
+ const ext = fileNameParts.pop() ?? '';
9
+ const fileName = fileNameParts.join('.');
10
+ const now = new Date();
11
+ const timestamp = now.getTime().toString(36);
12
+ const randomStr = [...Array(5)].map(() => Math.random().toString(36)[2]).join('');
13
+
14
+ return new Promise<string>((resolve, reject) => {
15
+ const img = new Image();
16
+ const imgUrl = URL.createObjectURL(file);
17
+
18
+ img.onload = () => {
19
+ URL.revokeObjectURL(imgUrl);
20
+ resolve(`${fileName}_${randomStr}@${timestamp}@${img.width}x${img.height}.${ext}`);
21
+ };
22
+
23
+ img.onerror = reject;
24
+ img.src = imgUrl;
25
+ });
26
+ }
27
+ }
@@ -0,0 +1,2 @@
1
+ export { AwsS3, type TGetParams } from './AwsS3';
2
+ export { ImageHandler, type FileHandler } from './fileHandlers';
@@ -0,0 +1 @@
1
+ export function getProxy(env: Record<string, string>): Record<string, any>;
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>
@@ -1 +1,2 @@
1
1
  export { InfiniteQuery } from './infinite-query';
2
+ export { ECharts } from './echarts';
@@ -1 +1 @@
1
- export { default as InfiniteQuery } from './src/InfiniteQuery.vue';
1
+ export { default as InfiniteQuery } from './src/InfiniteQuery.vue';