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

View File

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