接入自建后端 + Gitea CI/CD
部署到群晖 / deploy (push) Failing after 6m22s

- 新增 server/:Node + Express + SQLite + node-cron 实现登录、纪念日 CRUD 和定时订阅消息推送
- 新增 .gitea/workflows/deploy.yml:推送即触发群晖 Docker 部署,监听 15002
- utils/api.js:自动按 envVersion 切换本地/线上 BASE_URL
- app.js 与 add-anniversary.js 移除 wx.cloud 调用,改走自建后端
- cloudfunctions/ 暂保留以便回滚
- 一并提交此前未入库的首页 / 设置页 / 日历 / 万年历等改造

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yuming
2026-06-01 15:44:09 +08:00
parent 6747ade9c4
commit 3965e542fc
49 changed files with 5616 additions and 670 deletions
+37 -75
View File
@@ -1,11 +1,12 @@
// calendar.js
const storage = require('../../utils/storage')
const dateUtils = require('../../utils/date')
const { TYPE_NAMES, TYPE_ICONS, IMPORTANCE_COLORS } = require('../../utils/constants')
Page({
data: {
currentYear: 2024,
currentMonth: 1,
currentYear: new Date().getFullYear(),
currentMonth: new Date().getMonth() + 1,
calendarDays: [],
monthEvents: []
},
@@ -20,100 +21,75 @@ Page({
this.loadMonthEvents()
},
/**
* 构建当月事件索引 { "day": [anniversary, ...] }
*/
buildEventIndex(anniversaries, year, month) {
const index = {}
for (const a of anniversaries) {
if (a.solarYear === year && a.solarMonth === month) {
const key = String(a.solarDay)
if (!index[key]) index[key] = []
index[key].push(a)
}
}
return index
},
/**
* 渲染日历
*/
renderCalendar() {
const { currentYear, currentMonth } = this.data
const anniversaries = storage.getAnniversaries()
// 获取本月第一天是星期几
// 预建事件索引,避免 O(n×m) 过滤
const eventIndex = this.buildEventIndex(anniversaries, currentYear, currentMonth)
const firstDay = new Date(currentYear, currentMonth - 1, 1)
const startWeekday = firstDay.getDay()
// 获取本月天数
const daysInMonth = new Date(currentYear, currentMonth, 0).getDate()
// 获取上个月的天数
const prevMonthDays = new Date(currentYear, currentMonth - 1, 0).getDate()
// 构建日历天数数组
const calendarDays = []
const today = new Date()
// 填充上个月的日期
for (let i = startWeekday - 1; i >= 0; i--) {
const day = prevMonthDays - i
calendarDays.push({
day,
date: new Date(currentYear, currentMonth - 2, day),
isToday: false,
isOtherMonth: true,
events: [],
hasMore: false
})
calendarDays.push({ day, isToday: false, isOtherMonth: true, events: [], hasMore: false })
}
// 填充本月的日期
for (let day = 1; day <= daysInMonth; day++) {
const date = new Date(currentYear, currentMonth - 1, day)
const isToday = dateUtils.isToday(date)
// 查找该日期的纪念日
const events = anniversaries
.filter(a => this.isAnniversaryOnDate(a, date))
.map(a => ({
id: a.id,
color: this.getEventColor(a)
}))
.slice(0, 3)
const allEvents = eventIndex[String(day)] || []
const events = allEvents.slice(0, 3).map(a => ({ id: a.id, color: this.getEventColor(a) }))
calendarDays.push({
day,
date,
isToday,
isOtherMonth: false,
events,
hasMore: events.length > 2,
moreCount: anniversaries.filter(a => this.isAnniversaryOnDate(a, date)).length - 2
hasMore: allEvents.length > 3,
moreCount: allEvents.length - 3
})
}
// 填充下个月的日期(补全6行)
const remainingDays = 42 - calendarDays.length
for (let day = 1; day <= remainingDays; day++) {
calendarDays.push({
day,
date: new Date(currentYear, currentMonth, day),
isToday: false,
isOtherMonth: true,
events: [],
hasMore: false
})
calendarDays.push({ day, isToday: false, isOtherMonth: true, events: [], hasMore: false })
}
this.setData({ calendarDays })
},
/**
* 判断纪念日是否在某日期
*/
isAnniversaryOnDate(anniversary, date) {
return anniversary.solarYear === date.getFullYear() &&
anniversary.solarMonth === date.getMonth() + 1 &&
anniversary.solarDay === date.getDate()
this.setData({ calendarDays })
},
/**
* 获取事件颜色
*/
getEventColor(anniversary) {
const colors = {
high: '#ff5722',
medium: '#ff9800',
low: '#07c160'
}
return colors[anniversary.importance] || '#07c160'
return IMPORTANCE_COLORS[anniversary.importance] || '#07c160'
},
/**
@@ -150,28 +126,14 @@ Page({
* 获取类型图标
*/
getTypeIcon(type) {
const icons = {
birthday: '🎂',
lunar_birthday: '🌙',
wedding: '💍',
engagement: '💕',
other: '📅'
}
return icons[type] || '📅'
return TYPE_ICONS[type] || '📅'
},
/**
* 获取类型名称
*/
getTypeName(type) {
const names = {
birthday: '公历生日',
lunar_birthday: '农历生日',
wedding: '结婚纪念日',
engagement: '订婚纪念日',
other: '其他纪念日'
}
return names[type] || '其他'
return TYPE_NAMES[type] || '其他'
},
/**
+3 -1
View File
@@ -12,7 +12,9 @@
<!-- 星期标题 -->
<view class="week-header">
<view wx:for="{{['日', '一', '二', '三', '四', '五', '六']}}" wx:key="*this" class="week-title">{{item}}</view>
<view wx:for="{{['日', '一', '二', '三', '四', '五', '六']}}" wx:key="*this" class="week-title">
<text>{{item}}</text>
</view>
</view>
<!-- 日历内容 -->
+118 -51
View File
@@ -5,43 +5,61 @@
}
.calendar-header {
background-color: #fff;
padding: 32rpx;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 40rpx 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #f0f0f0;
box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.2);
}
.month-navigation {
display: flex;
align-items: center;
gap: 32rpx;
gap: 24rpx;
}
.nav-btn {
font-size: 48rpx;
color: #07c160;
font-size: 40rpx;
color: #fff;
font-weight: 300;
width: 60rpx;
text-align: center;
width: 56rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 50%;
transition: all 0.2s;
}
.nav-btn:active {
background-color: rgba(255, 255, 255, 0.3);
transform: scale(0.95);
}
.month-title {
font-size: 36rpx;
font-weight: 600;
color: #333;
color: #fff;
min-width: 240rpx;
text-align: center;
}
.today-btn {
padding: 12rpx 32rpx;
background-color: #f5f5f5;
color: #666;
padding: 14rpx 32rpx;
background-color: rgba(255, 255, 255, 0.25);
color: #fff;
border-radius: 40rpx;
font-size: 24rpx;
font-size: 26rpx;
border: none;
font-weight: 600;
transition: all 0.2s;
}
.today-btn:active {
background-color: rgba(255, 255, 255, 0.35);
transform: scale(0.95);
}
.today-btn::after {
@@ -49,96 +67,137 @@
}
.week-header {
display: flex;
background-color: #fff;
border-bottom: 1px solid #f0f0f0;
display: grid;
grid-template-columns: repeat(7, 1fr);
background: linear-gradient(to bottom, #fff 0%, #fafafa 100%);
padding: 20rpx 24rpx 12rpx 24rpx;
gap: 12rpx;
border-bottom: 2rpx solid #f0f0f0;
box-sizing: border-box;
}
.week-title {
flex: 1;
text-align: center;
padding: 20rpx 0;
font-size: 24rpx;
color: #999;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
height: 60rpx;
font-size: 26rpx;
color: #888;
font-weight: 600;
margin: 0;
padding: 0;
box-sizing: border-box;
}
.week-title text {
display: block;
}
.calendar-content {
height: calc(100vh - 200rpx);
background-color: #f5f5f5;
}
.calendar-grid {
display: grid;
grid-template-columns: repeat(7, 1fr);
background-color: #fff;
background-color: #f5f5f5;
padding: 16rpx 24rpx 16rpx 24rpx;
gap: 12rpx;
box-sizing: border-box;
}
.calendar-cell {
min-height: 120rpx;
border: 1px solid #f0f0f0;
padding: 8rpx;
min-height: 100rpx;
background-color: #fff;
border-radius: 12rpx;
padding: 12rpx 8rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
transition: all 0.2s;
box-sizing: border-box;
margin: 0;
}
.calendar-cell.other-month {
background-color: #fafafa;
background-color: transparent;
box-shadow: none;
}
.calendar-cell.today {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
box-shadow: 0 8rpx 16rpx rgba(102, 126, 234, 0.3);
transform: scale(1.05);
}
.calendar-cell.today .date-num {
background-color: #07c160;
color: #fff;
border-radius: 50%;
width: 48rpx;
height: 48rpx;
line-height: 48rpx;
text-align: center;
font-weight: 700;
}
.date-num {
font-size: 28rpx;
font-size: 32rpx;
color: #333;
margin-bottom: 8rpx;
font-weight: 600;
}
.calendar-cell.other-month .date-num {
color: #ccc;
color: #d0d0d0;
font-weight: 400;
}
.events {
display: flex;
gap: 4rpx;
gap: 6rpx;
flex-wrap: wrap;
justify-content: center;
max-width: 100%;
}
.event-dot {
width: 12rpx;
height: 12rpx;
width: 8rpx;
height: 8rpx;
border-radius: 50%;
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.15);
}
.calendar-cell.today .event-dot {
background-color: #fff !important;
}
.more-text {
font-size: 20rpx;
font-size: 18rpx;
color: #999;
margin-top: 4rpx;
font-weight: 500;
}
.calendar-cell.today .more-text {
color: #fff;
}
/* 事件列表 */
.events-list {
padding: 32rpx;
padding: 32rpx 24rpx;
}
.section-title {
font-size: 32rpx;
font-weight: 600;
font-weight: 700;
color: #333;
margin-bottom: 24rpx;
padding-left: 16rpx;
border-left: 6rpx solid #667eea;
}
.empty-state {
text-align: center;
padding: 120rpx 40rpx;
opacity: 0.6;
}
.empty-state .icon {
@@ -150,14 +209,17 @@
.empty-state .text {
font-size: 28rpx;
color: #999;
line-height: 1.6;
}
.event-card {
background-color: #fff;
background: linear-gradient(135deg, #fff 0%, #fafafa 100%);
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
margin-bottom: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
border: 2rpx solid rgba(102, 126, 234, 0.1);
transition: all 0.3s;
}
.event-header {
@@ -190,26 +252,31 @@
}
.lunar-badge {
padding: 4rpx 12rpx;
background-color: #e3f2fd;
padding: 6rpx 16rpx;
background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
color: #1976d2;
border-radius: 4rpx;
border-radius: 20rpx;
font-size: 20rpx;
font-weight: 600;
box-shadow: 0 2rpx 8rpx rgba(25, 118, 210, 0.15);
}
.status {
font-size: 22rpx;
padding: 4rpx 12rpx;
border-radius: 4rpx;
padding: 6rpx 16rpx;
border-radius: 20rpx;
font-weight: 600;
}
.status.urgent {
background-color: #fff3f0;
background: linear-gradient(135deg, #ffe0db 0%, #ffccbc 100%);
color: #ff5722;
box-shadow: 0 2rpx 8rpx rgba(255, 87, 34, 0.15);
}
.status.warning {
background-color: #fff8e6;
background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
color: #ff9800;
box-shadow: 0 2rpx 8rpx rgba(255, 152, 0, 0.15);
}