This commit is contained in:
2024-10-16 15:13:17 +08:00
parent 0c04f452ee
commit c7f2091874
8 changed files with 1223 additions and 1509 deletions

View File

@@ -54,7 +54,8 @@ const _sfc_main = defineComponent({
dragText: null,
modelValue: { default: null },
auto: { type: Boolean, default: true },
sizeOutMsg: null
sizeOutMsg: null,
quality: null
},
emits: [
"choose",
@@ -68,6 +69,24 @@ const _sfc_main = defineComponent({
],
setup(__props, { emit }) {
const props = __props;
function imgcomp(file) {
return new Promise((resolve, reject) => {
var options = {
file,
quality: 0.6,
mimeType: "image/jpeg",
maxWidth: 2e3,
maxHeight: 2e3,
convertSize: Infinity,
loose: true,
redressOrientation: true,
success: function(result) {
resolve(result);
}
};
new ImageCompressor(options);
});
}
const getCutDownResult = () => {
if (_cropper) {
const canvas = _cropper.getCroppedCanvas();
@@ -164,7 +183,7 @@ const _sfc_main = defineComponent({
computedCutLayerOption = computed(() => defaultCutLayerOption.value);
}
const innerCutVisible = ref(false);
const localUploadTransaction = (option) => {
const localUploadTransaction = async (option) => {
const { url, files } = option;
let formData = new FormData();
if (url.length <= 5) {
@@ -174,7 +193,8 @@ const _sfc_main = defineComponent({
if (Array.isArray(files) && files.length > 0) {
for (let i = 0; i < files.length; i++) {
let _file = files[i];
formData.append(props.field + "[" + i + "]", _file);
let f = await imgcomp(_file);
formData.append(props.field + "[" + i + "]", f);
}
}
if (props.data && props.data instanceof Object) {