From ee25f1d1f9cafad4f637704b4b82241f8a833fdb Mon Sep 17 00:00:00 2001 From: jmal Date: Sat, 8 Jun 2024 12:59:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?perf:=20=E9=80=82=E9=85=8D=20onlyoffice=20J?= =?UTF-8?q?WT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/file-api.js | 19 ++++++++++++++- src/components/office/OnlyOfficeEditor.vue | 28 ++++++++++++++++++++-- src/components/preview/OfficePreview.vue | 9 ++++--- src/views/public/share/shareList.vue | 4 +++- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/api/file-api.js b/src/api/file-api.js index bd92775..81e5f8e 100644 --- a/src/api/file-api.js +++ b/src/api/file-api.js @@ -338,5 +338,22 @@ export default { method: 'get', params }) - } + }, + // 获取office jwt + getOfficeJwt: function(data) { + return request({ + url: '/office/signature', + method: 'post', + data + }) + }, + // 获取office jwt + getPublicOfficeJwt: function(params, data) { + return request({ + url: '/public/office/signature', + method: 'post', + params, + data + }) + }, } diff --git a/src/components/office/OnlyOfficeEditor.vue b/src/components/office/OnlyOfficeEditor.vue index d48610c..e02d6c9 100644 --- a/src/components/office/OnlyOfficeEditor.vue +++ b/src/components/office/OnlyOfficeEditor.vue @@ -49,6 +49,10 @@ export default { type: String, default: '' }, + sharer: { + type: String, + default: undefined + }, file: { type: Object, default: function () { @@ -221,11 +225,14 @@ export default { this.$refs.historyPopover.loadHistoryList(this.file.id) }) this.destroyEditor() - this.fileUrl = window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token) + + const file_username = this.sharer ? this.sharer : this.$store.state.user.name + this.fileUrl = window.location.origin + fileConfig.previewUrl(file_username, this.file, this.$store.getters.token) + this.fileKey = `${new Date(this.file.updateDate).getTime()}-${SparkMD5.hash(this.file.id)}` if (this.readOnly && window.shareId) { this.fileUrl = window.location.origin + fileConfig.publicPreviewUrl(this.file, window.shareId, this.$store.getters.shareToken) + this.fileKey = `${new Date(this.file.updateDate).getTime()}-${SparkMD5.hash(window.shareId)}` } - this.fileKey = `${new Date(this.file.updateDate).getTime()}-${SparkMD5.hash(this.file.id)}` let callbackUrl = fileConfig.officeCallBackUrl(this.$store.getters.token, this.$store.getters.name, this.file.id) @@ -261,6 +268,22 @@ export default { callbackUrl: callbackUrl, } } + + if (this.readOnly && window.shareId) { + const shareToken = this.$store.getters.shareToken ? this.$store.getters.shareToken : 'token' + this.docEditorConfig.editorConfig.callbackUrl = null + api.getPublicOfficeJwt({shareId: window.shareId, shareToken: shareToken}, this.docEditorConfig).then(res => { + this.loadOffice(res.data) + }) + } else { + api.getOfficeJwt(this.docEditorConfig).then(res => { + this.loadOffice(res.data) + }) + } + + }, + loadOffice(token) { + this.docEditorConfig.token = token if (!this.$pc) { this.docEditorConfig.type = 'mobile' } @@ -277,6 +300,7 @@ export default { this.docEditorConfig.editorConfig.user.name = "Visitor_" + visitor } } + this.docEditorConfig.events = { "onAppReady": this.onAppReady, "onDocumentReady": this.onDocumentReady, diff --git a/src/components/preview/OfficePreview.vue b/src/components/preview/OfficePreview.vue index 6dcc55d..7e22b90 100644 --- a/src/components/preview/OfficePreview.vue +++ b/src/components/preview/OfficePreview.vue @@ -19,7 +19,7 @@ - + @@ -30,7 +30,6 @@ import OnlyOfficeEditor from "@/components/office/OnlyOfficeEditor"; import MessageDialog from "@/components/message/MessageDialog"; -import Bus from "@/assets/js/bus"; import fileConfig from "@/utils/file-config"; import PdfPreview from "@/components/office/PdfPreview"; import Drawio from "@/components/office/Drawio"; @@ -56,6 +55,10 @@ export default { type: String, default: undefined }, + sharer: { + type: String, + default: undefined + }, status: { type: Boolean, default: false @@ -207,7 +210,7 @@ export default { this.$message.info('请手动保存') }, /** - * 检查要预览调文件是否为只读 + * 检查要预览的文件是否为只读 * @param file userId */ checkReadOnly(file){ diff --git a/src/views/public/share/shareList.vue b/src/views/public/share/shareList.vue index f708f7c..7bf5f68 100644 --- a/src/views/public/share/shareList.vue +++ b/src/views/public/share/shareList.vue @@ -255,7 +255,7 @@ - +  {{ summaries }} @@ -418,6 +418,7 @@ export default { showUpdateDateItem: this.$pc,// 列表模式下是否显示修改时间 showSizeItem: this.$pc,// 列表模式下是否显示文件大小 sharer: undefined,//分享者信息, + sharerUsername: undefined, loginTitle: '', sharerAvatarUrl: '', netdiskName: 'JmalCloud', @@ -698,6 +699,7 @@ export default { if (this.sharer.netdiskName) { this.netdiskName = this.sharer.netdiskName } + this.sharerUsername = this.sharer.username if (this.sharer.netdiskLogo) { this.netdiskLogo = this.sharer.netdiskLogo } From b3d631eac5df0646c6b5519c1ff6fa4114993761 Mon Sep 17 00:00:00 2001 From: jmal Date: Sat, 8 Jun 2024 14:03:42 +0800 Subject: [PATCH 2/3] =?UTF-8?q?perf:=20=E9=80=82=E9=85=8D=20onlyoffice=20J?= =?UTF-8?q?WT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/office/OnlyOfficeEditor.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/office/OnlyOfficeEditor.vue b/src/components/office/OnlyOfficeEditor.vue index e02d6c9..a88f1b5 100644 --- a/src/components/office/OnlyOfficeEditor.vue +++ b/src/components/office/OnlyOfficeEditor.vue @@ -192,11 +192,15 @@ export default { this.docEditor = new DocsAPI.DocEditor(this.id, this.docEditorConfig) }, onRequestHistoryData(event, historyInfo, url) { - this.docEditor.setHistoryData({ + let historyConfig = { "fileType": this.fileType, "key": `${new Date(historyInfo.metadata.time).getTime()}-${SparkMD5.hash(this.file.id)}`, "url": url, "version": historyInfo.metadata.time, + } + api.getOfficeJwt(historyConfig).then(res => { + historyConfig.token = res.data + this.docEditor.setHistoryData(historyConfig) }) }, onRequestHistory() { @@ -341,6 +345,7 @@ export default { if (this.hasHistoryVersion && !doc.getElementById('box-doc-name-history-btn')) { const toolbar = doc.getElementById('box-doc-name') toolbar.style.justifyContent = 'right' + toolbar.style.padding = '0' let versionButton = document.createElement("button") versionButton.classList.add('btn', 'btn-header') versionButton.setAttribute('id', 'box-doc-name-history-btn') From 1ce18c8e10e6717eb003a062e588d8c4c17de7bf Mon Sep 17 00:00:00 2001 From: jmal Date: Sat, 8 Jun 2024 23:52:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?perf:=20=E9=80=82=E9=85=8D=20onlyoffice=20J?= =?UTF-8?q?WT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/setting-api.js | 15 ++++ src/components/ShowFile/ShowFile.vue | 2 +- src/components/office/OnlyOfficeEditor.vue | 88 ++++++++++++------- src/utils/file-config.js | 28 +++--- src/views/setting/cloudManager.vue | 16 ++-- .../setting/{ => cloudSetting}/ldapConfig.vue | 0 .../setting/cloudSetting/officeConfig.vue | 83 +++++++++++++++++ .../{ => cloudSetting}/transcodeConfig.vue | 6 +- 8 files changed, 190 insertions(+), 48 deletions(-) rename src/views/setting/{ => cloudSetting}/ldapConfig.vue (100%) create mode 100644 src/views/setting/cloudSetting/officeConfig.vue rename src/views/setting/{ => cloudSetting}/transcodeConfig.vue (91%) diff --git a/src/api/setting-api.js b/src/api/setting-api.js index 2547ea1..b65f110 100644 --- a/src/api/setting-api.js +++ b/src/api/setting-api.js @@ -83,6 +83,21 @@ export default { url: '/user/setting/resetMenuAndRole', method: 'put', }) + }, + // 获取office配置 + getOfficeConfig: function() { + return request({ + url: '/office/config', + method: 'get' + }) + }, + // 更新office配置 + updateOfficeConfig: function(data) { + return request({ + url: '/office/config', + method: 'put', + data + }) } } diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 8deb776..9899a23 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -2206,7 +2206,7 @@ export default { }, extendedInfo(file) { if (!file.exif && !file.video) { - return + return '' } return "\r\n" + formatExif(file.exif) + formatVideo(file.video) }, diff --git a/src/components/office/OnlyOfficeEditor.vue b/src/components/office/OnlyOfficeEditor.vue index a88f1b5..14785eb 100644 --- a/src/components/office/OnlyOfficeEditor.vue +++ b/src/components/office/OnlyOfficeEditor.vue @@ -22,6 +22,7 @@ + + diff --git a/src/views/setting/transcodeConfig.vue b/src/views/setting/cloudSetting/transcodeConfig.vue similarity index 91% rename from src/views/setting/transcodeConfig.vue rename to src/views/setting/cloudSetting/transcodeConfig.vue index 60306fb..c352070 100644 --- a/src/views/setting/transcodeConfig.vue +++ b/src/views/setting/cloudSetting/transcodeConfig.vue @@ -1,6 +1,6 @@