UNPKG

@glodon-aiot/react-components

Version:

aiot react components

66 lines (65 loc) 2.02 kB
var w = Object.defineProperty, k = Object.defineProperties; var I = Object.getOwnPropertyDescriptors; var f = Object.getOwnPropertySymbols; var y = Object.prototype.hasOwnProperty, M = Object.prototype.propertyIsEnumerable; var d = (e, t, i) => t in e ? w(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, r = (e, t) => { for (var i in t || (t = {})) y.call(t, i) && d(e, i, t[i]); if (f) for (var i of f(t)) M.call(t, i) && d(e, i, t[i]); return e; }, a = (e, t) => k(e, I(t)); import { jsx as m, jsxs as V, Fragment as b } from "react/jsx-runtime"; import { Image as h } from "antd"; import { ImageViewer as x } from "antd-mobile"; import { useState as s, useEffect as C } from "react"; import { isMobile as v } from "react-device-detect"; import T from "../Video/index.mjs"; import { checkMediaType as j } from "../../../utils/markdown/index.mjs"; const E = (e) => { const [t, i] = s(!1), [g, u] = s(); return C(() => { e.src && u(j(e.src)); }, [e.src]), g == "video" ? /* @__PURE__ */ m(T, { src: e.src, controls: !0 }) : v ? /* @__PURE__ */ V(b, { children: [/* @__PURE__ */ m("img", r({ style: { maxWidth: "100%" }, src: e == null ? void 0 : e.src, onClick: () => { i(!0); } }, e)), /* @__PURE__ */ m(x, { image: (e == null ? void 0 : e.src) || "", visible: t, onClose: () => { i(!1); } })] }) : /* @__PURE__ */ m(h, a(r({ style: { maxWidth: "100%" }, preview: { // 强制挂载到 body,解决 transform 包含块问题 getContainer: () => document.body } }, e), { onClick: (n) => { var c, o, l; (l = e.onClick) == null || l.call(e, a(r({}, n), { target: (o = (c = n.target) == null ? void 0 : c.offsetParent) == null ? void 0 : o.children[0] })); }, onError: () => { console.log(e), console.warn("图片加载失败"); } })); }, B = E; export { B as default };