优化:移动端文本预览

This commit is contained in:
jmal 2021-03-24 18:01:42 +08:00
parent b5aa808f3b
commit e637ee2366
2 changed files with 37 additions and 12 deletions

View File

@ -36,7 +36,7 @@
class="simtext-dialog" class="simtext-dialog"
v-dialogDrag="{ dialogWidthPercent: dialogWidthPercent}"> v-dialogDrag="{ dialogWidthPercent: dialogWidthPercent}">
<div slot="title" class="simtext-header-title"> <div slot="title" class="simtext-header-title">
<span><file-path-nav class="title-name" :path="filePathNav" @loadPath="loadPath"></file-path-nav></span> <span v-show="!moblie"><file-path-nav class="title-name" :path="filePathNav" @loadPath="loadPath"></file-path-nav></span>
<div class="title-extension"> <div class="title-extension">
<el-button v-if="isShowUpdateBtn" @click="saveAll(false)" :class="lightTheme?'':'dark-button'" size="small" :loading="updating">保存所有</el-button> <el-button v-if="isShowUpdateBtn" @click="saveAll(false)" :class="lightTheme?'':'dark-button'" size="small" :loading="updating">保存所有</el-button>
<el-button <el-button
@ -63,7 +63,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,left: options.readOnly?`-${contentsWidth}px`:`0px`}"> <div class="file-contents" :style="{width: contentsWidth+'px',height: editorHieght+32+'px',transition: transition,left: options.readOnly || moblie ?`-${contentsWidth}px`:`0px`}">
<div class="content-tree"> <div class="content-tree">
<fancy-tree <fancy-tree
ref="fancTree" ref="fancTree"
@ -80,9 +80,9 @@
</fancy-tree> </fancy-tree>
</div> </div>
</div> </div>
<div class="editor-resize" :style="{marginLeft: options.readOnly?`0px`:`${contentsWidth}px`,transition: transition}"> <div class="editor-resize" :style="{marginLeft: options.readOnly || moblie ?`0px`:`${contentsWidth}px`,transition: transition}">
<div class="darg-resize-conter"></div> <div class="darg-resize-conter"></div>
<i v-show="!options.readOnly" class="editor-resize-conter" icon="el-icon-arrow-right" title="影藏文件目录" @click="hideContents"/> <i v-show="!options.readOnly && !moblie " class="editor-resize-conter" icon="el-icon-arrow-right" title="影藏文件目录" @click="hideContents"/>
</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">
@ -176,6 +176,7 @@
contentsHide: false, contentsHide: false,
defalutLanguage: 'redis', defalutLanguage: 'redis',
lineWrapping: false, lineWrapping: false,
moblie: false,
options: { options: {
fontSize: 14, fontSize: 14,
contextmenu: true, contextmenu: true,
@ -254,6 +255,7 @@
return return
} }
this.editableTabs = [] this.editableTabs = []
this.checkMobile()
this.checkReadOnly(file.userId) this.checkReadOnly(file.userId)
this.loadEditorSize() this.loadEditorSize()
this.loading = this.$message({ this.loading = this.$message({
@ -541,13 +543,23 @@
containerResize() { containerResize() {
this.loadEditorSize() this.loadEditorSize()
}, },
checkMobile() {
if (!this.$pc) {
this.moblie = true
} else {
this.moblie = false
}
},
checkReadOnly(fileUserId){ checkReadOnly(fileUserId){
if(this.$store.state.user.token && this.$store.state.user.userId === fileUserId){ if(this.$store.state.user.token && this.$store.state.user.userId === fileUserId){
this.options.readOnly = false this.options.readOnly = false
} }
if(this.options.readOnly){ console.log(this.options.readOnly, this.moblie)
this.editorWidth += this.contentsWidth if(this.options.readOnly || this.moblie){
this.contentsHide = true this.$nextTick(()=> {
this.editorWidth += this.contentsWidth
this.contentsHide = true
})
} }
}, },
loadEditorSize(){ loadEditorSize(){
@ -863,6 +875,7 @@
.el-dialog__header { .el-dialog__header {
padding: 5px 20px 5px; padding: 5px 20px 5px;
overflow: hidden;
.el-dialog__headerbtn { .el-dialog__headerbtn {
top: 12px; top: 12px;

View File

@ -231,6 +231,7 @@
</van-cell> </van-cell>
</van-overlay> </van-overlay>
<!--为了不受右键区域的影响, 把弹窗之类的提取出来--> <!--为了不受右键区域的影响, 把弹窗之类的提取出来-->
<sim-text-preview :file.sync="textPreviewRow" :status.sync="textPreviewVisible"></sim-text-preview>
<image-viewer :fileList="fileList" :file="imagePreviewRow" :status.sync="imagePreviewVisible"></image-viewer> <image-viewer :fileList="fileList" :file="imagePreviewRow" :status.sync="imagePreviewVisible"></image-viewer>
<video-preview :file="videoPreviewRow" :status.sync="videoPreviewVisible"></video-preview> <video-preview :file="videoPreviewRow" :status.sync="videoPreviewVisible"></video-preview>
</div> </div>
@ -246,10 +247,13 @@
import fileConfig from "@/utils/file-config"; import fileConfig from "@/utils/file-config";
import ImageViewer from "@/components/preview/ImageViewer"; import ImageViewer from "@/components/preview/ImageViewer";
import VideoPreview from "@/components/preview/VideoPreview"; import VideoPreview from "@/components/preview/VideoPreview";
import SimTextPreview from "@/components/preview/SimTextPreview";
import {suffix} from "@/utils/file-type";
let pinyin = require("pinyin"); let pinyin = require("pinyin");
export default { export default {
components: { components: {
SimTextPreview,
VideoPreview, VideoPreview,
ImageViewer, IconFile, ImageViewer, IconFile,
}, },
@ -335,6 +339,8 @@
imagePreviewVisible: false, imagePreviewVisible: false,
videoPreviewRow: {}, videoPreviewRow: {},
videoPreviewVisible: false, videoPreviewVisible: false,
textPreviewVisible: false,
textPreviewRow: {},
}; };
}, },
mounted(){ mounted(){
@ -973,6 +979,12 @@
this.imagePreviewRow = row this.imagePreviewRow = row
return return
} }
if (suffix.simText.includes(row.suffix)) {
// 文本文件
this.textPreviewRow = row
this.textPreviewVisible = true
return
}
if (row.contentType.indexOf('video') > -1) { if (row.contentType.indexOf('video') > -1) {
// 视频文件 // 视频文件
this.videoPreviewVisible = true this.videoPreviewVisible = true
@ -1126,7 +1138,6 @@
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
* { * {
-webkit-touch-callout:none; /*系统默认菜单被禁用*/ -webkit-touch-callout:none; /*系统默认菜单被禁用*/
-webkit-user-select:none; /*webkit浏览器*/ -webkit-user-select:none; /*webkit浏览器*/
@ -1207,10 +1218,6 @@
height: 1em; height: 1em;
} }
} }
/deep/ .svg-icon {
width: 2.5em;
height: 2.5em;
}
/*.van-divider {*/ /*.van-divider {*/
/*margin: 5px 15px 0px 15px;*/ /*margin: 5px 15px 0px 15px;*/
/*}*/ /*}*/
@ -1234,6 +1241,11 @@
.list-item-content { .list-item-content {
margin-left: 5px; margin-left: 5px;
} }
/deep/ .svg-icon {
width: 2.5em;
height: 2.5em;
}
} }
.overlay-content-class { .overlay-content-class {
-webkit-transition: all .1s ease-in-out 0s; -webkit-transition: all .1s ease-in-out 0s;