2025-04-23 14:10:11 +08:00
|
|
|
import axios from 'axios';
|
|
|
|
|
2025-06-17 18:27:35 +08:00
|
|
|
class ExcalidrawServerApi {
|
2025-04-23 14:10:11 +08:00
|
|
|
|
|
|
|
constructor(options) {
|
|
|
|
this.server = options.exdrawServer;
|
|
|
|
this.docUuid = options.exdrawUuid;
|
|
|
|
this.accessToken = options.accessToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
getSceneContent() {
|
|
|
|
const { server, docUuid, accessToken } = this;
|
|
|
|
const url = `${server}/api/v1/exdraw/${docUuid}/`;
|
|
|
|
|
|
|
|
return axios.get(url, { headers: { Authorization: `Token ${accessToken}` } });
|
|
|
|
}
|
|
|
|
|
|
|
|
saveSceneContent(content) {
|
|
|
|
const { server, docUuid, accessToken } = this;
|
|
|
|
const url = `${server}/api/v1/exdraw/${docUuid}/`;
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append('doc_content', content);
|
|
|
|
|
|
|
|
return axios.post(url, formData, { headers: { Authorization: `Token ${accessToken}` } });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-06-17 18:27:35 +08:00
|
|
|
export default ExcalidrawServerApi;
|