Change class variable to initalize in created

`electron:serve` した時に表示が遅かったのでちょっと早くなる…気がする変更
This commit is contained in:
kPherox 2019-04-27 04:24:33 +09:00
parent 6c2a98e139
commit 69e5fb3f1b
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
2 changed files with 19 additions and 8 deletions

View File

@ -64,8 +64,8 @@ interface TheDeskInfo {
@Component
export default class About extends Vue {
public thedeskInfo: TheDeskInfo = ipcRenderer.sendSync('thedesk-info')
public isDarkMode: boolean = ipcRenderer.sendSync('dark-theme')
public thedeskInfo!: TheDeskInfo
public isDarkMode!: boolean
public get ctrHtml(): string {
return this.contributors.map(contributer => {
@ -105,13 +105,19 @@ export default class About extends Vue {
}
}
beforeDestroy() {
ipcRenderer.eventNames().forEach(name => ipcRenderer.removeAllListeners(name))
created() {
this.thedeskInfo = ipcRenderer.sendSync('thedesk-info')
this.isDarkMode = ipcRenderer.sendSync('dark-theme')
}
mounted() {
ipcRenderer.on('change-color-theme', () => this.isDarkMode = ipcRenderer.sendSync('dark-theme'))
}
beforeDestroy() {
ipcRenderer.eventNames().forEach(name => ipcRenderer.removeAllListeners(name))
}
}
</script>

View File

@ -15,8 +15,8 @@ import Welcome from '@/components/Welcome.vue'
},
})
export default class App extends Vue {
public isDarkMode: boolean = ipcRenderer.sendSync('dark-theme')
public fontSize: string = '16px'
public isDarkMode!: boolean
public fontSize!: string
public get styles(): { [key: string]: string } {
return {
@ -26,13 +26,18 @@ export default class App extends Vue {
}
}
beforeDestroy() {
ipcRenderer.eventNames().forEach(name => ipcRenderer.removeAllListeners(name))
created() {
this.isDarkMode = ipcRenderer.sendSync('dark-theme')
this.fontSize = '16px'
}
mounted() {
ipcRenderer.on('change-color-theme', () => this.isDarkMode = ipcRenderer.sendSync('dark-theme'))
}
beforeDestroy() {
ipcRenderer.eventNames().forEach(name => ipcRenderer.removeAllListeners(name))
}
}
</script>