Changed: showInputBox from plugin page -> mainPage layout

This commit is contained in:
Molunerfinn 2019-04-04 16:56:38 +08:00
parent 17302fe3e4
commit 0165879f2d
2 changed files with 33 additions and 30 deletions

View File

@ -143,6 +143,20 @@
<el-button type="primary" @click="confirmCustomLink">确定</el-button> <el-button type="primary" @click="confirmCustomLink">确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog
:title="inputBoxOptions.title || '输入框'"
:visible.sync="showInputBoxVisible"
:modal-append-to-body="false"
@close="handleInputBoxClose"
>
<el-input
v-model="inputBoxValue"
:placeholder="inputBoxOptions.placeholder"></el-input>
<span slot="footer">
<el-button @click="showInputBoxVisible = false" round>取消</el-button>
<el-button type="primary" @click="showInputBoxVisible = false" round>确定</el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
@ -182,7 +196,14 @@ export default {
shortKey: { shortKey: {
upload: db.read().get('shortKey.upload').value() upload: db.read().get('shortKey.upload').value()
}, },
picBed: [] picBed: [],
// for showInputBox
showInputBoxVisible: false,
inputBoxValue: '',
inputBoxOptions: {
title: '',
placeholder: ''
}
} }
}, },
created () { created () {
@ -190,6 +211,12 @@ export default {
this.buildMenu() this.buildMenu()
this.$electron.ipcRenderer.send('getPicBeds') this.$electron.ipcRenderer.send('getPicBeds')
this.$electron.ipcRenderer.on('getPicBeds', this.getPicBeds) this.$electron.ipcRenderer.on('getPicBeds', this.getPicBeds)
this.$electron.ipcRenderer.on('showInputBox', (evt, options) => {
this.inputBoxValue = ''
this.inputBoxOptions.title = options.title || ''
this.inputBoxOptions.placeholder = options.placeholder || ''
this.showInputBoxVisible = true
})
}, },
methods: { methods: {
handleSelect (index) { handleSelect (index) {
@ -280,6 +307,9 @@ export default {
}, },
getPicBeds (event, picBeds) { getPicBeds (event, picBeds) {
this.picBed = picBeds this.picBed = picBeds
},
handleInputBoxClose () {
this.$electron.ipcRenderer.send('showInputBox', this.inputBoxValue)
} }
}, },
beforeRouteEnter: (to, from, next) => { beforeRouteEnter: (to, from, next) => {
@ -289,6 +319,7 @@ export default {
}, },
beforeDestroy () { beforeDestroy () {
this.$electron.ipcRenderer.removeListener('getPicBeds', this.getPicBeds) this.$electron.ipcRenderer.removeListener('getPicBeds', this.getPicBeds)
this.$electron.ipcRenderer.removeAllListeners('showInputBox')
} }
} }
</script> </script>

View File

@ -91,20 +91,6 @@
<el-button type="primary" @click="handleConfirmConfig" round>确定</el-button> <el-button type="primary" @click="handleConfirmConfig" round>确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog
:title="inputBoxOptions.title || '输入框'"
:visible.sync="showInputBoxVisible"
:modal-append-to-body="false"
@close="handleInputBoxClose"
>
<el-input
v-model="inputBoxValue"
:placeholder="inputBoxOptions.placeholder"></el-input>
<span slot="footer">
<el-button @click="showInputBoxVisible = false" round>取消</el-button>
<el-button type="primary" @click="showInputBoxVisible = false" round>确定</el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
@ -128,14 +114,7 @@ export default {
loading: true, loading: true,
needReload: false, needReload: false,
id: '', id: '',
os: '', os: ''
// for showInputBox
showInputBoxVisible: false,
inputBoxValue: '',
inputBoxOptions: {
title: '',
placeholder: ''
}
} }
}, },
computed: { computed: {
@ -205,12 +184,6 @@ export default {
this.getPluginList() this.getPluginList()
this.getSearchResult = debounce(this.getSearchResult, 50) this.getSearchResult = debounce(this.getSearchResult, 50)
this.needReload = this.$db.read().get('needReload').value() this.needReload = this.$db.read().get('needReload').value()
this.$electron.ipcRenderer.on('showInputBox', (evt, options) => {
this.inputBoxValue = ''
this.inputBoxOptions.title = options.title || ''
this.inputBoxOptions.placeholder = options.placeholder || ''
this.showInputBoxVisible = true
})
}, },
methods: { methods: {
buildContextMenu (plugin) { buildContextMenu (plugin) {
@ -449,7 +422,6 @@ export default {
this.$electron.ipcRenderer.removeAllListeners('installSuccess') this.$electron.ipcRenderer.removeAllListeners('installSuccess')
this.$electron.ipcRenderer.removeAllListeners('uninstallSuccess') this.$electron.ipcRenderer.removeAllListeners('uninstallSuccess')
this.$electron.ipcRenderer.removeAllListeners('updateSuccess') this.$electron.ipcRenderer.removeAllListeners('updateSuccess')
this.$electron.ipcRenderer.removeAllListeners('showInputBox')
} }
} }
</script> </script>