zartui 3.1.76 → 3.1.78
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/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/media-picker/MediaPicker.d.ts +4 -0
- package/es/media-picker/MediaPicker.mjs +41 -1
- package/es/media-picker/index.d.ts +3 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/media-picker/MediaPicker.d.ts +4 -0
- package/lib/media-picker/MediaPicker.js +41 -1
- package/lib/media-picker/index.d.ts +3 -0
- package/lib/web-types.json +1 -1
- package/lib/zartui.cjs.js +42 -2
- package/lib/zartui.es.js +42 -2
- package/lib/zartui.js +3435 -21
- package/lib/zartui.min.js +2 -2
- package/package.json +4 -3
package/es/index.d.ts
CHANGED
package/es/index.mjs
CHANGED
|
@@ -77,7 +77,7 @@ import { Timeline } from "./timeline/index.mjs";
|
|
|
77
77
|
import { Toast } from "./toast/index.mjs";
|
|
78
78
|
import { Uploader } from "./uploader/index.mjs";
|
|
79
79
|
import { Video } from "./video/index.mjs";
|
|
80
|
-
const version = "3.1.
|
|
80
|
+
const version = "3.1.78";
|
|
81
81
|
function install(app) {
|
|
82
82
|
const components = [
|
|
83
83
|
ActionSheet,
|
|
@@ -90,6 +90,7 @@ declare const mediaPickerProps: {
|
|
|
90
90
|
default: MediaSizeType;
|
|
91
91
|
};
|
|
92
92
|
mediaPlayerProps: PropType<Partial<MediaPlayerProps>>;
|
|
93
|
+
autoCheckFileType: BooleanConstructor;
|
|
93
94
|
};
|
|
94
95
|
export type MediaPickerProps = ExtractPropTypes<typeof mediaPickerProps>;
|
|
95
96
|
export type MediaPickerInstance = ComponentPublicInstance<{
|
|
@@ -183,6 +184,7 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
183
184
|
default: MediaSizeType;
|
|
184
185
|
};
|
|
185
186
|
mediaPlayerProps: PropType<Partial<MediaPlayerProps>>;
|
|
187
|
+
autoCheckFileType: BooleanConstructor;
|
|
186
188
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("delete" | "processing" | "update:mediaList")[], "delete" | "processing" | "update:mediaList", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
|
187
189
|
sortable: {
|
|
188
190
|
type: BooleanConstructor;
|
|
@@ -271,6 +273,7 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
271
273
|
default: MediaSizeType;
|
|
272
274
|
};
|
|
273
275
|
mediaPlayerProps: PropType<Partial<MediaPlayerProps>>;
|
|
276
|
+
autoCheckFileType: BooleanConstructor;
|
|
274
277
|
}>> & Readonly<{
|
|
275
278
|
onDelete?: ((...args: any[]) => any) | undefined;
|
|
276
279
|
onProcessing?: ((...args: any[]) => any) | undefined;
|
|
@@ -301,5 +304,6 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
301
304
|
allowPickFile: boolean;
|
|
302
305
|
useWx: boolean;
|
|
303
306
|
imageSizeType: MediaSizeType;
|
|
307
|
+
autoCheckFileType: boolean;
|
|
304
308
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
305
309
|
export default _default;
|
|
@@ -23,6 +23,7 @@ import { createNamespace, isDef, isWeixin, makeArrayProp, makeNumberProp, makeSt
|
|
|
23
23
|
import { computed, defineComponent, ref, watch } from "vue";
|
|
24
24
|
import { showFailToast, showLoadingToast, closeToast } from "../toast/index.mjs";
|
|
25
25
|
import DeleteIcon from "./image/DeleteIcon.mjs";
|
|
26
|
+
import { fileTypeFromBuffer } from "file-type";
|
|
26
27
|
import ZtGrid from "../grid/index.mjs";
|
|
27
28
|
import ZtGridItem from "../grid-item/index.mjs";
|
|
28
29
|
import ZtActionSheet from "../action-sheet/index.mjs";
|
|
@@ -47,6 +48,17 @@ import { useExpose } from "../composables/use-expose.mjs";
|
|
|
47
48
|
import Sortable from "sortablejs";
|
|
48
49
|
const [name, bem] = createNamespace("media-picker");
|
|
49
50
|
const FILE_SIZE_LIMIT = 100;
|
|
51
|
+
const COMPATIBLE_TYPE_MAPPINGS = {
|
|
52
|
+
"mp3": /* @__PURE__ */ new Set(["mpga"]),
|
|
53
|
+
"mp4": /* @__PURE__ */ new Set(["qt"]),
|
|
54
|
+
"html": /* @__PURE__ */ new Set(["txt"]),
|
|
55
|
+
"json": /* @__PURE__ */ new Set(["txt"]),
|
|
56
|
+
"xml": /* @__PURE__ */ new Set(["txt"]),
|
|
57
|
+
"gif": /* @__PURE__ */ new Set(["png"]),
|
|
58
|
+
"jpeg": /* @__PURE__ */ new Set(["jpg"]),
|
|
59
|
+
"jpg": /* @__PURE__ */ new Set(["jpeg"]),
|
|
60
|
+
"m4a": /* @__PURE__ */ new Set(["mp4", "mp4a", "x-m4a"])
|
|
61
|
+
};
|
|
50
62
|
const mediaPickerProps = {
|
|
51
63
|
sortable: {
|
|
52
64
|
type: Boolean,
|
|
@@ -109,7 +121,9 @@ const mediaPickerProps = {
|
|
|
109
121
|
// 是否强制使用微信
|
|
110
122
|
useWx: Boolean,
|
|
111
123
|
imageSizeType: makeStringProp("compressed"),
|
|
112
|
-
mediaPlayerProps: Object
|
|
124
|
+
mediaPlayerProps: Object,
|
|
125
|
+
// 是否自动检查文件类型(校验文件扩展名与实际文件头信息是否匹配)
|
|
126
|
+
autoCheckFileType: Boolean
|
|
113
127
|
};
|
|
114
128
|
var stdin_default = defineComponent({
|
|
115
129
|
name,
|
|
@@ -519,6 +533,32 @@ var stdin_default = defineComponent({
|
|
|
519
533
|
if (!checkFileCountAfterAdd(files)) {
|
|
520
534
|
return;
|
|
521
535
|
}
|
|
536
|
+
if (props.autoCheckFileType) {
|
|
537
|
+
try {
|
|
538
|
+
for (const file of files) {
|
|
539
|
+
const buffer = yield file.slice(0, 4100).arrayBuffer();
|
|
540
|
+
const fileType = yield fileTypeFromBuffer(new Uint8Array(buffer));
|
|
541
|
+
const fileName = file.name.toLowerCase();
|
|
542
|
+
const extensionMatch = fileName.match(/\.([^.]+)$/);
|
|
543
|
+
const extension = extensionMatch ? extensionMatch[1] : "";
|
|
544
|
+
if (fileType && extension) {
|
|
545
|
+
if (fileType.ext !== extension) {
|
|
546
|
+
const compatibleTypes = COMPATIBLE_TYPE_MAPPINGS[extension];
|
|
547
|
+
const isCompatible = compatibleTypes && compatibleTypes.has(fileType.ext);
|
|
548
|
+
if (!isCompatible) {
|
|
549
|
+
showFailToast({
|
|
550
|
+
message: `\u6587\u4EF6\u540E\u7F00\u4E0E\u5B9E\u9645\u6587\u4EF6\u7C7B\u578B\u4E0D\u5339\u914D\uFF1A${file.name}`,
|
|
551
|
+
duration: 5e3
|
|
552
|
+
});
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
} catch (error) {
|
|
559
|
+
console.error("\u6587\u4EF6\u7C7B\u578B\u6821\u9A8C\u5931\u8D25:", error);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
522
562
|
if (props.beforeRead) {
|
|
523
563
|
try {
|
|
524
564
|
const response = yield props.beforeRead(files);
|
|
@@ -76,6 +76,7 @@ export declare const MediaPicker: import("../utils").WithInstall<import("vue").D
|
|
|
76
76
|
default: import("./type").MediaSizeType;
|
|
77
77
|
};
|
|
78
78
|
mediaPlayerProps: import("vue").PropType<Partial<import("..").MediaPlayerProps>>;
|
|
79
|
+
autoCheckFileType: BooleanConstructor;
|
|
79
80
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("delete" | "processing" | "update:mediaList")[], "delete" | "processing" | "update:mediaList", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
80
81
|
sortable: {
|
|
81
82
|
type: BooleanConstructor;
|
|
@@ -154,6 +155,7 @@ export declare const MediaPicker: import("../utils").WithInstall<import("vue").D
|
|
|
154
155
|
default: import("./type").MediaSizeType;
|
|
155
156
|
};
|
|
156
157
|
mediaPlayerProps: import("vue").PropType<Partial<import("..").MediaPlayerProps>>;
|
|
158
|
+
autoCheckFileType: BooleanConstructor;
|
|
157
159
|
}>> & Readonly<{
|
|
158
160
|
onDelete?: ((...args: any[]) => any) | undefined;
|
|
159
161
|
onProcessing?: ((...args: any[]) => any) | undefined;
|
|
@@ -184,6 +186,7 @@ export declare const MediaPicker: import("../utils").WithInstall<import("vue").D
|
|
|
184
186
|
allowPickFile: boolean;
|
|
185
187
|
useWx: boolean;
|
|
186
188
|
imageSizeType: import("./type").MediaSizeType;
|
|
189
|
+
autoCheckFileType: boolean;
|
|
187
190
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
|
188
191
|
export default MediaPicker;
|
|
189
192
|
export type { MediaPickerProps, MediaPickerInstance } from './MediaPicker';
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -182,7 +182,7 @@ __reExport(stdin_exports, require("./timeline"), module.exports);
|
|
|
182
182
|
__reExport(stdin_exports, require("./toast"), module.exports);
|
|
183
183
|
__reExport(stdin_exports, require("./uploader"), module.exports);
|
|
184
184
|
__reExport(stdin_exports, require("./video"), module.exports);
|
|
185
|
-
const version = "3.1.
|
|
185
|
+
const version = "3.1.78";
|
|
186
186
|
function install(app) {
|
|
187
187
|
const components = [
|
|
188
188
|
import_action_sheet.ActionSheet,
|
|
@@ -90,6 +90,7 @@ declare const mediaPickerProps: {
|
|
|
90
90
|
default: MediaSizeType;
|
|
91
91
|
};
|
|
92
92
|
mediaPlayerProps: PropType<Partial<MediaPlayerProps>>;
|
|
93
|
+
autoCheckFileType: BooleanConstructor;
|
|
93
94
|
};
|
|
94
95
|
export type MediaPickerProps = ExtractPropTypes<typeof mediaPickerProps>;
|
|
95
96
|
export type MediaPickerInstance = ComponentPublicInstance<{
|
|
@@ -183,6 +184,7 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
183
184
|
default: MediaSizeType;
|
|
184
185
|
};
|
|
185
186
|
mediaPlayerProps: PropType<Partial<MediaPlayerProps>>;
|
|
187
|
+
autoCheckFileType: BooleanConstructor;
|
|
186
188
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("delete" | "processing" | "update:mediaList")[], "delete" | "processing" | "update:mediaList", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
|
187
189
|
sortable: {
|
|
188
190
|
type: BooleanConstructor;
|
|
@@ -271,6 +273,7 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
271
273
|
default: MediaSizeType;
|
|
272
274
|
};
|
|
273
275
|
mediaPlayerProps: PropType<Partial<MediaPlayerProps>>;
|
|
276
|
+
autoCheckFileType: BooleanConstructor;
|
|
274
277
|
}>> & Readonly<{
|
|
275
278
|
onDelete?: ((...args: any[]) => any) | undefined;
|
|
276
279
|
onProcessing?: ((...args: any[]) => any) | undefined;
|
|
@@ -301,5 +304,6 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
301
304
|
allowPickFile: boolean;
|
|
302
305
|
useWx: boolean;
|
|
303
306
|
imageSizeType: MediaSizeType;
|
|
307
|
+
autoCheckFileType: boolean;
|
|
304
308
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
305
309
|
export default _default;
|
|
@@ -55,6 +55,7 @@ var import_utils = require("../utils");
|
|
|
55
55
|
var import_vue2 = require("vue");
|
|
56
56
|
var import_toast = require("../toast");
|
|
57
57
|
var import_DeleteIcon = __toESM(require("./image/DeleteIcon"));
|
|
58
|
+
var import_file_type = require("file-type");
|
|
58
59
|
var import_grid = __toESM(require("../grid"));
|
|
59
60
|
var import_grid_item = __toESM(require("../grid-item"));
|
|
60
61
|
var import_action_sheet = __toESM(require("../action-sheet"));
|
|
@@ -79,6 +80,17 @@ var import_use_expose = require("../composables/use-expose");
|
|
|
79
80
|
var import_sortablejs = __toESM(require("sortablejs"));
|
|
80
81
|
const [name, bem] = (0, import_utils.createNamespace)("media-picker");
|
|
81
82
|
const FILE_SIZE_LIMIT = 100;
|
|
83
|
+
const COMPATIBLE_TYPE_MAPPINGS = {
|
|
84
|
+
"mp3": /* @__PURE__ */ new Set(["mpga"]),
|
|
85
|
+
"mp4": /* @__PURE__ */ new Set(["qt"]),
|
|
86
|
+
"html": /* @__PURE__ */ new Set(["txt"]),
|
|
87
|
+
"json": /* @__PURE__ */ new Set(["txt"]),
|
|
88
|
+
"xml": /* @__PURE__ */ new Set(["txt"]),
|
|
89
|
+
"gif": /* @__PURE__ */ new Set(["png"]),
|
|
90
|
+
"jpeg": /* @__PURE__ */ new Set(["jpg"]),
|
|
91
|
+
"jpg": /* @__PURE__ */ new Set(["jpeg"]),
|
|
92
|
+
"m4a": /* @__PURE__ */ new Set(["mp4", "mp4a", "x-m4a"])
|
|
93
|
+
};
|
|
82
94
|
const mediaPickerProps = {
|
|
83
95
|
sortable: {
|
|
84
96
|
type: Boolean,
|
|
@@ -141,7 +153,9 @@ const mediaPickerProps = {
|
|
|
141
153
|
// 是否强制使用微信
|
|
142
154
|
useWx: Boolean,
|
|
143
155
|
imageSizeType: (0, import_utils.makeStringProp)("compressed"),
|
|
144
|
-
mediaPlayerProps: Object
|
|
156
|
+
mediaPlayerProps: Object,
|
|
157
|
+
// 是否自动检查文件类型(校验文件扩展名与实际文件头信息是否匹配)
|
|
158
|
+
autoCheckFileType: Boolean
|
|
145
159
|
};
|
|
146
160
|
var stdin_default = (0, import_vue2.defineComponent)({
|
|
147
161
|
name,
|
|
@@ -551,6 +565,32 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
|
551
565
|
if (!checkFileCountAfterAdd(files)) {
|
|
552
566
|
return;
|
|
553
567
|
}
|
|
568
|
+
if (props.autoCheckFileType) {
|
|
569
|
+
try {
|
|
570
|
+
for (const file of files) {
|
|
571
|
+
const buffer = yield file.slice(0, 4100).arrayBuffer();
|
|
572
|
+
const fileType = yield (0, import_file_type.fileTypeFromBuffer)(new Uint8Array(buffer));
|
|
573
|
+
const fileName = file.name.toLowerCase();
|
|
574
|
+
const extensionMatch = fileName.match(/\.([^.]+)$/);
|
|
575
|
+
const extension = extensionMatch ? extensionMatch[1] : "";
|
|
576
|
+
if (fileType && extension) {
|
|
577
|
+
if (fileType.ext !== extension) {
|
|
578
|
+
const compatibleTypes = COMPATIBLE_TYPE_MAPPINGS[extension];
|
|
579
|
+
const isCompatible = compatibleTypes && compatibleTypes.has(fileType.ext);
|
|
580
|
+
if (!isCompatible) {
|
|
581
|
+
(0, import_toast.showFailToast)({
|
|
582
|
+
message: `\u6587\u4EF6\u540E\u7F00\u4E0E\u5B9E\u9645\u6587\u4EF6\u7C7B\u578B\u4E0D\u5339\u914D\uFF1A${file.name}`,
|
|
583
|
+
duration: 5e3
|
|
584
|
+
});
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
} catch (error) {
|
|
591
|
+
console.error("\u6587\u4EF6\u7C7B\u578B\u6821\u9A8C\u5931\u8D25:", error);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
554
594
|
if (props.beforeRead) {
|
|
555
595
|
try {
|
|
556
596
|
const response = yield props.beforeRead(files);
|
|
@@ -76,6 +76,7 @@ export declare const MediaPicker: import("../utils").WithInstall<import("vue").D
|
|
|
76
76
|
default: import("./type").MediaSizeType;
|
|
77
77
|
};
|
|
78
78
|
mediaPlayerProps: import("vue").PropType<Partial<import("..").MediaPlayerProps>>;
|
|
79
|
+
autoCheckFileType: BooleanConstructor;
|
|
79
80
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("delete" | "processing" | "update:mediaList")[], "delete" | "processing" | "update:mediaList", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
80
81
|
sortable: {
|
|
81
82
|
type: BooleanConstructor;
|
|
@@ -154,6 +155,7 @@ export declare const MediaPicker: import("../utils").WithInstall<import("vue").D
|
|
|
154
155
|
default: import("./type").MediaSizeType;
|
|
155
156
|
};
|
|
156
157
|
mediaPlayerProps: import("vue").PropType<Partial<import("..").MediaPlayerProps>>;
|
|
158
|
+
autoCheckFileType: BooleanConstructor;
|
|
157
159
|
}>> & Readonly<{
|
|
158
160
|
onDelete?: ((...args: any[]) => any) | undefined;
|
|
159
161
|
onProcessing?: ((...args: any[]) => any) | undefined;
|
|
@@ -184,6 +186,7 @@ export declare const MediaPicker: import("../utils").WithInstall<import("vue").D
|
|
|
184
186
|
allowPickFile: boolean;
|
|
185
187
|
useWx: boolean;
|
|
186
188
|
imageSizeType: import("./type").MediaSizeType;
|
|
189
|
+
autoCheckFileType: boolean;
|
|
187
190
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
|
188
191
|
export default MediaPicker;
|
|
189
192
|
export type { MediaPickerProps, MediaPickerInstance } from './MediaPicker';
|