SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>账号密码管理器</title>
    <style>
        *{margin:0;padding:0;box-sizing:border-box;}
        body{
            font-family:system-ui;
            display:flex;
            flex-direction:column;
            align-items:center;
            justify-content:center;
            min-height:100vh;
            gap:10px;
            background:#181825;
            color:#fff;
            padding:20px;
        }
        label{
            width:320px;
            font-size:15px;
            margin-top:6px;
        }
        input{
            width:320px;
            padding:12px 14px;
            font-size:16px;
            border-radius:8px;
            border:none;
            outline:none;
            background:#27293d;
            color:#fff;
        }
        button{
            width:320px;
            padding:12px;
            border:none;
            border-radius:8px;
            font-size:16px;
            cursor:pointer;
        }
        .tip-green{color:#4ade80;height:20px;}
        .tip-orange{color:#fb923c;height:20px;}
        .tip-blue{color:#60a5fa;height:20px;margin-top:-17px;}
        .box{width:320px;padding:12px;border:1px solid #444;border-radius:8px;}
        .hide{display:none !important;}
    </style>
</head>
<body>
    <h2>账号密码管理器</h2>
    <label>账号</label>
    <input id="userInput" type="text">
    <div class="tip-blue" id="adminWelcome"></div>
    <label>密码</label>
    <input id="pwdInput" type="password">
    <div class="tip-green" id="msgTip"></div>

    <button id="loginBtn">登录</button>
    <button id="regBtn">注册申请</button>

    <div id="adminArea" class="hide">
        <button id="applyListBtn">申请注册列表</button>
        <button id="jumpBtn" style="background:#eab308;color:#000;margin-left:5px;">跳转</button>
        <div class="box" id="applyBox"></div>
    </div>

    <div class="box" id="myListBox">
        <h4>已注册列表(仅自己可见)</h4>
        <div id="myList"></div>
    </div>

<script>
// ==========配置后端地址==========
const API_URL = "http://127.0.0.1:5000/api/register";
const ADMIN_ACCOUNT = "admin";
const ADMIN_PWD = "8553160302";

// 本地存储
function escapeHtml(str){
    if(!str)return "";
    return String(str).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");
}
let applyList = JSON.parse(localStorage.getItem("applyList")||"[]");
let userList = JSON.parse(localStorage.getItem("userList")||"[]");
let blackList = JSON.parse(localStorage.getItem("blackList")||"[]");
let isAdmin = localStorage.getItem("isAdmin")==="true";

const userInput = document.getElementById("userInput");
const pwdInput = document.getElementById("pwdInput");
const msgTip = document.getElementById("msgTip");
const adminWelcome = document.getElementById("adminWelcome");
const loginBtn = document.getElementById("loginBtn");
const regBtn = document.getElementById("regBtn");
const adminArea = document.getElementById("adminArea");
const applyListBtn = document.getElementById("applyListBtn");
const jumpBtn = document.getElementById("jumpBtn");
const applyBox = document.getElementById("applyBox");
const myListBox = document.getElementById("myListBox");
const myList = document.getElementById("myList");

// 页面加载恢复管理员状态
if(isAdmin){
    adminArea.classList.remove("hide");
}

// 登录
loginBtn.onclick = function(){
    const u = userInput.value.trim();
    const p = pwdInput.value.trim();
    if(u===ADMIN_ACCOUNT && p===ADMIN_PWD){
        isAdmin = true;
        localStorage.setItem("isAdmin","true");
        adminWelcome.innerText = "管理员欢迎回家!";
        adminArea.classList.remove("hide");
        return;
    }
    const find = userList.find(i=>i.username===u&&i.password===p);
    if(find){
        renderMyList(u);
        msgTip.innerText = "登录成功";
    }else{
        msgTip.innerText = "账号密码错误";
    }
};

// 注册申请(同时发送给Flask后端)
regBtn.onclick = async function(){
    const u = userInput.value.trim();
    const p = pwdInput.value.trim();
    if(!u||!p){
        msgTip.innerText = "账号密码不能为空";
        return;
    }
    // 简单注入检测
    const injectReg = /<script|javascript:|on\w+=/i;
    if(injectReg.test(u)||injectReg.test(p)){
        blackList.push(u);
        localStorage.setItem("blackList",JSON.stringify(blackList));
        msgTip.innerText = "检测注入,已拉黑";
        return;
    }
    msgTip.innerText = "正在向管理员申请";
    setTimeout(()=>msgTip.innerText="",2000);

    const obj = {username:u,password:p,pass:false};
    applyList.push(obj);
    localStorage.setItem("applyList",JSON.stringify(applyList));

    // =====发送数据到你的python后端=====
    try{
        await fetch(API_URL,{
            method:"POST",
            headers:{"Content-Type":"application/json"},
            body:JSON.stringify({username:u,password:p})
        });
    }catch(e){
        console.log("后端未启动或连接失败",e);
    }
};

// 管理员点开申请列表
applyListBtn.onclick = function(){
    applyBox.innerHTML = "";
    applyList.forEach((item,idx)=>{
        const div = document.createElement("div");
        div.innerHTML = `
        <div>账号:${escapeHtml(item.username)} | 密码:${escapeHtml(item.password)}
        <button data-idx="${idx}">通过申请</button>
        </div>`;
        applyBox.appendChild(div);
    });
    // 通过申请按钮
    applyBox.querySelectorAll("button").forEach(btn=>{
        btn.onclick = function(){
            const i = Number(this.dataset.idx);
            const one = applyList[i];
            one.pass = true;
            userList.push({username:one.username,password:one.password});
            applyList.splice(i,1);
            localStorage.setItem("applyList",JSON.stringify(applyList));
            localStorage.setItem("userList",JSON.stringify(userList));
            applyListBtn.click();
            msgTip.innerText = "申请已通过";
        }
    })
};

jumpBtn.onclick = function(){
    window.open("https://jsrun.net/zSrKp/edit");
};

function renderMyList(currentUser){
    myList.innerHTML = "";
    const me = userList.find(x=>x.username===currentUser);
    if(me){
        myList.innerHTML = `<div>账号:${escapeHtml(me.username)} | 密码:${escapeHtml(me.password)}</div>`
    }
}
</script>
</body>
</html>