加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 4.70 KB
一键复制 编辑 原始数据 按行查看 历史
T-super21 提交于 2024-07-01 19:10 . v1.0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./js/base.js" data-path="./"></script>
<link rel="shortcut icon" href="./static/img/common/logo.png">
<title></title>
<style>
/* 默认隐藏盒子 */
#main {
display: none;
}
</style>
</head>
<body>
<div id="main">
<header>
<h1 id="header" class="title_linear1 login_header"></h1>
</header>
<section>
<div class="login">
<div class="login_left">
<trans-sphere></trans-sphere>
</div>
<div class="login_right">
<div-div1></div-div1>
<div class="form">
<div class="group-form">
<div class="group-label">用户名</div>
<input id="userName" placeholder="请输入用户名" required type="text" value="admin" >
</div>
<div class="group-form">
<div class="group-label">密码</div>
<input id="password" type="password" placeholder="请输入密码" required value="admin">
</div>
<div class="group-form">
<div class="group-label"></div>
<div class="checkbox">
<input type="checkbox" id="remeberMe" checked="checked">
<label for="remeberMe">记住我</label>
</div>
</div>
<div class="group-form">
<div class="group-label"></div>
<button type="button" class="btn bg-blue" onclick="login()">登录</button>
</div>
<div class="register_text" onclick="redirectPages('register')">暂无账号,去注册~</div>
</div>
<div id="version"></div>
</div>
</div>
</section>
<footer>
<div class="remark">本项目为演示项目,仅供线上演示使用, 切勿商用!!!</div>
</footer>
</div>
<div id="bgComponent">
<buttom-waves></buttom-waves>
</div>
</body>
<script>
// 页面加载完成回调函数
function onReady() {
checkLoginStatus();
console.log("onReady");
getEleVal("header").innerHTML = globalDatas.header;
}
// 登录
function login() {
let loginStatus = globalDatas.status.loginStatus;
let user = {
id: getUUID(),
name: null,
password: null,
remeberMe: null
}
user.name = getEleVal("userName").value;
user.password = getEleVal("password").value;
user.remeberMe = getEleVal("remeberMe").checked;
// 登录处理
if (user.name && user.password) {
let accountLists = globalDatas.datas.accountLists;
let databaseUser = accountLists.filter(item => {
return item.name == user.name
})[0]; // 获取注册的用户
if (databaseUser) {
// 验证密码(超级管理员不加密密码)
if (user.password == (databaseUser.name == "admin" ? databaseUser.password : aesDecrypt(databaseUser.password))) {
globalDatas.datas.remeberAccountID = user.id; // 记录当前登录的账号
globalDatas.status.remeberMe = remeberMe;
globalDatas.status.loginStatus = true; // 登录状态
globalDatas.status.activeUser = databaseUser; // 更新全局状态中的当前用户
setStorage("loginStatus", globalDatas.status.loginStatus);
setStorage("activeUser", databaseUser);
ice.pop({
icon: "success",
content: "登录成功~",
url: "./views/monitor/index.html"
})
} else {
ice.pop({
icon: "fail",
content: "密码错误,请检查~"
})
}
} else {
ice.pop({
icon: "fail",
content: `暂无${user.name}的用户,请注册~`
})
}
} else {
ice.pop({
icon: "warning",
content: "请输入用户名和密码!"
})
}
}
</script>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化