refactor(linuxdo): 优化账号绑定页面布局和代码结构
- 调整了页面布局,增加了 div 容器以改善元素排列 - 优化了 JavaScript 代码格式,提高了可读性 - 修复了一些小问题,如移除了多余的空行和不必要的换行符
This commit is contained in:
148
linuxdo.php
148
linuxdo.php
@@ -138,86 +138,90 @@ function get_curl($url, $post = 0, $referer = 0, $cookie = 0, $header = 0, $ua =
|
|||||||
?>
|
?>
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<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"/>
|
<head>
|
||||||
<meta name="applicable-device" content="mobile">
|
<meta charset="UTF-8">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
||||||
|
|
||||||
<meta name="full-screen" content="yes"/>
|
<meta name="viewport"
|
||||||
<meta name="x5-fullscreen" content="true"/>
|
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
<meta name="360-fullscreen" content="true"/>
|
<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="full-screen" content="yes" />
|
||||||
<meta name="x5-orientation" content="portrait">
|
<meta name="x5-fullscreen" content="true" />
|
||||||
<meta name="x5-page-mode" content="app">
|
<meta name="360-fullscreen" content="true" />
|
||||||
|
|
||||||
<title><?=$_CONFIG['game_name']?> <?=$_CONFIG['game_description']?></title>
|
<meta name="screen-orientation" content="portrait">
|
||||||
<meta name="description" content="<?=$_CONFIG['game_name']?> <?=$_CONFIG['game_description']?>">
|
<meta name="x5-orientation" content="portrait">
|
||||||
<meta name="keywords" content="<?=$_CONFIG['game_name']?>,<?=$_CONFIG['game_description']?>">
|
<meta name="x5-page-mode" content="app">
|
||||||
|
|
||||||
<link rel="stylesheet" href="static/css/login.css?v=1.1.6"/>
|
<title><?= $_CONFIG['game_name'] ?> <?= $_CONFIG['game_description'] ?></title>
|
||||||
<script>
|
<meta name="description" content="<?= $_CONFIG['game_name'] ?> <?= $_CONFIG['game_description'] ?>">
|
||||||
document.onkeydown = document.onkeyup = document.onkeypress = function(event) {
|
<meta name="keywords" content="<?= $_CONFIG['game_name'] ?>,<?= $_CONFIG['game_description'] ?>">
|
||||||
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>
|
|
||||||
|
|
||||||
layer.config({skin: 'dialogs'});
|
<link rel="stylesheet" href="static/css/login.css?v=1.1.6" />
|
||||||
</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'] ?>">
|
|
||||||
<script>
|
<script>
|
||||||
function handleBind(account, linuxdo_account) {
|
document.onkeydown = document.onkeyup = document.onkeypress = function (event) {
|
||||||
return fetch("/linuxdo?act=bind&account=" + account + "&connect_id=" + linuxdo_account).then(res => {
|
var e = event || window.event || arguments.callee.caller.arguments[0];
|
||||||
const { password } = res.data
|
if (e && e.keyCode == 123) {
|
||||||
location.href = "/play?account=" + document.getElementById("linuxdo").value + "&token=" + password;
|
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>
|
</script>
|
||||||
如果已有账号,请输入账号和密码<br>
|
</head>
|
||||||
<input type="text" id="account" placeholder="请输入账号" onKeyUp="value = value.replace(/[\W]/g, '')" autocomplete="off"
|
|
||||||
disableautocomplete>
|
<body oncontextmenu="return false" onselectstart="return false" ondragstart="return false">
|
||||||
<input type="password" id="password" placeholder="请输入密码">
|
<?php if (empty($row)) { ?>
|
||||||
<button type="submit" @click="linkAccount">绑定并登录</button>
|
<div style="width:400px">
|
||||||
<?php } ?>
|
当前尚未有你的游戏账号,请选择<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>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user