From 49acb2c7b7bba7dbd41b5d2ce82cb9415046f8d3 Mon Sep 17 00:00:00 2001 From: kPherox Date: Wed, 24 Apr 2019 03:40:04 +0900 Subject: [PATCH] Move Timeline.ready to Application.onReady Disabled add column button if not input --- src/background.ts | 3 -- src/components/AddColumn/PublicTimeline.vue | 33 +++++++++++---------- src/main/Application.ts | 6 +++- src/main/Timeline.ts | 28 ++++++++--------- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/background.ts b/src/background.ts index 7d5b1203..04ff598f 100644 --- a/src/background.ts +++ b/src/background.ts @@ -12,7 +12,6 @@ import ContextMenu from 'electron-context-menu' import Application from './main/Application' import ApplicationMenu from './main/ApplicationMenu' -import Timeline from './main/Timeline' export type PackageJson = typeof import('../package.json') import { author, contributors, homepage } from '../package.json' @@ -46,8 +45,6 @@ if (process.env.NODE_ENV !== 'production') { protocol.registerStandardSchemes(['app'], { secure: true }) ContextMenu() -//この書き方がいいのかは知りません。(cutls|main/Timeline.ts) -Timeline.timelineReady() const TheDeskVueApp: Application = Application.shared TheDeskVueApp.setApplicationMenu(ApplicationMenu.buildTemplate()) \ No newline at end of file diff --git a/src/components/AddColumn/PublicTimeline.vue b/src/components/AddColumn/PublicTimeline.vue index fc920bd7..5aef79db 100644 --- a/src/components/AddColumn/PublicTimeline.vue +++ b/src/components/AddColumn/PublicTimeline.vue @@ -5,7 +5,8 @@ Add Column
@@ -14,11 +15,11 @@
Show Menu + v-if="!showInput" + @click.native="showInput = true" + class="primary fill" + style="--font-size:.8em;" + >Show Menu @@ -26,16 +27,18 @@ import { ipcRenderer } from 'electron' import { Component, Vue } from 'vue-property-decorator' -type Status = 'welcome' | 'login' | 'public_timeline' -type Instance = String +type Instance = string type showInput = boolean -type Timelines = String[] +type Timelines = string[] @Component export default class AddColumn extends Vue { - public status: Status = 'welcome' public instance: Instance = '' - public showInput : showInput = true - public pubTL : Timelines = [] + public showInput: showInput = true + public pubTL: Timelines = [] + + public get hasDomain() { + return this.instance != '' + } public addTL() { this.showInput = false @@ -43,9 +46,9 @@ export default class AddColumn extends Vue { this.timeline() } - public timeline(){ - this.pubTL.forEach(function( value ) { - ipcRenderer.send('no-auth-streaming', value); + public timeline() { + this.pubTL.forEach(function (value) { + ipcRenderer.send('no-auth-streaming', value); }); } } diff --git a/src/main/Application.ts b/src/main/Application.ts index 615aa41b..333ede61 100644 --- a/src/main/Application.ts +++ b/src/main/Application.ts @@ -9,13 +9,14 @@ import { } from 'vue-cli-plugin-electron-builder/lib' import Window from './Window' +import Timeline from './Timeline' const isDevelopment = process.env.NODE_ENV !== 'production' export default class Application { private static _instance: Application - public static get shared() { + public static get shared(): Application { // Do you need arguments? Make it a regular static method instead. return this._instance || (this._instance = new this()) } @@ -46,6 +47,9 @@ export default class Application { } } if (!process.env.WEBPACK_DEV_SERVER_URL) createProtocol('app') + + Timeline.ready() + Window.Main() } diff --git a/src/main/Timeline.ts b/src/main/Timeline.ts index 1f5da407..fc991b59 100644 --- a/src/main/Timeline.ts +++ b/src/main/Timeline.ts @@ -1,20 +1,20 @@ import { - ipcMain + ipcMain } from 'electron' import Mastodon, { Status, Response } from 'megalodon' -//この書き方がいいのかは知りません。(cutls|background.ts) + export default class Timeline { - static timelineReady() { - ipcMain.on('no-auth-streaming', (event: Event, instance :String) => { - const client = new Mastodon( - "", - "https://"+instance + '/api/v1' - ) - - client.get<[Status]>('/timelines/public?local=true') - .then((resp: Response<[Status]>) => { - console.log(resp.data) - }) - }) + public static ready() { + ipcMain.on('no-auth-streaming', (event: Event, instance: string) => { + const client = new Mastodon( + '', + 'https://' + instance + '/api/v1' + ) + + client.get<[Status]>('/timelines/public?local=true') + .then((resp: Response<[Status]>) => { + console.log(resp.data) + }) + }) } } \ No newline at end of file