From dc7ecaaffc624afa5c8bce0e030ef00e5e54fa0c Mon Sep 17 00:00:00 2001 From: jmal Date: Mon, 31 Aug 2020 00:06:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/preview/SimTextPreview.vue | 31 +++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/components/preview/SimTextPreview.vue b/src/components/preview/SimTextPreview.vue index 4615329..c5782b0 100644 --- a/src/components/preview/SimTextPreview.vue +++ b/src/components/preview/SimTextPreview.vue @@ -64,7 +64,7 @@
-
+
-
+
- - +
@@ -185,7 +184,11 @@ options: { fontSize: 14, contextmenu: true, - readOnly: !this.$store.state.user.token, + codeLens: true, + readOnly: true, + minimap: { + enabled: this.$pc + }, // 换行 wordWrap: this.lineWrapping ? 'wordWrapColumn':'', wordWrapMinified: true, @@ -252,12 +255,13 @@ }, watch: { //监听file的变化,进行相应的操作即可 file(file) { + console.log('watich:file',file) if(!file.path){ return } this.editableTabs = [] + this.checkReadOnly(file.userId) this.loadEditorSize() - this.loading = this.$message({ iconClass: 'el-icon-loading', type: 'info', @@ -275,12 +279,10 @@ let request = 'previewText' if(this.shareId){ request = 'sharePreviewText' - this.options.readOnly = true } if(this.filepath){ request = 'previewTextByPath' file.path = this.filepath - this.options.readOnly = true } if(!file.id){ request = 'previewTextByPath' @@ -544,6 +546,16 @@ containerResize() { this.loadEditorSize() }, + checkReadOnly(fileUserId){ + console.log('readOnly',this.options.readOnly) + if(this.$store.state.user.token && this.$store.state.user.userId === fileUserId){ + this.options.readOnly = false + } + if(this.options.readOnly){ + this.editorWidth += this.contentsWidth + this.contentsHide = true + } + }, loadEditorSize(){ this.dialogWidth = document.body.clientWidth * this.dialogWidthPercent if(this.contentsHide){ @@ -1208,6 +1220,9 @@ float: right; cursor: nwse-resize; } + .el-button--small.is-circle { + padding: 9px 9px; + } }