parent
da9f6928b8
commit
f9316f01e7
|
@ -318,4 +318,6 @@ export default {
|
|||
http: "Http",
|
||||
control: "Control",
|
||||
"restart now": "Restart Now",
|
||||
_SOFT_PAD_LOGIN_TITLE_: "LEDPLAYER",
|
||||
welcome: "Welcome",
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
class="full-height text-h4 text-white text-center text-weight-bold"
|
||||
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
|
||||
v-if="landspace"
|
||||
|
@ -46,7 +46,7 @@
|
|||
<q-card-section class="fit">
|
||||
<q-form ref="login_form" @submit="onSubmit" @reset="onReset">
|
||||
<q-list class="fit text-h6">
|
||||
<q-item>
|
||||
<q-item v-if="$store.state.advanced_debug">
|
||||
<q-item-section>
|
||||
<q-input
|
||||
:autofocus="!data.ip_address"
|
||||
|
@ -256,6 +256,7 @@ import EventBus, { EventNamesDefine } from "src/common/EventBus";
|
|||
import { useStore } from "src/store";
|
||||
import { Md5 } from "ts-md5/dist/md5";
|
||||
import Initializer from "src/common/Initializer";
|
||||
import { api } from "src/boot/axios";
|
||||
|
||||
class _Data {
|
||||
user_name: string | null = null;
|
||||
|
@ -349,7 +350,6 @@ export default defineComponent({
|
|||
}
|
||||
|
||||
if (remember_password.value) {
|
||||
data.ip_address = Cookies.get("name") ?? data.ip_address;
|
||||
data.user_name = Cookies.get("user_name") ?? data.user_name;
|
||||
cache_password = Cookies.get("password");
|
||||
if (
|
||||
|
@ -383,126 +383,140 @@ export default defineComponent({
|
|||
show_show_password,
|
||||
full_screen,
|
||||
async onSubmit() {
|
||||
data.loading = true;
|
||||
return new Promise((resolve) => {
|
||||
data.loading = true;
|
||||
try {
|
||||
let global_data = GlobalData.getInstance();
|
||||
const url =
|
||||
"ws://" +
|
||||
data.ip_address +
|
||||
":" +
|
||||
GlobalData.kDefaultWebsocektPort.toString() +
|
||||
GlobalData.kWebsocketResource;
|
||||
web_socket = new ClientConnection(
|
||||
url,
|
||||
data.user_name,
|
||||
data.password == cache_password
|
||||
? data.password
|
||||
: Md5.hashStr(data.password ?? "admin")
|
||||
);
|
||||
let timer = setTimeout(() => {
|
||||
web_socket?.destory();
|
||||
web_socket = null;
|
||||
$q.notify({
|
||||
color: "negative",
|
||||
icon: "warning",
|
||||
message:
|
||||
$t.t("login fail!") +
|
||||
$t.t("connect time out!") +
|
||||
$t.t(
|
||||
"please check server state, or check server ip address!"
|
||||
),
|
||||
position: "center",
|
||||
timeout: 1500,
|
||||
});
|
||||
SessionStorage.set("auth", PermissionLevel.None);
|
||||
resolve(false);
|
||||
data.loading = false;
|
||||
}, 5000);
|
||||
web_socket.login_callback = (is_login) => {
|
||||
clearTimeout(timer);
|
||||
if (is_login && web_socket) {
|
||||
global_data.addClient(data.ip_address, web_socket);
|
||||
global_data.setCurrentClientName(data.ip_address);
|
||||
|
||||
SessionStorage.set("auth", PermissionLevel.Root);
|
||||
SessionStorage.set("url", url);
|
||||
SessionStorage.set("name", data.ip_address);
|
||||
SessionStorage.set("user_name", data.user_name);
|
||||
SessionStorage.set(
|
||||
"password",
|
||||
data.password == cache_password
|
||||
? data.password
|
||||
: Md5.hashStr(data.password ?? "admin")
|
||||
);
|
||||
|
||||
// TODO add self to setConnects
|
||||
|
||||
if (remember_password.value) {
|
||||
{
|
||||
Cookies.set("remember_password", JSON.stringify(true), {
|
||||
expires: 15,
|
||||
});
|
||||
Cookies.set(
|
||||
"auto_login",
|
||||
JSON.stringify(auto_login.value),
|
||||
{
|
||||
expires: 15,
|
||||
}
|
||||
);
|
||||
Cookies.set("name", data.ip_address, {
|
||||
expires: 15,
|
||||
});
|
||||
Cookies.set("user_name", data.user_name ?? "admin", {
|
||||
expires: 15,
|
||||
});
|
||||
Cookies.set(
|
||||
"password",
|
||||
data.password == cache_password
|
||||
? data.password ?? Md5.hashStr("admin")
|
||||
: Md5.hashStr(data.password ?? "admin"),
|
||||
{
|
||||
expires: 15,
|
||||
}
|
||||
);
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
Cookies.remove("remember_password");
|
||||
Cookies.remove("auto_login");
|
||||
Cookies.remove("name");
|
||||
Cookies.remove("user_name");
|
||||
Cookies.remove("password");
|
||||
}
|
||||
|
||||
$store.commit("setDeviceIpAddress", data.ip_address);
|
||||
|
||||
setTimeout(() => {
|
||||
new Initializer({
|
||||
$t,
|
||||
$store,
|
||||
$q,
|
||||
})
|
||||
.initialize()
|
||||
.then(() => {
|
||||
$store.commit("setInitialized");
|
||||
const url =
|
||||
"ws://" +
|
||||
data.ip_address +
|
||||
":" +
|
||||
final_ws_port.toString() +
|
||||
GlobalData.kWebsocketResource;
|
||||
web_socket = new ClientConnection(
|
||||
url,
|
||||
data.user_name,
|
||||
data.password == cache_password
|
||||
? data.password
|
||||
: Md5.hashStr(data.password ?? "admin")
|
||||
);
|
||||
let timer = setTimeout(() => {
|
||||
web_socket?.destory();
|
||||
web_socket = null;
|
||||
$q.notify({
|
||||
color: "negative",
|
||||
icon: "warning",
|
||||
message:
|
||||
$t.t("login fail!") +
|
||||
$t.t("connect time out!") +
|
||||
$t.t(
|
||||
"please check server state, or check server ip address!"
|
||||
),
|
||||
position: "center",
|
||||
timeout: 1500,
|
||||
});
|
||||
}, 0);
|
||||
SessionStorage.set("auth", PermissionLevel.None);
|
||||
resolve(false);
|
||||
data.loading = false;
|
||||
}, 5000);
|
||||
web_socket.login_callback = (is_login) => {
|
||||
clearTimeout(timer);
|
||||
if (is_login && web_socket) {
|
||||
global_data.addClient(data.ip_address, web_socket);
|
||||
global_data.setCurrentClientName(data.ip_address);
|
||||
|
||||
$route.push("/");
|
||||
} else {
|
||||
$q.notify({
|
||||
color: "negative",
|
||||
icon: "warning",
|
||||
message:
|
||||
$t.t("login fail!") + $t.t("user or password error!"),
|
||||
position: "center",
|
||||
timeout: 1500,
|
||||
});
|
||||
SessionStorage.set("auth", PermissionLevel.None);
|
||||
}
|
||||
resolve(true);
|
||||
data.loading = false;
|
||||
};
|
||||
SessionStorage.set("auth", PermissionLevel.Root);
|
||||
SessionStorage.set("url", url);
|
||||
SessionStorage.set("name", data.ip_address);
|
||||
SessionStorage.set("user_name", data.user_name);
|
||||
SessionStorage.set(
|
||||
"password",
|
||||
data.password == cache_password
|
||||
? data.password
|
||||
: Md5.hashStr(data.password ?? "admin")
|
||||
);
|
||||
|
||||
// TODO add self to setConnects
|
||||
|
||||
if (remember_password.value) {
|
||||
Cookies.set("remember_password", JSON.stringify(true), {
|
||||
expires: 15,
|
||||
});
|
||||
Cookies.set(
|
||||
"auto_login",
|
||||
JSON.stringify(auto_login.value),
|
||||
{
|
||||
expires: 15,
|
||||
}
|
||||
);
|
||||
Cookies.set("user_name", data.user_name ?? "admin", {
|
||||
expires: 15,
|
||||
});
|
||||
Cookies.set(
|
||||
"password",
|
||||
data.password == cache_password
|
||||
? data.password ?? Md5.hashStr("admin")
|
||||
: Md5.hashStr(data.password ?? "admin"),
|
||||
{
|
||||
expires: 15,
|
||||
}
|
||||
);
|
||||
} else {
|
||||
Cookies.remove("remember_password");
|
||||
Cookies.remove("auto_login");
|
||||
Cookies.remove("name");
|
||||
Cookies.remove("user_name");
|
||||
Cookies.remove("password");
|
||||
}
|
||||
|
||||
$store.commit("setDeviceIpAddress", data.ip_address);
|
||||
|
||||
setTimeout(() => {
|
||||
new Initializer({
|
||||
$t,
|
||||
$store,
|
||||
$q,
|
||||
})
|
||||
.initialize()
|
||||
.then(() => {
|
||||
$store.commit("setInitialized");
|
||||
});
|
||||
}, 0);
|
||||
|
||||
$route.push("/");
|
||||
} else {
|
||||
$q.notify({
|
||||
color: "negative",
|
||||
icon: "warning",
|
||||
message:
|
||||
$t.t("login fail!") + $t.t("user or password error!"),
|
||||
position: "center",
|
||||
timeout: 1500,
|
||||
});
|
||||
SessionStorage.set("auth", PermissionLevel.None);
|
||||
}
|
||||
resolve(true);
|
||||
data.loading = false;
|
||||
};
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
resolve(true);
|
||||
data.loading = false;
|
||||
});
|
||||
} catch {
|
||||
resolve(true);
|
||||
data.loading = false;
|
||||
|
|
|
@ -314,8 +314,8 @@ export default defineComponent({
|
|||
landspace,
|
||||
is_pwa,
|
||||
async onSubmit() {
|
||||
data.loading = true;
|
||||
return new Promise((resolve) => {
|
||||
data.loading = true;
|
||||
try {
|
||||
let global_data = GlobalData.getInstance();
|
||||
api
|
||||
|
@ -447,10 +447,6 @@ export default defineComponent({
|
|||
.catch(() => {
|
||||
resolve(true);
|
||||
data.loading = false;
|
||||
})
|
||||
.finally(() => {
|
||||
resolve(true);
|
||||
data.loading = false;
|
||||
});
|
||||
} catch {
|
||||
resolve(true);
|
||||
|
|
Loading…
Reference in New Issue