Преглед изворни кода

onlyoffice预览页下载打印权限控制

cfort пре 2 година
родитељ
комит
f6d0bdaec3
1 измењених фајлова са 23 додато и 22 уклоњено
  1. 23 22
      src/views/viewFile/index.vue

+ 23 - 22
src/views/viewFile/index.vue

@@ -1,7 +1,7 @@
 <!--onlyoffice 编辑器-->
 <template>
     <div>
-        <div id="editorDiv" class="nav" ref="editor" />
+        <div id="editorDiv" ref="editor" class="nav" />
     </div>
 </template>
 
@@ -18,7 +18,17 @@ export default {
             newId: '',
             timer: '',
             configKey: '',
-            option: {}
+            option: {},
+            hasRole: localStorage.getItem('hasHighRole') === '1'
+        }
+    },
+    watch: {
+        option: {
+            handler: function (n, o) {
+                this.setEditor(n)
+                this.doctype = handleDocType(n.fileType)
+            },
+            deep: true
         }
     },
     mounted () {
@@ -31,9 +41,9 @@ export default {
     methods: {
         setEditor (option) {
             this.doctype = handleDocType(option.fileType)
-            let url = option.url + '&access_token=' + getToken();
-            console.log("url:" + url)
-            let config = {
+            const url = option.url + '&access_token=' + getToken()
+            console.log('url:' + url)
+            const config = {
                 document: {
                     fileType: option.fileType,
                     key: option.key,
@@ -41,10 +51,10 @@ export default {
                     permissions: {
                         comment: true,
                         copy: true,
-                        download: false,
+                        download: this.hasRole,
                         modifyContentControl: true,
                         modifyFilter: true,
-                        print: false,
+                        print: this.hasRole,
                         edit: true,
                         fillForms: true,
                         review: true
@@ -64,32 +74,23 @@ export default {
                         compactToolbar: true,
                         feedback: false,
                         plugins: true,
-                        "feedback": {
-                            "visible": true // 隐藏反馈按钮
+                        'feedback': {
+                            'visible': true // 隐藏反馈按钮
                         },
-                        "forcesave": true, // true 表示强制文件保存请求添加到回调处理程序
-                        "atuosave": false, // 取消强制保存,进行手动保存
+                        'forcesave': true, // true 表示强制文件保存请求添加到回调处理程序
+                        'atuosave': false // 取消强制保存,进行手动保存
                     },
                     user: {
                         id: this.$store.getters.userId,
                         name: this.$store.getters.name
                     },
-                    mode: option.mode,
+                    mode: option.mode
                 },
                 width: '100%',
                 height: document.body.clientHeight + 'px'
             }
-            let docEditor = new DocsAPI.DocEditor('editorDiv', config)
+            const docEditor = new DocsAPI.DocEditor('editorDiv', config)
             this.configKey = config.document.key
-        },
-    },
-    watch: {
-        option: {
-            handler: function (n, o) {
-                this.setEditor(n)
-                this.doctype = handleDocType(n.fileType)
-            },
-            deep: true,
         }
     }
 }