测试wps 的sdk

v0.0.1-final
tangjie 2026-07-17 10:17:13 +08:00
parent 99381e8ed5
commit cd25fa5e9a
2 changed files with 15 additions and 36 deletions

View File

@ -21,7 +21,6 @@
},
"dependencies": {
"@ant-design/icons": "^5.0.0",
"@cqsjjb/jjb-common-decorator": "latest",
"@cqsjjb/jjb-common-lib": "latest",
"@cqsjjb/jjb-dva-runtime": "latest",
@ -29,7 +28,6 @@
"@eigenpal/docx-editor-react": "^1.9.0",
"@rc-component/motion": "^1.0.0",
"@rc-component/util": "^1.11.1",
"antd": "^5.29.2",
"dayjs": "^1.11.7",
"echarts": "^6.1.0",
@ -46,7 +44,6 @@
"@babel/preset-react": "^7.29.7",
"@cqsjjb/scripts": "latest",
"@eslint-react/eslint-plugin": "^2.2.2",
"babel-loader": "^9.1.3",
"cross-env": "^7.0.3",
"css-loader": "^6.8.1",

View File

@ -1,39 +1,21 @@
// App.tsx
import { useRef, useState, useEffect } from "react";
import { DocxEditor } from "@eigenpal/docx-editor-react";
import { createEmptyDocument } from "@eigenpal/docx-editor-core";
import "@eigenpal/docx-editor-react/styles.css";
import "./index.less";
import WebOfficeSDK from "web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.es.js";
export default function App() {
const editorRef = useRef(null);
const [currentDocument, setCurrentDocument] = useState(createEmptyDocument());
const [documentBuffer, setDocumentBuffer] = useState();
const chooseWord = () => {
fetch(
`https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a589a40e4b0f40a8d939aa1.docx`,
)
.then((res) => res.arrayBuffer())
.then((buffer) => {
setDocumentBuffer(buffer);
useEffect(() => {
window.onload = async function () {
const instance = WebOfficeSDK.init({
// 必填项
officeType: WebOfficeSDK.OfficeType.Writer,
appId: "SX20260717TSGKEA",
fileId: "EOCVQPCDCCE4ZJ2X6MTF",
});
};
return (
<div style={{ height: "100vh", display: "flex" }}>
<DocxEditor
ref={editorRef}
document={documentBuffer ? undefined : currentDocument}
documentBuffer={documentBuffer}
mode="editing"
onSave={()=>{
console.log('save');
}}
/>
<div className="pick-word-container">
<div onClick={chooseWord}>文档</div>
</div>
</div>
);
// 需要等待实例 ready 之后再调用 API
await instance.ready();
};
}, []);
return <div style={{ height: "100vh", display: "flex" }}></div>;
}