Manual reconnect

This commit is contained in:
Jiang Yio 2022-09-27 21:35:26 -04:00
parent 406e96ce39
commit aa3a3b06a7

View File

@ -2,8 +2,9 @@
<div class="accordion mb-3 shadow">
<div class="accordion-item">
<h2 class="accordion-header"><button class="accordion-button" :class="{ testing: (x_server) && (x_server.production) && (x_server.production != '1') }" type="button" @click="() => show = !show"><template v-if="user">{{user[2]}}<template v-if="server"> @ {{server.domain}}</template></template><template v-else>Login</template></button></h2>
<div class="accordion-collapse collapse" :class="{ show }">
<div class="accordion-body">
<div class="accordion-collapse collapse" :class="{ show: (show) || (!x_client) }">
<div class="accordion-body" v-if="!x_client"><button v-if="fail" class="btn btn-primary btn-lg" style="width: 100%;" @click="connect">Reconnect</button><button v-else class="btn btn-outline-primary btn-lg" style="width: 100%;" @click="connect">Connect</button></div>
<div class="accordion-body" v-else>
<div class="card">
<div class="card-body">
<p class="card-text row"><code class="col" v-if="banner"><pre>{{banner.join('\n')}}</pre></code><code class="col" v-if="user"><pre>{{user.join('\n')}}</pre></code></p>
@ -73,6 +74,7 @@
data() {
return {
show: false,
fail: false,
x_client: this.client,
x_server: this.server,
x_user: this.user,
@ -98,7 +100,7 @@
}, immediate: true
},
client(value) { this.x_client = value; },
x_client(value) { this.$emit('update:client', value); if(!value) this.connect(); },
x_client(value) { this.$emit('update:client', value); },
server(value) { this.x_server = value; },
x_server(value) { this.$emit('update:server', value); },
user(value) { this.x_user = value; },
@ -107,19 +109,20 @@
methods: {
async connect() {
this.logout();
this.x_client = await (this.host ? vistax.Client.fromCookie(this.secret, this.host) : vistax.Client.fromCookie(this.secret));
this.banner = await this.x_client.XUS_INTRO_MSG();
if((await this.x_client.userinfo()).result) try {
var user = await this.x_client.XUS_GET_USER_INFO();
this.x_user = user[0] ? user : null
} catch(ex) {
this.x_user = null;
}
this.$emit('update:user', this.x_user);
this.show = !this.x_user;
this.$emit('update:server', this.x_server = (await this.x_client.serverinfo()).result);
console.log('Backend secret', this.secret);
console.log(this.banner);
if(this.x_client = await (this.host ? vistax.Client.fromCookie(this.secret, this.host) : vistax.Client.fromCookie(this.secret))) {
this.banner = await this.x_client.XUS_INTRO_MSG();
if((await this.x_client.userinfo()).result) try {
var user = await this.x_client.XUS_GET_USER_INFO();
this.x_user = user[0] ? user : null
} catch(ex) {
this.x_user = null;
}
this.$emit('update:user', this.x_user);
this.show = !this.x_user;
this.$emit('update:server', this.x_server = (await this.x_client.serverinfo()).result);
console.log('Backend secret', this.secret);
console.log(this.banner);
} else this.fail = true;
},
async login(evt) {
if(this.x_client) {