Commit 1f531d1f authored by 以墨为白's avatar 以墨为白 🎧

文档预览

parent deb50e5d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Title</title> <title>文件预览</title>
</head> </head>
<body> <body>
...@@ -11,9 +11,29 @@ ...@@ -11,9 +11,29 @@
<script src="http://192.168.168.213:9000/web-apps/apps/api/documents/api.js"></script> <script src="http://192.168.168.213:9000/web-apps/apps/api/documents/api.js"></script>
<script> <script>
var getParameters = function () {
var search = window.location.search;
var obj = {};
if (search != '') {
// window.location.search '' or start with '?'
search = search.substring(1);
var keypairArray = search.split('&');
for (i in keypairArray) {
keypair = keypairArray[i];
partArray = keypair.split('=');
if (partArray.length == 2) {
obj[partArray[0]] = partArray[1];
}
}
}
return obj;
}
var param = getParameters();
var docEditor = new DocsAPI.DocEditor("placeholder", { var docEditor = new DocsAPI.DocEditor("placeholder", {
"document": { "document": {
"fileType": "pptx", "fileType": param.fileType.replace(".", ""),
"permissions": { "permissions": {
"edit": false, "edit": false,
"copy": false, "copy": false,
...@@ -22,8 +42,8 @@ ...@@ -22,8 +42,8 @@
"chat": false "chat": false
}, },
// "key": "C8D7FB890BAC496FB0D27B163EDB88BDAA", // "key": "C8D7FB890BAC496FB0D27B163EDB88BDAA",
"title": "zf张飞.pptx", "title": decodeURIComponent(param.filename),
"url": "http://192.168.168.110:9006/document/DD27367D-5680-46FF-9A6D-F248F4567511.pptx?Content-Disposition=attachment%3B%20filename%3D%22DD27367D-5680-46FF-9A6D-F248F4567511.pptx%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20231127%2F%2Fs3%2Faws4_request&X-Amz-Date=20231127T031344Z&X-Amz-Expires=432000&X-Amz-SignedHeaders=host&X-Amz-Signature=c5fb3f67663eb945adfe54b8f1783b08ed08a9704464bd86465459fc0ef6917e", "url": decodeURIComponent(param.url),
}, },
"height": "1000px", "height": "1000px",
"width": "100%", "width": "100%",
......
<template> <template>
<div> <div id="placeholder"></div>
</div>
</template> </template>
<script> <script>
...@@ -15,7 +13,7 @@ export default { ...@@ -15,7 +13,7 @@ export default {
mounted() { mounted() {
var docEditor = new DocsAPI.DocEditor("placeholder", { var docEditor = new DocsAPI.DocEditor("placeholder", {
"document": { "document": {
"fileType": "pptx", "fileType": this.fileType,
"permissions": { "permissions": {
"edit": false, "edit": false,
"copy": false, "copy": false,
...@@ -24,10 +22,10 @@ export default { ...@@ -24,10 +22,10 @@ export default {
"chat": false "chat": false
}, },
// "key": "C8D7FB890BAC496FB0D27B163EDB88BDAA", // "key": "C8D7FB890BAC496FB0D27B163EDB88BDAA",
"title": "zf张飞.pptx", "title": this.filename,
"url": "http://192.168.168.110:9006/document/DD27367D-5680-46FF-9A6D-F248F4567511.pptx?Content-Disposition=attachment%3B%20filename%3D%22DD27367D-5680-46FF-9A6D-F248F4567511.pptx%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20231127%2F%2Fs3%2Faws4_request&X-Amz-Date=20231127T031344Z&X-Amz-Expires=432000&X-Amz-SignedHeaders=host&X-Amz-Signature=c5fb3f67663eb945adfe54b8f1783b08ed08a9704464bd86465459fc0ef6917e", "url": this.url,
}, },
"height": "1000px", "height": "400px",
"width": "100%", "width": "100%",
"editorConfig": { "editorConfig": {
"mode": 'view', "mode": 'view',
......
...@@ -303,7 +303,7 @@ let download = (url, filename) => { ...@@ -303,7 +303,7 @@ let download = (url, filename) => {
* @return {Promise} * @return {Promise}
*/ */
let getBlob = (url) => { let getBlob = (url) => {
return new Promise((resolve) => { return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open("GET", url, true); xhr.open("GET", url, true);
...@@ -311,6 +311,8 @@ let getBlob = (url) => { ...@@ -311,6 +311,8 @@ let getBlob = (url) => {
xhr.onload = () => { xhr.onload = () => {
if (xhr.status === 200) { if (xhr.status === 200) {
resolve(xhr.response); resolve(xhr.response);
} else {
reject();
} }
}; };
...@@ -703,6 +705,7 @@ let post_technique_entity = (url, data, headers = {}) => { ...@@ -703,6 +705,7 @@ let post_technique_entity = (url, data, headers = {}) => {
export { export {
get, get,
getBlob,
post, post,
delete_util, delete_util,
fileUpload, fileUpload,
......
...@@ -354,7 +354,7 @@ ...@@ -354,7 +354,7 @@
<div style="height: 400px; position: relative"> <div style="height: 400px; position: relative">
<!-- <video id="video" class="" preload="meta" controls width="100%" object-fit="fill" height="100%" <!-- <video id="video" class="" preload="meta" controls width="100%" object-fit="fill" height="100%"
controlslist="nodownload" :src="video_src" disablePictureInPicture autoplay muted></video> --> controlslist="nodownload" :src="video_src" disablePictureInPicture autoplay muted></video> -->
<VideoPlayer v-if="centerDialogVisible_video" :src="video_src"></VideoPlayer> <VideoPlayer v-if="centerDialogVisible_video" :src="video_src"></VideoPlayer>
</div> </div>
</el-dialog> </el-dialog>
...@@ -367,6 +367,7 @@ ...@@ -367,6 +367,7 @@
import { import {
lastIndexOf, lastIndexOf,
get, get,
getBlob,
post, post,
fileUpload, fileUpload,
delete_util, delete_util,
...@@ -622,7 +623,17 @@ export default { ...@@ -622,7 +623,17 @@ export default {
// let path_srt = // let path_srt =
// "api/rest/document/pdf/" + _this.type_folder + "/" + row.file.uuid; // "api/rest/document/pdf/" + _this.type_folder + "/" + row.file.uuid;
// window.open(path_srt); // window.open(path_srt);
window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`); // window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`);
getBlob(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`).then(res => {
window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`);
}).catch(err => {
post("api/rest/file/path?bucket=Document&filename=" + row.file.uuid).then(res => {
window.open(`./onlyoffice.html?url=${encodeURIComponent(res)}&fileType=${row.file.type}&filename=${row.name}`);
}).catch(err => {
this.$message("预览失败");
});
});
} }
}, },
//table_全文搜索预览 //table_全文搜索预览
......
...@@ -348,7 +348,7 @@ ...@@ -348,7 +348,7 @@
<div style="height: 400px; position: relative"> <div style="height: 400px; position: relative">
<!-- <video id="video" class="" preload="meta" controls width="100%" object-fit="fill" height="100%" <!-- <video id="video" class="" preload="meta" controls width="100%" object-fit="fill" height="100%"
controlslist="nodownload" :src="video_src" disablePictureInPicture autoplay muted></video> --> controlslist="nodownload" :src="video_src" disablePictureInPicture autoplay muted></video> -->
<VideoPlayer v-if="centerDialogVisible_video" :src="video_src"></VideoPlayer> <VideoPlayer v-if="centerDialogVisible_video" :src="video_src"></VideoPlayer>
</div> </div>
</el-dialog> </el-dialog>
...@@ -361,6 +361,7 @@ ...@@ -361,6 +361,7 @@
import { import {
lastIndexOf, lastIndexOf,
get, get,
getBlob,
post, post,
fileUpload, fileUpload,
delete_util, delete_util,
...@@ -617,7 +618,17 @@ export default { ...@@ -617,7 +618,17 @@ export default {
// let path_srt = // let path_srt =
// "api/rest/document/pdf/" + _this.type_folder + "/" + row.file.uuid; // "api/rest/document/pdf/" + _this.type_folder + "/" + row.file.uuid;
// window.open(path_srt); // window.open(path_srt);
window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`); // window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`);
getBlob(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`).then(res => {
window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`);
}).catch(err => {
post("api/rest/file/path?bucket=Document&filename=" + row.file.uuid).then(res => {
window.open(`./onlyoffice.html?url=${encodeURIComponent(res)}&fileType=${row.file.type}&filename=${row.name}`);
}).catch(err => {
this.$message("预览失败");
});
});
} }
}, },
//table_全文搜索预览 //table_全文搜索预览
......
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
<!-- <video id="video" class="" preload="meta" controls width="100%" object-fit="fill" height="100%" <!-- <video id="video" class="" preload="meta" controls width="100%" object-fit="fill" height="100%"
controlslist="nodownload" :src="video_src" disablePictureInPicture muted autoplay type="video/x-flv"></video> --> controlslist="nodownload" :src="video_src" disablePictureInPicture muted autoplay type="video/x-flv"></video> -->
<VideoPlayer v-if="centerDialogVisible_video" :src="video_src"></VideoPlayer> <VideoPlayer v-if="centerDialogVisible_video" :src="video_src"></VideoPlayer>
</div> </div>
</el-dialog> </el-dialog>
...@@ -287,6 +287,7 @@ ...@@ -287,6 +287,7 @@
import { import {
lastIndexOf, lastIndexOf,
get, get,
getBlob,
post, post,
fileUpload_PUT, fileUpload_PUT,
fileUploadProgress, fileUploadProgress,
...@@ -527,7 +528,7 @@ export default { ...@@ -527,7 +528,7 @@ export default {
// // path_srt = path_srt + row.file.uuid; // // path_srt = path_srt + row.file.uuid;
// // _this.video_src = path_srt; // // _this.video_src = path_srt;
// // if (document.getElementById("video").currentTime != 0) // // if (document.getElementById("video").currentTime != 0)
// // document.getElementById("video").currentTime = 0; // // document.getElementById("video").currentTime = 0;
// }, 500); // }, 500);
...@@ -548,7 +549,21 @@ export default { ...@@ -548,7 +549,21 @@ export default {
// "/" + // "/" +
// row.file.uuid; // row.file.uuid;
// window.open(path_srt); // window.open(path_srt);
window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`); getBlob(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`).then(res => {
window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`);
}).catch(err => {
post("api/rest/file/path?bucket=Document&filename=" + row.file.uuid).then(res => {
window.open(`./onlyoffice.html?url=${encodeURIComponent(res)}&fileType=${row.file.type}&filename=${row.name}`);
}).catch(err => {
this.$message("预览失败");
});
});
// window.open(`api/rest/file/pdf/DocumentPDF?objectName=${row.file.uuid}`);
// post("api/rest/file/path?bucket=Document&filename=" + row.file.uuid).then(res => {
// // window.open(`./onlyoffice.html?url=${encodeURIComponent(res)}&fileType=docx&filename=${row.name}`);
// }).catch(err => {
// });
} }
}, },
//table_全文搜索预览 //table_全文搜索预览
...@@ -764,7 +779,7 @@ export default { ...@@ -764,7 +779,7 @@ export default {
//单个文件上传 //单个文件上传
let load = startLoadingProgress("0%"); let load = startLoadingProgress("0%");
let self = this; let self = this;
this.centerDialogVisible_add = false; this.centerDialogVisible_add = false;
load.text = ""; load.text = "";
let md5 = ""; let md5 = "";
let file = null; let file = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment