refactor(linuxdo): 优化账号绑定页面布局和代码结构

- 调整了页面布局,增加了 div 容器以改善元素排列
- 优化了 JavaScript 代码格式,提高了可读性
- 修复了一些小问题,如移除了多余的空行和不必要的换行符
This commit is contained in:
2024-12-22 11:22:36 +08:00
parent 2515e69686
commit 35c1afacc3

View File

@@ -138,86 +138,90 @@ function get_curl($url, $post = 0, $referer = 0, $cookie = 0, $header = 0, $ua =
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="applicable-device" content="mobile">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes" />
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="full-screen" content="yes"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="applicable-device" content="mobile">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="screen-orientation" content="portrait">
<meta name="x5-orientation" content="portrait">
<meta name="x5-page-mode" content="app">
<meta name="full-screen" content="yes" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<title><?=$_CONFIG['game_name']?> <?=$_CONFIG['game_description']?></title>
<meta name="description" content="<?=$_CONFIG['game_name']?> <?=$_CONFIG['game_description']?>">
<meta name="keywords" content="<?=$_CONFIG['game_name']?>,<?=$_CONFIG['game_description']?>">
<meta name="screen-orientation" content="portrait">
<meta name="x5-orientation" content="portrait">
<meta name="x5-page-mode" content="app">
<link rel="stylesheet" href="static/css/login.css?v=1.1.6"/>
<script>
document.onkeydown = document.onkeyup = document.onkeypress = function(event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
if (e && e.keyCode == 123) {
e.returnValue = false;
return false;
}
}
</script>
<script src="static/layer/layer.js"></script>
<script src="static/js/common.js?v=1"></script>
<script>
<title><?= $_CONFIG['game_name'] ?> <?= $_CONFIG['game_description'] ?></title>
<meta name="description" content="<?= $_CONFIG['game_name'] ?> <?= $_CONFIG['game_description'] ?>">
<meta name="keywords" content="<?= $_CONFIG['game_name'] ?>,<?= $_CONFIG['game_description'] ?>">
layer.config({skin: 'dialogs'});
</script>
</head>
<body oncontextmenu="return false" onselectstart="return false" ondragstart="return false">
<?php if (empty($row)) {?>
当前尚未有你的游戏账号,请选择<br>
<a onclick="registerDirect">Linuxdo账号绑定</a></br>
<input type="hidden" id="linuxdo" value="<?= $userInfo['user_username'] ?>">
<link rel="stylesheet" href="static/css/login.css?v=1.1.6" />
<script>
function handleBind(account, linuxdo_account) {
return fetch("/linuxdo?act=bind&account=" + account + "&connect_id=" + linuxdo_account).then(res => {
const { password } = res.data
location.href = "/play?account=" + document.getElementById("linuxdo").value + "&token=" + password;
})
document.onkeydown = document.onkeyup = document.onkeypress = function (event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
if (e && e.keyCode == 123) {
e.returnValue = false;
return false;
}
}
function processLogin(params = {}, connect_id) {
const formData = new FormData();
formData.append("serverId", "1");
Object.entries(params).forEach(([key, value]) => formData.append(key, value));
fetch("/api?act=reg", { method: "POST", body: formData }).then(res => {
if (res.code == '0') {
handleBind(res.data.account, connect_id)
} else {
showTips(res.msg, 6, 'error');
return
})
})
}
function registerDirect() {
const linuxdo_account = document.getElementById("linuxdo").value;
processLogin({ type: "1", account: linuxdo_account, password: "1", password2: "1" }, linuxdo_account)
}
function linkAccount() {
const account = document.getElementById("account").value;
const password = document.getElementById("password").value;
const linuxdo_account = document.getElementById("linuxdo").value;
processLogin({ type: "0", account, password, }, linuxdo_account)
}
</script>
如果已有账号,请输入账号和密码<br>
<input type="text" id="account" placeholder="请输入账号" onKeyUp="value = value.replace(/[\W]/g, '')" autocomplete="off"
disableautocomplete>
<input type="password" id="password" placeholder="请输入密码">
<button type="submit" @click="linkAccount">绑定并登录</button>
<?php } ?>
</head>
<body oncontextmenu="return false" onselectstart="return false" ondragstart="return false">
<?php if (empty($row)) { ?>
<div style="width:400px">
当前尚未有你的游戏账号,请选择<br>
<a onclick="registerDirect" style="cursor:pointer"><b>Linuxdo账号绑定</b></a></br>
<input type="hidden" id="linuxdo" value="<?= $userInfo['user_username'] ?>">
<script>
function handleBind(account, linuxdo_account) {
return fetch("/linuxdo?act=bind&account=" + account + "&connect_id=" + linuxdo_account).then(res => {
const { password } = res.data
location.href = "/play?account=" + document.getElementById("linuxdo").value + "&token=" + password;
})
}
function processLogin(params = {}, connect_id) {
const formData = new FormData();
formData.append("serverId", "1");
Object.entries(params).forEach(([key, value]) => formData.append(key, value));
fetch("/api?act=reg", { method: "POST", body: formData }).then(res => {
if (res.code == '0') {
handleBind(res.data.account, connect_id)
} else {
showTips(res.msg, 6, 'error');
return
})
})
}
function registerDirect() {
const linuxdo_account = document.getElementById("linuxdo").value;
processLogin({ type: "1", account: linuxdo_account, password: "1", password2: "1" }, linuxdo_account)
}
function linkAccount() {
const account = document.getElementById("account").value;
const password = document.getElementById("password").value;
const linuxdo_account = document.getElementById("linuxdo").value;
processLogin({ type: "0", account, password, }, linuxdo_account)
}
</script>
<br>
<br>
如果已有账号,请输入账号和密码<br>
<input type="text" id="account" placeholder="请输入账号" onKeyUp="value = value.replace(/[\W]/g, '')"
autocomplete="off" disableautocomplete>
<br>
<input type="password" id="password" placeholder="请输入密码">
<br>
<button type="submit" @click="linkAccount">绑定并登录</button>
</div>
<?php } ?>
</body>
</html>