From 23a3ef069ede469cbd5d32af6ff0ead8a9522b08 Mon Sep 17 00:00:00 2001 From: freedomlang Date: Tue, 19 Nov 2019 20:02:35 +0800 Subject: [PATCH] refactor: Optimize prompts component --- frontend/src/components/prompts/Prompts.vue | 39 ++++++++++----------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/frontend/src/components/prompts/Prompts.vue b/frontend/src/components/prompts/Prompts.vue index 529f79c3..8e530a27 100644 --- a/frontend/src/components/prompts/Prompts.vue +++ b/frontend/src/components/prompts/Prompts.vue @@ -1,16 +1,6 @@ @@ -56,16 +46,23 @@ export default { }, computed: { ...mapState(['show', 'plugins']), - showInfo: function () { return this.show === 'info' }, - showHelp: function () { return this.show === 'help' }, - showDelete: function () { return this.show === 'delete' }, - showRename: function () { return this.show === 'rename' }, - showMove: function () { return this.show === 'move' }, - showCopy: function () { return this.show === 'copy' }, - showNewFile: function () { return this.show === 'newFile' }, - showNewDir: function () { return this.show === 'newDir' }, - showDownload: function () { return this.show === 'download' }, - showReplace: function () { return this.show === 'replace' }, + currentComponent: function () { + const matched = [ + 'info', + 'help', + 'delete', + 'rename', + 'move', + 'copy', + 'newFile', + 'newDir', + 'download', + 'replace', + 'share' + ].indexOf(this.show) >= 0; + + return matched && this.show || null; + }, showOverlay: function () { return (this.show !== null && this.show !== 'search' && this.show !== 'more') }