🐛 Fix: correct inputbox value && remove listener

This commit is contained in:
Molunerfinn 2020-02-25 20:58:39 +08:00
parent 96544f5475
commit 32334e9bc1
2 changed files with 10 additions and 4 deletions

View File

@ -3,14 +3,13 @@
:title="inputBoxOptions.title || '输入框'" :title="inputBoxOptions.title || '输入框'"
:visible.sync="showInputBoxVisible" :visible.sync="showInputBoxVisible"
:modal-append-to-body="false" :modal-append-to-body="false"
@close="handleInputBoxClose"
> >
<el-input <el-input
v-model="inputBoxValue" v-model="inputBoxValue"
:placeholder="inputBoxOptions.placeholder"></el-input> :placeholder="inputBoxOptions.placeholder"></el-input>
<span slot="footer"> <span slot="footer">
<el-button @click="showInputBoxVisible = false" round>取消</el-button> <el-button @click="handleInputBoxCancel" round>取消</el-button>
<el-button type="primary" @click="showInputBoxVisible = false" round>确定</el-button> <el-button type="primary" @click="handleInputBoxConfirm" round>确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
</template> </template>
@ -44,11 +43,17 @@ export default class extends Vue {
this.inputBoxOptions.placeholder = options.placeholder || '' this.inputBoxOptions.placeholder = options.placeholder || ''
this.showInputBoxVisible = true this.showInputBoxVisible = true
} }
handleInputBoxClose () { handleInputBoxCancel () {
// TODO: RPCServer // TODO: RPCServer
this.showInputBoxVisible = false
ipcRenderer.send(SHOW_INPUT_BOX, '') ipcRenderer.send(SHOW_INPUT_BOX, '')
this.$bus.$emit(SHOW_INPUT_BOX_RESPONSE, '') this.$bus.$emit(SHOW_INPUT_BOX_RESPONSE, '')
} }
handleInputBoxConfirm () {
this.showInputBoxVisible = false
ipcRenderer.send(SHOW_INPUT_BOX, this.inputBoxValue)
this.$bus.$emit(SHOW_INPUT_BOX_RESPONSE, this.inputBoxValue)
}
beforeDestroy () { beforeDestroy () {
ipcRenderer.removeListener(SHOW_INPUT_BOX, this.ipcEventHandler) ipcRenderer.removeListener(SHOW_INPUT_BOX, this.ipcEventHandler)
this.$bus.$off(SHOW_INPUT_BOX) this.$bus.$off(SHOW_INPUT_BOX)

View File

@ -115,6 +115,7 @@ export default class extends Vue {
} }
} }
beforeDestroy () { beforeDestroy () {
this.$bus.$off(SHOW_INPUT_BOX_RESPONSE)
ipcRenderer.removeAllListeners('uploadProgress') ipcRenderer.removeAllListeners('uploadProgress')
ipcRenderer.removeAllListeners('syncPicBed') ipcRenderer.removeAllListeners('syncPicBed')
ipcRenderer.removeListener('getPicBeds', this.getPicBeds) ipcRenderer.removeListener('getPicBeds', this.getPicBeds)