百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术文章 > 正文

用deepseek开发一款记事日历(用deepseek搭建本地知识库)

zhezhongyun 2025-07-28 01:23 26 浏览

打开 chat.deepseek.com

输入提示词: 制作一个记事日历工具,每个月自动更新当前的月份,每天可以添加当天的备注,点击后即标记为完成


结果:

<!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>
        body {
            font-family: 'Arial', sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        
        .calendar-container {
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            padding: 20px;
        }
        
        .calendar-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .month-year {
            font-size: 24px;
            font-weight: bold;
        }
        
        .days-header {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            text-align: center;
            font-weight: bold;
            margin-bottom: 10px;
        }
        
        .days-grid {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 10px;
        }
        
        .day-cell {
            min-height: 80px;
            border: 1px solid #ddd;
            border-radius: 5px;
            padding: 5px;
            position: relative;
            background-color: white;
        }
        
        .day-cell.empty {
            background-color: #f9f9f9;
            border: none;
        }
        
        .day-number {
            font-weight: bold;
            margin-bottom: 5px;
        }
        
        .day-cell.today {
            background-color: #e6f7ff;
            border-color: #91d5ff;
        }
        
        .note-input {
            width: 100%;
            font-size: 12px;
            border: 1px solid #eee;
            border-radius: 3px;
            padding: 3px;
            margin-top: 5px;
        }
        
        .note {
            font-size: 12px;
            background-color: #f0f0f0;
            border-radius: 3px;
            padding: 3px;
            margin-top: 3px;
            word-break: break-word;
            cursor: pointer;
        }
        
        .note.completed {
            text-decoration: line-through;
            color: #888;
            background-color: #e8f5e9;
        }
        
        .nav-button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 8px 15px;
            border-radius: 5px;
            cursor: pointer;
        }
        
        .nav-button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <div class="calendar-container">
        <div class="calendar-header">
            <button class="nav-button" id="prev-month">上个月</button>
            <div class="month-year" id="month-year"></div>
            <button class="nav-button" id="next-month">下个月</button>
        </div>
        
        <div class="days-header">
            <div>日</div>
            <div>一</div>
            <div>二</div>
            <div>三</div>
            <div>四</div>
            <div>五</div>
            <div>六</div>
        </div>
        
        <div class="days-grid" id="days-grid"></div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            let currentDate = new Date();
            let currentYear = currentDate.getFullYear();
            let currentMonth = currentDate.getMonth();
            
            // 从本地存储加载笔记
            let notes = JSON.parse(localStorage.getItem('calendarNotes')) || {};
            
            // 初始化日历
            renderCalendar(currentYear, currentMonth);
            
            // 上个月按钮事件
            document.getElementById('prev-month').addEventListener('click', function() {
                currentMonth--;
                if (currentMonth < 0) {
                    currentMonth = 11;
                    currentYear--;
                }
                renderCalendar(currentYear, currentMonth);
            });
            
            // 下个月按钮事件
            document.getElementById('next-month').addEventListener('click', function() {
                currentMonth++;
                if (currentMonth > 11) {
                    currentMonth = 0;
                    currentYear++;
                }
                renderCalendar(currentYear, currentMonth);
            });
            
            // 渲染日历
            function renderCalendar(year, month) {
                const monthNames = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"];
                document.getElementById('month-year').textContent = `${year}年 ${monthNames[month]}`;
                
                const firstDay = new Date(year, month, 1);
                const startingDay = firstDay.getDay();
                
                const daysInMonth = new Date(year, month + 1, 0).getDate();
                const today = new Date();
                
                let daysGrid = document.getElementById('days-grid');
                daysGrid.innerHTML = '';
                
                // 添加空白单元格
                for (let i = 0; i < startingDay; i++) {
                    const emptyCell = document.createElement('div');
                    emptyCell.className = 'day-cell empty';
                    daysGrid.appendChild(emptyCell);
                }
                
                // 添加日期单元格
                for (let day = 1; day <= daysInMonth; day++) {
                    const dayCell = document.createElement('div');
                    dayCell.className = 'day-cell';
                    
                    // 如果是今天,添加特殊样式
                    if (year === today.getFullYear() && month === today.getMonth() && day === today.getDate()) {
                        dayCell.classList.add('today');
                    }
                    
                    const dayNumber = document.createElement('div');
                    dayNumber.className = 'day-number';
                    dayNumber.textContent = day;
                    dayCell.appendChild(dayNumber);
                    
                    // 添加笔记输入框
                    const noteInput = document.createElement('input');
                    noteInput.className = 'note-input';
                    noteInput.placeholder = '添加备注...';
                    noteInput.dataset.date = `${year}-${month}-${day}`;
                    
                    noteInput.addEventListener('keypress', function(e) {
                        if (e.key === 'Enter' && this.value.trim() !== '') {
                            const dateKey = this.dataset.date;
                            if (!notes[dateKey]) {
                                notes[dateKey] = [];
                            }
                            notes[dateKey].push({
                                text: this.value.trim(),
                                completed: false
                            });
                            localStorage.setItem('calendarNotes', JSON.stringify(notes));
                            renderDayNotes(dayCell, dateKey);
                            this.value = '';
                        }
                    });
                    
                    dayCell.appendChild(noteInput);
                    
                    // 渲染已有的笔记
                    const dateKey = `${year}-${month}-${day}`;
                    renderDayNotes(dayCell, dateKey);
                    
                    daysGrid.appendChild(dayCell);
                }
            }
            
            // 渲染某天的笔记
            function renderDayNotes(dayCell, dateKey) {
                // 移除现有的笔记(除了输入框)
                const notesToRemove = dayCell.querySelectorAll('.note');
                notesToRemove.forEach(note => note.remove());
                
                // 添加新的笔记
                if (notes[dateKey]) {
                    notes[dateKey].forEach((note, index) => {
                        const noteElement = document.createElement('div');
                        noteElement.className = 'note';
                        if (note.completed) {
                            noteElement.classList.add('completed');
                        }
                        noteElement.textContent = note.text;
                        noteElement.dataset.date = dateKey;
                        noteElement.dataset.index = index;
                        
                        noteElement.addEventListener('click', function() {
                            const dateKey = this.dataset.date;
                            const index = parseInt(this.dataset.index);
                            notes[dateKey][index].completed = !notes[dateKey][index].completed;
                            localStorage.setItem('calendarNotes', JSON.stringify(notes));
                            this.classList.toggle('completed');
                        });
                        
                        // 在输入框之前插入笔记
                        dayCell.insertBefore(noteElement, dayCell.querySelector('.note-input'));
                    });
                }
            }
        });
    </script>
