jit-viewer 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iife/jit-viewer.min.css +1 -1
- package/dist/iife/jit-viewer.min.js +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +28 -7
- package/dist/index.js +235 -177
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13834,7 +13834,7 @@ function useViewerState() {
|
|
|
13834
13834
|
}
|
|
13835
13835
|
return context;
|
|
13836
13836
|
}
|
|
13837
|
-
const _hoisted_1$
|
|
13837
|
+
const _hoisted_1$b = ["disabled", "title"];
|
|
13838
13838
|
const _hoisted_2$7 = { class: "jv-toolbar-btn__icon" };
|
|
13839
13839
|
const _hoisted_3$2 = {
|
|
13840
13840
|
key: 0,
|
|
@@ -13868,7 +13868,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
13868
13868
|
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
13869
13869
|
]),
|
|
13870
13870
|
__props.label ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(__props.label), 1)) : createCommentVNode("", true)
|
|
13871
|
-
], 10, _hoisted_1$
|
|
13871
|
+
], 10, _hoisted_1$b);
|
|
13872
13872
|
};
|
|
13873
13873
|
}
|
|
13874
13874
|
});
|
|
@@ -13880,7 +13880,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
13880
13880
|
return target;
|
|
13881
13881
|
};
|
|
13882
13882
|
const ActionButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-9abd52f0"]]);
|
|
13883
|
-
const _hoisted_1$
|
|
13883
|
+
const _hoisted_1$a = { class: "jv-zoom-control" };
|
|
13884
13884
|
const _hoisted_2$6 = { class: "jv-zoom-control__value" };
|
|
13885
13885
|
const ZOOM_STEP = 0.1;
|
|
13886
13886
|
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
@@ -13898,7 +13898,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
13898
13898
|
resetTransform();
|
|
13899
13899
|
}
|
|
13900
13900
|
return (_ctx, _cache) => {
|
|
13901
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
13901
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
13902
13902
|
createVNode(ActionButton, {
|
|
13903
13903
|
type: "zoom-out",
|
|
13904
13904
|
title: unref(t)("toolbar.zoomOut"),
|
|
@@ -14007,7 +14007,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
14007
14007
|
}
|
|
14008
14008
|
});
|
|
14009
14009
|
const ZoomControl = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-874ddbac"]]);
|
|
14010
|
-
const _hoisted_1$
|
|
14010
|
+
const _hoisted_1$9 = { class: "jv-rotate-control" };
|
|
14011
14011
|
const ROTATE_STEP = 90;
|
|
14012
14012
|
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
14013
14013
|
__name: "RotateControl",
|
|
@@ -14021,7 +14021,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14021
14021
|
setRotate(ROTATE_STEP);
|
|
14022
14022
|
}
|
|
14023
14023
|
return (_ctx, _cache) => {
|
|
14024
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
14024
|
+
return openBlock(), createElementBlock("div", _hoisted_1$9, [
|
|
14025
14025
|
createVNode(ActionButton, {
|
|
14026
14026
|
type: "rotate-left",
|
|
14027
14027
|
title: unref(t)("toolbar.rotateLeft"),
|
|
@@ -14061,7 +14061,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14061
14061
|
}
|
|
14062
14062
|
});
|
|
14063
14063
|
const RotateControl = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-ad291658"]]);
|
|
14064
|
-
const _hoisted_1$
|
|
14064
|
+
const _hoisted_1$8 = {
|
|
14065
14065
|
key: 0,
|
|
14066
14066
|
viewBox: "0 0 24 24",
|
|
14067
14067
|
fill: "none",
|
|
@@ -14104,7 +14104,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
14104
14104
|
onClick: toggleFullscreen
|
|
14105
14105
|
}, {
|
|
14106
14106
|
default: withCtx(() => [
|
|
14107
|
-
!isFullscreen.value ? (openBlock(), createElementBlock("svg", _hoisted_1$
|
|
14107
|
+
!isFullscreen.value ? (openBlock(), createElementBlock("svg", _hoisted_1$8, [..._cache[0] || (_cache[0] = [
|
|
14108
14108
|
createBaseVNode("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" }, null, -1)
|
|
14109
14109
|
])])) : (openBlock(), createElementBlock("svg", _hoisted_2$5, [..._cache[1] || (_cache[1] = [
|
|
14110
14110
|
createBaseVNode("path", { d: "M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3" }, null, -1)
|
|
@@ -14115,7 +14115,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
14115
14115
|
};
|
|
14116
14116
|
}
|
|
14117
14117
|
});
|
|
14118
|
-
const _hoisted_1$
|
|
14118
|
+
const _hoisted_1$7 = {
|
|
14119
14119
|
key: 0,
|
|
14120
14120
|
class: "jv-pagination"
|
|
14121
14121
|
};
|
|
@@ -14126,7 +14126,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
14126
14126
|
const { t } = useLocale();
|
|
14127
14127
|
const { currentPage, totalPages, prevPage, nextPage } = useViewerState();
|
|
14128
14128
|
return (_ctx, _cache) => {
|
|
14129
|
-
return unref(totalPages) > 1 ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
14129
|
+
return unref(totalPages) > 1 ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
14130
14130
|
createVNode(ActionButton, {
|
|
14131
14131
|
type: "prev",
|
|
14132
14132
|
title: unref(t)("toolbar.prevPage"),
|
|
@@ -14169,7 +14169,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
14169
14169
|
}
|
|
14170
14170
|
});
|
|
14171
14171
|
const Pagination = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-97c0759f"]]);
|
|
14172
|
-
const _hoisted_1$
|
|
14172
|
+
const _hoisted_1$6 = {
|
|
14173
14173
|
key: 0,
|
|
14174
14174
|
class: "jv-toolbar__top"
|
|
14175
14175
|
};
|
|
@@ -14197,133 +14197,6 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
14197
14197
|
const props = __props;
|
|
14198
14198
|
const { t } = useLocale();
|
|
14199
14199
|
const { filename, fileSource } = useViewerState();
|
|
14200
|
-
const brandingRef = /* @__PURE__ */ ref();
|
|
14201
|
-
let copyrightObserver = null;
|
|
14202
|
-
let copyrightCheckInterval = null;
|
|
14203
|
-
function checkCopyright() {
|
|
14204
|
-
const branding = brandingRef.value;
|
|
14205
|
-
if (!branding) return false;
|
|
14206
|
-
if (!document.body.contains(branding)) {
|
|
14207
|
-
showCopyrightWarning();
|
|
14208
|
-
return false;
|
|
14209
|
-
}
|
|
14210
|
-
const link = branding.querySelector(".jv-branding-link");
|
|
14211
|
-
if (!link) {
|
|
14212
|
-
showCopyrightWarning();
|
|
14213
|
-
return false;
|
|
14214
|
-
}
|
|
14215
|
-
const href = link.getAttribute("href");
|
|
14216
|
-
if (href !== "https://github.com/jitOffice/jit-viewer-sdk") {
|
|
14217
|
-
showCopyrightWarning();
|
|
14218
|
-
return false;
|
|
14219
|
-
}
|
|
14220
|
-
const text = branding.textContent || "";
|
|
14221
|
-
if (!text.includes("JitViewer") || !text.includes("提供文档预览支持")) {
|
|
14222
|
-
showCopyrightWarning();
|
|
14223
|
-
return false;
|
|
14224
|
-
}
|
|
14225
|
-
return true;
|
|
14226
|
-
}
|
|
14227
|
-
function showCopyrightWarning() {
|
|
14228
|
-
var _a;
|
|
14229
|
-
if (document.querySelector(".jv-copyright-warning")) return;
|
|
14230
|
-
const warning = document.createElement("div");
|
|
14231
|
-
warning.className = "jv-copyright-warning";
|
|
14232
|
-
warning.innerHTML = `
|
|
14233
|
-
<div class="jv-copyright-warning__content">
|
|
14234
|
-
<div class="jv-copyright-warning__icon">⚠️</div>
|
|
14235
|
-
<div class="jv-copyright-warning__title">版权信息被移除</div>
|
|
14236
|
-
<div class="jv-copyright-warning__text">
|
|
14237
|
-
请保留 "JitViewer提供文档预览支持" 版权信息<br>
|
|
14238
|
-
<a href="https://github.com/jitOffice/jit-viewer-sdk" target="_blank">https://github.com/jitOffice/jit-viewer-sdk</a>
|
|
14239
|
-
</div>
|
|
14240
|
-
<button class="jv-copyright-warning__btn">我知道了</button>
|
|
14241
|
-
</div>
|
|
14242
|
-
`;
|
|
14243
|
-
const style = document.createElement("style");
|
|
14244
|
-
style.textContent = `
|
|
14245
|
-
.jv-copyright-warning {
|
|
14246
|
-
position: fixed;
|
|
14247
|
-
top: 0;
|
|
14248
|
-
left: 0;
|
|
14249
|
-
right: 0;
|
|
14250
|
-
bottom: 0;
|
|
14251
|
-
background: rgba(0, 0, 0, 0.7);
|
|
14252
|
-
display: flex;
|
|
14253
|
-
align-items: center;
|
|
14254
|
-
justify-content: center;
|
|
14255
|
-
z-index: 99999;
|
|
14256
|
-
}
|
|
14257
|
-
.jv-copyright-warning__content {
|
|
14258
|
-
background: white;
|
|
14259
|
-
padding: 32px;
|
|
14260
|
-
border-radius: 12px;
|
|
14261
|
-
text-align: center;
|
|
14262
|
-
max-width: 400px;
|
|
14263
|
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
|
14264
|
-
}
|
|
14265
|
-
.jv-copyright-warning__icon {
|
|
14266
|
-
font-size: 48px;
|
|
14267
|
-
margin-bottom: 16px;
|
|
14268
|
-
}
|
|
14269
|
-
.jv-copyright-warning__title {
|
|
14270
|
-
font-size: 18px;
|
|
14271
|
-
font-weight: 600;
|
|
14272
|
-
margin-bottom: 12px;
|
|
14273
|
-
color: #333;
|
|
14274
|
-
}
|
|
14275
|
-
.jv-copyright-warning__text {
|
|
14276
|
-
font-size: 14px;
|
|
14277
|
-
color: #666;
|
|
14278
|
-
margin-bottom: 20px;
|
|
14279
|
-
line-height: 1.6;
|
|
14280
|
-
}
|
|
14281
|
-
.jv-copyright-warning__text a {
|
|
14282
|
-
color: #1890ff;
|
|
14283
|
-
}
|
|
14284
|
-
.jv-copyright-warning__btn {
|
|
14285
|
-
background: #1890ff;
|
|
14286
|
-
color: white;
|
|
14287
|
-
border: none;
|
|
14288
|
-
padding: 10px 32px;
|
|
14289
|
-
border-radius: 6px;
|
|
14290
|
-
font-size: 14px;
|
|
14291
|
-
cursor: pointer;
|
|
14292
|
-
}
|
|
14293
|
-
.jv-copyright-warning__btn:hover {
|
|
14294
|
-
background: #40a9ff;
|
|
14295
|
-
}
|
|
14296
|
-
`;
|
|
14297
|
-
document.head.appendChild(style);
|
|
14298
|
-
document.body.appendChild(warning);
|
|
14299
|
-
(_a = warning.querySelector(".jv-copyright-warning__btn")) == null ? void 0 : _a.addEventListener("click", () => {
|
|
14300
|
-
location.reload();
|
|
14301
|
-
});
|
|
14302
|
-
}
|
|
14303
|
-
function startCopyrightProtection() {
|
|
14304
|
-
copyrightObserver = new MutationObserver(() => {
|
|
14305
|
-
checkCopyright();
|
|
14306
|
-
});
|
|
14307
|
-
if (brandingRef.value) {
|
|
14308
|
-
copyrightObserver.observe(document.body, {
|
|
14309
|
-
childList: true,
|
|
14310
|
-
subtree: true,
|
|
14311
|
-
attributes: true,
|
|
14312
|
-
attributeFilter: ["href", "style", "class"]
|
|
14313
|
-
});
|
|
14314
|
-
}
|
|
14315
|
-
copyrightCheckInterval = setInterval(checkCopyright, 1e3);
|
|
14316
|
-
}
|
|
14317
|
-
function stopCopyrightProtection() {
|
|
14318
|
-
if (copyrightObserver) {
|
|
14319
|
-
copyrightObserver.disconnect();
|
|
14320
|
-
copyrightObserver = null;
|
|
14321
|
-
}
|
|
14322
|
-
if (copyrightCheckInterval) {
|
|
14323
|
-
clearInterval(copyrightCheckInterval);
|
|
14324
|
-
copyrightCheckInterval = null;
|
|
14325
|
-
}
|
|
14326
|
-
}
|
|
14327
14200
|
const defaultItems = [
|
|
14328
14201
|
"zoom",
|
|
14329
14202
|
"rotate",
|
|
@@ -14368,19 +14241,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
14368
14241
|
await downloadFile(fileSource.value, filename.value);
|
|
14369
14242
|
}
|
|
14370
14243
|
}
|
|
14371
|
-
onMounted(() => {
|
|
14372
|
-
setTimeout(() => {
|
|
14373
|
-
startCopyrightProtection();
|
|
14374
|
-
}, 100);
|
|
14375
|
-
});
|
|
14376
|
-
onUnmounted(() => {
|
|
14377
|
-
stopCopyrightProtection();
|
|
14378
|
-
});
|
|
14379
14244
|
return (_ctx, _cache) => {
|
|
14380
14245
|
return openBlock(), createElementBlock("div", {
|
|
14381
14246
|
class: normalizeClass(["jv-toolbar", [positionClass.value, { "jv-toolbar--hidden": !__props.visible }]])
|
|
14382
14247
|
}, [
|
|
14383
|
-
showTop.value ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
14248
|
+
showTop.value ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
14384
14249
|
createBaseVNode("div", _hoisted_2$3, [
|
|
14385
14250
|
renderSlot(_ctx.$slots, "top-left", {}, () => [
|
|
14386
14251
|
unref(filename) ? (openBlock(), createElementBlock("span", _hoisted_3$1, toDisplayString(unref(filename)), 1)) : createCommentVNode("", true)
|
|
@@ -14408,27 +14273,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
14408
14273
|
]),
|
|
14409
14274
|
createBaseVNode("div", _hoisted_9, [
|
|
14410
14275
|
renderSlot(_ctx.$slots, "bottom-right", {}, () => [
|
|
14411
|
-
createBaseVNode("span", {
|
|
14412
|
-
class: "jv-toolbar__branding",
|
|
14413
|
-
ref_key: "brandingRef",
|
|
14414
|
-
ref: brandingRef,
|
|
14415
|
-
"data-jv-copyright": "true"
|
|
14416
|
-
}, [..._cache[0] || (_cache[0] = [
|
|
14417
|
-
createBaseVNode("a", {
|
|
14418
|
-
href: "https://github.com/jitOffice/jit-viewer-sdk",
|
|
14419
|
-
target: "_blank",
|
|
14420
|
-
rel: "noopener noreferrer",
|
|
14421
|
-
class: "jv-branding-link"
|
|
14422
|
-
}, "JitViewer", -1),
|
|
14423
|
-
createTextVNode("提供文档预览支持 ", -1)
|
|
14424
|
-
])], 512),
|
|
14425
14276
|
hasItem("download") ? (openBlock(), createBlock(ActionButton, {
|
|
14426
14277
|
key: 0,
|
|
14427
14278
|
type: "download",
|
|
14428
14279
|
title: unref(t)("toolbar.download"),
|
|
14429
14280
|
onClick: handleDownload
|
|
14430
14281
|
}, {
|
|
14431
|
-
default: withCtx(() => [..._cache[
|
|
14282
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
14432
14283
|
createBaseVNode("svg", {
|
|
14433
14284
|
viewBox: "0 0 24 24",
|
|
14434
14285
|
fill: "none",
|
|
@@ -14454,7 +14305,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
14454
14305
|
};
|
|
14455
14306
|
}
|
|
14456
14307
|
});
|
|
14457
|
-
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-
|
|
14308
|
+
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-74d3b30f"]]);
|
|
14458
14309
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
14459
14310
|
function getDefaultExportFromCjs(x) {
|
|
14460
14311
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -64180,13 +64031,15 @@ var t={4186:(t,e,r)=>{var n=r(3749),i=r(8055),a=TypeError;t.exports=function(t){
|
|
|
64180
64031
|
})(lib$1);
|
|
64181
64032
|
var libExports$1 = lib$1.exports;
|
|
64182
64033
|
const VueOfficePdf = /* @__PURE__ */ getDefaultExportFromCjs(libExports$1);
|
|
64034
|
+
const _hoisted_1$5 = ["src"];
|
|
64183
64035
|
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
64184
64036
|
__name: "PdfRender",
|
|
64185
64037
|
props: {
|
|
64186
64038
|
source: {},
|
|
64187
|
-
zoom: {},
|
|
64039
|
+
zoom: { default: 1 },
|
|
64188
64040
|
proxyUrl: {},
|
|
64189
|
-
requestAdapter: {
|
|
64041
|
+
requestAdapter: {},
|
|
64042
|
+
pdfRender: { default: "inset" }
|
|
64190
64043
|
},
|
|
64191
64044
|
emits: ["load", "error"],
|
|
64192
64045
|
setup(__props, { emit: __emit }) {
|
|
@@ -64194,22 +64047,59 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
64194
64047
|
const emit2 = __emit;
|
|
64195
64048
|
const containerRef = /* @__PURE__ */ ref();
|
|
64196
64049
|
const src = /* @__PURE__ */ ref();
|
|
64050
|
+
const iframeSrc = /* @__PURE__ */ ref("");
|
|
64197
64051
|
const loading = /* @__PURE__ */ ref(true);
|
|
64052
|
+
let objectUrl = null;
|
|
64053
|
+
const isNative = computed(() => props.pdfRender === "native");
|
|
64198
64054
|
const renderStyle = computed(() => ({
|
|
64199
64055
|
transform: `scale(${props.zoom})`,
|
|
64200
64056
|
transformOrigin: "top center"
|
|
64201
64057
|
}));
|
|
64058
|
+
function revokeObjectUrl() {
|
|
64059
|
+
if (objectUrl) {
|
|
64060
|
+
URL.revokeObjectURL(objectUrl);
|
|
64061
|
+
objectUrl = null;
|
|
64062
|
+
}
|
|
64063
|
+
}
|
|
64202
64064
|
async function loadFile() {
|
|
64203
64065
|
try {
|
|
64204
64066
|
loading.value = true;
|
|
64205
|
-
|
|
64206
|
-
|
|
64207
|
-
|
|
64208
|
-
}
|
|
64067
|
+
revokeObjectUrl();
|
|
64068
|
+
if (isNative.value) {
|
|
64069
|
+
await loadNativePdf();
|
|
64070
|
+
} else {
|
|
64071
|
+
src.value = await fileToArrayBuffer(props.source, {
|
|
64072
|
+
proxyUrl: props.proxyUrl,
|
|
64073
|
+
requestAdapter: props.requestAdapter
|
|
64074
|
+
});
|
|
64075
|
+
}
|
|
64209
64076
|
} catch (error) {
|
|
64210
64077
|
handleError2(error);
|
|
64211
64078
|
}
|
|
64212
64079
|
}
|
|
64080
|
+
async function loadNativePdf() {
|
|
64081
|
+
const source = props.source;
|
|
64082
|
+
if (typeof source === "string") {
|
|
64083
|
+
iframeSrc.value = source;
|
|
64084
|
+
return;
|
|
64085
|
+
}
|
|
64086
|
+
if (source instanceof File || source instanceof Blob) {
|
|
64087
|
+
objectUrl = URL.createObjectURL(source);
|
|
64088
|
+
iframeSrc.value = objectUrl;
|
|
64089
|
+
return;
|
|
64090
|
+
}
|
|
64091
|
+
if (source instanceof ArrayBuffer) {
|
|
64092
|
+
const blob = new Blob([source], { type: "application/pdf" });
|
|
64093
|
+
objectUrl = URL.createObjectURL(blob);
|
|
64094
|
+
iframeSrc.value = objectUrl;
|
|
64095
|
+
return;
|
|
64096
|
+
}
|
|
64097
|
+
if (typeof source === "object" && "url" in source) {
|
|
64098
|
+
iframeSrc.value = source.url;
|
|
64099
|
+
return;
|
|
64100
|
+
}
|
|
64101
|
+
throw new Error("Unsupported PDF source for native render");
|
|
64102
|
+
}
|
|
64213
64103
|
function handleRendered() {
|
|
64214
64104
|
loading.value = false;
|
|
64215
64105
|
emit2("load");
|
|
@@ -64219,23 +64109,34 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
64219
64109
|
emit2("error", error);
|
|
64220
64110
|
}
|
|
64221
64111
|
watch(() => props.source, loadFile, { immediate: true });
|
|
64112
|
+
onBeforeUnmount(() => {
|
|
64113
|
+
revokeObjectUrl();
|
|
64114
|
+
});
|
|
64222
64115
|
return (_ctx, _cache) => {
|
|
64223
64116
|
return openBlock(), createElementBlock("div", {
|
|
64224
64117
|
ref_key: "containerRef",
|
|
64225
64118
|
ref: containerRef,
|
|
64226
64119
|
class: "jv-file-render jv-file-render--pdf"
|
|
64227
64120
|
}, [
|
|
64228
|
-
|
|
64121
|
+
!isNative.value ? (openBlock(), createBlock(unref(VueOfficePdf), {
|
|
64122
|
+
key: 0,
|
|
64229
64123
|
src: src.value,
|
|
64230
64124
|
style: normalizeStyle(renderStyle.value),
|
|
64231
64125
|
onRendered: handleRendered,
|
|
64232
64126
|
onError: handleError2
|
|
64233
|
-
}, null, 8, ["src", "style"])
|
|
64127
|
+
}, null, 8, ["src", "style"])) : (openBlock(), createElementBlock("iframe", {
|
|
64128
|
+
key: 1,
|
|
64129
|
+
class: "jv-pdf-iframe",
|
|
64130
|
+
src: iframeSrc.value,
|
|
64131
|
+
style: normalizeStyle(renderStyle.value),
|
|
64132
|
+
frameborder: "0",
|
|
64133
|
+
onLoad: handleRendered
|
|
64134
|
+
}, null, 44, _hoisted_1$5))
|
|
64234
64135
|
], 512);
|
|
64235
64136
|
};
|
|
64236
64137
|
}
|
|
64237
64138
|
});
|
|
64238
|
-
const PdfRender = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-
|
|
64139
|
+
const PdfRender = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-32fed398"]]);
|
|
64239
64140
|
var lib = { exports: {} };
|
|
64240
64141
|
(function(module, exports$1) {
|
|
64241
64142
|
(function(Ma, No) {
|
|
@@ -128858,6 +128759,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
128858
128759
|
height: { default: "100%" },
|
|
128859
128760
|
className: {},
|
|
128860
128761
|
style: {},
|
|
128762
|
+
pdfRender: {},
|
|
128861
128763
|
proxyUrl: {},
|
|
128862
128764
|
requestAdapter: {},
|
|
128863
128765
|
onReady: {},
|
|
@@ -128874,6 +128776,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
128874
128776
|
const viewerRef = /* @__PURE__ */ ref();
|
|
128875
128777
|
const contentRef = /* @__PURE__ */ ref();
|
|
128876
128778
|
const ofdRenderRef = /* @__PURE__ */ ref(null);
|
|
128779
|
+
const brandingRef = /* @__PURE__ */ ref();
|
|
128780
|
+
let viewerRoot = null;
|
|
128781
|
+
let copyrightObserver = null;
|
|
128782
|
+
let copyrightCheckInterval = null;
|
|
128877
128783
|
const events = createEventBus();
|
|
128878
128784
|
const { t } = useLocaleProvider(props.locale);
|
|
128879
128785
|
const viewerRefForTheme = computed(() => viewerRef.value || null);
|
|
@@ -128907,6 +128813,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
128907
128813
|
transform: `rotate(${state.rotate.value}deg)`
|
|
128908
128814
|
}));
|
|
128909
128815
|
const showToolbar = computed(() => props.toolbar !== false);
|
|
128816
|
+
const pdfRenderMode = computed(() => props.pdfRender ?? "inset");
|
|
128910
128817
|
const toolbarConfig = computed(() => {
|
|
128911
128818
|
if (props.toolbar === true || props.toolbar === void 0) {
|
|
128912
128819
|
return void 0;
|
|
@@ -128963,6 +128870,141 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
128963
128870
|
}
|
|
128964
128871
|
});
|
|
128965
128872
|
}
|
|
128873
|
+
function checkCopyright() {
|
|
128874
|
+
const branding = brandingRef.value;
|
|
128875
|
+
if (!branding) return false;
|
|
128876
|
+
if (!viewerRoot) {
|
|
128877
|
+
viewerRoot = branding.closest(".jv-viewer");
|
|
128878
|
+
}
|
|
128879
|
+
if (!viewerRoot || !document.body.contains(viewerRoot)) {
|
|
128880
|
+
return false;
|
|
128881
|
+
}
|
|
128882
|
+
if (!viewerRoot.contains(branding)) {
|
|
128883
|
+
showCopyrightWarning();
|
|
128884
|
+
return false;
|
|
128885
|
+
}
|
|
128886
|
+
const link = branding.querySelector(".jv-branding-link");
|
|
128887
|
+
if (!link) {
|
|
128888
|
+
showCopyrightWarning();
|
|
128889
|
+
return false;
|
|
128890
|
+
}
|
|
128891
|
+
const href = link.getAttribute("href");
|
|
128892
|
+
if (href !== "https://github.com/jitOffice/jit-viewer-sdk") {
|
|
128893
|
+
showCopyrightWarning();
|
|
128894
|
+
return false;
|
|
128895
|
+
}
|
|
128896
|
+
const text = branding.textContent || "";
|
|
128897
|
+
if (!text.includes("JitViewer") || !text.includes("提供文档预览支持")) {
|
|
128898
|
+
showCopyrightWarning();
|
|
128899
|
+
return false;
|
|
128900
|
+
}
|
|
128901
|
+
return true;
|
|
128902
|
+
}
|
|
128903
|
+
function showCopyrightWarning() {
|
|
128904
|
+
var _a2;
|
|
128905
|
+
if (document.querySelector(".jv-copyright-warning")) return;
|
|
128906
|
+
const warning = document.createElement("div");
|
|
128907
|
+
warning.className = "jv-copyright-warning";
|
|
128908
|
+
warning.innerHTML = `
|
|
128909
|
+
<div class="jv-copyright-warning__content">
|
|
128910
|
+
<div class="jv-copyright-warning__icon">⚠️</div>
|
|
128911
|
+
<div class="jv-copyright-warning__title">版权信息被移除</div>
|
|
128912
|
+
<div class="jv-copyright-warning__text">
|
|
128913
|
+
请保留 "JitViewer提供文档预览支持" 版权信息<br>
|
|
128914
|
+
<a href="https://github.com/jitOffice/jit-viewer-sdk" target="_blank">https://github.com/jitOffice/jit-viewer-sdk</a>
|
|
128915
|
+
</div>
|
|
128916
|
+
<button class="jv-copyright-warning__btn">我知道了</button>
|
|
128917
|
+
</div>
|
|
128918
|
+
`;
|
|
128919
|
+
const style = document.createElement("style");
|
|
128920
|
+
style.textContent = `
|
|
128921
|
+
.jv-copyright-warning {
|
|
128922
|
+
position: fixed;
|
|
128923
|
+
top: 0;
|
|
128924
|
+
left: 0;
|
|
128925
|
+
right: 0;
|
|
128926
|
+
bottom: 0;
|
|
128927
|
+
background: rgba(0, 0, 0, 0.7);
|
|
128928
|
+
display: flex;
|
|
128929
|
+
align-items: center;
|
|
128930
|
+
justify-content: center;
|
|
128931
|
+
z-index: 99999;
|
|
128932
|
+
}
|
|
128933
|
+
.jv-copyright-warning__content {
|
|
128934
|
+
background: white;
|
|
128935
|
+
padding: 32px;
|
|
128936
|
+
border-radius: 12px;
|
|
128937
|
+
text-align: center;
|
|
128938
|
+
max-width: 400px;
|
|
128939
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
|
128940
|
+
}
|
|
128941
|
+
.jv-copyright-warning__icon {
|
|
128942
|
+
font-size: 48px;
|
|
128943
|
+
margin-bottom: 16px;
|
|
128944
|
+
}
|
|
128945
|
+
.jv-copyright-warning__title {
|
|
128946
|
+
font-size: 18px;
|
|
128947
|
+
font-weight: 600;
|
|
128948
|
+
margin-bottom: 12px;
|
|
128949
|
+
color: #333;
|
|
128950
|
+
}
|
|
128951
|
+
.jv-copyright-warning__text {
|
|
128952
|
+
font-size: 14px;
|
|
128953
|
+
color: #666;
|
|
128954
|
+
margin-bottom: 20px;
|
|
128955
|
+
line-height: 1.6;
|
|
128956
|
+
}
|
|
128957
|
+
.jv-copyright-warning__text a {
|
|
128958
|
+
color: #1890ff;
|
|
128959
|
+
}
|
|
128960
|
+
.jv-copyright-warning__btn {
|
|
128961
|
+
background: #1890ff;
|
|
128962
|
+
color: white;
|
|
128963
|
+
border: none;
|
|
128964
|
+
padding: 10px 32px;
|
|
128965
|
+
border-radius: 6px;
|
|
128966
|
+
font-size: 14px;
|
|
128967
|
+
cursor: pointer;
|
|
128968
|
+
}
|
|
128969
|
+
.jv-copyright-warning__btn:hover {
|
|
128970
|
+
background: #40a9ff;
|
|
128971
|
+
}
|
|
128972
|
+
`;
|
|
128973
|
+
document.head.appendChild(style);
|
|
128974
|
+
document.body.appendChild(warning);
|
|
128975
|
+
(_a2 = warning.querySelector(".jv-copyright-warning__btn")) == null ? void 0 : _a2.addEventListener("click", () => {
|
|
128976
|
+
location.reload();
|
|
128977
|
+
});
|
|
128978
|
+
}
|
|
128979
|
+
function startCopyrightProtection() {
|
|
128980
|
+
copyrightObserver = new MutationObserver(() => {
|
|
128981
|
+
checkCopyright();
|
|
128982
|
+
});
|
|
128983
|
+
if (brandingRef.value) {
|
|
128984
|
+
const viewer = brandingRef.value.closest(".jv-viewer");
|
|
128985
|
+
if (viewer) {
|
|
128986
|
+
viewerRoot = viewer;
|
|
128987
|
+
copyrightObserver.observe(viewerRoot, {
|
|
128988
|
+
childList: true,
|
|
128989
|
+
subtree: true,
|
|
128990
|
+
attributes: true,
|
|
128991
|
+
attributeFilter: ["href", "style", "class"]
|
|
128992
|
+
});
|
|
128993
|
+
}
|
|
128994
|
+
}
|
|
128995
|
+
copyrightCheckInterval = setInterval(checkCopyright, 1e3);
|
|
128996
|
+
}
|
|
128997
|
+
function stopCopyrightProtection() {
|
|
128998
|
+
if (copyrightObserver) {
|
|
128999
|
+
copyrightObserver.disconnect();
|
|
129000
|
+
copyrightObserver = null;
|
|
129001
|
+
}
|
|
129002
|
+
if (copyrightCheckInterval) {
|
|
129003
|
+
clearInterval(copyrightCheckInterval);
|
|
129004
|
+
copyrightCheckInterval = null;
|
|
129005
|
+
}
|
|
129006
|
+
viewerRoot = null;
|
|
129007
|
+
}
|
|
128966
129008
|
async function mount(target) {
|
|
128967
129009
|
var _a2;
|
|
128968
129010
|
const el = target ? getElement(target) : viewerRef.value;
|
|
@@ -129012,11 +129054,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
129012
129054
|
if (props.file) {
|
|
129013
129055
|
setFileInternal(props.file, props.filename);
|
|
129014
129056
|
}
|
|
129057
|
+
startCopyrightProtection();
|
|
129015
129058
|
emit2("ready");
|
|
129016
129059
|
events.emit("ready");
|
|
129017
129060
|
(_a2 = props.onReady) == null ? void 0 : _a2.call(props);
|
|
129018
129061
|
});
|
|
129019
129062
|
onUnmounted(() => {
|
|
129063
|
+
stopCopyrightProtection();
|
|
129020
129064
|
state.setPageController(null);
|
|
129021
129065
|
destroy();
|
|
129022
129066
|
});
|
|
@@ -129077,13 +129121,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
129077
129121
|
config: toolbarConfig.value,
|
|
129078
129122
|
visible: toolbarVisible.value
|
|
129079
129123
|
}, null, 8, ["config", "visible"])) : createCommentVNode("", true),
|
|
129124
|
+
createBaseVNode("div", {
|
|
129125
|
+
class: "jv-viewer__branding",
|
|
129126
|
+
ref_key: "brandingRef",
|
|
129127
|
+
ref: brandingRef
|
|
129128
|
+
}, [..._cache[0] || (_cache[0] = [
|
|
129129
|
+
createBaseVNode("a", {
|
|
129130
|
+
href: "https://github.com/jitOffice/jit-viewer-sdk",
|
|
129131
|
+
target: "_blank",
|
|
129132
|
+
rel: "noopener noreferrer",
|
|
129133
|
+
class: "jv-branding-link"
|
|
129134
|
+
}, "JitViewer", -1),
|
|
129135
|
+
createTextVNode("提供文档预览支持 ", -1)
|
|
129136
|
+
])], 512),
|
|
129080
129137
|
createBaseVNode("div", {
|
|
129081
129138
|
ref_key: "contentRef",
|
|
129082
129139
|
ref: contentRef,
|
|
129083
129140
|
class: "jv-viewer__content"
|
|
129084
129141
|
}, [
|
|
129085
129142
|
unref(error) ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
129086
|
-
_cache[
|
|
129143
|
+
_cache[1] || (_cache[1] = createBaseVNode("svg", {
|
|
129087
129144
|
class: "jv-error-icon",
|
|
129088
129145
|
viewBox: "0 0 24 24",
|
|
129089
129146
|
fill: "none",
|
|
@@ -129117,7 +129174,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
129117
129174
|
style: normalizeStyle(renderStyle.value)
|
|
129118
129175
|
}, [
|
|
129119
129176
|
withDirectives(createBaseVNode("div", _hoisted_5, [
|
|
129120
|
-
_cache[
|
|
129177
|
+
_cache[2] || (_cache[2] = createBaseVNode("div", { class: "jv-loading-spinner" }, null, -1)),
|
|
129121
129178
|
createBaseVNode("span", _hoisted_6, toDisplayString(unref(t)("loading")), 1)
|
|
129122
129179
|
], 512), [
|
|
129123
129180
|
[vShow, unref(loading)]
|
|
@@ -129144,9 +129201,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
129144
129201
|
zoom: unref(zoom),
|
|
129145
129202
|
"proxy-url": proxyUrl.value,
|
|
129146
129203
|
"request-adapter": requestAdapter.value,
|
|
129204
|
+
"pdf-render": pdfRenderMode.value,
|
|
129147
129205
|
onLoad: handleLoad,
|
|
129148
129206
|
onError: handleError2
|
|
129149
|
-
}, null, 8, ["source", "zoom", "proxy-url", "request-adapter"])) : unref(fileType) === "pptx" || unref(fileType) === "ppt" ? (openBlock(), createBlock(unref(PptxRender), {
|
|
129207
|
+
}, null, 8, ["source", "zoom", "proxy-url", "request-adapter", "pdf-render"])) : unref(fileType) === "pptx" || unref(fileType) === "ppt" ? (openBlock(), createBlock(unref(PptxRender), {
|
|
129150
129208
|
key: 3,
|
|
129151
129209
|
source: unref(fileSource),
|
|
129152
129210
|
zoom: unref(zoom),
|
|
@@ -129183,7 +129241,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
129183
129241
|
"request-adapter": requestAdapter.value,
|
|
129184
129242
|
onLoad: handleLoad,
|
|
129185
129243
|
onError: handleError2
|
|
129186
|
-
}, null, 8, ["source", "zoom", "proxy-url", "request-adapter"])) : unref(fileType) === "unknown" && unref(fileSource) ? (openBlock(), createElementBlock("div", _hoisted_7, [..._cache[
|
|
129244
|
+
}, null, 8, ["source", "zoom", "proxy-url", "request-adapter"])) : unref(fileType) === "unknown" && unref(fileSource) ? (openBlock(), createElementBlock("div", _hoisted_7, [..._cache[3] || (_cache[3] = [
|
|
129187
129245
|
createBaseVNode("span", null, "未知文件类型", -1)
|
|
129188
129246
|
])])) : (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
129189
129247
|
createBaseVNode("span", null, toDisplayString(unref(t)("error.unsupportedType")), 1)
|
|
@@ -129194,7 +129252,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
129194
129252
|
};
|
|
129195
129253
|
}
|
|
129196
129254
|
});
|
|
129197
|
-
const Viewer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
129255
|
+
const Viewer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6150f325"]]);
|
|
129198
129256
|
function createViewer(options) {
|
|
129199
129257
|
const events = createEventBus();
|
|
129200
129258
|
let app = null;
|