测试wps 的sdk
parent
99381e8ed5
commit
cd25fa5e9a
|
|
@ -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,12 +28,11 @@
|
|||
"@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",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
||||
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"zy-react-library": "^1.2.3"
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue