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

文档预览

parent deb50e5d
......@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Title</title>
<title>文件预览</title>
</head>
<body>
......@@ -11,9 +11,29 @@
<script src="http://192.168.168.213:9000/web-apps/apps/api/documents/api.js"></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", {
"document": {
"fileType": "pptx",
"fileType": param.fileType.replace(".", ""),
"permissions": {
"edit": false,
"copy": false,
......@@ -22,8 +42,8 @@
"chat": false
},
// "key": "C8D7FB890BAC496FB0D27B163EDB88BDAA",
"title": "zf张飞.pptx",
"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",
"title": decodeURIComponent(param.filename),
"url": decodeURIComponent(param.url),
},
"height": "1000px",
"width": "100%",
......
<template>
<div>
</div>
<div id="placeholder"></div>
</template>
<script>
......@@ -15,7 +13,7 @@ export default {
mounted() {
var docEditor = new DocsAPI.DocEditor("placeholder", {
"document": {
"fileType": "pptx",
"fileType": this.fileType,
"permissions": {
"edit": false,
"copy": false,
......@@ -24,10 +22,10 @@ export default {
"chat": false
},
// "key": "C8D7FB890BAC496FB0D27B163EDB88BDAA",
"title": "zf张飞.pptx",
"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",
"title": this.filename,
"url": this.url,
},
"height": "1000px",
"height": "400px",
"width": "100%",
"editorConfig": {
"mode": 'view',
......
......@@ -303,7 +303,7 @@ let download = (url, filename) => {
* @return {Promise}
*/
let getBlob = (url) => {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
......@@ -311,6 +311,8 @@ let getBlob = (url) => {
xhr.onload = () => {
if (xhr.status === 200) {
resolve(xhr.response);
} else {
reject();
}
};
......@@ -703,6 +705,7 @@ let post_technique_entity = (url, data, headers = {}) => {
export {
get,
getBlob,
post,
delete_util,
fileUpload,
......
......@@ -354,7 +354,7 @@
<div style="height: 400px; position: relative">
<!-- <video id="video" class="" preload="meta" controls width="100%" object-fit="fill" height="100%"
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>
</el-dialog>
......@@ -367,6 +367,7 @@
import {
lastIndexOf,
get,
getBlob,
post,
fileUpload,
delete_util,
......@@ -622,7 +623,17 @@ export default {
// let path_srt =
// "api/rest/document/pdf/" + _this.type_folder + "/" + row.file.uuid;
// 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_全文搜索预览
......
......@@ -348,7 +348,7 @@
<div style="height: 400px; position: relative">
<!-- <video id="video" class="" preload="meta" controls width="100%" object-fit="fill" height="100%"
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>
</el-dialog>
......@@ -361,6 +361,7 @@
import {
lastIndexOf,
get,
getBlob,
post,
fileUpload,
delete_util,
......@@ -617,7 +618,17 @@ export default {
// let path_srt =
// "api/rest/document/pdf/" + _this.type_folder + "/" + row.file.uuid;
// 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_全文搜索预览
......
......@@ -274,7 +274,7 @@
<!-- <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> -->
<VideoPlayer v-if="centerDialogVisible_video" :src="video_src"></VideoPlayer>
<VideoPlayer v-if="centerDialogVisible_video" :src="video_src"></VideoPlayer>
</div>
</el-dialog>
......@@ -287,6 +287,7 @@
import {
lastIndexOf,
get,
getBlob,
post,
fileUpload_PUT,
fileUploadProgress,
......@@ -527,7 +528,7 @@ export default {
// // path_srt = path_srt + row.file.uuid;
// // _this.video_src = path_srt;
// // if (document.getElementById("video").currentTime != 0)
// // document.getElementById("video").currentTime = 0;
// }, 500);
......@@ -548,7 +549,21 @@ export default {
// "/" +
// row.file.uuid;
// 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_全文搜索预览
......@@ -764,7 +779,7 @@ export default {
//单个文件上传
let load = startLoadingProgress("0%");
let self = this;
this.centerDialogVisible_add = false;
this.centerDialogVisible_add = false;
load.text = "";
let md5 = "";
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