@cmstops/pro-compo
Version:
[物料平台文档中心](https://arco.design/docs/material/guide)
200 lines (199 loc) • 9.51 kB
JavaScript
import { defineComponent, toRef, onMounted, openBlock, createElementBlock, createElementVNode, createVNode, unref, withModifiers, withCtx, Fragment, createCommentVNode, createTextVNode, toDisplayString, isRef, renderList, createBlock } from "vue";
import { Spin, Link, Button, Select, Option } from "@arco-design/web-vue";
import { IconClose } from "@arco-design/web-vue/es/icon";
import { DEFAULT_BASE_API } from "../config.js";
import _sfc_main$1 from "./components/PreviewIframe.js";
import { useDocPreview, EXPIRE_TIME_OPTIONS } from "./scripts/hook.js";
const _hoisted_1 = { class: "preview-close" };
const _hoisted_2 = { class: "doc-preview-share-img" };
const _hoisted_3 = ["src"];
const _hoisted_4 = { class: "doc-preview-share-header" };
const _hoisted_5 = { class: "doc-preview-share-link" };
const _hoisted_6 = { class: "doc-preview-share-link-value" };
const _hoisted_7 = { class: "doc-preview-share-link-hint" };
const _hoisted_8 = { class: "doc-preview-share-action" };
const _hoisted_9 = { class: "doc-preview-share-header" };
const _hoisted_10 = { class: "doc-preview-share-link" };
const _hoisted_11 = { class: "doc-preview-share-link-value" };
const _hoisted_12 = { class: "doc-preview-share-header" };
const _hoisted_13 = { class: "doc-preview-share-action" };
const _sfc_main = defineComponent({
...{ name: "docPreview" },
__name: "component",
props: {
BASE_API: {},
hashid: {},
docInfo: {}
},
emits: ["close"],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const BASE_API = props.BASE_API || DEFAULT_BASE_API;
const {
genQrCode,
generate,
cancel,
copy,
shareData,
innerUrl,
expireTime,
intervalTime,
loading,
isPublish
} = useDocPreview(BASE_API, toRef(props, "hashid"));
onMounted(() => {
if (props.docInfo && [14, 15].includes(props.docInfo.state)) {
if (props.docInfo.share_link) {
genQrCode(props.docInfo.share_link, "qr-code-is-pub");
return;
}
}
generate();
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
class: "doc-preview-container",
onClick: _cache[7] || (_cache[7] = ($event) => emits("close"))
}, [
createElementVNode("div", _hoisted_1, [
createVNode(unref(IconClose), {
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => emits("close"), ["stop"]))
})
]),
_cache[21] || (_cache[21] = createElementVNode("div", { class: "doc-preview-share" }, null, -1)),
createVNode(_sfc_main$1, {
src: unref(innerUrl),
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
}, ["stop"]))
}, null, 8, ["src"]),
createVNode(unref(Spin), { loading: unref(loading) }, {
default: withCtx(() => [
createElementVNode("div", {
class: "doc-preview-share",
onClick: _cache[6] || (_cache[6] = withModifiers(() => {
}, ["stop"]))
}, [
unref(shareData) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
createCommentVNode(" \u4E8C\u7EF4\u7801 "),
createElementVNode("div", _hoisted_2, [
createElementVNode("img", {
src: unref(shareData).qrCode,
alt: ""
}, null, 8, _hoisted_3)
]),
createCommentVNode(" \u5907\u6CE8 "),
_cache[12] || (_cache[12] = createElementVNode("div", { class: "doc-preview-share-tips" }, "\u626B\u63CF\u4E8C\u7EF4\u7801\u8BBF\u95EE", -1)),
createCommentVNode(" \u94FE\u63A5\u524D\u7F6E\u64CD\u4F5C "),
createElementVNode("div", _hoisted_4, [
_cache[9] || (_cache[9] = createElementVNode("span", null, "\u9884\u89C8\u5730\u5740", -1)),
createVNode(unref(Link), {
type: "text",
onClick: unref(copy)
}, {
default: withCtx(() => _cache[8] || (_cache[8] = [
createTextVNode(" \u590D\u5236\u94FE\u63A5 ")
])),
_: 1,
__: [8]
}, 8, ["onClick"])
]),
createCommentVNode(" \u94FE\u63A5 "),
createElementVNode("div", _hoisted_5, [
createElementVNode("div", _hoisted_6, toDisplayString(unref(shareData).shareUrl), 1),
createElementVNode("div", _hoisted_7, " \u94FE\u63A5\u5269\u4F59\u65F6\u95F4\uFF1A" + toDisplayString(unref(intervalTime)), 1)
]),
createCommentVNode(" \u64CD\u4F5C "),
createElementVNode("div", _hoisted_8, [
createVNode(unref(Button), {
onClick: _cache[2] || (_cache[2] = ($event) => unref(cancel)())
}, {
default: withCtx(() => _cache[10] || (_cache[10] = [
createTextVNode("\u53D6\u6D88\u9884\u89C8\u94FE\u63A5")
])),
_: 1,
__: [10]
}),
createVNode(unref(Button), {
type: "primary",
onClick: _cache[3] || (_cache[3] = ($event) => unref(cancel)(true))
}, {
default: withCtx(() => _cache[11] || (_cache[11] = [
createTextVNode(" \u66F4\u65B0\u9884\u89C8\u6709\u6548\u671F ")
])),
_: 1,
__: [11]
})
])
], 64)) : unref(isPublish) ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
createCommentVNode(" \u4E8C\u7EF4\u7801 "),
_cache[15] || (_cache[15] = createElementVNode("div", { class: "doc-preview-share-img" }, [
createElementVNode("div", { id: "qr-code-is-pub" })
], -1)),
createCommentVNode(" \u5907\u6CE8 "),
_cache[16] || (_cache[16] = createElementVNode("div", { class: "doc-preview-share-tips" }, "\u626B\u63CF\u4E8C\u7EF4\u7801\u8BBF\u95EE", -1)),
createCommentVNode(" \u94FE\u63A5\u524D\u7F6E\u64CD\u4F5C "),
createElementVNode("div", _hoisted_9, [
_cache[14] || (_cache[14] = createElementVNode("span", null, "\u9884\u89C8\u5730\u5740", -1)),
createVNode(unref(Link), {
type: "text",
onClick: unref(copy)
}, {
default: withCtx(() => _cache[13] || (_cache[13] = [
createTextVNode(" \u590D\u5236\u94FE\u63A5 ")
])),
_: 1,
__: [13]
}, 8, ["onClick"])
]),
createCommentVNode(" \u94FE\u63A5 "),
createElementVNode("div", _hoisted_10, [
createElementVNode("div", _hoisted_11, toDisplayString(unref(innerUrl)), 1)
])
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [
_cache[19] || (_cache[19] = createElementVNode("div", { class: "doc-preview-share-img" }, [
createElementVNode("div", { class: "doc-preview-share-img-hint" }, " \u6682\u65E0\u9884\u89C8 ")
], -1)),
_cache[20] || (_cache[20] = createElementVNode("div", { class: "doc-preview-share-tips" }, " \u5185\u5BB9\u6682\u65E0\u9884\u89C8\u94FE\u63A5\uFF0C\u53EF\u751F\u6210\u9884\u89C8\u94FE\u63A5 ", -1)),
createElementVNode("div", _hoisted_12, [
_cache[17] || (_cache[17] = createElementVNode("span", null, "\u94FE\u63A5\u6709\u6548\u65F6\u957F", -1)),
createVNode(unref(Select), {
modelValue: unref(expireTime),
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => isRef(expireTime) ? expireTime.value = $event : null),
size: "mini",
style: { "width": "120px" }
}, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(EXPIRE_TIME_OPTIONS), (t, index) => {
return openBlock(), createBlock(unref(Option), {
key: index,
label: t.label,
value: t.value
}, null, 8, ["label", "value"]);
}), 128))
]),
_: 1
}, 8, ["modelValue"])
]),
createElementVNode("div", _hoisted_13, [
createVNode(unref(Button), {
type: "primary",
onClick: _cache[5] || (_cache[5] = () => unref(generate)())
}, {
default: withCtx(() => _cache[18] || (_cache[18] = [
createTextVNode(" \u751F\u6210\u9884\u89C8\u94FE\u63A5 ")
])),
_: 1,
__: [18]
})
])
], 64))
])
]),
_: 1
}, 8, ["loading"])
]);
};
}
});
export { _sfc_main as default };