From 10b633ef6b32519fb0e20a95b529c49ba154a97c Mon Sep 17 00:00:00 2001 From: godo Date: Wed, 11 Dec 2024 09:12:41 +0800 Subject: [PATCH] add onlyoffice --- frontend/src/components/window/OnlyOffice.vue | 45 +++---------------- .../src/components/window/WindowInner.vue | 30 +++++++++---- godo/cmd/main.go | 22 +-------- godo/cmd/serve.go | 22 ++++++++- 4 files changed, 51 insertions(+), 68 deletions(-) diff --git a/frontend/src/components/window/OnlyOffice.vue b/frontend/src/components/window/OnlyOffice.vue index 8554f1d..b96fe27 100644 --- a/frontend/src/components/window/OnlyOffice.vue +++ b/frontend/src/components/window/OnlyOffice.vue @@ -7,7 +7,6 @@ import { DocumentEditor } from "@onlyoffice/document-editor-vue"; import { getSystemConfig } from "@/system/config"; import { BrowserWindow, Dialog, Notify, System } from "@/system"; -import { generateRandomString } from "@/util/common"; const config = getSystemConfig(); const sys: any = inject("system"); const win: any = inject("browserWindow"); @@ -26,56 +25,26 @@ const props = defineProps({ }, }); const editorConfig: any = ref({}) -// async function fetchDocumentKey(path: string): Promise { -// try { -// const response:any = await fetch(`${config.onlyoffice.url}/get-document-key?path=${path}`); -// console.log(response) -// const res = await response.json(); -// return res.data.key; -// } catch (error) { -// console.error("Failed to fetch document key:", error); -// throw error; -// } -// } onMounted(() => { const path = win?.config?.path; - const uniqueKey = generateRandomString(12); //const uniqueKey = fetchDocumentKey(path) const readUrl = config.apiUrl + "/file/readfile?stream=1&path=" + path editorConfig.value = { document: { fileType: "docx", - //key: "ojR1OasBPnlIwF9WA80AW4NTrIWqs9", - //"key": uniqueKey, key: "docx" + Math.random(), - // "permissions": { - // "chat": true, - // "comment": true, - // "copy": true, - // "download": true, - // "edit": true, - // "fillForms": true, - // "modifyContentControl": true, - // "modifyFilter": true, - // "print": true, - // "review": true, - // "reviewGroups": null, - // "commentGroups": {}, - // "userInfoGroups": null, - // "protect": true - // }, title: "Example Document Title.docx", url: readUrl }, documentType: "word", editorConfig: { - callbackUrl: "https://example.com/url-to-callback.ashx", - // customization: { - // "anonymous": { - // request: true, - // label: "Guest", - // } - // }, + //callbackUrl: "https://example.com/url-to-callback.ashx", + customization: { + "anonymous": { + request: true, + label: "Guest", + } + }, } } }) diff --git a/frontend/src/components/window/WindowInner.vue b/frontend/src/components/window/WindowInner.vue index 25ca7fd..d8167e2 100644 --- a/frontend/src/components/window/WindowInner.vue +++ b/frontend/src/components/window/WindowInner.vue @@ -1,11 +1,15 @@