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

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

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

打开 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. 不需要服务器支持,纯前端实现

最终效果:


相关推荐

Excel高效技巧:批量合并重复数据的实用指南

在日常数据处理中,我们常会遇到需要合并相邻重复单元格的场景。无论是整理分类标签、统计重复项还是优化报表格式,手动逐个合并不仅耗时且容易出错。本文将详细介绍三种专业高效的批量合并方法,助您轻松应对各种复...

自主研发高速动车组列车又添新成员(新时代画卷)

数据来源:国铁集团">数据来源:国铁集团CR400AF—S型列车驶过重庆。龙帆摄(人民视觉)">CR400AF—S型列车驶过重庆。龙帆摄(人民视觉)CR400BF—GZ型列车行驶在京...

福彩双色球幻圆图的VBA程序(第一部分)

很多朋友喜欢玩福彩双色球彩票,都知道下面的这张图——福彩双色球红球幻圆图和篮球幻方图。图2是福彩双色球2024104期(红色)和2024105期(黄色)的幻圆图。图3是福彩双色球2024105期(红色...

技巧 | 往MCP服务器添加提示词模板

在我的上一篇文章[1]中,我已经构建了一个本地MCP服务器并向其添加了一些工具。在本文中,我们将向该MCP服务器添加提示词。这是如同上一篇博客的文件结构。但在这里,我为此创建了两个新文件。.├──...

Avalonia日志组件实现与优化指南

背景Avalonia目前没有富文本框可实现日志输出显示,但提供了SelectableTextBlock控件可以替换,这是站长实现的一个日志组件效果:可展示日志时间、日志级别、日志详细内容等,后台除输...

vim编辑器最后几行@代表什么意思

使用vim编辑文本时,屏幕下方会出现一些@符号,这些符号代表什么意思?当vim设置了wrap属性时,若一行太长则就会发生折行现象,此时一个逻辑行就会显示多个屏幕行,如下图由于文件的第2行太长,一个真实...

浅色AI云食堂APP完整代码(二)

以下是整合后的浅色AI云食堂APP完整代码,包含后端核心功能、前端界面以及优化增强功能。项目采用Django框架开发,支持库存管理、订单处理、财务管理等核心功能,并包含库存预警、数据导出、权限管理等增...

QML控件:TextInput, TextField, TextEdit, TextArea用法及自定义

本文主要介绍基本元素TextInput,TextField,TextEdit,TextArea等的基本属性。Textlnput与TextField为行编辑控件,TextEdit与T...

WPF - 10.特殊容器控件

摘要这里我们要介绍的特殊容器空间是ScrollViewer,该控件与其他控件不同的是,可以支持滚动显示容器内的元素。下面我们举例说明如何在WPF中使用ScrollViewer控件。新建一个WPF程...

rhino6.0 python中ETO的组件案例

1.按钮组件按钮几乎放置在每个对话框上。创建一个新的按钮很简单。使用forms.Button并指定Text显示在按钮面上。除了创建新按钮外,通常还通过.Click事件附加一个操作。使用+=语法,如下...

Rhino6.0 窗口开发使用角本说明

第1个:生成窗口代码第2点:Eto界面主要由Dialog(主程序界面)、Layout(界面布局)和Controls(控件)三个部分构成,逻辑简单且清晰。这个脚本被分为三个主要部分。该import...

手把手教你搭建属于自己的服务器!

最近总是想搭建自己的网站,奈何皮夹里空空如也,服务器也租不起,更别说域名了。于是我就寻思能否自己搭建个服务器,还不要钱呢?还真行!!!经过几天的冲浪,我发现有两个免费的建站工具:Apache和Ng...

HEAT杂志《欧美猛男》排行!“雷神”居然没进前三!

提到猛男的必备条件,应该就是要有着让人看了会流口水的大块肌肉,而一说到猛男,小编第一个想到的就是spanstyle="text-transform:none;background-color:...

Power Query 表格列历遍函数Table.TransformColumns函数

PowerQuery提取数字应该是非常方便的,EH有这样一道题:一看到这题首先想的是PowerQuery,可能中毒有点深,思路挺简单的,PowerQuery有一个从数字到非数字的分列分列后再提取...

自学前端踩了30个坑,终于整理出这份新手避坑指南

这是我在自学前端的第37天,对着一个简单的HTML页面卡了整整一下午。不是逻辑错误,不是语法问题,只是我不知道为什么,一个div死活居中不了。那时候的我,以为前端就是写写页面、调调样式,直到后来才...