| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import { computed as i, ref as y, watch as U, resolveComponent as b, openBlock as k, createBlock as I, withCtx as S, createElementVNode as a, createVNode as m, unref as f } from "vue";
- import { n as B, a0 as F, a1 as N } from "./index2.js";
- const O = { class: "preview-content" }, $ = { class: "view-content" }, M = ["src"], P = {
- __name: "SFilePreview",
- props: {
- /**
- * 是否显示,配合 v-model:value 使用
- */
- value: {
- type: Boolean,
- default: !1
- },
- /**
- * 文件列表,用于左右翻页
- */
- list: {
- type: Array,
- default: () => []
- },
- /**
- * 初始预览项下标,弹窗打开时生效
- */
- active: {
- type: Number,
- default: 0
- },
- /**
- * 自定义标题,为空时取文件名
- */
- title: {
- type: String,
- default: ""
- }
- },
- emits: ["update:value", "change"],
- setup(_, { emit: w }) {
- const n = _, u = w, r = i({
- get: () => n.value,
- set: (t) => u("update:value", t)
- }), g = (t = {}) => t.imageUrl || t.url || t.uid || "", x = (t = "") => {
- const e = String(t).split("?")[0].split("#")[0], s = e.substring(e.lastIndexOf("/") + 1);
- try {
- return decodeURIComponent(s);
- } catch (o) {
- return s;
- }
- }, l = y(0), c = (t) => {
- const e = (n.list || []).length;
- return e ? Math.min(Math.max(t, 0), e - 1) : 0;
- };
- U(
- () => n.value,
- (t) => {
- t && (l.value = c(n.active));
- },
- { immediate: !0 }
- );
- const v = i(() => (n.list || [])[l.value] || {}), d = i(() => g(v.value)), h = i(
- () => n.title || v.value.name || x(d.value) || window.$l("预览")
- ), p = (t) => {
- const e = c(l.value + t);
- e !== l.value && (l.value = e, u("change", e));
- }, C = () => {
- r.value = !1;
- };
- return (t, e) => {
- const s = b("s-modal");
- return k(), I(s, {
- value: r.value,
- "onUpdate:value": e[2] || (e[2] = (o) => r.value = o),
- title: h.value,
- width: "800px",
- onHandCancel: C
- }, {
- default: S(() => [
- a("div", O, [
- a("div", {
- class: "prev",
- onClick: e[0] || (e[0] = (o) => p(-1))
- }, [
- m(f(F))
- ]),
- a("div", $, [
- a("img", {
- alt: "preview",
- class: "view",
- src: d.value
- }, null, 8, M)
- ]),
- a("div", {
- class: "next",
- onClick: e[1] || (e[1] = (o) => p(1))
- }, [
- m(f(N))
- ])
- ])
- ]),
- _: 1
- }, 8, ["value", "title"]);
- };
- }
- }, A = /* @__PURE__ */ B(P, [["__scopeId", "data-v-58b32905"]]);
- export {
- A as default
- };
|