课堂随机点名edit icon

创建者:
用户zdlDCoL7
Fork(复制)
下载
嵌入
BUG反馈
index.html
style.css
index.js
index.html
            
            <!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>
        @font-face {
            font-family: 'HYWenHei';
            src: url('https://cdn.jsdelivr.net/npm/[email protected]/HYWenHei-85W.ttf');
        }

        body {
            background: linear-gradient(to bottom right, #2c3951, #1b2638),
                        url('https://img-static.mihoyo.com/component/upload/component/20200528/3f0d5f4fdc5c4f8a5d8c6e4d0c6d0b4a.png');
            background-blend-mode: multiply;
            background-size: cover;
            min-height: 100vh;
            font-family: 'HYWenHei', Arial, sans-serif;
            color: #ffd700;
            text-align: center;
            padding: 20px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 30px;
            background: rgba(16, 23, 36, 0.8);
            border-radius: 15px;
            box-shadow: 0 0 20px rgba(74, 144, 226, 0.3);
            border: 1px solid #4a90e2;
        }

        h1 {
            font-size: 2.8em;
            margin-bottom: 30px;
            color: #ffd700;
            text-transform: uppercase;
            letter-spacing: 3px;
        }

        .genshin-btn {
            background: linear-gradient(45deg, #4a90e2, #6c5b7b);
            color: #fff;
            padding: 20px 40px;
            border: none;
            border-radius: 50px;
            font-size: 1.2em;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            margin: 20px 0;
        }

        .genshin-btn:hover {
            transform: scale(1.05);
            box-shadow: 0 0 25px rgba(74, 144, 226, 0.5);
        }

        .genshin-btn::after {
            content: '✦';
            position: absolute;
            right: 15px;
            opacity: 0.5;
        }

        #result {
            font-size: 2.5em;
            margin: 40px 0;
            min-height: 60px;
            padding: 20px;
            background: rgba(0,0,0,0.3);
            border-radius: 10px;
            animation: fadeIn 0.5s ease;
        }

        .elemental-decoration {
            display: flex;
            justify-content: space-around;
            margin: 30px 0;
        }

        .element {
            width: 60px;
            height: 60px;
            background-size: contain;
            opacity: 0.6;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .anemo { background-image: url('https://genshin.honeyhunterworld.com/img/element/anemo_35.webp'); }
        .geo { background-image: url('https://genshin.honeyhunterworld.com/img/element/geo_35.webp'); }
        .electro { background-image: url('https://genshin.honeyhunterworld.com/img/element/electro_35.webp'); }
    </style>
</head>
<body>
    <div class="container">
        <h1>🜸 课堂幸运星 🜷</h1>
        <div class="elemental-decoration">
            <div class="element anemo"></div>
            <div class="element geo"></div>
            <div class="element electro"></div>
        </div>
        <button class="genshin-btn" onclick="startRandomCall()">启动元素召唤</button>
        <div id="result"></div>
    </div>

    <script>
        // 最新学生名单(共40人)
        const students = [
            "丁子洵", "卢靖轩", "李国沔", "刘航诚", "王牧遥",
            "陈梓濠", "侯詹云熙", "孙家晟", "李有有", "梁亦隽",
            "张吴维", "吴嘉颖", "任大任", "余思莹", "温思雅",
            "李俊熠", "文诗雨", "曾梓恒", "唐浩宇", "李想",
            "彭鸣湃", "黄钺涵", "高浚峰", "王希晨", "王夕",
            "张峰瑜", "李家齐", "蒋妍", "刘嘉浚", "秦业煌",
            "马煜腾", "李浩冉", "张俐", "汪义烜", "白悦涵",
            "曾宇恒", "洪昕博", "温子堃", "任一翀", "黄崇炜",
            "张思越"
        ];

        // 系统状态管理
        let isRunning = false;
        let intervalId = null;
        let lastPick = null;
        let secondLastPick = null;

        // 键盘事件监听
        document.addEventListener('keydown', (event) => {
            if (event.code === 'Space') {
                event.preventDefault();
                startRandomCall();
            }
        });

        function startRandomCall() {
            if (!isRunning) {
                isRunning = true;
                document.querySelector('.genshin-btn').textContent = '停止召唤';
                intervalId = setInterval(() => {
                    let candidate;
                    do {
                        candidate = students[Math.floor(Math.random() * students.length)];
                    } while (candidate === lastPick || candidate === secondLastPick);
                    
                    secondLastPick = lastPick;
                    lastPick = candidate;
                    document.getElementById('result').textContent = candidate;
                }, 50);
            } else {
                clearInterval(intervalId);
                isRunning = false;
                document.querySelector('.genshin-btn').textContent = '启动元素召唤';
                animateResult();
                // 添加1秒冷却时间
                document.querySelector('.genshin-btn').disabled = true;
                setTimeout(() => {
                    document.querySelector('.genshin-btn').disabled = false;
                }, 1000);
            }
        }

        function animateResult() {
            const resultDiv = document.getElementById('result');
            resultDiv.style.animation = 'none';
            void resultDiv.offsetWidth; // 触发重绘
            resultDiv.style.animation = 'fadeIn 0.5s ease';
        }
    </script>
</body>
</html>
        
编辑器加载中
预览
控制台