Change code formatter config
This commit is contained in:
parent
ba5350bf59
commit
4887dfbd5b
|
@ -58,112 +58,112 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ipcRenderer } from "electron";
|
import { ipcRenderer } from "electron"
|
||||||
import { Component, Vue } from "vue-property-decorator";
|
import { Component, Vue } from "vue-property-decorator"
|
||||||
import { Status } from "megalodon";
|
import { Status } from "megalodon"
|
||||||
|
|
||||||
import "@/extensions/map-sortbyvalue"; // Add sortByValue function to Map prototype
|
import "@/extensions/map-sortbyvalue" // Add sortByValue function to Map prototype
|
||||||
|
|
||||||
type DeleteListener = (e: Event, id: number) => void;
|
type DeleteListener = (e: Event, id: number) => void
|
||||||
type Instance = string;
|
type Instance = string
|
||||||
type Timeline = {
|
type Timeline = {
|
||||||
name: string;
|
name: string
|
||||||
statuses?: Map<number, Status>;
|
statuses?: Map<number, Status>
|
||||||
};
|
}
|
||||||
type Timelines = Timeline[];
|
type Timelines = Timeline[]
|
||||||
type UpdateListener = (e: Event, status: Status) => void;
|
type UpdateListener = (e: Event, status: Status) => void
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class AddColumn extends Vue {
|
export default class AddColumn extends Vue {
|
||||||
public instance: Instance = "";
|
public instance: Instance = ""
|
||||||
public showInput: boolean = true;
|
public showInput: boolean = true
|
||||||
public updateListeners: [string, UpdateListener][] = [];
|
public updateListeners: [string, UpdateListener][] = []
|
||||||
public deleteListeners: [string, DeleteListener][] = [];
|
public deleteListeners: [string, DeleteListener][] = []
|
||||||
public pubTL: Timelines = [];
|
public pubTL: Timelines = []
|
||||||
//test
|
//test
|
||||||
public pref = {
|
public pref = {
|
||||||
static: false
|
static: false
|
||||||
};
|
}
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.updateListeners.forEach(([name, listener]) => {
|
this.updateListeners.forEach(([name, listener]) => {
|
||||||
ipcRenderer.removeListener(name, listener);
|
ipcRenderer.removeListener(name, listener)
|
||||||
});
|
})
|
||||||
this.deleteListeners.forEach(([name, listener]) => {
|
this.deleteListeners.forEach(([name, listener]) => {
|
||||||
ipcRenderer.removeListener(name, listener);
|
ipcRenderer.removeListener(name, listener)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public get hasDomain() {
|
public get hasDomain() {
|
||||||
return this.instance != "";
|
return this.instance != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
public sortedStatus(statuses: Map<number, Status>): Map<number, Status> {
|
public sortedStatus(statuses: Map<number, Status>): Map<number, Status> {
|
||||||
return statuses.sortByValue(
|
return statuses.sortByValue(
|
||||||
(s1, s2): number => {
|
(s1, s2): number => {
|
||||||
return s1.created_at > s2.created_at ? -1 : 1;
|
return s1.created_at > s2.created_at ? -1 : 1
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public addTL() {
|
public addTL() {
|
||||||
let timeline: Timeline = { name: this.instance };
|
let timeline: Timeline = { name: this.instance }
|
||||||
|
|
||||||
this.showInput = false;
|
this.showInput = false
|
||||||
this.instance = "";
|
this.instance = ""
|
||||||
|
|
||||||
this.pubTL.push(timeline);
|
this.pubTL.push(timeline)
|
||||||
// 最新のTLを取得
|
// 最新のTLを取得
|
||||||
this.loadTL(timeline);
|
this.loadTL(timeline)
|
||||||
|
|
||||||
// streamingを開始
|
// streamingを開始
|
||||||
this.subscribeStreaming(timeline);
|
this.subscribeStreaming(timeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadTL(timeline: Timeline) {
|
public loadTL(timeline: Timeline) {
|
||||||
let statuses: Status[] = ipcRenderer.sendSync(
|
let statuses: Status[] = ipcRenderer.sendSync(
|
||||||
"no-auth-timeline",
|
"no-auth-timeline",
|
||||||
timeline.name
|
timeline.name
|
||||||
);
|
)
|
||||||
timeline.statuses = new Map(
|
timeline.statuses = new Map(
|
||||||
statuses.map((status): [number, Status] => [status.id, status])
|
statuses.map((status): [number, Status] => [status.id, status])
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async subscribeStreaming(timeline: Timeline) {
|
public async subscribeStreaming(timeline: Timeline) {
|
||||||
// updateイベントを購読
|
// updateイベントを購読
|
||||||
let updateListener = (_: Event, status: Status) => {
|
let updateListener = (_: Event, status: Status) => {
|
||||||
if (timeline.statuses === undefined) {
|
if (timeline.statuses === undefined) {
|
||||||
timeline.statuses = new Map();
|
timeline.statuses = new Map()
|
||||||
}
|
}
|
||||||
timeline.statuses.set(status.id, status);
|
timeline.statuses.set(status.id, status)
|
||||||
this.$forceUpdate();
|
this.$forceUpdate()
|
||||||
};
|
}
|
||||||
ipcRenderer.on(`update-${timeline.name}-no-auth`, updateListener);
|
ipcRenderer.on(`update-${timeline.name}-no-auth`, updateListener)
|
||||||
this.updateListeners.push([
|
this.updateListeners.push([
|
||||||
`update-${timeline.name}-no-auth`,
|
`update-${timeline.name}-no-auth`,
|
||||||
updateListener
|
updateListener
|
||||||
]);
|
])
|
||||||
|
|
||||||
// deleteイベントを購読
|
// deleteイベントを購読
|
||||||
let deleteListener = (_: Event, id: number) => {
|
let deleteListener = (_: Event, id: number) => {
|
||||||
if (timeline.statuses === undefined) {
|
if (timeline.statuses === undefined) {
|
||||||
timeline.statuses = new Map();
|
timeline.statuses = new Map()
|
||||||
}
|
}
|
||||||
timeline.statuses.delete(id);
|
timeline.statuses.delete(id)
|
||||||
this.$forceUpdate();
|
this.$forceUpdate()
|
||||||
};
|
}
|
||||||
ipcRenderer.on(`delete-${timeline.name}-no-auth`, deleteListener);
|
ipcRenderer.on(`delete-${timeline.name}-no-auth`, deleteListener)
|
||||||
this.deleteListeners.push([
|
this.deleteListeners.push([
|
||||||
`delete-${timeline.name}-no-auth`,
|
`delete-${timeline.name}-no-auth`,
|
||||||
deleteListener
|
deleteListener
|
||||||
]);
|
])
|
||||||
|
|
||||||
ipcRenderer.send("open-streaming", timeline.name, "no-auth");
|
ipcRenderer.send("open-streaming", timeline.name, "no-auth")
|
||||||
}
|
}
|
||||||
|
|
||||||
public showAccount(id: number) {
|
public showAccount(id: number) {
|
||||||
console.log("Account dialog:" + id);
|
console.log("Account dialog:" + id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>=
|
</script>=
|
||||||
|
@ -202,8 +202,8 @@ input {
|
||||||
grid-template-areas: "avatar user user" "avatar content content" "avatar media media" "avatar card card" "avatar action action";
|
grid-template-areas: "avatar user user" "avatar content content" "avatar media media" "avatar card card" "avatar action action";
|
||||||
.tootAvatar {
|
.tootAvatar {
|
||||||
grid-area: avatar;
|
grid-area: avatar;
|
||||||
img{
|
img {
|
||||||
width:100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.tootUser {
|
.tootUser {
|
||||||
|
|
63
src/components/Preference/AccountManager.vue
Normal file
63
src/components/Preference/AccountManager.vue
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<template>
|
||||||
|
<form @submit.prevent="authCode" v-if="inputCode">
|
||||||
|
<input type="text" placeholder="input code" v-model="code">
|
||||||
|
<BaseButton
|
||||||
|
type="submit"
|
||||||
|
class="primary fill"
|
||||||
|
style="--font-size:.8em;"
|
||||||
|
:disabled="!hasDomain"
|
||||||
|
>Auth</BaseButton>
|
||||||
|
</form>
|
||||||
|
<form @submit.prevent="addAccount" v-else>
|
||||||
|
<input type="text" placeholder="e.g:mstdn.jp" v-model="instance">
|
||||||
|
<BaseButton
|
||||||
|
type="submit"
|
||||||
|
class="primary fill"
|
||||||
|
style="--font-size:.8em;"
|
||||||
|
:disabled="!hasDomain"
|
||||||
|
>Login</BaseButton>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
import { ipcRenderer } from "electron"
|
||||||
|
import { Component, Vue } from "vue-property-decorator"
|
||||||
|
type Instance = string
|
||||||
|
@Component
|
||||||
|
export default class Auth extends Vue {
|
||||||
|
public instance: Instance = ""
|
||||||
|
public inputCode: boolean = false
|
||||||
|
public get hasDomain() {
|
||||||
|
return this.instance != ""
|
||||||
|
}
|
||||||
|
public addAccount() {
|
||||||
|
let target = this.instance
|
||||||
|
this.inputCode = true
|
||||||
|
ipcRenderer.send(`new-account-setup`, target)
|
||||||
|
}
|
||||||
|
public authCode() {
|
||||||
|
let code = this.code
|
||||||
|
this.inputCode = true
|
||||||
|
ipcRenderer.send(`new-account-setup`, target)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped lang="postcss">
|
||||||
|
input {
|
||||||
|
color: var(--color);
|
||||||
|
background-color: transparent;
|
||||||
|
font-size: var(--font-size);
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid #9e9e9e;
|
||||||
|
border-radius: 0;
|
||||||
|
line-height: 3em;
|
||||||
|
width: 80%;
|
||||||
|
outline: none;
|
||||||
|
margin: 1em;
|
||||||
|
|
||||||
|
transition-duration: 0.5s;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
border-color: #26d69a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -2,7 +2,7 @@
|
||||||
<div id="welcome">
|
<div id="welcome">
|
||||||
<img alt="Vue logo" src="@/assets/logo.png">
|
<img alt="Vue logo" src="@/assets/logo.png">
|
||||||
<h1>Welcome to TheDesk</h1>
|
<h1>Welcome to TheDesk</h1>
|
||||||
<BaseButton @click.native="status = 'login'" class="primary fill" disabled>{{ loginButton }}</BaseButton>
|
<BaseButton @click.native="status = 'login'" class="primary fill">{{ loginButton }}</BaseButton>
|
||||||
<BaseButton @click.native="status = 'public_timeline'" class="primary">{{ publicTLButton }}</BaseButton>
|
<BaseButton @click.native="status = 'public_timeline'" class="primary">{{ publicTLButton }}</BaseButton>
|
||||||
|
|
||||||
<BaseOverlay
|
<BaseOverlay
|
||||||
|
@ -21,12 +21,13 @@ import { Component, Vue } from 'vue-property-decorator'
|
||||||
|
|
||||||
//import Login from './Accounts/Login.vue'
|
//import Login from './Accounts/Login.vue'
|
||||||
import PublicTimeline from './AddColumn/PublicTimeline.vue'
|
import PublicTimeline from './AddColumn/PublicTimeline.vue'
|
||||||
|
import Login from './Preference/AccountManager.vue'
|
||||||
|
|
||||||
type Status = 'welcome' | 'login' | 'public_timeline'
|
type Status = 'welcome' | 'login' | 'public_timeline'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
//Login,
|
Login,
|
||||||
PublicTimeline,
|
PublicTimeline,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
import Window from './Window'
|
import Window from './Window'
|
||||||
import Timeline from './Timeline'
|
import Timeline from './Timeline'
|
||||||
import Streaming from './Streaming'
|
import Streaming from './Streaming'
|
||||||
|
import Auth from './Auth'
|
||||||
|
|
||||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
const isDevelopment = process.env.NODE_ENV !== 'production'
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ export default class Application {
|
||||||
|
|
||||||
Timeline.ready()
|
Timeline.ready()
|
||||||
Streaming.ready()
|
Streaming.ready()
|
||||||
|
Auth.ready()
|
||||||
|
|
||||||
ipcMain.on('dark-theme', (e: Event) => e.returnValue = this.isDarkMode)
|
ipcMain.on('dark-theme', (e: Event) => e.returnValue = this.isDarkMode)
|
||||||
|
|
||||||
|
|
38
src/main/Auth.ts
Normal file
38
src/main/Auth.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import { ipcMain, Event, shell } from "electron"
|
||||||
|
import Mastodon from "megalodon"
|
||||||
|
|
||||||
|
export default class Auth {
|
||||||
|
public static ready() {
|
||||||
|
ipcMain.on("new-account-setup", async (event: Event, instance: string) => {
|
||||||
|
const SCOPES: string = "read write follow"
|
||||||
|
let clientId: string
|
||||||
|
let clientSecret: string
|
||||||
|
let url: string | null
|
||||||
|
Mastodon.registerApp(
|
||||||
|
"TheDesk",
|
||||||
|
{
|
||||||
|
scopes: SCOPES
|
||||||
|
},
|
||||||
|
"https://"+instance
|
||||||
|
).then(appData => {
|
||||||
|
clientId = appData.clientId
|
||||||
|
clientSecret = appData.clientSecret
|
||||||
|
url = appData.url
|
||||||
|
if(url){
|
||||||
|
shell.openExternal(
|
||||||
|
url,
|
||||||
|
{
|
||||||
|
activate: false
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
if (err) console.log(err)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}else{
|
||||||
|
console.log(appData)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user