接入自建后端 + 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
+92 -7
View File
@@ -1,6 +1,7 @@
// add-anniversary.js
const storage = require('../../utils/storage')
const dateUtils = require('../../utils/date')
const api = require('../../utils/api')
Page({
data: {
@@ -188,11 +189,32 @@ Page({
*/
onRemindDaysChange(e) {
const index = parseInt(e.detail.value)
const days = [3, 7, 14, 30, 7][index]
this.setData({
remindDaysIndex: index,
'formData.remindDays': days
})
this.setData({ remindDaysIndex: index })
if (index === 4) {
// 自定义天数
wx.showModal({
title: '自定义提前天数',
editable: true,
placeholderText: '请输入天数(1-365',
success: (res) => {
if (res.confirm) {
const days = parseInt(res.content)
if (!days || days < 1 || days > 365) {
wx.showToast({ title: '请输入1-365之间的天数', icon: 'none' })
this.setData({ remindDaysIndex: 1, 'formData.remindDays': 7 })
return
}
this.setData({ 'formData.remindDays': days })
} else {
// 取消则回到默认7天
this.setData({ remindDaysIndex: 1, 'formData.remindDays': 7 })
}
}
})
} else {
const days = [3, 7, 14, 30][index]
this.setData({ 'formData.remindDays': days })
}
},
/**
@@ -214,8 +236,8 @@ Page({
/**
* 提交
*/
onSubmit() {
const { formData, personId, anniversaryId } = this.data
async onSubmit() {
const { formData, personId, anniversaryId, personList } = this.data
// 验证关联人员
if (!personId) {
@@ -235,14 +257,36 @@ Page({
return
}
// 如果开启了提醒,请求订阅消息授权
if (formData.remindEnabled) {
try {
await this.requestSubscribe()
} catch (err) {
console.log('用户拒绝订阅消息')
// 继续保存,即使用户拒绝订阅
}
}
// 获取人员名称
const person = personList.find(p => p.id === personId)
const personName = person ? person.name : ''
if (anniversaryId) {
// 编辑模式
const success = storage.updateAnniversary(anniversaryId, {
personId,
personName,
...formData
})
if (success) {
// 同步到云端
this.syncToCloud(anniversaryId, {
personId,
personName,
...formData
}, 'update')
wx.showToast({ title: '保存成功', icon: 'success' })
setTimeout(() => wx.navigateBack(), 1500)
}
@@ -250,14 +294,55 @@ Page({
// 新增模式
const newAnniversary = storage.addAnniversary({
personId,
personName,
...formData
})
if (newAnniversary) {
// 同步到云端
this.syncToCloud(newAnniversary.id, newAnniversary, 'add')
wx.showToast({ title: '添加成功', icon: 'success' })
setTimeout(() => wx.navigateBack(), 1500)
}
}
},
/**
* 请求订阅消息授权
*/
requestSubscribe() {
return new Promise((resolve, reject) => {
wx.requestSubscribeMessage({
tmplIds: ['6J7Stt-lu7DKU6jblJ0nZGq_D81z5glnksf7qWfy5Yw'],
success: (res) => {
console.log('订阅消息授权结果:', res)
resolve(res)
},
fail: (err) => {
console.error('订阅消息授权失败:', err)
reject(err)
}
})
})
},
/**
* 同步到自建后端
*/
async syncToCloud(id, data, action) {
try {
const openid = wx.getStorageSync('openid')
if (!openid) {
console.log('未获取到openid,跳过云端同步')
return
}
const res = await api.anniversary(action, { id, ...data })
console.log('云端同步成功:', res)
} catch (err) {
console.error('云端同步失败:', err)
// 不影响本地保存
}
}
})
+32 -6
View File
@@ -6,7 +6,7 @@
}
.form {
padding: 32rpx;
padding: 0 32rpx 32rpx;
}
.form-item {
@@ -15,6 +15,11 @@
padding: 32rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
box-sizing: border-box;
}
.form-item:first-child {
margin-top: 6rpx;
}
.label {
@@ -100,36 +105,57 @@
}
.textarea {
width: 100%;
background-color: #f5f5f5;
border-radius: 8rpx;
padding: 24rpx;
font-size: 28rpx;
min-height: 160rpx;
box-sizing: border-box;
}
.buttons {
display: flex;
gap: 24rpx;
margin-top: 40rpx;
padding: 0 32rpx 32rpx;
}
.btn {
flex: 1;
height: 88rpx;
line-height: 88rpx;
border-radius: 16rpx;
height: 96rpx;
line-height: 96rpx;
border-radius: 48rpx;
font-size: 32rpx;
font-weight: 600;
border: none;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
}
.btn-cancel {
background-color: #f5f5f5;
background: linear-gradient(135deg, #f5f7fa 0%, #e8eaf0 100%);
color: #666;
border: 2rpx solid rgba(102, 126, 234, 0.2);
}
.btn-cancel:active {
transform: scale(0.98);
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}
.btn-submit {
background: linear-gradient(135deg, #07c160 0%, #06ad56 100%);
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
box-shadow: 0 8rpx 24rpx rgba(102, 126, 234, 0.4);
}
.btn-submit:active {
transform: scale(0.98);
box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.3);
}
.btn-cancel::after,