</body>
</html>

功能说明

  1. 自动显示当前月份:日历会自动显示当前月份和年份
  2. 导航功能:可以通过"上个月"和"下个月"按钮切换月份
  3. 添加备注:每天都有一个输入框,输入内容后按回车键添加备注
  4. 标记完成:点击备注可以标记为完成/未完成
  5. 数据保存:所有备注会保存在浏览器的本地存储中,刷新页面不会丢失
  6. 今日高亮:当前日期会有特殊背景色标记

使用方法

  1. 将上述代码保存为HTML文件(如calendar.html)
  2. 用浏览器打开该文件即可使用
  3. 不需要服务器支持,纯前端实现

最终效果:


相关推荐

Opinion丨Struggle Against U.S. Mind colonization in the Global South

Editor'snote:Thismonth,XinhuaNewsAgency'sThinkTankreleasedareporttitled"Colonizationof...

爱可可AI论文推介(2020.11.4)_爱可可女装旗舰店

LG-机器学习CV-计算机视觉CL-计算与语言AS-音频与语音RO-机器人(*表示值得重点关注)1、[LG]*CombiningLabelPropagationan...

何新:罗马伪史考英文版序言_罗马史学

2019-10-2514:48:27何新:罗马伪史考序言(英文译本)HeXin:PreambleofResearchonPseudo-historyofRome1Afewyear...

XPeng Stock Rises Over 4% after Q2 Revenue and EV Margin Set Records

TMTPOST--TheAmericandepositaryreceipts(ADRs)ofXPengInc.rosearound4.2%onTuesdayaftert...

英汉世界语部首(八)_英文部首字典

本节讲八个部首,分别是:弓gōng【ECWLrad】bow廾gǒng【ECWLrad】twen广guǎng【ECWLrad】vast己jǐ【ECWLrad】self已yǐ...

一课译词:划水_划水是什么地方的方言

[Photo/SIPA]懒惰是人类的天性,因此才总有人会在工作时“划水”。“划水【huáshuǐ】”,本意是指“用胳膊划的动作(makestrokeswithone’sarms)”,延伸为“...

首测!GPT-4o做Code Review可行吗?

编辑|言征出品|51CTO技术栈(微信号:blog51cto)近日,OpenAI一记重拳,推出了GPT-4o(“o”表示“omni”),将语音识别和对话方面的优势展示的淋漓尽致。几乎可以肯定,...

C++|漫谈STL细节及内部原理_c++ stl详解

1988年,AlexanderStepanov开始进入惠普的PaloAlto实验室工作,在随后的4年中,他从事的是有关磁盘驱动器方面的工作。直到1992年,由于参加并主持了实验室主任BillWo...

C++ inline关键字深度解析:不止于优化的头文件定义许可

在C++开发中,几乎每个程序员都用过inline关键字,但多数人只停留在“内联优化”的表层理解。事实上,inline的真正威力在于它打破了C++的单一定义规则(ODR)限制,成为头文件中安全定义函数的...

实用 | 10分钟教你搭建一个嵌入式web服务器

之前分享的文章中提到了几种可以在嵌入式中使用的web服务器。嵌入式web服务器就是把web服务器移植到嵌入式系统的服务器。它仍然是基于http文本协议进行通信的,具有标准的接口形式,对客户端...

中间语言格式_中间格式文本是什么

在通常情况下,编译器会将目标语言转换成某种中间语言格式,而不是直接将源代码转换成二进制机器指令,不少c语言编译器,都会将代码编译成汇编语言,然后再通过汇编语言编译器将汇编代码转换成目标机器可执行的二进...

一线开发大牛带你深度解析探讨模板解释器,解释器的生成

解释器生成解释器的机器代码片段都是在TemplateInterpreterGenerator::generate_all()中生成的,下面将分小节详细展示该函数的具体细节,以及解释器某个组件的机器代码...

干货,Web开发和前端开发逆天工具大全

微信ID:WEB_wysj(点击关注)◎◎◎◎◎◎◎◎◎一┳═┻︻▄(点击页底“阅读原文”前往下载)●●●逆天工具CDN资源库国内Bootstrap中文网开源项目免费CDN服务36...

移动端rem+vw适配_移动端web页面适配方案

rem:rem是相对单位,设置根元素html的font-size,比如给html设置字体大小为100px,1rem=100px;rem缺点:1.和根元素font-size值强耦合,系统字...

从零搭建 React 开发 H5 模板_react html5

项目创建创建项目文件夹mkdir react-democd react-demonpm init -y依赖安装yarn add rea...