refactor: Optimize prompts component
parent
2a81ea90db
commit
23a3ef069e
|
@ -1,16 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<help v-if="showHelp" ></help>
|
<component :is="currentComponent"></component>
|
||||||
<download v-else-if="showDownload"></download>
|
|
||||||
<new-file v-else-if="showNewFile"></new-file>
|
|
||||||
<new-dir v-else-if="showNewDir"></new-dir>
|
|
||||||
<rename v-else-if="showRename"></rename>
|
|
||||||
<delete v-else-if="showDelete"></delete>
|
|
||||||
<info v-else-if="showInfo"></info>
|
|
||||||
<move v-else-if="showMove"></move>
|
|
||||||
<copy v-else-if="showCopy"></copy>
|
|
||||||
<replace v-else-if="showReplace"></replace>
|
|
||||||
<share v-else-if="show === 'share'"></share>
|
|
||||||
<div v-show="showOverlay" @click="resetPrompts" class="overlay"></div>
|
<div v-show="showOverlay" @click="resetPrompts" class="overlay"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -56,16 +46,23 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['show', 'plugins']),
|
...mapState(['show', 'plugins']),
|
||||||
showInfo: function () { return this.show === 'info' },
|
currentComponent: function () {
|
||||||
showHelp: function () { return this.show === 'help' },
|
const matched = [
|
||||||
showDelete: function () { return this.show === 'delete' },
|
'info',
|
||||||
showRename: function () { return this.show === 'rename' },
|
'help',
|
||||||
showMove: function () { return this.show === 'move' },
|
'delete',
|
||||||
showCopy: function () { return this.show === 'copy' },
|
'rename',
|
||||||
showNewFile: function () { return this.show === 'newFile' },
|
'move',
|
||||||
showNewDir: function () { return this.show === 'newDir' },
|
'copy',
|
||||||
showDownload: function () { return this.show === 'download' },
|
'newFile',
|
||||||
showReplace: function () { return this.show === 'replace' },
|
'newDir',
|
||||||
|
'download',
|
||||||
|
'replace',
|
||||||
|
'share'
|
||||||
|
].indexOf(this.show) >= 0;
|
||||||
|
|
||||||
|
return matched && this.show || null;
|
||||||
|
},
|
||||||
showOverlay: function () {
|
showOverlay: function () {
|
||||||
return (this.show !== null && this.show !== 'search' && this.show !== 'more')
|
return (this.show !== null && this.show !== 'search' && this.show !== 'more')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue