This commit is contained in:
theluyuan 2024-10-16 15:24:01 +08:00
parent c7f2091874
commit 6a15bbb2e0
10 changed files with 734 additions and 212 deletions

View File

@ -172,11 +172,13 @@ function triggerRefValue(ref, newVal) {
}
}
}
var _a;
class ComputedRefImpl {
constructor(getter, _setter, isReadonly, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__v_isRef = true;
this[_a] = false;
this._dirty = true;
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
@ -201,6 +203,7 @@ class ComputedRefImpl {
this._setter(newValue);
}
}
_a = "__v_isReadonly";
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;

View File

@ -1,15 +1,15 @@
import { getCurrentScope, onScopeDispose, computed, toRefs, getCurrentInstance, onMounted, nextTick, ref, unref, isRef, reactive, watch, customRef, onUpdated } from "vue";
var _a$1;
const isClient$1 = typeof window !== "undefined";
const toString$1 = Object.prototype.toString;
var _a;
const isClient = typeof window !== "undefined";
const toString = Object.prototype.toString;
const isFunction = (val) => typeof val === "function";
const isNumber = (val) => typeof val === "number";
const isString = (val) => typeof val === "string";
const isObject$1 = (val) => toString$1.call(val) === "[object Object]";
const isObject = (val) => toString.call(val) === "[object Object]";
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
const noop = () => {
};
isClient$1 && ((_a$1 = window == null ? void 0 : window.navigator) == null ? void 0 : _a$1.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
function resolveUnref(r) {
return typeof r === "function" ? r() : unref(r);
}
@ -141,7 +141,7 @@ function useTimeoutFn(cb, interval, options = {}) {
}
if (immediate) {
isPending.value = true;
if (isClient$1)
if (isClient)
start();
}
tryOnScopeDispose(stop);
@ -156,7 +156,7 @@ function unrefElement(elRef) {
const plain = resolveUnref(elRef);
return (_a2 = plain == null ? void 0 : plain.$el) != null ? _a2 : plain;
}
const defaultWindow = isClient$1 ? window : void 0;
const defaultWindow = isClient ? window : void 0;
function useEventListener(...args) {
let target;
let event;
@ -561,9 +561,4 @@ function useWindowSize(options = {}) {
useEventListener("orientationchange", update, { passive: true });
return { width, height };
}
var _a;
const isClient = typeof window !== "undefined";
const toString = Object.prototype.toString;
const isObject = (val) => toString.call(val) === "[object Object]";
isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
export { TransitionPresets as T, useResizeObserver as a, useThrottleFn as b, useEventListener as c, useEyeDropper as d, useTransition as e, useMousePressed as f, isObject as g, isObject$1 as i, onClickOutside as o, reactiveOmit as r, templateRef as t, useWindowSize as u };
export { TransitionPresets as T, useResizeObserver as a, useThrottleFn as b, useEventListener as c, useEyeDropper as d, useTransition as e, useMousePressed as f, isObject as i, onClickOutside as o, reactiveOmit as r, templateRef as t, useWindowSize as u };

View File

@ -0,0 +1,261 @@
var jsImageCompressor = { exports: {} };
var imageCompressor_min = { exports: {} };
(function(module, exports) {
!function(e, t) {
module.exports = t();
}(window, function() {
return function(e) {
var t = {};
function n(r) {
if (t[r])
return t[r].exports;
var a = t[r] = { i: r, l: false, exports: {} };
return e[r].call(a.exports, a, a.exports, n), a.l = true, a.exports;
}
return n.m = e, n.c = t, n.d = function(e2, t2, r) {
n.o(e2, t2) || Object.defineProperty(e2, t2, { enumerable: true, get: r });
}, n.r = function(e2) {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e2, "__esModule", { value: true });
}, n.t = function(e2, t2) {
if (1 & t2 && (e2 = n(e2)), 8 & t2)
return e2;
if (4 & t2 && "object" == typeof e2 && e2 && e2.__esModule)
return e2;
var r = /* @__PURE__ */ Object.create(null);
if (n.r(r), Object.defineProperty(r, "default", { enumerable: true, value: e2 }), 2 & t2 && "string" != typeof e2)
for (var a in e2)
n.d(r, a, function(t3) {
return e2[t3];
}.bind(null, a));
return r;
}, n.n = function(e2) {
var t2 = e2 && e2.__esModule ? function() {
return e2.default;
} : function() {
return e2;
};
return n.d(t2, "a", t2), t2;
}, n.o = function(e2, t2) {
return Object.prototype.hasOwnProperty.call(e2, t2);
}, n.p = "", n(n.s = 0);
}([function(e, t, n) {
n.r(t);
var r = window, a = /^image\//, i = /\.\w+$/, o = {}, s = { file: null, quality: 0.8, convertSize: 2048e3, loose: true, redressOrientation: true }, f = function(e2) {
return "function" == typeof e2;
}, c = function(e2) {
return a.test(e2);
};
function l(e2) {
e2 = Object.assign({}, s, e2), this.options = e2, this.file = e2.file, this.image = null, this.ParsedOrientationInfo = null, this.init();
}
var u = l.prototype;
for (var h in t.default = l, u.init = function() {
var e2 = this, t2 = this.file, n2 = this.options;
t2 && c(t2.type) ? (c(n2.mimeType) || (n2.mimeType = t2.type), o.file2Image(t2, function(r2) {
f(e2.beforeCompress) && (e2.image = r2, t2.width = r2.naturalWidth, t2.height = r2.naturalHeight, e2.beforeCompress(t2)), "image/jpeg" === t2.type && n2.redressOrientation ? e2.getParsedOrientationInfo(function(t3) {
e2.parsedOrientationInfo = t3, e2.rendCanvas();
}) : (e2.parsedOrientationInfo = { rotate: 0, scaleX: 1, scaleY: 1 }, e2.rendCanvas());
}, e2.error)) : e2.error("\u8BF7\u4E0A\u4F20\u56FE\u7247\u6587\u4EF6!");
}, u.rendCanvas = function() {
var e2 = this, t2 = this.options, n2 = this.image, r2 = this.getExpectedEdge(), a2 = r2.dWidth, i2 = r2.dHeight, s2 = r2.width, f2 = r2.height, c2 = o.image2Canvas(n2, a2, i2, e2.beforeDraw.bind(e2), e2.afterDraw.bind(e2), s2, f2);
o.canvas2Blob(c2, function(t3) {
t3 && (t3.width = c2.width, t3.height = c2.height), e2.success(t3);
}, t2.quality, t2.mimeType);
}, u.beforeCompress = function() {
f(this.options.beforeCompress) && this.options.beforeCompress(this.file);
}, u.getExpectedEdge = function() {
var e2, t2 = this.image, n2 = this.parsedOrientationInfo.rotate, r2 = this.options, a2 = t2.naturalWidth, i2 = t2.naturalHeight, o2 = Math.abs(n2) % 180 == 90;
o2 && (e2 = i2, i2 = a2, a2 = e2);
var s2 = a2 / i2, f2 = Math.max(r2.maxWidth, 0) || 1 / 0, c2 = Math.max(r2.maxHeight, 0) || 1 / 0, l2 = Math.max(r2.minWidth, 0) || 0, u2 = Math.max(r2.minHeight, 0) || 0, h2 = Math.max(r2.width, 0) || a2, d = Math.max(r2.height, 0) || i2;
f2 < 1 / 0 && c2 < 1 / 0 ? c2 * s2 > f2 ? c2 = f2 / s2 : f2 = c2 * s2 : f2 < 1 / 0 ? c2 = f2 / s2 : c2 < 1 / 0 && (f2 = c2 * s2), l2 > 0 && u2 > 0 ? u2 * s2 > l2 ? u2 = l2 / s2 : l2 = u2 * s2 : l2 > 0 ? u2 = l2 / s2 : u2 > 0 && (l2 = u2 * s2), d * s2 > h2 ? d = h2 / s2 : h2 = d * s2;
var g = h2 = Math.floor(Math.min(Math.max(h2, l2), f2)), p = d = Math.floor(Math.min(Math.max(d, u2), c2));
return o2 && (e2 = p, p = g, g = e2), { dWidth: g, dHeight: p, width: h2, height: d };
}, u.getParsedOrientationInfo = function(e2) {
var t2 = this;
this.getOrientation(function(n2) {
f(e2) && e2(t2.parseOrientation(n2));
});
}, u.getOrientation = function(e2) {
var t2 = this;
o.file2ArrayBuffer(this.file, function(n2) {
f(e2) && e2(t2.resetAndGetOrientation(n2));
});
}, u.resetAndGetOrientation = function(e2) {
var t2, n2 = new DataView(e2);
try {
var r2, a2, i2;
if (255 === n2.getUint8(0) && 216 === n2.getUint8(1))
for (var s2 = n2.byteLength, f2 = 2; f2 + 1 < s2; ) {
if (255 === n2.getUint8(f2) && 225 === n2.getUint8(f2 + 1)) {
a2 = f2;
break;
}
f2 += 1;
}
if (a2) {
var c2 = a2 + 4, l2 = a2 + 10;
if ("Exif" === o.getStringFromCharCode(n2, c2, 4)) {
var u2 = n2.getUint16(l2);
if (((r2 = 18761 === u2) || 19789 === u2) && 42 === n2.getUint16(l2 + 2, r2)) {
var h2 = n2.getUint32(l2 + 4, r2);
h2 >= 8 && (i2 = l2 + h2);
}
}
}
if (i2) {
var d;
s2 = n2.getUint16(i2, r2);
for (d = 0; d < s2; d += 1)
if (f2 = i2 + 12 * d + 2, 274 === n2.getUint16(f2, r2)) {
f2 += 8, t2 = n2.getUint16(f2, r2), n2.setUint16(f2, 1, r2);
break;
}
}
} catch (e3) {
console.error(e3), t2 = 1;
}
return t2;
}, u.parseOrientation = function(e2) {
var t2 = 0, n2 = 1, r2 = 1;
switch (e2) {
case 2:
n2 = -1;
break;
case 3:
t2 = -180;
break;
case 4:
r2 = -1;
break;
case 5:
t2 = 90, r2 = -1;
break;
case 6:
t2 = 90;
break;
case 7:
t2 = 90, n2 = -1;
break;
case 8:
t2 = -90;
}
return { rotate: t2, scaleX: n2, scaleY: r2 };
}, u.beforeDraw = function(e2, t2) {
var n2 = this.parsedOrientationInfo, r2 = n2.rotate, a2 = n2.scaleX, i2 = n2.scaleY, o2 = this.file, s2 = this.options, c2 = "transparent", l2 = t2.width, u2 = t2.height;
switch (o2.size > s2.convertSize && "image/png" === s2.mimeType && (c2 = "#fff", s2.mimeType = "image/jpeg"), e2.fillStyle = c2, e2.fillRect(0, 0, l2, u2), f(s2.beforeDraw) && s2.beforeDraw.call(this, e2, t2), e2.save(), r2) {
case 90:
e2.translate(l2, 0);
break;
case -90:
e2.translate(0, u2);
break;
case -180:
e2.translate(l2, u2);
}
e2.rotate(r2 * Math.PI / 180), e2.scale(a2, i2);
}, u.afterDraw = function(e2, t2) {
var n2 = this.options;
f(n2.afterDraw) && n2.afterDraw.call(this, e2, t2);
}, u.error = function(e2) {
var t2 = this.options;
if (!f(t2.error))
throw new Error(e2);
t2.error.call(this, e2);
}, u.success = function(e2) {
var t2, n2, r2 = this.options, a2 = this.file, o2 = this.image, s2 = this.getExpectedEdge(), l2 = o2.naturalHeight, u2 = o2.naturalWidth;
if (e2 && e2.size)
if (!r2.loose && e2.size > a2.size && !(s2.width > u2 || s2.height > l2))
console.warn("\u5F53\u524D\u8BBE\u7F6E\u7684\u662F\u975E\u5BBD\u677E\u6A21\u5F0F\uFF0C\u538B\u7F29\u7ED3\u679C\u5927\u4E8E\u6E90\u56FE\u7247\uFF0C\u8F93\u51FA\u6E90\u56FE\u7247"), e2 = a2;
else {
var h2 = new Date();
e2.lastModified = h2.getTime(), e2.lastModifiedDate = h2, e2.name = a2.name, e2.name && e2.type !== a2.type && (e2.name = e2.name.replace(i, (t2 = e2.type, "jpeg" === (n2 = c(t2) ? t2.substr(6) : "") && (n2 = "jpg"), "." + n2)));
}
else
console.warn("\u56FE\u7247\u538B\u7F29\u51FA\u4E86\u70B9\u610F\u5916\uFF0C\u8F93\u51FA\u6E90\u56FE\u7247"), e2 = a2;
f(r2.success) && r2.success.call(this, e2);
}, o.file2DataUrl = function(e2, t2, n2) {
var r2 = new FileReader();
r2.onload = function() {
t2(r2.result);
}, r2.onerror = function() {
f(n2) && n2("\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF01");
}, r2.readAsDataURL(e2);
}, o.file2ArrayBuffer = function(e2, t2, n2) {
var r2 = new FileReader();
r2.onload = function(e3) {
t2(e3.target.result);
}, r2.onerror = function() {
f(n2) && n2("\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF01");
}, r2.readAsArrayBuffer(e2);
}, o.getStringFromCharCode = function(e2, t2, n2) {
var r2, a2 = "";
for (n2 += t2, r2 = t2; r2 < n2; r2 += 1)
a2 += String.fromCharCode(e2.getUint8(r2));
return a2;
}, o.file2Image = function(e2, t2, n2) {
var a2 = new Image(), i2 = r.URL || r.webkitURL;
if (r.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(r.navigator.userAgent) && (a2.crossOrigin = "anonymous"), a2.alt = e2.name, a2.onerror = function() {
f(n2) && n2("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01");
}, i2) {
var o2 = i2.createObjectURL(e2);
a2.onload = function() {
t2(a2), i2.revokeObjectURL(o2);
}, a2.src = o2;
} else
this.file2DataUrl(e2, function(e3) {
a2.onload = function() {
t2(a2);
}, a2.src = e3;
}, n2);
}, o.url2Image = function(e2, t2, n2) {
var r2 = new Image();
r2.src = e2, r2.onload = function() {
t2(r2);
}, r2.onerror = function() {
f(n2) && n2("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01");
};
}, o.image2Canvas = function(e2, t2, n2, r2, a2, i2, o2) {
var s2 = document.createElement("canvas"), c2 = s2.getContext("2d");
return s2.width = i2 || e2.naturalWidth, s2.height = o2 || e2.naturalHeight, f(r2) && r2(c2, s2), c2.save(), c2.drawImage(e2, 0, 0, t2, n2), c2.restore(), f(a2) && a2(c2, s2), s2;
}, o.canvas2DataUrl = function(e2, t2, n2) {
return e2.toDataURL(n2 || "image/jpeg", t2);
}, o.dataUrl2Image = function(e2, t2, n2) {
var r2 = new Image();
r2.onload = function() {
t2(r2);
}, r2.error = function() {
f(n2) && n2("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01");
}, r2.src = e2;
}, o.dataUrl2Blob = function(e2, t2) {
for (var n2 = e2.split(",")[1], r2 = e2.match(/^data:(.*?)(;base64)?,/)[1], a2 = atob(n2), i2 = n2.length, o2 = new Uint8Array(i2), s2 = 0; s2 < i2; s2++)
o2[s2] = a2.charCodeAt(s2);
return new Blob([o2], { type: t2 || r2 });
}, o.blob2DataUrl = function(e2, t2, n2) {
this.file2DataUrl(e2, t2, n2);
}, o.blob2Image = function(e2, t2, n2) {
this.file2Image(e2, t2, n2);
}, o.canvas2Blob = function(e2, t2, n2, r2) {
var a2 = this;
HTMLCanvasElement.prototype.toBlob || Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", { value: function(e3, t3, n3) {
var r3 = this.toDataURL(t3, n3);
e3(a2.dataUrl2Blob(r3));
} }), e2.toBlob(function(e3) {
t2(e3);
}, r2 || "image/jpeg", n2 || 0.8);
}, o.upload = function(e2, t2, n2) {
var r2 = new XMLHttpRequest(), a2 = new FormData();
a2.append("file", t2), r2.onreadystatechange = function() {
if (4 !== r2.readyState || 200 !== r2.status)
throw new Error(r2);
n2 && n2(r2.responseText);
}, r2.open("POST", e2, true), r2.send(a2);
}, o)
o.hasOwnProperty(h) && (l[h] = o[h]);
}]).default;
});
})(imageCompressor_min);
{
jsImageCompressor.exports = imageCompressor_min.exports;
}
var ImageCompressor = jsImageCompressor.exports;
export { ImageCompressor as I };

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
import { w as withInstall } from "../badge/index2.js";
import { defineComponent, ref, computed, watch, openBlock, createElementBlock, createElementVNode, normalizeClass, unref, createVNode, createCommentVNode, toDisplayString } from "vue";
import { _ as _sfc_main$2W } from "../_chunks/@layui/index.js";
import { g as isObject } from "../_chunks/@vueuse/index.js";
import { i as isObject } from "../_chunks/@vueuse/index.js";
var index = /* @__PURE__ */ (() => ":root{--textarea-border-radius: var(--global-border-radius);--textarea-border-color: var(--global-neutral-color-3)}.layui-textarea{border-width:1px;border-style:solid;background-color:#fff;color:#000000d9;border-radius:var(--textarea-border-radius);border-color:var(--textarea-border-color);display:block;width:100%;height:auto;line-height:20px;min-height:100px;padding:6px 10px;resize:vertical;position:relative;transition:none;-webkit-transition:none}.layui-textarea-wrapper{position:relative}.layui-textarea:hover,.layui-textarea:focus{border-color:#d2d2d2!important}.layui-textarea-clear{position:absolute;color:#00000073;right:10px;top:10px}.layui-textarea::-webkit-input-placeholder{line-height:1.3}.layui-texterea-count{color:inherit;white-space:nowrap;pointer-events:none;text-align:right;margin-top:4px}.layui-textarea-disabled{cursor:not-allowed!important;opacity:.6}\n")();
const _hoisted_1 = { class: "layui-textarea-wrapper" };
const _hoisted_2 = ["value", "placeholder", "name", "disabled", "maxlength"];

