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

测试wps

上级 20ffa9e7
差异被折叠。
......@@ -314,8 +314,8 @@ const fileFunction = {
const WORD = ['doc', 'docx']
const PDF = ['pdf']
// 若当前点击项是word
let extentName = row.extendName || row.suffix || row.showType
if (WORD.includes(extentName.toLowerCase())) {
let extendName = row.extendName || row.suffix || row.showType
if (WORD.includes(extendName.toLowerCase()) || PDF.includes(extendName.toLowerCase())) {
let flag = false
const { fileId, userId, id } = row
// 根据当前文件的作者的userId进行判断,和本人一致则是可编辑
......@@ -353,8 +353,8 @@ const fileFunction = {
query: {
wpsUrl: res.data.wpsUrl,
token: res.data.token,
fileId
fileId,
extendName
}
})
window.open(resolve.href, '_blank')
......@@ -362,14 +362,12 @@ const fileFunction = {
})
return false
// 实际实现逻辑---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 @@
'sidebar-open': $store.state.app.sidebar.opened,
}"
>
<div
ref="myIframe"
id="wps-container"
class="wps-container"
></div>
<div ref="myIframe" id="wps-container" class="wps-container"></div>
<RightPanel
ref="RightPanel"
:class="[
......@@ -28,7 +24,8 @@
</div>
</template>
<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 AddOrUpdateNoteDialog from "./component/addOrUpdateNoteDialog.vue";
import { addNearRead } from "@/api/user";
......@@ -59,23 +56,11 @@ export default {
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() {
const { wpsUrl, token, fileId } = this.$route.query;
this.routeParams = { wpsUrl, token, fileId };
this.form.docId = fileId;
this.initWps(wpsUrl, token);
this.initWps(wpsUrl, token, fileId);
},
destroyed() {
this.removeSelectionChangeListener();
......@@ -101,14 +86,22 @@ export default {
}
},
// 初始化WPS
async initWps(wpsUrl, token) {
async initWps(wpsUrl, token, fileId) {
this.wpsInstance = WebOfficeSDK.config({
wpsUrl,
mount: document.querySelector("#wps-container"),
});
this.wpsInstance.setToken({ token });
this.wpsInstance.ApiEvent.AddApiEventListener("fileOpen", (data) => {
console.log("fileOpen: ", data);
});
// 等待加载完毕
await this.wpsInstance.ready();
const app = this.wpsInstance.Application;
console.log("app", app);
this.addSelectionListen();
this.initAddNoteButton();
this.addViewRecord();
......@@ -123,6 +116,21 @@ export default {
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() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论