UNPKG

quick-admin-vue3-core

Version:

以快(计算机执行效率、开发效率)为核心的后台管理系统开发模板

62 lines (61 loc) 2.06 kB
import { defineComponent as h, computed as k, resolveComponent as p, createBlock as m, openBlock as s, withCtx as u, createElementBlock as U, createVNode as V, unref as x } from "vue"; import { a as j } from "./avatar-s8MIdAJl.js"; import { b as d } from "./platform-DsTwHxm6.js"; import { n as w } from "./index-D-KS7NhM.js"; import { _ as y } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const z = ["src"], B = /* @__PURE__ */ h({ __name: "UploadAvatar", props: { modelValue: { default: j }, accepts: { default: () => ["image/png", "image/jpeg"] }, maxSize: { default: 1 } }, emits: ["update:modelValue"], setup(i, { emit: f }) { const c = i, r = f, l = k({ get: () => c.modelValue, set: (e) => r("update:modelValue", e) }), _ = (e, t) => { r("update:modelValue", URL.createObjectURL(t.raw)); }, g = (e) => { const { type: t, size: a } = e, { accepts: o, maxSize: n } = c; if (!o.includes(t)) { const v = o.map((b) => b.split("/")[1]).join(","); return d(`请上传 ${v} 格式的图片!`, "error"), !1; } return a / 1024 / 1024 > n ? (d(`图片大小不能超过 ${n}MB!`, "error"), !1) : !0; }; return (e, t) => { const a = p("el-icon"), o = p("el-upload"); return s(), m(o, { class: "upload-avatar f-c-c", action: "https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15", "show-file-list": !1, "on-success": _, "before-upload": g, accept: e.accepts.join(",") }, { default: u(() => [ l.value ? (s(), U("img", { key: 0, src: l.value, class: "img" }, null, 8, z)) : (s(), m(a, { key: 1, name: "Plus", size: "32" }, { default: u(() => [ V(x(w)) ]), _: 1 })) ]), _: 1 }, 8, ["accept"]); }; } }), L = /* @__PURE__ */ y(B, [["__scopeId", "data-v-eb62b1f3"]]); export { L as U };