thedesk/src/views/App.vue

79 lines
1.8 KiB
Vue
Raw Normal View History

2019-04-05 16:50:07 +09:00
<template>
2019-04-22 23:59:37 +09:00
<div id="app" :style="styles">
2019-04-27 04:28:19 +09:00
<Welcome v-if="isStartup"/>
<Main v-else/>
2019-04-05 16:50:07 +09:00
</div>
</template>
2019-04-08 05:47:07 +09:00
<script lang="ts">
2019-04-24 20:59:30 +09:00
import { ipcRenderer } from 'electron'
2019-04-22 18:39:16 +09:00
import { Component, Vue } from 'vue-property-decorator'
2019-04-27 04:28:19 +09:00
import Main from '@/components/Main.vue'
2019-04-22 18:39:16 +09:00
import Welcome from '@/components/Welcome.vue'
2019-04-05 16:50:07 +09:00
2019-04-08 05:47:07 +09:00
@Component({
2019-04-05 16:50:07 +09:00
components: {
2019-04-27 04:28:19 +09:00
Main,
2019-04-10 04:10:24 +09:00
Welcome,
2019-04-08 05:47:07 +09:00
},
})
2019-04-22 23:59:37 +09:00
export default class App extends Vue {
2019-05-05 23:22:18 +09:00
public isDarkMode: boolean = false
public isStartup: boolean = true
public fontSize: string = '16px'
2019-04-22 23:59:37 +09:00
public get styles(): { [key: string]: string } {
return {
2019-04-24 20:59:30 +09:00
'--color': this.isDarkMode ? 'white' : 'black',
'--bg-color': this.isDarkMode ? '#212121' : 'white',
2019-04-22 23:59:37 +09:00
'--font-size': this.fontSize,
}
}
2019-04-23 00:10:22 +09:00
created() {
this.isDarkMode = ipcRenderer.sendSync('dark-theme')
2019-05-05 23:22:18 +09:00
this.isStartup = ipcRenderer.sendSync('is-startup') // TODO: ipcで初回起動かのboolean値を取得する
2019-04-24 20:59:30 +09:00
}
mounted() {
ipcRenderer.on('change-color-theme', () => this.isDarkMode = ipcRenderer.sendSync('dark-theme'))
2019-04-27 04:28:19 +09:00
// TODO: アカウントか公開TLの追加を確認する。初回起動時のみ
if (this.isStartup) {
2019-05-05 23:22:18 +09:00
ipcRenderer.once('add-timeline', (_e: Event, _tl: Object, error?: Error) => {
if (error) {
console.error(error)
return
}
this.isStartup = false
})
2019-04-27 04:28:19 +09:00
}
2019-04-23 00:10:22 +09:00
}
beforeDestroy() {
ipcRenderer.eventNames().forEach(name => ipcRenderer.removeAllListeners(name))
}
2019-04-22 23:59:37 +09:00
}
2019-04-05 16:50:07 +09:00
</script>
<style>
2019-04-22 23:59:37 +09:00
html {
2019-04-10 00:26:04 +09:00
font-family: "Avenir", Helvetica, Arial, sans-serif;
2019-04-05 16:50:07 +09:00
-webkit-font-smoothing: antialiased;
2019-04-22 23:59:37 +09:00
}
body {
margin: 0;
padding: 0;
width: 100%;
height: 100vh;
}
#app {
color: var(--color);
2019-04-23 00:10:22 +09:00
background-color: var(--bg-color);
2019-04-22 23:59:37 +09:00
font-size: var(--font-size);
2019-04-05 16:50:07 +09:00
text-align: center;
2019-04-22 23:59:37 +09:00
height: 100%;
2019-04-05 16:50:07 +09:00
}
</style>