专业编程基础技术教程

网站首页 > 基础教程 正文

课堂点名总尴尬?试试 DeepSeek,或能实现点名自由!(附教程)

ccvgpt 2025-04-27 12:43:56 基础教程 4 ℃

2025 年 2 月 26 日
" 你有没有经历过这样的场景?老师拿着花名册扫视全班:' 今天我们来点名...'
那一刻心跳加速,默念:' 别点我!'
但现在,我要告诉你:我用 DeepSeek 实现了课堂点名自由!"

这个点名神器有多炸裂?

  • 卡通风格界面:学生直呼 "太可爱了!"
  • 随机滚动特效:点击开始后姓名飞速滚动,心跳指数
  • 智能高亮显示:暂停时自动高亮选中者,仪式感 MAX
  • 速度无极调节:滑轮控制 0.1x - 10x 变速,掌控课堂节奏

四步打造点名神器(附完整代码)

第一步:唤醒 DeepSeek

 https://www.deepseek.com 
如果官网比较卡的话,现在有很多的平替平台,火山、百度、搜狗、360、腾讯等
都接入了deepseekR1满血版的大模型

第二步:输入魔法指令

" 帮我写课堂随机点名网页,要求:

课堂点名总尴尬?试试 DeepSeek,或能实现点名自由!(附教程)

帮我写一个课堂随机点名网页,要求如下:

网页背景为卡通风格,标题为“随机抽签”。

中间区域显示滚动的姓名,底部有“开始点名”按钮。

点击按钮开始滚动,再次点击暂停并高亮显示选中姓名。

提供一个滑轮控件,可以控制滚动速度。’

第三步:获取 AI 生成代码

<!DOCTYPE html>
<html>
<head>
    <title>随机抽签</title>
    <style>
        body {
            /* 卡通背景 */
            background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
            margin: 0;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            font-family: 'Comic Sans MS', cursive;
        }

        h1 {
            color: #ff6b6b;
            margin: 20px 0;
        }

        .container {
            width: 500px;
            height: 200px;
            overflow: hidden;
            position: relative;
            border: 3px solid #4ecdc4;
            border-radius: 15px;
            background: white;
        }

        #names {
            position: absolute;
            transition: transform 0.1s; /* 平滑移动 */
            width: 100%;
        }

        .name {
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            color: #2d3436;
        }

        .highlight {
            color: #ff6b6b;
            font-weight: bold;
            font-size: 36px;
        }

        .controls {
            margin-top: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
        }

        #speed {
            width: 200px;
        }

        button {
            padding: 10px 20px;
            font-size: 18px;
            background: #4ecdc4;
            border: none;
            border-radius: 25px;
            color: white;
            cursor: pointer;
            transition: transform 0.2s;
        }

        button:hover {
            transform: scale(1.1);
            background: #45b7af;
        }
    </style>
</head>
<body>
    <h1>随机抽签</h1>
    <div class="container">
        <div id="names"></div>
    </div>
    <div class="controls">
        <input type="range" id="speed" min="1" max="10" value="5">
        <button id="startBtn">开始点名</button>
    </div>

    <script>
        const names = ['张三', '李四', '王五', '赵六', '小明', '小红', '小刚', '小芳', '陈七', '周八','张四', '李五', '王七', '赵八', '李小明', '李小红', '要小刚', '小大芳', '陈九', '周一'];
        const namesElement = document.getElementById('names');
        const speedSlider = document.getElementById('speed');
        const startBtn = document.getElementById('startBtn');
        let isRolling = false;
        let translateY = 0;
        let animationFrameId = null;
        const itemHeight = 40; // 每个姓名元素的高度

        // 初始化姓
        function initNames() {
            namesElement.innerHTML = '';
            // 复制姓名数组多次以形成循环效果
            for (let i = 0; i < 5; i++) { // 复制5次,足够长
                names.forEach(name => {
                    const div = document.createElement('div');
                    div.className = 'name';
                    div.textContent = name;
                    namesElement.appendChild(div);
                });
            }
        }
        initNames();

        function roll() {
            if (!isRolling) return;

            // 根据速度调整移动距离
            const speed = parseInt(speedSlider.value);
            translateY += speed;

            // 如果超过总高度,重置以实现循环
            const totalHeight = names.length * itemHeight;
            if (translateY >= totalHeight) {
                translateY -= totalHeight;
            }

            namesElement.style.transform = `translateY(-${translateY}px)`;

            animationFrameId = requestAnimationFrame(roll);
        }

        startBtn.addEventListener('click', () => {
            if (!isRolling) {
                isRolling = true;
                startBtn.textContent = '暂停点名';
                // 移除之前的高亮
                document.querySelectorAll('.name').forEach(name => {
                    name.classList.remove('highlight');
                });
                roll();
            } else {
                isRolling = false;
                startBtn.textContent = '开始点名';
                cancelAnimationFrame(animationFrameId);

                // 计算选中的姓名
                const totalHeight = names.length * itemHeight;
                const virtualTranslateY = translateY % totalHeight;
                const selectedIndex = Math.floor(virtualTranslateY / itemHeight);
                const selectedName = names[selectedIndex];

                // 找到所有对应的元素并高亮
                document.querySelectorAll('.name').forEach((nameEl, index) => {
                    const actualIndex = index % names.length;
                    if (actualIndex === selectedIndex) {
                        nameEl.classList.add('highlight');
                    }
                });
            }
        });

        // 初始速度显示
        speedSlider.addEventListener('input', (e) => {
            // 可以实时调整速度,但当前实现中,速度在roll函数里每一帧读取,所以不用做特别处理
        });
    </script>
</body>
</html>


第四步:个性化定制

  1. 替换names数组为你班的真实姓名



  1. 修改 CSS 中的background更换主题色
  2. 可以给出更多的指令,让AI帮你再修改完善,(比如:同时选出2个人),更多更高级的功能等你解锁哦!

三大创新教学场景

  1. 课前预热:用 "幸运儿讲题" 开启课堂
  2. 随堂测验:随机抽选答题勇士
  3. 小组竞赛:动态组队激发团队精神

高频问题解答

  • Q:会重复抽到同一人吗?
    A:完全随机算法,建议抽中后临时移出名单
  • Q:手机端能用吗?
    A:响应式设计,完美适配所有设备
  • Q:数据会保存吗?
    A:纯前端实现,零数据追踪更安全

互动时间
你遇到过最尴尬的点名场景是?
在评论区分享你的故事!

关注【秋枫红叶】,获取更多 AI 教学黑科技!

最近发表
标签列表