Move Timeline.ready to Application.onReady

Disabled add column button if not input
This commit is contained in:
kPherox 2019-04-24 03:40:04 +09:00
parent e5b723837d
commit 49acb2c7b7
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
4 changed files with 37 additions and 33 deletions

View File

@ -12,7 +12,6 @@ import ContextMenu from 'electron-context-menu'
import Application from './main/Application' import Application from './main/Application'
import ApplicationMenu from './main/ApplicationMenu' import ApplicationMenu from './main/ApplicationMenu'
import Timeline from './main/Timeline'
export type PackageJson = typeof import('../package.json') export type PackageJson = typeof import('../package.json')
import { author, contributors, homepage } from '../package.json' import { author, contributors, homepage } from '../package.json'
@ -46,8 +45,6 @@ if (process.env.NODE_ENV !== 'production') {
protocol.registerStandardSchemes(['app'], { secure: true }) protocol.registerStandardSchemes(['app'], { secure: true })
ContextMenu() ContextMenu()
//この書き方がいいのかは知りません。(cutls|main/Timeline.ts)
Timeline.timelineReady()
const TheDeskVueApp: Application = Application.shared const TheDeskVueApp: Application = Application.shared
TheDeskVueApp.setApplicationMenu(ApplicationMenu.buildTemplate()) TheDeskVueApp.setApplicationMenu(ApplicationMenu.buildTemplate())

View File

@ -5,7 +5,8 @@
<BaseButton <BaseButton
@click.native="addTL" @click.native="addTL"
class="primary fill" class="primary fill"
style="font-size:.8em;" style="--font-size:.8em;"
:disabled="!hasDomain"
>Add Column</BaseButton> >Add Column</BaseButton>
</div> </div>
<div id="timelines"> <div id="timelines">
@ -17,7 +18,7 @@
v-if="!showInput" v-if="!showInput"
@click.native="showInput = true" @click.native="showInput = true"
class="primary fill" class="primary fill"
style="font-size:.8em;" style="--font-size:.8em;"
>Show Menu</BaseButton> >Show Menu</BaseButton>
</div> </div>
</template> </template>
@ -26,16 +27,18 @@
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
type Status = 'welcome' | 'login' | 'public_timeline' type Instance = string
type Instance = String
type showInput = boolean type showInput = boolean
type Timelines = String[] type Timelines = string[]
@Component @Component
export default class AddColumn extends Vue { export default class AddColumn extends Vue {
public status: Status = 'welcome'
public instance: Instance = '' public instance: Instance = ''
public showInput : showInput = true public showInput: showInput = true
public pubTL : Timelines = [] public pubTL: Timelines = []
public get hasDomain() {
return this.instance != ''
}
public addTL() { public addTL() {
this.showInput = false this.showInput = false
@ -43,8 +46,8 @@ export default class AddColumn extends Vue {
this.timeline() this.timeline()
} }
public timeline(){ public timeline() {
this.pubTL.forEach(function( value ) { this.pubTL.forEach(function (value) {
ipcRenderer.send('no-auth-streaming', value); ipcRenderer.send('no-auth-streaming', value);
}); });
} }

View File

@ -9,13 +9,14 @@ import {
} from 'vue-cli-plugin-electron-builder/lib' } from 'vue-cli-plugin-electron-builder/lib'
import Window from './Window' import Window from './Window'
import Timeline from './Timeline'
const isDevelopment = process.env.NODE_ENV !== 'production' const isDevelopment = process.env.NODE_ENV !== 'production'
export default class Application { export default class Application {
private static _instance: 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. // Do you need arguments? Make it a regular static method instead.
return this._instance || (this._instance = new this()) return this._instance || (this._instance = new this())
} }
@ -46,6 +47,9 @@ export default class Application {
} }
} }
if (!process.env.WEBPACK_DEV_SERVER_URL) createProtocol('app') if (!process.env.WEBPACK_DEV_SERVER_URL) createProtocol('app')
Timeline.ready()
Window.Main() Window.Main()
} }

View File

@ -2,13 +2,13 @@ import {
ipcMain ipcMain
} from 'electron' } from 'electron'
import Mastodon, { Status, Response } from 'megalodon' import Mastodon, { Status, Response } from 'megalodon'
//この書き方がいいのかは知りません。(cutls|background.ts)
export default class Timeline { export default class Timeline {
static timelineReady() { public static ready() {
ipcMain.on('no-auth-streaming', (event: Event, instance :String) => { ipcMain.on('no-auth-streaming', (event: Event, instance: string) => {
const client = new Mastodon( const client = new Mastodon(
"", '',
"https://"+instance + '/api/v1' 'https://' + instance + '/api/v1'
) )
client.get<[Status]>('/timelines/public?local=true') client.get<[Status]>('/timelines/public?local=true')