From b714ba14853adaebbd2c8666748674a457e4d38c Mon Sep 17 00:00:00 2001 From: ariz-ansari Date: Fri, 12 May 2023 17:11:45 +0530 Subject: [PATCH] #289 started work on it --- client/src/components/connect.vue | 16 ++++++++++++++-- client/src/neko/base.ts | 2 +- client/src/neko/index.ts | 4 ++-- client/src/store/index.ts | 13 ++++++++----- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/client/src/components/connect.vue b/client/src/components/connect.vue index 92d044769..ebb045d9e 100644 --- a/client/src/components/connect.vue +++ b/client/src/components/connect.vue @@ -152,9 +152,11 @@ @Component({ name: 'neko-connect' }) export default class extends Vue { private autoPassword: string | null = new URL(location.href).searchParams.get('pwd') + private autoUrl: string | null = new URL(location.href).searchParams.get('url') private displayname: string = '' private password: string = '' + private url: string = '' mounted() { // auto-password fill @@ -164,6 +166,11 @@ password = this.autoPassword } + let url = this.$accessor.browseurl + if (this.autoUrl !== null) { + url = this.autoUrl + } + // auto-user fill let displayname = this.$accessor.displayname const usr = new URL(location.href).searchParams.get('usr') @@ -173,7 +180,7 @@ } if (displayname !== '' && password !== '') { - this.$accessor.login({ displayname, password }) + this.$accessor.login({ displayname, password, browseurl: url }) this.autoPassword = null } } @@ -209,6 +216,11 @@ password = this.autoPassword } + let url = this.url + if (this.autoUrl !== null) { + url = this.autoUrl + } + if (this.displayname == '') { this.$swal({ title: this.$t('connect.error') as string, @@ -218,7 +230,7 @@ return } - this.$accessor.login({ displayname: this.displayname, password }) + this.$accessor.login({ displayname: this.displayname, password, browseurl: url }) this.autoPassword = null } diff --git a/client/src/neko/base.ts b/client/src/neko/base.ts index 43267b1d2..a0708f613 100644 --- a/client/src/neko/base.ts +++ b/client/src/neko/base.ts @@ -48,7 +48,7 @@ export abstract class BaseClient extends EventEmitter { return this.peerConnected && this.socketOpen } - public connect(url: string, password: string, displayname: string) { + public connect(url: string, password: string, displayname: string, browseurl: string) { if (this.socketOpen) { this.emit('warn', `attempting to create websocket while connection open`) return diff --git a/client/src/neko/index.ts b/client/src/neko/index.ts index 16ca0b6fa..6ff40b6a0 100644 --- a/client/src/neko/index.ts +++ b/client/src/neko/index.ts @@ -57,8 +57,8 @@ export class NekoClient extends BaseClient implements EventEmitter { this.$accessor.chat.reset() } - login(password: string, displayname: string) { - this.connect(this.url, password, displayname) + login(password: string, displayname: string, browseurl: string) { + this.connect(this.url, password, displayname, browseurl) } logout() { diff --git a/client/src/store/index.ts b/client/src/store/index.ts index 2bc6c91a0..caf019010 100644 --- a/client/src/store/index.ts +++ b/client/src/store/index.ts @@ -17,6 +17,7 @@ import * as emoji from './emoji' export const state = () => ({ displayname: get('displayname', ''), password: get('password', ''), + browseurl: get('url', ''), active: false, connecting: false, connected: false, @@ -28,9 +29,10 @@ export const mutations = mutationTree(state, { state.active = true }, - setLogin(state, { displayname, password }: { displayname: string; password: string }) { + setLogin(state, { displayname, password, browseurl }: { displayname: string; password: string, browseurl: string }) { state.displayname = displayname state.password = password + state.browseurl = browseurl }, setLocked(state, resource: string) { @@ -92,15 +94,16 @@ export const actions = actionTree( } }, - login(store, { displayname, password }: { displayname: string; password: string }) { - accessor.setLogin({ displayname, password }) - $client.login(password, displayname) + login(store, { displayname, password, browseurl }: { displayname: string; password: string, browseurl: string }) { + accessor.setLogin({ displayname, password, browseurl }) + $client.login(password, displayname, browseurl) }, logout() { - accessor.setLogin({ displayname: '', password: '' }) + accessor.setLogin({ displayname: '', password: '', browseurl: '' }) set('displayname', '') set('password', '') + set('browseurl', '') $client.logout() }, },