1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-10-21 19:00:12 +00:00

optimize code (#8289)

Co-authored-by: 小强 <shuntian@Mac.lan>
This commit is contained in:
杨顺强
2025-10-10 11:29:41 +08:00
committed by GitHub
parent aa368c105c
commit dfaa8480f1
4 changed files with 29 additions and 9 deletions

View File

@@ -1,12 +1,18 @@
import axios from 'axios';
import { seafileAPI } from '../../utils/seafile-api';
const { rawPath } = window.shared.pageOptions;
const { rawPath, docUuid, exdrawAccessToken, exdrawServerUrl } = window.shared.pageOptions;
class EditorApi {
getFileContent = () => {
return seafileAPI.getFileContent(rawPath);
};
getExdrawContent = () => {
const url = `${exdrawServerUrl}/api/v1/exdraw/${docUuid}/`;
return axios.get(url, { headers: { Authorization: `Token ${exdrawAccessToken}` } });
};
}
const editorApi = new EditorApi();

View File

@@ -12,7 +12,7 @@ const ExcaliViewer = () => {
const [isResize, setIsResize] = useState(false);
useEffect(() => {
editorApi.getFileContent().then(res => {
editorApi.getExdrawContent().then(res => {
if (res.data?.appState?.collaborators && !Array.isArray(res.data.appState.collaborators)) {
// collaborators.forEach is not a function
res.data['appState']['collaborators'] = [];