Add check startup event
This commit is contained in:
parent
4ca3ec4b1e
commit
17c25d7f00
|
@ -30,6 +30,7 @@ export default class Application {
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
this.isDarkMode = systemPreferences.isDarkMode()
|
this.isDarkMode = systemPreferences.isDarkMode()
|
||||||
|
|
||||||
const gotTheLock = app.requestSingleInstanceLock()
|
const gotTheLock = app.requestSingleInstanceLock()
|
||||||
if (!gotTheLock) {
|
if (!gotTheLock) {
|
||||||
app.quit()
|
app.quit()
|
||||||
|
@ -77,6 +78,11 @@ export default class Application {
|
||||||
|
|
||||||
ipcMain.on('dark-theme', (e: Event) => e.returnValue = this.isDarkMode)
|
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()
|
Window.Main()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { join } from "path"
|
||||||
|
|
||||||
type Protocol = 'http' | 'websocket'
|
type Protocol = 'http' | 'websocket'
|
||||||
|
|
||||||
export default class Clients {
|
export default class Client {
|
||||||
// Authorized Accounts. keyには`username@domain`を設定します
|
// Authorized Accounts. keyには`username@domain`を設定します
|
||||||
private static authorizedHTTP: Map<string, Mastodon> = new Map()
|
private static authorizedHTTP: Map<string, Mastodon> = new Map()
|
||||||
private static authorizedWebSocket: Map<string, Mastodon> = new Map()
|
private static authorizedWebSocket: Map<string, Mastodon> = new Map()
|
||||||
|
@ -27,7 +27,7 @@ export default class Clients {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
} else {
|
} 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 {
|
private static createNoAuthClient(protocol: Protocol, domain: string): Mastodon {
|
||||||
let scheme = protocol === 'http' ? 'https://' : 'wss://'
|
let scheme = protocol === 'http' ? 'https://' : 'wss://'
|
||||||
return new Mastodon(
|
return new Mastodon(
|
||||||
'',
|
'', // pleromaでは空文字ではなくnullを指定しないと毎秒403エラーになるアクセスを繰り返すことになる。TypeScriptではnullを入れられないのでmegalodonの方を修正する必要あり
|
||||||
scheme + domain + '/api/v1'
|
scheme + domain + '/api/v1'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ import Welcome from '@/components/Welcome.vue'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class App extends Vue {
|
export default class App extends Vue {
|
||||||
public isDarkMode!: boolean
|
public isDarkMode: boolean = false
|
||||||
public isStartup!: boolean
|
public isStartup: boolean = true
|
||||||
public fontSize!: string
|
public fontSize: string = '16px'
|
||||||
|
|
||||||
public get styles(): { [key: string]: string } {
|
public get styles(): { [key: string]: string } {
|
||||||
return {
|
return {
|
||||||
|
@ -33,15 +33,20 @@ export default class App extends Vue {
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.isDarkMode = ipcRenderer.sendSync('dark-theme')
|
this.isDarkMode = ipcRenderer.sendSync('dark-theme')
|
||||||
this.isStartup = true // TODO: ipcで初回起動かのboolean値を取得する
|
this.isStartup = ipcRenderer.sendSync('is-startup') // TODO: ipcで初回起動かのboolean値を取得する
|
||||||
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'))
|
||||||
// TODO: アカウントか公開TLの追加を確認する。初回起動時のみ
|
// TODO: アカウントか公開TLの追加を確認する。初回起動時のみ
|
||||||
if (this.isStartup) {
|
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
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user