Add check startup event

This commit is contained in:
kPherox 2019-05-05 23:22:18 +09:00
parent 4ca3ec4b1e
commit 17c25d7f00
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
3 changed files with 20 additions and 9 deletions

View File

@ -30,6 +30,7 @@ export default class Application {
private constructor() {
this.isDarkMode = systemPreferences.isDarkMode()
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
@ -77,6 +78,11 @@ export default class Application {
ipcMain.on('dark-theme', (e: Event) => e.returnValue = this.isDarkMode)
ipcMain.on('is-startup', (e: Event) => {
// 初回起動かどうかをここで判断させる。timeline.dbかaccount.dbがあれば初回起動じゃない扱いでもいいか
e.returnValue = true
})
Window.Main()
}

View File

@ -5,7 +5,7 @@ import { join } from "path"
type Protocol = 'http' | 'websocket'
export default class Clients {
export default class Client {
// Authorized Accounts. keyには`username@domain`を設定します
private static authorizedHTTP: Map<string, Mastodon> = new Map()
private static authorizedWebSocket: Map<string, Mastodon> = new Map()
@ -27,7 +27,7 @@ export default class Clients {
if (err) {
console.log(err)
} else {
Clients.setAuthClient(protocol, username, Clients.createAuthClient(protocol, docs.domain, docs.accessToken))
Client.setAuthClient(protocol, username, Client.createAuthClient(protocol, docs.domain, docs.accessToken))
}
})
}
@ -66,7 +66,7 @@ export default class Clients {
private static createNoAuthClient(protocol: Protocol, domain: string): Mastodon {
let scheme = protocol === 'http' ? 'https://' : 'wss://'
return new Mastodon(
'',
'', // pleromaでは空文字ではなくnullを指定しないと毎秒403エラーになるアクセスを繰り返すことになる。TypeScriptではnullを入れられないのでmegalodonの方を修正する必要あり
scheme + domain + '/api/v1'
)
}

View File

@ -19,9 +19,9 @@ import Welcome from '@/components/Welcome.vue'
},
})
export default class App extends Vue {
public isDarkMode!: boolean
public isStartup!: boolean
public fontSize!: string
public isDarkMode: boolean = false
public isStartup: boolean = true
public fontSize: string = '16px'
public get styles(): { [key: string]: string } {
return {
@ -33,15 +33,20 @@ export default class App extends Vue {
created() {
this.isDarkMode = ipcRenderer.sendSync('dark-theme')
this.isStartup = true // TODO: ipcboolean
this.fontSize = '16px'
this.isStartup = ipcRenderer.sendSync('is-startup') // TODO: ipcboolean
}
mounted() {
ipcRenderer.on('change-color-theme', () => this.isDarkMode = ipcRenderer.sendSync('dark-theme'))
// TODO: TL
if (this.isStartup) {
//ipcRenderer.once('add-timeline', () => this.isStartup = false)
ipcRenderer.once('add-timeline', (_e: Event, _tl: Object, error?: Error) => {
if (error) {
console.error(error)
return
}
this.isStartup = false
})
}
}