完成右键菜单新建文件功能

This commit is contained in:
jmal 2020-07-17 10:33:04 +08:00
parent f08bb8e2f0
commit 1832a9d339
3 changed files with 11 additions and 15 deletions

View File

@ -31,7 +31,6 @@ export default {
}, },
watch: { watch: {
path(path){ path(path){
console.log('path', path)
this.pathList = [{folder:'',path: '/'}] this.pathList = [{folder:'',path: '/'}]
let list = path.split('/').filter((item)=>item.length>0) let list = path.split('/').filter((item)=>item.length>0)
list.forEach((pathName,index)=>{ list.forEach((pathName,index)=>{

View File

@ -823,11 +823,6 @@
this.stompClient.unsubscribe() this.stompClient.unsubscribe()
} }
}, },
// watch: {
// fileList: function (newValue,oldValue) {
// console.log(newValue,oldValue)
// }
// },
directives: { directives: {
// 注册一个局部的自定义指令 v-focus // 注册一个局部的自定义指令 v-focus
focus: { focus: {
@ -861,7 +856,6 @@
this.stompClient = ws.stompClient.subscribe('/user/queue/update', (msg) => { this.stompClient = ws.stompClient.subscribe('/user/queue/update', (msg) => {
let fileDoc = JSON.parse(msg.body) let fileDoc = JSON.parse(msg.body)
const url = msg.headers.url const url = msg.headers.url
console.log('onmessage.url', url, fileDoc)
let index = this.fileList.findIndex(file=>file.id === fileDoc.id) let index = this.fileList.findIndex(file=>file.id === fileDoc.id)
if('updateFile' === url){ if('updateFile' === url){
if(index > -1){ if(index > -1){
@ -1524,7 +1518,10 @@
this.textPreviewVisible = true this.textPreviewVisible = true
this.$message.success(`新建文件成功`) this.$message.success(`新建文件成功`)
this.newTextFileDialog = false const that = this
setTimeout(function () {
that.newTextFileDialog = false
},200)
}).catch(()=>{ }).catch(()=>{
}) })
@ -2178,7 +2175,6 @@
}, 1000) }, 1000)
}, },
hide() { hide() {
console.log('菜单隐藏了')
const that = this const that = this
this.isJustHideMenus = true this.isJustHideMenus = true
setTimeout(function() { setTimeout(function() {
@ -2188,7 +2184,6 @@
}, },
// 全局右键菜单操作 // 全局右键菜单操作
contextmenuClick(operation) { contextmenuClick(operation) {
console.log(operation)
switch (operation) { switch (operation) {
case 'vmode-list': case 'vmode-list':
this.grid=true;this.changeVmode() this.grid=true;this.changeVmode()
@ -2460,7 +2455,6 @@
}).then((res) => { }).then((res) => {
data.newFolder = false data.newFolder = false
data.id = res.data.id data.id = res.data.id
console.log(data)
}).catch(() => { }).catch(() => {
window.event.preventDefault() window.event.preventDefault()
window.event.stopPropagation() window.event.stopPropagation()

View File

@ -204,7 +204,6 @@
}, },
watch: { //监听file的变化,进行相应的操作即可 watch: { //监听file的变化,进行相应的操作即可
file(file) { file(file) {
console.log('watch file',file)
if(!file.path){ if(!file.path){
return return
} }
@ -239,7 +238,6 @@
if(!file.id){ if(!file.id){
request = 'previewTextByPath' request = 'previewTextByPath'
} }
console.log(request,file)
api[request]({ api[request]({
shareId: this.shareId, shareId: this.shareId,
fileId: file.id, fileId: file.id,
@ -252,16 +250,21 @@
this.textPreviewVisible = true this.textPreviewVisible = true
this.content = res.data.contentText this.content = res.data.contentText
let pathname = res.data.path.substring(1,res.data.path.length)+res.data.name
if('previewTextByPath' === request){
pathname = `/${res.data.path}/${res.data.name}`
}
// 加载tabs // 加载tabs
this.editableTabs.push({ this.editableTabs.push({
title: res.data.name, title: res.data.name,
copyTitle: res.data.name, copyTitle: res.data.name,
language: this.getEditorLanguage(res.data.suffix), language: this.getEditorLanguage(res.data.suffix),
status: undefined,//标签状态 status: undefined,//标签状态
name: res.data.path.substring(1,res.data.path.length)+res.data.name, name: pathname,
content: res.data.contentText content: res.data.contentText
}) })
this.editableTabsValue = res.data.path.substring(1,res.data.path.length)+res.data.name this.editableTabsValue = pathname
// 界面的渲染后的初始化工作 // 界面的渲染后的初始化工作
this.$nextTick(()=>{ this.$nextTick(()=>{