@vunk/form 2.18.2 → 2.19.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.
- package/components/_plugin-vue_export-helper.cjs +1 -11
- package/components/api-tables-select/index.cjs +1 -467
- package/components/api-tables-select/index.mjs +56 -413
- package/components/api-tables-select/src/ctx.d.ts +147 -173
- package/components/api-tables-select/src/index.vue.d.ts +390 -983
- package/components/button/index.cjs +1 -112
- package/components/button/index.mjs +56 -85
- package/components/button/src/ctx.d.ts +28 -113
- package/components/button/src/index.vue.d.ts +314 -621
- package/components/card-input-collection/index.cjs +1 -370
- package/components/card-input-collection/index.mjs +175 -277
- package/components/card-input-collection/src/core.vue.d.ts +57 -950
- package/components/card-input-collection/src/ctx.d.ts +19 -49
- package/components/card-input-collection/src/index.vue.d.ts +49 -112
- package/components/cascader/index.cjs +1 -150
- package/components/cascader/index.mjs +88 -116
- package/components/cascader/src/ctx.d.ts +148 -207
- package/components/cascader/src/index.vue.d.ts +335 -525
- package/components/cascader/src/use.d.ts +1 -1
- package/components/checkbox/index.cjs +1 -152
- package/components/checkbox/index.mjs +75 -119
- package/components/checkbox/src/ctx.d.ts +46 -69
- package/components/checkbox/src/index.vue.d.ts +445 -1012
- package/components/cloneDeep.cjs +1 -2106
- package/components/color-picker/index.cjs +1 -80
- package/components/color-picker/index.mjs +46 -69
- package/components/color-picker/src/ctx.d.ts +138 -107
- package/components/color-picker/src/index.vue.d.ts +305 -255
- package/components/date-picker/index.cjs +1 -119
- package/components/date-picker/index.mjs +63 -97
- package/components/date-picker/src/ctx.d.ts +131 -206
- package/components/date-picker/src/index.vue.d.ts +287 -1359
- package/components/date-picker/src/types.d.ts +7 -7
- package/components/date-picker-range/index.cjs +1 -177
- package/components/date-picker-range/index.mjs +62 -113
- package/components/date-picker-range/src/ctx.d.ts +139 -207
- package/components/date-picker-range/src/index.vue.d.ts +896 -450
- package/components/debounce.cjs +1 -0
- package/components/dialog/index.cjs +1 -126
- package/components/dialog/index.mjs +65 -99
- package/components/dialog/src/ctx.d.ts +17 -108
- package/components/dialog/src/index.vue.d.ts +77 -1070
- package/components/dialog-input-collection/index.cjs +1 -624
- package/components/dialog-input-collection/index.mjs +276 -498
- package/components/dialog-input-collection/src/ctx.d.ts +20 -50
- package/components/dialog-input-collection/src/dialog-form.vue.d.ts +28 -6366
- package/components/dialog-input-collection/src/index.vue.d.ts +66 -7629
- package/components/dialog-input-collection/src/layout.vue.d.ts +16 -72
- package/components/download-plus/index.cjs +1 -456
- package/components/download-plus/index.mjs +214 -358
- package/components/download-plus/src/ctx.d.ts +20 -50
- package/components/download-plus/src/index.vue.d.ts +434 -1171
- package/components/editable-text/index.cjs +1 -295
- package/components/editable-text/index.mjs +113 -239
- package/components/editable-text/src/ctx.d.ts +20 -50
- package/components/editable-text/src/index.vue.d.ts +62 -3257
- package/components/el-slider/index.cjs +1 -0
- package/components/el-slider/index.d.ts +5 -0
- package/components/el-slider/index.mjs +475 -0
- package/components/el-slider/src/button.d.ts +36 -0
- package/components/el-slider/src/button.vue.d.ts +42 -0
- package/components/el-slider/src/composables/index.cjs +1 -0
- package/components/el-slider/src/composables/index.d.ts +6 -0
- package/components/el-slider/src/composables/index.mjs +9 -0
- package/components/el-slider/src/composables/use-lifecycle.d.ts +4 -0
- package/components/el-slider/src/composables/use-marks.d.ts +7 -0
- package/components/el-slider/src/composables/use-slide.d.ts +23 -0
- package/components/el-slider/src/composables/use-slider-button.d.ts +18 -0
- package/components/el-slider/src/composables/use-stops.d.ts +8 -0
- package/components/el-slider/src/composables/use-watch.d.ts +4 -0
- package/components/el-slider/src/constants.d.ts +14 -0
- package/components/el-slider/src/marker.d.ts +37 -0
- package/components/el-slider/src/slider-core.vue.d.ts +219 -0
- package/components/el-slider/src/slider.d.ts +175 -0
- package/components/esri-input-geojson/index.cjs +2 -1604
- package/components/esri-input-geojson/index.mjs +666 -1289
- package/components/esri-input-geojson/src/append.vue.d.ts +225 -1084
- package/components/esri-input-geojson/src/const.d.ts +1 -1
- package/components/esri-input-geojson/src/ctx.d.ts +62 -158
- package/components/esri-input-geojson/src/default-view.vue.d.ts +12 -132
- package/components/esri-input-geojson/src/index.vue.d.ts +1470 -789
- package/components/esri-input-geojson/src/viewer.vue.d.ts +424 -287
- package/components/fieldset/index.cjs +1 -110
- package/components/fieldset/index.mjs +62 -77
- package/components/fieldset/src/ctx.d.ts +4 -4
- package/components/fieldset/src/index.vue.d.ts +10 -9
- package/components/form/index.cjs +1 -248
- package/components/form/index.mjs +107 -161
- package/components/form/src/ctx.d.ts +15 -64
- package/components/form/src/index.vue.d.ts +360 -2416
- package/components/form-item/index.cjs +1 -294
- package/components/form-item/index.mjs +139 -229
- package/components/form-item/src/core.vue.d.ts +33 -1853
- package/components/form-item/src/ctx.d.ts +17 -47
- package/components/form-item/src/index.vue.d.ts +41 -103
- package/components/form-item-renderer/index.cjs +1 -193
- package/components/form-item-renderer/index.mjs +102 -162
- package/components/form-item-renderer/src/core.vue.d.ts +12 -11
- package/components/form-item-renderer/src/ctx.d.ts +3 -3
- package/components/form-item-renderer/src/index.vue.d.ts +25 -73
- package/components/form-item-renderer-template/index.cjs +1 -47
- package/components/form-item-renderer-template/index.mjs +19 -33
- package/components/form-item-renderer-template/src/index.vue.d.ts +4 -3
- package/components/forms-provider/index.cjs +1 -99
- package/components/forms-provider/index.mjs +44 -73
- package/components/forms-provider/src/core.d.ts +3 -2
- package/components/forms-provider/src/index.vue.d.ts +5 -2
- package/components/forms-provider/src/segment.vue.d.ts +12 -8
- package/components/forms-provider/src/view.vue.d.ts +17 -3
- package/components/index.cjs +1 -399
- package/components/index2.cjs +1 -17
- package/components/information/index.cjs +1 -65
- package/components/information/index.mjs +28 -38
- package/components/information/src/ctx.d.ts +2 -2
- package/components/information/src/index.vue.d.ts +7 -6
- package/components/information-collection/index.cjs +1 -81
- package/components/information-collection/index.mjs +44 -48
- package/components/information-collection/src/ctx.d.ts +20 -50
- package/components/information-collection/src/index.vue.d.ts +49 -112
- package/components/information-renderer/index.cjs +1 -16
- package/components/information-renderer/index.mjs +9 -10
- package/components/information-tag/index.cjs +1 -101
- package/components/information-tag/index.mjs +44 -54
- package/components/information-tag/src/ctx.d.ts +5 -19
- package/components/information-tag/src/index.vue.d.ts +24 -51
- package/components/information-templates-default/index.cjs +1 -101
- package/components/information-templates-default/index.mjs +63 -73
- package/components/information-templates-default/src/index.vue.d.ts +2 -1
- package/components/input/index.cjs +1 -115
- package/components/input/index.mjs +60 -83
- package/components/input/src/ctx.d.ts +50 -151
- package/components/input/src/index.vue.d.ts +389 -947
- package/components/input-array/index.cjs +1 -310
- package/components/input-array/index.mjs +114 -244
- package/components/input-array/src/ctx.d.ts +19 -49
- package/components/input-array/src/form-template.vue.d.ts +2 -901
- package/components/input-array/src/index.vue.d.ts +45 -731
- package/components/input-collection/index.cjs +1 -452
- package/components/input-collection/index.mjs +195 -355
- package/components/input-collection/src/core.vue.d.ts +59 -1019
- package/components/input-collection/src/ctx.d.ts +19 -49
- package/components/input-collection/src/index.vue.d.ts +47 -110
- package/components/input-file/index.cjs +1 -142
- package/components/input-file/index.mjs +68 -100
- package/components/input-file/src/ctx.d.ts +8 -29
- package/components/input-file/src/index.vue.d.ts +447 -76
- package/components/input-file/src/template.vue.d.ts +2 -124
- package/components/input-link/index.cjs +1 -167
- package/components/input-link/index.mjs +60 -83
- package/components/input-link/src/ctx.d.ts +48 -135
- package/components/input-link/src/index.vue.d.ts +835 -312
- package/components/input-number/index.cjs +1 -119
- package/components/input-number/index.mjs +73 -87
- package/components/input-number/src/ctx.d.ts +38 -131
- package/components/input-number/src/index.vue.d.ts +321 -682
- package/components/input-tag/index.cjs +1 -100
- package/components/input-tag/index.mjs +51 -78
- package/components/input-tag/src/ctx.d.ts +41 -143
- package/components/input-tag/src/index.vue.d.ts +322 -775
- package/components/isObject.cjs +1 -165
- package/components/monaco-editor/index.cjs +1 -83
- package/components/monaco-editor/index.mjs +40 -59
- package/components/monaco-editor/src/ctx.d.ts +19 -44
- package/components/monaco-editor/src/index.vue.d.ts +212 -111
- package/components/radio/index.cjs +1 -267
- package/components/radio/index.mjs +110 -209
- package/components/radio/src/ctx.d.ts +27 -91
- package/components/radio/src/index.vue.d.ts +299 -1279
- package/components/radio/src/option.vue.d.ts +28 -878
- package/components/radio/src/wraper.vue.d.ts +67 -198
- package/components/renderer-data/index.cjs +1 -41
- package/components/renderer-data/index.mjs +19 -26
- package/components/renderer-data/src/ctx.d.ts +1 -1
- package/components/renderer-data/src/index.vue.d.ts +5 -4
- package/components/select/index.cjs +1 -311
- package/components/select/index.mjs +156 -214
- package/components/select/src/core.vue.d.ts +446 -1028
- package/components/select/src/ctx.d.ts +60 -215
- package/components/select/src/index.vue.d.ts +318 -593
- package/components/select/src/options.vue.d.ts +4 -3
- package/components/slider/index.cjs +1 -88
- package/components/slider/index.mjs +41 -70
- package/components/slider/src/ctx.d.ts +63 -174
- package/components/slider/src/index.vue.d.ts +154 -419
- package/components/style.css +1 -0
- package/components/switch/index.cjs +1 -88
- package/components/switch/index.mjs +37 -69
- package/components/switch/src/ctx.d.ts +30 -109
- package/components/switch/src/index.vue.d.ts +90 -697
- package/components/switch/src/types.d.ts +2 -2
- package/components/tables-select/index.cjs +1 -263
- package/components/tables-select/index.mjs +101 -172
- package/components/tables-select/src/ctx.d.ts +68 -99
- package/components/tables-select/src/index.vue.d.ts +233 -4988
- package/components/template-instances-provider/index.cjs +1 -31
- package/components/template-instances-provider/index.mjs +18 -22
- package/components/template-instances-provider/src/index.vue.d.ts +5 -4
- package/components/templates-default/index.cjs +1 -235
- package/components/templates-default/index.mjs +152 -211
- package/components/templates-default/src/ctx.d.ts +2 -2
- package/components/templates-default/src/index.vue.d.ts +7337 -145
- package/components/templates-element-plus/index.cjs +1 -112
- package/components/templates-element-plus/index.mjs +49 -91
- package/components/templates-element-plus/src/ctx.d.ts +1 -1
- package/components/templates-element-plus/src/index.vue.d.ts +59 -251
- package/components/templates-esri/index.cjs +1 -65
- package/components/templates-esri/index.mjs +29 -39
- package/components/templates-esri/src/ctx.d.ts +1 -1
- package/components/templates-esri/src/index.vue.d.ts +2184 -25
- package/components/templates-layout/index.cjs +1 -137
- package/components/templates-layout/index.mjs +78 -116
- package/components/templates-layout/src/ctx.d.ts +1 -1
- package/components/templates-layout/src/index.vue.d.ts +73 -404
- package/components/templates-variant/index.cjs +1 -70
- package/components/templates-variant/index.mjs +33 -43
- package/components/templates-variant/src/ctx.d.ts +1 -1
- package/components/templates-variant/src/index.vue.d.ts +1272 -25
- package/components/time-picker/index.cjs +1 -104
- package/components/time-picker/index.mjs +57 -87
- package/components/time-picker/src/ctx.d.ts +130 -212
- package/components/time-picker/src/index.vue.d.ts +283 -1371
- package/components/upload/index.cjs +1 -663
- package/components/upload/index.mjs +343 -537
- package/components/upload/src/ctx.d.ts +106 -191
- package/components/upload/src/file.vue.d.ts +168 -745
- package/components/upload/src/index.vue.d.ts +647 -1888
- package/components/upload/src/types.d.ts +1 -1
- package/components/upload/src/wraper.vue.d.ts +233 -407
- package/components/upload-plus/index.cjs +21 -18673
- package/components/upload-plus/index.mjs +4566 -18366
- package/components/upload-plus/src/api.d.ts +1 -1
- package/components/upload-plus/src/ctx.d.ts +21 -51
- package/components/upload-plus/src/index.vue.d.ts +53 -1657
- package/components/use-watch.cjs +1 -0
- package/components/van-cascader/index.cjs +1 -125
- package/components/van-cascader/index.mjs +51 -96
- package/components/van-cascader/src/ctx.d.ts +143 -203
- package/components/van-cascader/src/index.vue.d.ts +332 -988
- package/components/var-datetime-picker/index.cjs +1 -333
- package/components/var-datetime-picker/index.mjs +173 -254
- package/components/var-datetime-picker/src/ctx.d.ts +18 -48
- package/components/var-datetime-picker/src/index.vue.d.ts +628 -1090
- package/components/vditor/index.cjs +1 -86
- package/components/vditor/index.mjs +40 -66
- package/components/vditor/src/ctx.d.ts +15 -45
- package/components/vditor/src/index.vue.d.ts +195 -120
- package/composables/element-plus/index.cjs +1 -23
- package/composables/element-plus/index.mjs +14 -18
- package/composables/index.cjs +1 -161
- package/composables/index.d.ts +1 -0
- package/composables/index.mjs +100 -135
- package/composables/useForm.d.ts +2 -2
- package/composables/useRtl.d.ts +18 -0
- package/composables/useTemplateInstances.d.ts +3 -3
- package/index.css +1 -562
- package/index.d.ts +0 -3
- package/index.esm.js +23 -48
- package/locale/index.cjs +1 -102
- package/locale/index.mjs +34 -34
- package/locale/lang/index.cjs +1 -2
- package/locale/lang/index.d.ts +1 -0
- package/package.json +14 -85
- package/shared/const/index.cjs +1 -59
- package/shared/const/index.d.ts +1 -1
- package/shared/const/index.mjs +18 -20
- package/shared/element-plus/ctx.d.ts +40 -37
- package/shared/element-plus/index.cjs +1 -211
- package/shared/element-plus/index.mjs +93 -161
- package/shared/element-plus/instances.d.ts +224 -321
- package/shared/form/index.cjs +1 -33
- package/shared/form/index.mjs +23 -25
- package/shared/helper/index.cjs +1 -11
- package/shared/helper/index.mjs +7 -8
- package/shared/index.cjs +1 -8
- package/shared/index.mjs +5 -1
- package/shared/infer-prop/index.cjs +1 -36
- package/shared/infer-prop/index.mjs +22 -28
- package/shared/progress-it/index.cjs +1 -42
- package/shared/progress-it/index.mjs +15 -31
- package/shared/rules/index.cjs +1 -56
- package/shared/rules/index.mjs +19 -18
- package/shared/types/form/index.cjs +1 -2
- package/shared/types/index.cjs +1 -2
- package/shared/types/source/index.cjs +1 -2
- package/shared/types/source-manager/index.cjs +1 -2
- package/shared/upload/index.cjs +1 -774
- package/shared/upload/index.mjs +180 -764
- package/component.d.ts +0 -3
- package/components/_plugin-vue_export-helper.mjs +0 -9
- package/components/card-input-collection/index.css +0 -21
- package/components/cascader/index.css +0 -9
- package/components/checkbox/index.css +0 -30
- package/components/cloneDeep.mjs +0 -2104
- package/components/date-picker-range/index.css +0 -18
- package/components/dialog-input-collection/index.css +0 -21
- package/components/download-plus/index.css +0 -68
- package/components/editable-text/index.css +0 -9
- package/components/esri-input-geojson/index.css +0 -32
- package/components/fieldset/index.css +0 -5
- package/components/form-item/index.css +0 -35
- package/components/index.mjs +0 -378
- package/components/index2.mjs +0 -14
- package/components/information-tag/index.css +0 -6
- package/components/information-templates-default/index.css +0 -16
- package/components/input-array/index.css +0 -14
- package/components/input-collection/index.css +0 -20
- package/components/input-link/index.css +0 -4
- package/components/input-number/index.css +0 -13
- package/components/isObject.mjs +0 -158
- package/components/monaco-editor/index.css +0 -4
- package/components/radio/index.css +0 -40
- package/components/select/index.css +0 -15
- package/components/switch/index.css +0 -10
- package/components/tables-select/index.css +0 -3
- package/components/templates-layout/index.css +0 -3
- package/components/upload/index.css +0 -34
- package/components/upload-plus/index.css +0 -84
- package/components/van-cascader/index.css +0 -6
- package/components/var-datetime-picker/index.css +0 -17
- package/defaults.d.ts +0 -5
|
@@ -1,85 +1,29 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare var __VLS_42: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_42) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
6
|
data: {
|
|
3
7
|
type: ObjectConstructor;
|
|
4
8
|
default: () => {};
|
|
5
9
|
};
|
|
6
|
-
}>, {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type: import("vue").PropType<import("packages/entry").NormalObject>;
|
|
10
|
-
default: () => {};
|
|
11
|
-
};
|
|
12
|
-
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
}>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
-
setData: (e: import("packages/entry").SetDataEvent) => import("packages/entry").SetDataEvent;
|
|
16
|
-
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
|
-
data: {
|
|
18
|
-
type: import("vue").PropType<import("packages/entry").NormalObject>;
|
|
19
|
-
default: () => {};
|
|
20
|
-
};
|
|
21
|
-
}>> & Readonly<{
|
|
22
|
-
onSetData?: (e: import("packages/entry").SetDataEvent) => any;
|
|
23
|
-
}>, {
|
|
24
|
-
data: import("packages/entry").NormalObject;
|
|
25
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
|
-
readonly VkfInformationTemplates: import("vue").DefineComponent<{}, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
27
|
-
[key: string]: any;
|
|
28
|
-
}>[]) | (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
29
|
-
[key: string]: any;
|
|
30
|
-
}>[][]), {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
31
|
-
readonly VkfInformationTemplatesDefault: {
|
|
32
|
-
new (...args: any[]): any;
|
|
33
|
-
__isFragment?: never;
|
|
34
|
-
__isTeleport?: never;
|
|
35
|
-
__isSuspense?: never;
|
|
36
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<Record<string | symbol, any>>>, Record<string | symbol, any>, any, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
37
|
-
[x: string]: any;
|
|
38
|
-
[x: symbol]: any;
|
|
39
|
-
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
40
|
-
install(app: import("vue").App): void;
|
|
41
|
-
};
|
|
42
|
-
readonly VkfRendererData: {
|
|
43
|
-
new (...args: any[]): any;
|
|
44
|
-
__isFragment?: never;
|
|
45
|
-
__isTeleport?: never;
|
|
46
|
-
__isSuspense?: never;
|
|
47
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<Record<string | symbol, any>>>, Record<string | symbol, any>, any, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
48
|
-
[x: string]: any;
|
|
49
|
-
[x: symbol]: any;
|
|
50
|
-
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
51
|
-
install(app: import("vue").App): void;
|
|
52
|
-
};
|
|
53
|
-
readonly VkfTemplateInstancesProvider: {
|
|
54
|
-
new (...args: any[]): any;
|
|
55
|
-
__isFragment?: never;
|
|
56
|
-
__isTeleport?: never;
|
|
57
|
-
__isSuspense?: never;
|
|
58
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<Record<string | symbol, any>>>, Record<string | symbol, any>, any, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
59
|
-
[x: string]: any;
|
|
60
|
-
[x: symbol]: any;
|
|
61
|
-
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
62
|
-
install(app: import("vue").App): void;
|
|
63
|
-
};
|
|
64
|
-
readonly VkfTemplatesDefault: {
|
|
65
|
-
new (...args: any[]): any;
|
|
66
|
-
__isFragment?: never;
|
|
67
|
-
__isTeleport?: never;
|
|
68
|
-
__isSuspense?: never;
|
|
69
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<Record<string | symbol, any>>>, Record<string | symbol, any>, any, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
70
|
-
[x: string]: any;
|
|
71
|
-
[x: symbol]: any;
|
|
72
|
-
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
73
|
-
install(app: import("vue").App): void;
|
|
74
|
-
};
|
|
75
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "setData"[], "setData", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
10
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
+
setData: (...args: any[]) => void;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
76
13
|
data: {
|
|
77
14
|
type: ObjectConstructor;
|
|
78
15
|
default: () => {};
|
|
79
16
|
};
|
|
80
17
|
}>> & Readonly<{
|
|
81
|
-
onSetData?: (...args: any[]) => any;
|
|
18
|
+
onSetData?: ((...args: any[]) => any) | undefined;
|
|
82
19
|
}>, {
|
|
83
20
|
data: Record<string, any>;
|
|
84
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
22
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
23
|
+
declare const _default: typeof __VLS_export;
|
|
85
24
|
export default _default;
|
|
25
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
26
|
+
new (): {
|
|
27
|
+
$slots: S;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -1,456 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var formItem = require('@vunk/form/components/form-item');
|
|
6
|
-
var vue = require('vue');
|
|
7
|
-
var basic = require('@skzz/platform/api/basic');
|
|
8
|
-
var platform = require('@skzz/platform/shared/fetch/platform');
|
|
9
|
-
var elementPlus = require('element-plus');
|
|
10
|
-
var utilsFetch = require('@vunk/core/shared/utils-fetch');
|
|
11
|
-
var index = require('../index2.cjs');
|
|
12
|
-
var composables = require('@vunk/core/composables');
|
|
13
|
-
var index$1 = require('../index.cjs');
|
|
14
|
-
var utilsClass = require('@vunk/core/shared/utils-class');
|
|
15
|
-
var elementPlus$1 = require('@vunk/form/composables/element-plus');
|
|
16
|
-
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
17
|
-
|
|
18
|
-
const props = {
|
|
19
|
-
...formItem._VkfFormItemCtx.props,
|
|
20
|
-
fileId: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: ""
|
|
23
|
-
},
|
|
24
|
-
url: {
|
|
25
|
-
type: String,
|
|
26
|
-
default: void 0
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
* @description 分片大小
|
|
30
|
-
*/
|
|
31
|
-
chunkSize: {
|
|
32
|
-
type: Number,
|
|
33
|
-
default: 1024 * 1024 * 10
|
|
34
|
-
},
|
|
35
|
-
fileServiceType: {
|
|
36
|
-
type: String,
|
|
37
|
-
default: void 0
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* @description
|
|
41
|
-
* v-model:fileStatus 当前文件状态: wait, doPause, pause, doDownload, downloading, error, done
|
|
42
|
-
*/
|
|
43
|
-
fileStatus: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: void 0
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const emits = {
|
|
49
|
-
"update:fileStatus": null
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var Status = /* @__PURE__ */ ((Status2) => {
|
|
53
|
-
Status2["wait"] = "wait";
|
|
54
|
-
Status2["doPause"] = "doPause";
|
|
55
|
-
Status2["pause"] = "pause";
|
|
56
|
-
Status2["doDownload"] = "doDownload";
|
|
57
|
-
Status2["downloading"] = "downloading";
|
|
58
|
-
Status2["error"] = "error";
|
|
59
|
-
Status2["done"] = "done";
|
|
60
|
-
return Status2;
|
|
61
|
-
})(Status || {});
|
|
62
|
-
|
|
63
|
-
const restFetch = new utilsFetch.RestFetch({
|
|
64
|
-
baseURL: platform.restFetch.baseURL,
|
|
65
|
-
presetRequestInit: (config) => {
|
|
66
|
-
const header = config.headers;
|
|
67
|
-
const token = index.getToken();
|
|
68
|
-
if (token) {
|
|
69
|
-
header.set("Token", token);
|
|
70
|
-
}
|
|
71
|
-
return config;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
const downChunk = (params, init) => {
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
const xhr = new XMLHttpRequest();
|
|
77
|
-
let url = `${restFetch.baseURL}/file/downloadByRange?fileId=${params.fileId}`;
|
|
78
|
-
if (params.fileServiceType) {
|
|
79
|
-
url += `&fileServiceType=${params.fileServiceType}`;
|
|
80
|
-
xhr.setRequestHeader("fileServiceType", params.fileServiceType);
|
|
81
|
-
}
|
|
82
|
-
if (init?.onprogress) {
|
|
83
|
-
xhr.onprogress = init?.onprogress;
|
|
84
|
-
}
|
|
85
|
-
xhr.open("GET", url, true);
|
|
86
|
-
xhr.responseType = "blob";
|
|
87
|
-
xhr.setRequestHeader("Token", index.getToken());
|
|
88
|
-
xhr.setRequestHeader("tenant", "default");
|
|
89
|
-
xhr.setRequestHeader("application", "platform");
|
|
90
|
-
xhr.setRequestHeader("Content-Range", `bytes=${params.start}-${params.end}`);
|
|
91
|
-
xhr.setRequestHeader("Accept-Ranges", "bytes");
|
|
92
|
-
xhr.onreadystatechange = (e) => {
|
|
93
|
-
const target = e.target;
|
|
94
|
-
if (xhr.readyState === 4) {
|
|
95
|
-
if (xhr.status === 200 || xhr.status === 206) {
|
|
96
|
-
if (init?.xhrs) {
|
|
97
|
-
const i = init.xhrs.findIndex((req) => req === xhr);
|
|
98
|
-
init.xhrs.splice(i, 1);
|
|
99
|
-
}
|
|
100
|
-
resolve({
|
|
101
|
-
data: target.response
|
|
102
|
-
});
|
|
103
|
-
} else if (xhr.status === 500) {
|
|
104
|
-
reject(target.response);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
xhr.onerror = () => {
|
|
109
|
-
reject(xhr.response);
|
|
110
|
-
};
|
|
111
|
-
try {
|
|
112
|
-
xhr.send();
|
|
113
|
-
} catch (err) {
|
|
114
|
-
reject(err);
|
|
115
|
-
}
|
|
116
|
-
init?.xhrs?.push(xhr);
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
var _sfc_main = vue.defineComponent({
|
|
121
|
-
name: "VkfDownloadPlus",
|
|
122
|
-
components: {
|
|
123
|
-
VkfFormItem: formItem.VkfFormItem,
|
|
124
|
-
ElButtonGroup: elementPlus.ElButtonGroup,
|
|
125
|
-
ElButton: elementPlus.ElButton,
|
|
126
|
-
ElInput: elementPlus.ElInput
|
|
127
|
-
},
|
|
128
|
-
props,
|
|
129
|
-
emits,
|
|
130
|
-
setup(props2, { emit }) {
|
|
131
|
-
const formItemBindProps = formItem._VkfFormItemCtx.createBindProps(props2);
|
|
132
|
-
const { tr } = elementPlus$1.useLocale();
|
|
133
|
-
vue.watchEffect(() => {
|
|
134
|
-
restFetch.baseURL = props2.url || platform.restFetch.baseURL;
|
|
135
|
-
});
|
|
136
|
-
const fileInfo = vue.ref();
|
|
137
|
-
rFileInfo();
|
|
138
|
-
vue.watch(() => props2.fileId, rFileInfo);
|
|
139
|
-
function rFileInfo() {
|
|
140
|
-
if (!props2.fileId) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
basic.rFile({
|
|
144
|
-
fileId: props2.fileId
|
|
145
|
-
}).then((res) => {
|
|
146
|
-
fileInfo.value = res;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
const filePrefixIcon = vue.computed(() => {
|
|
150
|
-
if (fileStatus.value === Status.error) {
|
|
151
|
-
return index$1.circle_close_filled_default;
|
|
152
|
-
}
|
|
153
|
-
return index$1.download_default;
|
|
154
|
-
});
|
|
155
|
-
const chunks = vue.ref([]);
|
|
156
|
-
const downloadingXhrs = vue.ref([]);
|
|
157
|
-
const fileStatus = composables.useModelComputed({
|
|
158
|
-
default: Status.wait,
|
|
159
|
-
key: "fileStatus"
|
|
160
|
-
}, props2, emit);
|
|
161
|
-
const handleDownload = () => {
|
|
162
|
-
if (!fileInfo.value) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const fileSize = fileInfo.value.size;
|
|
166
|
-
const fileId = fileInfo.value.id;
|
|
167
|
-
const chunksLength = Math.ceil(fileSize / props2.chunkSize);
|
|
168
|
-
chunks.value = Array.from({ length: chunksLength }, (_, i) => {
|
|
169
|
-
const start = i * props2.chunkSize;
|
|
170
|
-
const end = Math.min(
|
|
171
|
-
start + props2.chunkSize,
|
|
172
|
-
fileSize
|
|
173
|
-
) - 1;
|
|
174
|
-
let downloadedChunk = {};
|
|
175
|
-
if (chunks.value[i] && chunks.value[i].start === start && chunks.value[i].end === end && chunks.value[i].status === Status.done) {
|
|
176
|
-
downloadedChunk = chunks.value[i];
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
start,
|
|
180
|
-
end,
|
|
181
|
-
index: i,
|
|
182
|
-
status: Status.wait,
|
|
183
|
-
fileId,
|
|
184
|
-
fileServiceType: props2.fileServiceType,
|
|
185
|
-
progress: 0,
|
|
186
|
-
...downloadedChunk
|
|
187
|
-
};
|
|
188
|
-
});
|
|
189
|
-
fileStatus.value = Status.downloading;
|
|
190
|
-
const needDownloadChunks = chunks.value.filter(
|
|
191
|
-
(v) => v.status === Status.wait || v.status === Status.error
|
|
192
|
-
);
|
|
193
|
-
rChunkFiles(needDownloadChunks).then(() => {
|
|
194
|
-
const blobs = chunks.value.map((item) => {
|
|
195
|
-
return item.data;
|
|
196
|
-
});
|
|
197
|
-
return new Blob(
|
|
198
|
-
blobs,
|
|
199
|
-
{ type: "application/octet-stream" }
|
|
200
|
-
);
|
|
201
|
-
}).then((blob) => {
|
|
202
|
-
const url = URL.createObjectURL(blob);
|
|
203
|
-
const a = document.createElement("a");
|
|
204
|
-
a.href = url;
|
|
205
|
-
a.download = fileInfo.value?.realName || tr("vkf.downloadPlus.unknownFile", "\u672A\u77E5\u6587\u4EF6");
|
|
206
|
-
a.click();
|
|
207
|
-
URL.revokeObjectURL(url);
|
|
208
|
-
}).then(() => {
|
|
209
|
-
fileStatus.value = Status.done;
|
|
210
|
-
}).catch(() => {
|
|
211
|
-
fileStatus.value = Status.error;
|
|
212
|
-
elementPlus.ElMessage.error(tr("vkf.downloadPlus.downloadFailed", "\u4E0B\u8F7D\u5931\u8D25"));
|
|
213
|
-
});
|
|
214
|
-
};
|
|
215
|
-
vue.watch(() => fileStatus.value, (newVal) => {
|
|
216
|
-
if (newVal === Status.doDownload) {
|
|
217
|
-
handleDownload();
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
function rChunkFiles(chunks2, max = 4, retrys = 10) {
|
|
221
|
-
return new Promise((resolve, reject) => {
|
|
222
|
-
const len = chunks2.length;
|
|
223
|
-
let counter = 0;
|
|
224
|
-
if (len === 0) {
|
|
225
|
-
return resolve(void 0);
|
|
226
|
-
}
|
|
227
|
-
const retryArr = [];
|
|
228
|
-
const start = async () => {
|
|
229
|
-
while (counter < len && max > 0) {
|
|
230
|
-
max--;
|
|
231
|
-
const i = chunks2.findIndex(
|
|
232
|
-
(v) => v.status === Status.wait || v.status === Status.error
|
|
233
|
-
);
|
|
234
|
-
const currentChunk = chunks2[i];
|
|
235
|
-
if (currentChunk) {
|
|
236
|
-
currentChunk.status = Status.downloading;
|
|
237
|
-
downChunk(currentChunk, {
|
|
238
|
-
onprogress(ev) {
|
|
239
|
-
currentChunk.progress = parseInt(ev.loaded / ev.total * 100 + "");
|
|
240
|
-
},
|
|
241
|
-
xhrs: downloadingXhrs.value
|
|
242
|
-
}).then((res) => {
|
|
243
|
-
currentChunk.status = Status.done;
|
|
244
|
-
currentChunk.data = res.data;
|
|
245
|
-
max++;
|
|
246
|
-
counter++;
|
|
247
|
-
}).then(() => {
|
|
248
|
-
if (counter === len) {
|
|
249
|
-
resolve(void 0);
|
|
250
|
-
} else {
|
|
251
|
-
start();
|
|
252
|
-
}
|
|
253
|
-
}).catch(() => {
|
|
254
|
-
currentChunk.status = Status.error;
|
|
255
|
-
const index = currentChunk.index;
|
|
256
|
-
if (typeof retryArr[index] !== "number") {
|
|
257
|
-
retryArr[index] = 0;
|
|
258
|
-
}
|
|
259
|
-
retryArr[index]++;
|
|
260
|
-
console.warn(
|
|
261
|
-
index,
|
|
262
|
-
currentChunk,
|
|
263
|
-
retryArr[index],
|
|
264
|
-
"\u6B21\u62A5\u9519"
|
|
265
|
-
);
|
|
266
|
-
currentChunk.progress = -1;
|
|
267
|
-
if (retryArr[index] >= retrys) {
|
|
268
|
-
return reject();
|
|
269
|
-
}
|
|
270
|
-
max++;
|
|
271
|
-
start();
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
start();
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
const handlePause = () => {
|
|
280
|
-
downloadingXhrs.value.forEach((xhr) => {
|
|
281
|
-
xhr.abort();
|
|
282
|
-
});
|
|
283
|
-
downloadingXhrs.value = [];
|
|
284
|
-
fileStatus.value = Status.pause;
|
|
285
|
-
};
|
|
286
|
-
vue.watch(() => fileStatus.value, (newVal) => {
|
|
287
|
-
if (newVal === Status.doPause) {
|
|
288
|
-
handlePause();
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
vue.onBeforeUnmount(() => {
|
|
292
|
-
handlePause();
|
|
293
|
-
});
|
|
294
|
-
class OnlineToggle extends utilsClass.ToggleHandler {
|
|
295
|
-
constructor(listener) {
|
|
296
|
-
super();
|
|
297
|
-
this.listener = listener;
|
|
298
|
-
}
|
|
299
|
-
add() {
|
|
300
|
-
window.addEventListener("online", this.listener);
|
|
301
|
-
this.removeHandler = () => {
|
|
302
|
-
window.removeEventListener("online", this.listener);
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
const onlineToggle = new OnlineToggle(() => {
|
|
307
|
-
if (fileStatus.value === Status.error) {
|
|
308
|
-
fileStatus.value = Status.doDownload;
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
onlineToggle.add();
|
|
312
|
-
vue.onBeforeUnmount(() => {
|
|
313
|
-
onlineToggle.remove();
|
|
314
|
-
});
|
|
315
|
-
return {
|
|
316
|
-
formItemBindProps,
|
|
317
|
-
fileInfo,
|
|
318
|
-
handleDownload,
|
|
319
|
-
handlePause,
|
|
320
|
-
Status,
|
|
321
|
-
chunks,
|
|
322
|
-
fileStatus,
|
|
323
|
-
filePrefixIcon,
|
|
324
|
-
tr
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
const _hoisted_1 = { class: "vkf-download-plus-main" };
|
|
330
|
-
const _hoisted_2 = { class: "vkf-download-plus-label" };
|
|
331
|
-
const _hoisted_3 = {
|
|
332
|
-
key: 0,
|
|
333
|
-
class: "vkf-download-plus-cube-x"
|
|
334
|
-
};
|
|
335
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
336
|
-
const _component_ElInput = vue.resolveComponent("ElInput");
|
|
337
|
-
const _component_el_button = vue.resolveComponent("el-button");
|
|
338
|
-
const _component_el_button_group = vue.resolveComponent("el-button-group");
|
|
339
|
-
const _component_VkfFormItem = vue.resolveComponent("VkfFormItem");
|
|
340
|
-
return vue.openBlock(), vue.createBlock(
|
|
341
|
-
_component_VkfFormItem,
|
|
342
|
-
vue.mergeProps(_ctx.formItemBindProps, { class: "vkf-download-plus" }),
|
|
343
|
-
{
|
|
344
|
-
default: vue.withCtx(() => [
|
|
345
|
-
vue.createElementVNode("div", _hoisted_1, [
|
|
346
|
-
vue.createElementVNode("label", _hoisted_2, [
|
|
347
|
-
vue.createVNode(_component_ElInput, {
|
|
348
|
-
class: vue.normalizeClass({
|
|
349
|
-
"is-error": _ctx.fileStatus === _ctx.Status.error
|
|
350
|
-
}),
|
|
351
|
-
"prefix-icon": _ctx.filePrefixIcon,
|
|
352
|
-
"model-value": _ctx.fileInfo?.realName,
|
|
353
|
-
readonly: ""
|
|
354
|
-
}, null, 8, ["class", "prefix-icon", "model-value"]),
|
|
355
|
-
_ctx.fileStatus === _ctx.Status.downloading || _ctx.fileStatus === _ctx.Status.pause ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, [
|
|
356
|
-
(vue.openBlock(true), vue.createElementBlock(
|
|
357
|
-
vue.Fragment,
|
|
358
|
-
null,
|
|
359
|
-
vue.renderList(_ctx.chunks, (chunk) => {
|
|
360
|
-
return vue.openBlock(), vue.createElementBlock(
|
|
361
|
-
"div",
|
|
362
|
-
{
|
|
363
|
-
key: chunk.fileId + "-" + chunk.index,
|
|
364
|
-
class: vue.normalizeClass(["vkf-download-plus-cube", {
|
|
365
|
-
"error": chunk.status == _ctx.Status.error
|
|
366
|
-
}]),
|
|
367
|
-
style: vue.normalizeStyle({
|
|
368
|
-
width: 100 / _ctx.chunks.length + "%"
|
|
369
|
-
})
|
|
370
|
-
},
|
|
371
|
-
[
|
|
372
|
-
vue.createElementVNode(
|
|
373
|
-
"div",
|
|
374
|
-
{
|
|
375
|
-
class: vue.normalizeClass({
|
|
376
|
-
"uploading": chunk.progress > 0 && chunk.progress < 100,
|
|
377
|
-
"success": chunk.progress == 100
|
|
378
|
-
}),
|
|
379
|
-
style: vue.normalizeStyle({
|
|
380
|
-
height: chunk.progress + "%"
|
|
381
|
-
})
|
|
382
|
-
},
|
|
383
|
-
null,
|
|
384
|
-
6
|
|
385
|
-
/* CLASS, STYLE */
|
|
386
|
-
)
|
|
387
|
-
],
|
|
388
|
-
6
|
|
389
|
-
/* CLASS, STYLE */
|
|
390
|
-
);
|
|
391
|
-
}),
|
|
392
|
-
128
|
|
393
|
-
/* KEYED_FRAGMENT */
|
|
394
|
-
))
|
|
395
|
-
])) : vue.createCommentVNode("v-if", true)
|
|
396
|
-
]),
|
|
397
|
-
vue.createVNode(_component_el_button_group, { class: "vkf-download-plus-btng" }, {
|
|
398
|
-
default: vue.withCtx(() => [
|
|
399
|
-
_ctx.fileStatus === _ctx.Status.downloading ? (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
400
|
-
key: 0,
|
|
401
|
-
type: "danger",
|
|
402
|
-
onClick: _ctx.handlePause
|
|
403
|
-
}, {
|
|
404
|
-
default: vue.withCtx(() => [
|
|
405
|
-
vue.createTextVNode(
|
|
406
|
-
vue.toDisplayString(_ctx.tr("vkf.common.pause", "\u6682\u505C")),
|
|
407
|
-
1
|
|
408
|
-
/* TEXT */
|
|
409
|
-
)
|
|
410
|
-
]),
|
|
411
|
-
_: 1
|
|
412
|
-
/* STABLE */
|
|
413
|
-
}, 8, ["onClick"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
414
|
-
key: 1,
|
|
415
|
-
type: "primary",
|
|
416
|
-
onClick: _ctx.handleDownload
|
|
417
|
-
}, {
|
|
418
|
-
default: vue.withCtx(() => [
|
|
419
|
-
vue.createTextVNode(
|
|
420
|
-
vue.toDisplayString(_ctx.tr("vkf.common.download", "\u4E0B\u8F7D")),
|
|
421
|
-
1
|
|
422
|
-
/* TEXT */
|
|
423
|
-
)
|
|
424
|
-
]),
|
|
425
|
-
_: 1
|
|
426
|
-
/* STABLE */
|
|
427
|
-
}, 8, ["onClick"]))
|
|
428
|
-
]),
|
|
429
|
-
_: 1
|
|
430
|
-
/* STABLE */
|
|
431
|
-
})
|
|
432
|
-
])
|
|
433
|
-
]),
|
|
434
|
-
_: 1
|
|
435
|
-
/* STABLE */
|
|
436
|
-
},
|
|
437
|
-
16
|
|
438
|
-
/* FULL_PROPS */
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
var VkfDownloadPlus = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/download-plus/src/index.vue"]]);
|
|
442
|
-
|
|
443
|
-
var types = /*#__PURE__*/Object.freeze({
|
|
444
|
-
__proto__: null
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
VkfDownloadPlus.install = (app) => {
|
|
448
|
-
app.component(
|
|
449
|
-
VkfDownloadPlus.name || "VkfDownloadPlus",
|
|
450
|
-
VkfDownloadPlus
|
|
451
|
-
);
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
exports.VkfDownloadPlus = VkfDownloadPlus;
|
|
455
|
-
exports.__VkfDownloadPlus = types;
|
|
456
|
-
exports.default = VkfDownloadPlus;
|
|
1
|
+
"use strict";var N=Object.defineProperty;var U=(e,o,c)=>o in e?N(e,o,{enumerable:!0,configurable:!0,writable:!0,value:c}):e[o]=c;var R=(e,o,c)=>U(e,typeof o!="symbol"?o+"":o,c);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@vunk/form/components/form-item"),t=require("vue"),$=require("@skzz/platform/api/basic"),q=require("@skzz/platform/shared/fetch/platform"),C=require("element-plus"),x=require("@vunk/core/shared/utils-fetch"),V=require("../index2.cjs"),H=require("@vunk/core/composables"),T=require("../index.cjs"),M=require("@vunk/core/shared/utils-class"),O=require("@vunk/form/composables/element-plus"),j=require("../_plugin-vue_export-helper.cjs"),A={...P._VkfFormItemCtx.props,fileId:{type:String,default:""},url:{type:String,default:void 0},chunkSize:{type:Number,default:1024*1024*10},fileServiceType:{type:String,default:void 0},fileStatus:{type:String,default:void 0}},G={"update:fileStatus":null};var r=(e=>(e.wait="wait",e.doPause="doPause",e.pause="pause",e.doDownload="doDownload",e.downloading="downloading",e.error="error",e.done="done",e))(r||{});const F=new x.RestFetch({baseURL:q.restFetch.baseURL,presetRequestInit:e=>{const o=e.headers,c=V.getToken();return c&&o.set("Token",c),e}}),X=(e,o)=>new Promise((c,h)=>{var b;const n=new XMLHttpRequest;let y=`${F.baseURL}/file/downloadByRange?fileId=${e.fileId}`;e.fileServiceType&&(y+=`&fileServiceType=${e.fileServiceType}`,n.setRequestHeader("fileServiceType",e.fileServiceType)),o!=null&&o.onprogress&&(n.onprogress=o==null?void 0:o.onprogress),n.open("GET",y,!0),n.responseType="blob",n.setRequestHeader("Token",V.getToken()),n.setRequestHeader("tenant","default"),n.setRequestHeader("application","platform"),n.setRequestHeader("Content-Range",`bytes=${e.start}-${e.end}`),n.setRequestHeader("Accept-Ranges","bytes"),n.onreadystatechange=l=>{const w=l.target;if(n.readyState===4)if(n.status===200||n.status===206){if(o!=null&&o.xhrs){const u=o.xhrs.findIndex(g=>g===n);o.xhrs.splice(u,1)}c({data:w.response})}else n.status===500&&h(w.response)},n.onerror=()=>{h(n.response)};try{n.send()}catch(l){h(l)}(b=o==null?void 0:o.xhrs)==null||b.push(n)}),J=t.defineComponent({name:"VkfDownloadPlus",components:{VkfFormItem:P.VkfFormItem,ElButtonGroup:C.ElButtonGroup,ElButton:C.ElButton,ElInput:C.ElInput},props:A,emits:G,setup(e,{emit:o}){const c=P._VkfFormItemCtx.createBindProps(e),{tr:h}=O.useLocale();t.watchEffect(()=>{F.baseURL=e.url||q.restFetch.baseURL});const n=t.ref();y(),t.watch(()=>e.fileId,y);function y(){e.fileId&&$.rFile({fileId:e.fileId}).then(a=>{n.value=a})}const b=t.computed(()=>u.value===r.error?T.circle_close_filled_default:T.download_default),l=t.ref([]),w=t.ref([]),u=H.useModelComputed({default:r.wait,key:"fileStatus"},e,o),g=()=>{if(!n.value)return;const a=n.value.size,k=n.value.id,I=Math.ceil(a/e.chunkSize);l.value=Array.from({length:I},(v,s)=>{const i=s*e.chunkSize,f=Math.min(i+e.chunkSize,a)-1;let S={};return l.value[s]&&l.value[s].start===i&&l.value[s].end===f&&l.value[s].status===r.done&&(S=l.value[s]),{start:i,end:f,index:s,status:r.wait,fileId:k,fileServiceType:e.fileServiceType,progress:0,...S}}),u.value=r.downloading;const _=l.value.filter(v=>v.status===r.wait||v.status===r.error);m(_).then(()=>{const v=l.value.map(s=>s.data);return new Blob(v,{type:"application/octet-stream"})}).then(v=>{var f;const s=URL.createObjectURL(v),i=document.createElement("a");i.href=s,i.download=((f=n.value)==null?void 0:f.realName)||h("vkf.downloadPlus.unknownFile","未知文件"),i.click(),URL.revokeObjectURL(s)}).then(()=>{u.value=r.done}).catch(()=>{u.value=r.error,C.ElMessage.error(h("vkf.downloadPlus.downloadFailed","下载失败"))})};t.watch(()=>u.value,a=>{a===r.doDownload&&g()});function m(a,k=4,I=10){return new Promise((_,v)=>{const s=a.length;let i=0;if(s===0)return _(void 0);const f=[],S=async()=>{for(;i<s&&k>0;){k--;const z=a.findIndex(d=>d.status===r.wait||d.status===r.error),p=a[z];p&&(p.status=r.downloading,X(p,{onprogress(d){p.progress=parseInt(d.loaded/d.total*100+"")},xhrs:w.value}).then(d=>{p.status=r.done,p.data=d.data,k++,i++}).then(()=>{i===s?_(void 0):S()}).catch(()=>{p.status=r.error;const d=p.index;if(typeof f[d]!="number"&&(f[d]=0),f[d]++,console.warn(d,p,f[d],"次报错"),p.progress=-1,f[d]>=I)return v();k++,S()}))}};S()})}const B=()=>{w.value.forEach(a=>{a.abort()}),w.value=[],u.value=r.pause};t.watch(()=>u.value,a=>{a===r.doPause&&B()}),t.onBeforeUnmount(()=>{B()});class D extends M.ToggleHandler{constructor(I){super();R(this,"listener");this.listener=I}add(){window.addEventListener("online",this.listener),this.removeHandler=()=>{window.removeEventListener("online",this.listener)}}}const E=new D(()=>{u.value===r.error&&(u.value=r.doDownload)});return E.add(),t.onBeforeUnmount(()=>{E.remove()}),{formItemBindProps:c,fileInfo:n,handleDownload:g,handlePause:B,Status:r,chunks:l,fileStatus:u,filePrefixIcon:b,tr:h}}}),K={class:"vkf-download-plus-main"},Q={class:"vkf-download-plus-label"},W={key:0,class:"vkf-download-plus-cube-x"};function Y(e,o,c,h,n,y){const b=t.resolveComponent("ElInput"),l=t.resolveComponent("el-button"),w=t.resolveComponent("el-button-group"),u=t.resolveComponent("VkfFormItem");return t.openBlock(),t.createBlock(u,t.mergeProps(e.formItemBindProps,{class:"vkf-download-plus"}),{default:t.withCtx(()=>{var g;return[t.createElementVNode("div",K,[t.createElementVNode("label",Q,[t.createVNode(b,{class:t.normalizeClass({"is-error":e.fileStatus===e.Status.error}),"prefix-icon":e.filePrefixIcon,"model-value":(g=e.fileInfo)==null?void 0:g.realName,readonly:""},null,8,["class","prefix-icon","model-value"]),e.fileStatus===e.Status.downloading||e.fileStatus===e.Status.pause?(t.openBlock(),t.createElementBlock("div",W,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.chunks,m=>(t.openBlock(),t.createElementBlock("div",{key:m.fileId+"-"+m.index,class:t.normalizeClass(["vkf-download-plus-cube",{error:m.status==e.Status.error}]),style:t.normalizeStyle({width:100/e.chunks.length+"%"})},[t.createElementVNode("div",{class:t.normalizeClass({uploading:m.progress>0&&m.progress<100,success:m.progress==100}),style:t.normalizeStyle({height:m.progress+"%"})},null,6)],6))),128))])):t.createCommentVNode("",!0)]),t.createVNode(w,{class:"vkf-download-plus-btng"},{default:t.withCtx(()=>[e.fileStatus===e.Status.downloading?(t.openBlock(),t.createBlock(l,{key:0,type:"danger",onClick:e.handlePause},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.tr("vkf.common.pause","暂停")),1)]),_:1},8,["onClick"])):(t.openBlock(),t.createBlock(l,{key:1,type:"primary",onClick:e.handleDownload},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.tr("vkf.common.download","下载")),1)]),_:1},8,["onClick"]))]),_:1})])]}),_:1},16)}const L=j._export_sfc(J,[["render",Y]]),Z=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.VkfDownloadPlus=L;exports.__VkfDownloadPlus=Z;exports.default=L;
|