修改:分享模式修改

This commit is contained in:
jmal 2020-08-31 00:06:24 +08:00
parent f4055bdff0
commit dc7ecaaffc

View File

@ -64,7 +64,7 @@
</div> </div>
</div> </div>
<div class="content" :style="{height: editorHieght+26+'px'}"> <div class="content" :style="{height: editorHieght+26+'px'}">
<div class="file-contents" :style="{width: contentsWidth+'px',height: editorHieght+32+'px',transition: transition}"> <div class="file-contents" :style="{width: contentsWidth+'px',height: editorHieght+32+'px',transition: transition,left: options.readOnly?`-${contentsWidth}px`:`0px`}">
<div class="content-tree"> <div class="content-tree">
<fancy-tree <fancy-tree
ref="fancTree" ref="fancTree"
@ -81,10 +81,9 @@
</fancy-tree> </fancy-tree>
</div> </div>
</div> </div>
<div class="editor-resize" :style="{marginLeft: contentsWidth+'px',transition: transition}"> <div class="editor-resize" :style="{marginLeft: options.readOnly?`0px`:`${contentsWidth}px`,transition: transition}">
<div class="darg-resize-conter"></div> <div class="darg-resize-conter"></div>
<i class="editor-resize-conter" icon="el-icon-arrow-right" title="影藏文件目录" @click="hideContents"> <i v-show="!options.readOnly" class="editor-resize-conter" icon="el-icon-arrow-right" title="影藏文件目录" @click="hideContents"/>
</i>
</div> </div>
<div :style="{width: editorWidth-2+'px'}"> <div :style="{width: editorWidth-2+'px'}">
<el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab"> <el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab">
@ -185,7 +184,11 @@
options: { options: {
fontSize: 14, fontSize: 14,
contextmenu: true, contextmenu: true,
readOnly: !this.$store.state.user.token, codeLens: true,
readOnly: true,
minimap: {
enabled: this.$pc
},
// 换行 // 换行
wordWrap: this.lineWrapping ? 'wordWrapColumn':'', wordWrap: this.lineWrapping ? 'wordWrapColumn':'',
wordWrapMinified: true, wordWrapMinified: true,
@ -252,12 +255,13 @@
}, },
watch: { //监听file的变化,进行相应的操作即可 watch: { //监听file的变化,进行相应的操作即可
file(file) { file(file) {
console.log('watich:file',file)
if(!file.path){ if(!file.path){
return return
} }
this.editableTabs = [] this.editableTabs = []
this.checkReadOnly(file.userId)
this.loadEditorSize() this.loadEditorSize()
this.loading = this.$message({ this.loading = this.$message({
iconClass: 'el-icon-loading', iconClass: 'el-icon-loading',
type: 'info', type: 'info',
@ -275,12 +279,10 @@
let request = 'previewText' let request = 'previewText'
if(this.shareId){ if(this.shareId){
request = 'sharePreviewText' request = 'sharePreviewText'
this.options.readOnly = true
} }
if(this.filepath){ if(this.filepath){
request = 'previewTextByPath' request = 'previewTextByPath'
file.path = this.filepath file.path = this.filepath
this.options.readOnly = true
} }
if(!file.id){ if(!file.id){
request = 'previewTextByPath' request = 'previewTextByPath'
@ -544,6 +546,16 @@
containerResize() { containerResize() {
this.loadEditorSize() 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(){ loadEditorSize(){
this.dialogWidth = document.body.clientWidth * this.dialogWidthPercent this.dialogWidth = document.body.clientWidth * this.dialogWidthPercent
if(this.contentsHide){ if(this.contentsHide){
@ -1208,6 +1220,9 @@
float: right; float: right;
cursor: nwse-resize; cursor: nwse-resize;
} }
.el-button--small.is-circle {
padding: 9px 9px;
}
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>