mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
onlyoffice: support pdf documents
This commit is contained in:
6 files changed
+38
-24
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { sign } from 'jsonwebtoken';
|
||||
import { } from '@hydrooj/ui-default/backendlib/markdown-it-media';
|
||||
import {
|
||||
Context, Handler, SystemModel, UiContextBase,
|
||||
} from 'hydrooj';
|
||||
@@ -15,6 +16,7 @@ class OnlyofficeJWTHandler extends Handler {
|
||||
|
||||
async get({ url }) {
|
||||
const path = new URL(url).pathname;
|
||||
const allowDownload = !!SystemModel.get('onlyoffice.allowDownload');
|
||||
const payload = {
|
||||
document: {
|
||||
fileType: path.split('.').pop(),
|
||||
@@ -23,19 +25,19 @@ class OnlyofficeJWTHandler extends Handler {
|
||||
url,
|
||||
permissions: {
|
||||
comment: false,
|
||||
copy: true,
|
||||
download: true,
|
||||
copy: allowDownload,
|
||||
download: allowDownload,
|
||||
edit: false,
|
||||
fillForms: false,
|
||||
modifyContentControl: false,
|
||||
modifyFilter: false,
|
||||
print: true,
|
||||
print: allowDownload,
|
||||
protect: false,
|
||||
review: false,
|
||||
},
|
||||
},
|
||||
editorConfig: {
|
||||
lang: this.user.viewLang.includes('_') ? this.user.viewLang.split('_')[0] : this.user.viewLang,
|
||||
lang: this.user.viewLang?.includes('_') ? this.user.viewLang.split('_')[0] : this.user.viewLang || 'zh',
|
||||
mode: 'view',
|
||||
user: {
|
||||
group: 'Hydro',
|
||||
@@ -73,4 +75,11 @@ export function apply(ctx: Context) {
|
||||
});
|
||||
});
|
||||
ctx.Route('onlyoffice-jwt', '/onlyoffice-jwt', OnlyofficeJWTHandler);
|
||||
if (SystemModel.get('onlyoffice.pdf')) {
|
||||
ctx.provideModule('richmedia', 'pdf', {
|
||||
get(service, src, md) {
|
||||
return `<div data-${service}>${md.utils.escapeHtml(src)}</div>`;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user