提交 b03e1a2d authored 作者: 龙菲's avatar 龙菲

测试wps

上级 20ffa9e7
差异被折叠。
...@@ -314,8 +314,8 @@ const fileFunction = { ...@@ -314,8 +314,8 @@ const fileFunction = {
const WORD = ['doc', 'docx'] const WORD = ['doc', 'docx']
const PDF = ['pdf'] const PDF = ['pdf']
// 若当前点击项是word // 若当前点击项是word
let extentName = row.extendName || row.suffix || row.showType let extendName = row.extendName || row.suffix || row.showType
if (WORD.includes(extentName.toLowerCase())) { if (WORD.includes(extendName.toLowerCase()) || PDF.includes(extendName.toLowerCase())) {
let flag = false let flag = false
const { fileId, userId, id } = row const { fileId, userId, id } = row
// 根据当前文件的作者的userId进行判断,和本人一致则是可编辑 // 根据当前文件的作者的userId进行判断,和本人一致则是可编辑
...@@ -353,8 +353,8 @@ const fileFunction = { ...@@ -353,8 +353,8 @@ const fileFunction = {
query: { query: {
wpsUrl: res.data.wpsUrl, wpsUrl: res.data.wpsUrl,
token: res.data.token, token: res.data.token,
fileId fileId,
extendName
} }
}) })
window.open(resolve.href, '_blank') window.open(resolve.href, '_blank')
...@@ -362,14 +362,12 @@ const fileFunction = { ...@@ -362,14 +362,12 @@ const fileFunction = {
}) })
return false return false
// 实际实现逻辑---end // 实际实现逻辑---end
}
// 若当前点击项是pdf
else if (PDF.includes(extentName.toLowerCase())) {
router.push('/pdfReader')
return false
} }
// // 若当前点击项是pdf
// else if (PDF.includes(extendName.toLowerCase())) {
// router.push('/pdfReader')
// return false
// }
} }
}, },
/** /**
......
...@@ -5,11 +5,7 @@ ...@@ -5,11 +5,7 @@
'sidebar-open': $store.state.app.sidebar.opened, 'sidebar-open': $store.state.app.sidebar.opened,
}" }"
> >
<div <div ref="myIframe" id="wps-container" class="wps-container"></div>
ref="myIframe"
id="wps-container"
class="wps-container"
></div>
<RightPanel <RightPanel
ref="RightPanel" ref="RightPanel"
:class="[ :class="[
...@@ -28,7 +24,8 @@ ...@@ -28,7 +24,8 @@
</div> </div>
</template> </template>
<script> <script>
import WebOfficeSDK from "/public/weboffice/web-office-sdk-v1.1.19.es"; import WebOfficeSDK from "/public/weboffice/web-office-sdk19.es";
// import WebOfficeSDK from "/public/weboffice/web-office-sdk-solution-v2.0.4.es";
import RightPanel from "./component/rightPanel.vue"; import RightPanel from "./component/rightPanel.vue";
import AddOrUpdateNoteDialog from "./component/addOrUpdateNoteDialog.vue"; import AddOrUpdateNoteDialog from "./component/addOrUpdateNoteDialog.vue";
import { addNearRead } from "@/api/user"; import { addNearRead } from "@/api/user";
...@@ -59,23 +56,11 @@ export default { ...@@ -59,23 +56,11 @@ export default {
return this.$store.state.app.sidebar.opened; return this.$store.state.app.sidebar.opened;
}, },
}, },
watch: {
panelVisible(value) {
debugger
// 获取office-iframe的dom并修改宽度为100vw
const officeIframe = document.getElementById("office-iframe");
if (!value) {
officeIframe.style.width = "100vw !important";
} else {
officeIframe.style.width = "100% !important";
}
},
},
mounted() { mounted() {
const { wpsUrl, token, fileId } = this.$route.query; const { wpsUrl, token, fileId } = this.$route.query;
this.routeParams = { wpsUrl, token, fileId }; this.routeParams = { wpsUrl, token, fileId };
this.form.docId = fileId; this.form.docId = fileId;
this.initWps(wpsUrl, token); this.initWps(wpsUrl, token, fileId);
}, },
destroyed() { destroyed() {
this.removeSelectionChangeListener(); this.removeSelectionChangeListener();
...@@ -101,14 +86,22 @@ export default { ...@@ -101,14 +86,22 @@ export default {
} }
}, },
// 初始化WPS // 初始化WPS
async initWps(wpsUrl, token) { async initWps(wpsUrl, token, fileId) {
this.wpsInstance = WebOfficeSDK.config({ this.wpsInstance = WebOfficeSDK.config({
wpsUrl, wpsUrl,
mount: document.querySelector("#wps-container"), mount: document.querySelector("#wps-container"),
}); });
this.wpsInstance.setToken({ token }); this.wpsInstance.setToken({ token });
this.wpsInstance.ApiEvent.AddApiEventListener("fileOpen", (data) => {
console.log("fileOpen: ", data);
});
// 等待加载完毕 // 等待加载完毕
await this.wpsInstance.ready(); await this.wpsInstance.ready();
const app = this.wpsInstance.Application;
console.log("app", app);
this.addSelectionListen(); this.addSelectionListen();
this.initAddNoteButton(); this.initAddNoteButton();
this.addViewRecord(); this.addViewRecord();
...@@ -123,6 +116,21 @@ export default { ...@@ -123,6 +116,21 @@ export default {
this.handleSelectionChange(data); this.handleSelectionChange(data);
} }
); );
this.wpsInstance.ApiEvent.AddApiEventListener(
"TextSelectChange",
async (data) => {
console.log("TextSelectChange");
// 复制选中的批注文案
const app = this.wpsInstance.Application;
console.log("app", app);
await app.ActivePDF.AnnoAPI.SetSelectionAnno({
type: app.Enum.AnnoType.Highlight,
color: "rgba(0,0,0,1)",
});
}
);
}, },
// 初始化并监听新建笔记按钮 // 初始化并监听新建笔记按钮
async initAddNoteButton() { async initAddNoteButton() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论