View File

@ -1,5 +1,6 @@
import { w as withInstall } from "../badge/index2.js";
import { defineComponent, computed, useSlots, getCurrentInstance, watch, ref, onMounted, nextTick, onUnmounted, openBlock, createElementBlock, normalizeClass, createElementVNode, withModifiers, unref, renderSlot, createBlock, withCtx, createTextVNode, toDisplayString, createVNode, Fragment, renderList } from "vue";
import { I as ImageCompressor } from "../_chunks/js-image-compressor/index.js";
import { a as _sfc_main$2, l as layer } from "../_chunks/@layui/index.js";
import { t as templateRef } from "../_chunks/@vueuse/index.js";
import { _ as _sfc_main$1 } from "../button/index2.js";

File diff suppressed because one or more lines are too long

View File

@ -43,6 +43,7 @@
"cropperjs": "^1.5.12",
"dayjs": "^1.11.0",
"evtd": "^0.2.3",
"js-image-compressor": "^2.0.0",
"vue-i18n": "^9.1.10",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.0/xlsx-0.20.0.tgz"
},

View File

@ -4,6 +4,8 @@ export default {
};
</script>
<script lang="ts" setup>
// @ts-ignore
import ImageCompressor from "js-image-compressor";
import "./index.less";
import { Recordable } from "../../types";
import { layer } from "@layui/layer-vue";
@ -77,7 +79,7 @@ export interface UploadProps {
quality?: number;
}
function imgcomp(file: File) {
function imgcomp(file: any) {
return new Promise((resolve, reject) => {
var options = {
file: file,
@ -88,7 +90,7 @@ function imgcomp(file: File) {
convertSize: Infinity,
loose: true,
redressOrientation: true,
success: function (result) {
success: function (result: any) {
resolve(result);
},
};

File diff suppressed because one or more lines are too long