修复点击登录按钮后不会立即进入loading模式的BUG

PAD隐藏
This commit is contained in:
fangxiang 2022-07-22 14:50:12 +08:00
parent da9f6928b8
commit f9316f01e7
3 changed files with 134 additions and 122 deletions

View File

@ -318,4 +318,6 @@ export default {
http: "Http", http: "Http",
control: "Control", control: "Control",
"restart now": "Restart Now", "restart now": "Restart Now",
_SOFT_PAD_LOGIN_TITLE_: "LEDPLAYER",
welcome: "Welcome",
}; };

View File

@ -11,7 +11,7 @@
class="full-height text-h4 text-white text-center text-weight-bold" class="full-height text-h4 text-white text-center text-weight-bold"
style="position: fixed; writing-mode: vertical-lr; left: 56.5%" style="position: fixed; writing-mode: vertical-lr; left: 56.5%"
> >
<span> {{ $t("welcome") }}{{ $t("login") }} </span> <span> {{ $t("welcome") }}{{ $t(" ") }}{{ $t("login") }} </span>
</div> </div>
<div <div
v-if="landspace" v-if="landspace"
@ -46,7 +46,7 @@
<q-card-section class="fit"> <q-card-section class="fit">
<q-form ref="login_form" @submit="onSubmit" @reset="onReset"> <q-form ref="login_form" @submit="onSubmit" @reset="onReset">
<q-list class="fit text-h6"> <q-list class="fit text-h6">
<q-item> <q-item v-if="$store.state.advanced_debug">
<q-item-section> <q-item-section>
<q-input <q-input
:autofocus="!data.ip_address" :autofocus="!data.ip_address"
@ -256,6 +256,7 @@ import EventBus, { EventNamesDefine } from "src/common/EventBus";
import { useStore } from "src/store"; import { useStore } from "src/store";
import { Md5 } from "ts-md5/dist/md5"; import { Md5 } from "ts-md5/dist/md5";
import Initializer from "src/common/Initializer"; import Initializer from "src/common/Initializer";
import { api } from "src/boot/axios";
class _Data { class _Data {
user_name: string | null = null; user_name: string | null = null;
@ -349,7 +350,6 @@ export default defineComponent({
} }
if (remember_password.value) { if (remember_password.value) {
data.ip_address = Cookies.get("name") ?? data.ip_address;
data.user_name = Cookies.get("user_name") ?? data.user_name; data.user_name = Cookies.get("user_name") ?? data.user_name;
cache_password = Cookies.get("password"); cache_password = Cookies.get("password");
if ( if (
@ -383,15 +383,28 @@ export default defineComponent({
show_show_password, show_show_password,
full_screen, full_screen,
async onSubmit() { async onSubmit() {
return new Promise((resolve) => {
data.loading = true; data.loading = true;
return new Promise((resolve) => {
try { try {
let global_data = GlobalData.getInstance(); let global_data = GlobalData.getInstance();
api
.get("/get_websocket_port")
.then((response) => {
let final_ws_port = GlobalData.kDefaultWebsocektPort;
if (response && typeof response.data != "undefined") {
if (typeof response.data != "number") {
const temp_port = parseInt(response.data);
if (!isNaN(temp_port) && temp_port != Infinity) {
final_ws_port = temp_port;
}
} else {
final_ws_port = response.data;
}
const url = const url =
"ws://" + "ws://" +
data.ip_address + data.ip_address +
":" + ":" +
GlobalData.kDefaultWebsocektPort.toString() + final_ws_port.toString() +
GlobalData.kWebsocketResource; GlobalData.kWebsocketResource;
web_socket = new ClientConnection( web_socket = new ClientConnection(
url, url,
@ -439,7 +452,6 @@ export default defineComponent({
// TODO add self to setConnects // TODO add self to setConnects
if (remember_password.value) { if (remember_password.value) {
{
Cookies.set("remember_password", JSON.stringify(true), { Cookies.set("remember_password", JSON.stringify(true), {
expires: 15, expires: 15,
}); });
@ -450,9 +462,6 @@ export default defineComponent({
expires: 15, expires: 15,
} }
); );
Cookies.set("name", data.ip_address, {
expires: 15,
});
Cookies.set("user_name", data.user_name ?? "admin", { Cookies.set("user_name", data.user_name ?? "admin", {
expires: 15, expires: 15,
}); });
@ -465,7 +474,6 @@ export default defineComponent({
expires: 15, expires: 15,
} }
); );
}
} else { } else {
Cookies.remove("remember_password"); Cookies.remove("remember_password");
Cookies.remove("auto_login"); Cookies.remove("auto_login");
@ -503,6 +511,12 @@ export default defineComponent({
resolve(true); resolve(true);
data.loading = false; data.loading = false;
}; };
}
})
.catch(() => {
resolve(true);
data.loading = false;
});
} catch { } catch {
resolve(true); resolve(true);
data.loading = false; data.loading = false;

View File

@ -314,8 +314,8 @@ export default defineComponent({
landspace, landspace,
is_pwa, is_pwa,
async onSubmit() { async onSubmit() {
return new Promise((resolve) => {
data.loading = true; data.loading = true;
return new Promise((resolve) => {
try { try {
let global_data = GlobalData.getInstance(); let global_data = GlobalData.getInstance();
api api
@ -447,10 +447,6 @@ export default defineComponent({
.catch(() => { .catch(() => {
resolve(true); resolve(true);
data.loading = false; data.loading = false;
})
.finally(() => {
resolve(true);
data.loading = false;
}); });
} catch { } catch {
resolve(true); resolve(true);