尝试加入重命名

This commit is contained in:
marvzhang
2019-12-25 21:07:56 +08:00
parent 6e0718e646
commit fca2302308
3 changed files with 42 additions and 1 deletions

View File

@@ -22,6 +22,21 @@
</el-button>
</template>
</el-popover>
<el-popover v-model="isShowRename">
<el-input v-model="name" :placeholder="$t('Name')" style="margin-bottom: 10px"/>
<div style="text-align: right">
<el-button size="small" type="warning" @click="onRenameFile">
{{$t('Confirm')}}
</el-button>
</div>
<template slot="reference">
<el-button v-if="showFile" type="warning" size="small" style="margin-right: 10px;"
@click="onOpenRename">
<font-awesome-icon :icon="['fa', 'redo']"/>
{{$t('Rename')}}
</el-button>
</template>
</el-popover>
<el-button v-if="showFile" type="success" size="small" style="margin-right: 10px;" @click="onFileSave">
<font-awesome-icon :icon="['fa', 'save']"/>
{{$t('Save')}}
@@ -100,7 +115,8 @@ export default {
showFile: false,
name: '',
isShowAdd: false,
isShowDelete: false
isShowDelete: false,
isShowRename: false
}
},
computed: {
@@ -180,6 +196,24 @@ export default {
this.$message.success(this.$t('Deleted successfully'))
this.isShowDelete = false
this.onBackFile()
},
onOpenRename () {
this.isShowRename = true
const arr = this.currentPath.split('/')
this.name = arr[arr.length - 1]
},
async onRenameFile () {
let newPath
if (this.currentPath === '') {
newPath = this.name
} else {
const arr = this.currentPath.split('/')
newPath = arr[0] + '/' + this.name
}
await this.$store.dispatch('file/renameFile', { path: this.currentPath, newPath })
this.$store.commit('file/SET_CURRENT_PATH', newPath)
this.$message.success(this.$t('Renamed successfully'))
this.isShowRename = false
}
},
created () {