zartui 3.1.77 → 3.1.79
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.mjs +38 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/media-picker/MediaPicker.js +38 -0
- package/lib/web-types.json +1 -1
- package/lib/zartui.cjs.js +39 -1
- package/lib/zartui.es.js +39 -1
- package/lib/zartui.js +3418 -13
- package/lib/zartui.min.js +2 -2
- package/package.json +7 -6
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.79";
|
|
81
81
|
function install(app) {
|
|
82
82
|
const components = [
|
|
83
83
|
ActionSheet,
|
|
@@ -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,
|
|
@@ -519,6 +531,32 @@ var stdin_default = defineComponent({
|
|
|
519
531
|
if (!checkFileCountAfterAdd(files)) {
|
|
520
532
|
return;
|
|
521
533
|
}
|
|
534
|
+
if (props.keepFileType) {
|
|
535
|
+
try {
|
|
536
|
+
for (const file of files) {
|
|
537
|
+
const buffer = yield file.slice(0, 4100).arrayBuffer();
|
|
538
|
+
const fileType = yield fileTypeFromBuffer(new Uint8Array(buffer));
|
|
539
|
+
const fileName = file.name.toLowerCase();
|
|
540
|
+
const extensionMatch = fileName.match(/\.([^.]+)$/);
|
|
541
|
+
const extension = extensionMatch ? extensionMatch[1] : "";
|
|
542
|
+
if (fileType && extension) {
|
|
543
|
+
if (fileType.ext !== extension) {
|
|
544
|
+
const compatibleTypes = COMPATIBLE_TYPE_MAPPINGS[extension];
|
|
545
|
+
const isCompatible = compatibleTypes && compatibleTypes.has(fileType.ext);
|
|
546
|
+
if (!isCompatible) {
|
|
547
|
+
showFailToast({
|
|
548
|
+
message: `\u6587\u4EF6\u540E\u7F00\u4E0E\u5B9E\u9645\u6587\u4EF6\u7C7B\u578B\u4E0D\u5339\u914D\uFF1A${file.name}`,
|
|
549
|
+
duration: 5e3
|
|
550
|
+
});
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
} catch (error) {
|
|
557
|
+
console.error("\u6587\u4EF6\u7C7B\u578B\u6821\u9A8C\u5931\u8D25:", error);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
522
560
|
if (props.beforeRead) {
|
|
523
561
|
try {
|
|
524
562
|
const response = yield props.beforeRead(files);
|
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.79";
|
|
186
186
|
function install(app) {
|
|
187
187
|
const components = [
|
|
188
188
|
import_action_sheet.ActionSheet,
|
|
@@ -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,
|
|
@@ -551,6 +563,32 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
|
551
563
|
if (!checkFileCountAfterAdd(files)) {
|
|
552
564
|
return;
|
|
553
565
|
}
|
|
566
|
+
if (props.keepFileType) {
|
|
567
|
+
try {
|
|
568
|
+
for (const file of files) {
|
|
569
|
+
const buffer = yield file.slice(0, 4100).arrayBuffer();
|
|
570
|
+
const fileType = yield (0, import_file_type.fileTypeFromBuffer)(new Uint8Array(buffer));
|
|
571
|
+
const fileName = file.name.toLowerCase();
|
|
572
|
+
const extensionMatch = fileName.match(/\.([^.]+)$/);
|
|
573
|
+
const extension = extensionMatch ? extensionMatch[1] : "";
|
|
574
|
+
if (fileType && extension) {
|
|
575
|
+
if (fileType.ext !== extension) {
|
|
576
|
+
const compatibleTypes = COMPATIBLE_TYPE_MAPPINGS[extension];
|
|
577
|
+
const isCompatible = compatibleTypes && compatibleTypes.has(fileType.ext);
|
|
578
|
+
if (!isCompatible) {
|
|
579
|
+
(0, import_toast.showFailToast)({
|
|
580
|
+
message: `\u6587\u4EF6\u540E\u7F00\u4E0E\u5B9E\u9645\u6587\u4EF6\u7C7B\u578B\u4E0D\u5339\u914D\uFF1A${file.name}`,
|
|
581
|
+
duration: 5e3
|
|
582
|
+
});
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
} catch (error) {
|
|
589
|
+
console.error("\u6587\u4EF6\u7C7B\u578B\u6821\u9A8C\u5931\u8D25:", error);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
554
592
|
if (props.beforeRead) {
|
|
555
593
|
try {
|
|
556
594
|
const response = yield props.beforeRead(files);
|