Author SHA1 Message Date
CodeBuddy 0530523750 UGC 2026-10-30 23:46:55 +08:00
CodeBuddy bf99e52937 feat: 存储空间管理、虚拟支付接入与容量守卫
- 新增存储空间管理:会员套餐配置、用户容量/到期管理、后台支付记录查询
- 接入个人主体小程序虚拟支付:下单/发货推送/兜底查单(query_order)
- 修复 adminStorageUsers 等接口鉴权、out_trade_no 长度、前端 requestVirtualPayment 参数
- 前端上传前容量预检,超容引导升级无限空间
- 我的页会员卡片展示「无限空间」与已用容量/到期时间
- 后台「存储空间管理」新增支付记录标签页
2026-10-30 23:45:39 +08:00
Blizzard b7c6224e54 Refine subscription renewal button layout 2026-10-11 10:43:53 +08:00
Blizzard 31eae87a63 Fix subscription renewal and partner notification delivery 2026-10-11 10:32:30 +08:00
Blizzard c5cab1b945 Record subscription message delivery and add admin log page 2026-10-11 10:21:15 +08:00
Blizzard 7854d94e7b Add server and mini-program pagination for shared lists 2026-10-11 10:10:49 +08:00
Blizzard c0a3db5c8e 增加抽烟周月支数及买烟金额统计 2026-10-11 09:58:18 +08:00
Blizzard 02d200fe12 日记列表超过100字显示省略号并保留完整正文 2026-10-11 09:53:27 +08:00
Blizzard 2ffee9d7fb 为打卡详情记录增加分页并保持全量统计 2026-10-11 09:50:36 +08:00
Blizzard 7133ea583d 隐藏相册列表照片信息仅在预览展示 2026-10-11 09:37:38 +08:00
Blizzard 45c81aeaac 调整日记评论面板跟随键盘并保留输入草稿 2026-10-11 09:32:45 +08:00
Blizzard 1bafb01741 修复日记长文输入布局并减少输入时正文回传 2026-10-11 09:22:29 +08:00
Blizzard 5365e13963 按桌面past-go原样同步首页样式与后端通知逻辑 2026-10-11 09:16:38 +08:00
Blizzard 4e751410b3 将首页双方地址调整为同行显示 2026-10-11 09:13:45 +08:00
Blizzard a41c4d91cb 按桌面压缩包原样同步小程序开发工具配置 2026-10-11 09:12:49 +08:00
Blizzard 2b2adfc0d3 恢复与线上及桌面源码一致的生日同行排版 2026-10-11 09:11:02 +08:00
Blizzard 92f211fc3b 修复同步覆盖的首页生日排版与当天提示 2026-10-11 08:59:52 +08:00
Blizzard b10fc3c4ac 同步小程序与管理端更新,完善抽烟记录和解绑冷静期 2026-10-09 22:15:51 +08:00
Blizzard a68a4ef411 init: initial commit 2026-10-07 09:28:43 +08:00
23 changed files with 252 additions and 161 deletions
+2
View File
@@ -7,6 +7,8 @@ run/
# 本地配置(含密钥,不入库)
config.yaml
# 生产部署配置模板(含数据库密码,不入库;部署时复制到服务器后按需修改)
deploy/linux/config.prod.yaml
# 依赖与构建产物
node_modules/
+10
View File
@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GoImports">
<option name="excludedPackages">
<array>
<option value="golang.org/x/net/context" />
</array>
</option>
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/past-go.iml" filepath="$PROJECT_DIR$/.idea/past-go.iml" />
</modules>
</component>
</project>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+18
View File
@@ -0,0 +1,18 @@
# 宝塔网站 → 设置 → 配置文件,把下面整段放到 server { } 内(或改用宝塔“反向代理”UI)
# 作用:把域名的所有请求反代到本地 Go 后端(:8080),由宝塔 Nginx 负责 HTTPS/SSL。
# 允许大文件上传(与 config.yaml 的 max_upload_mb 保持一致,默认 50MB)
client_max_body_size 50m;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 大文件/慢请求超时,与后端 ReadTimeout 对应
proxy_connect_timeout 60s;
proxy_read_timeout 180s;
proxy_send_timeout 180s;
}
+21
View File
@@ -0,0 +1,21 @@
[Unit]
Description=past-go backend service
After=network.target mysql.service
Wants=mysql.service
[Service]
Type=simple
# 运行用户:宝塔默认站点用户为 www,需对该用户有 data_dir/uploads 写权限
User=www
Group=www
# 改为你实际上传二进制与 config.yaml 的目录
WorkingDirectory=/www/wwwroot/past
ExecStart=/www/wwwroot/past/past-server -config /www/wwwroot/past/config.yaml
Restart=always
RestartSec=3
# 标准输出/错误会进 journalctl;程序自身也会写 data/go-server.log
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
+1
View File
@@ -114,6 +114,7 @@ func adminStatsDetail(c *httpapi.Ctx) error {
"date_contents_total": total,
"total_users": tableCount(c, "users"),
"total_couples": tableCount(c, "couples"),
"total_storage_used": allStorageUsedBytes(),
})
}
+36
View File
@@ -9,6 +9,7 @@ import (
"path/filepath"
"sort"
"strings"
"sync"
"time"
"past/internal/config"
@@ -99,6 +100,41 @@ func dirSize(root string) int64 {
return total
}
// storageUsedTotalCache 缓存全站已用存储总量,避免后台统计页频繁整目录遍历。
var storageUsedTotalCache = struct {
sync.RWMutex
bytes int64
at time.Time
}{}
// allStorageUsedBytes 统计存储目录所有文件占用字节数,即全站所有用户已使用的存储空间总量。
// 注意:按文件系统实际占用计算(情侣共享空间只计一次),更准确反映磁盘消耗。结果缓存 60 秒。
func allStorageUsedBytes() int64 {
storageUsedTotalCache.RLock()
if !storageUsedTotalCache.at.IsZero() && time.Since(storageUsedTotalCache.at) < time.Minute {
v := storageUsedTotalCache.bytes
storageUsedTotalCache.RUnlock()
return v
}
storageUsedTotalCache.RUnlock()
root := up.Dir
var total int64
if root != "" {
_ = filepath.Walk(root, func(_ string, info os.FileInfo, err error) error {
if err == nil && info != nil && !info.IsDir() {
total += info.Size()
}
return nil
})
}
storageUsedTotalCache.Lock()
storageUsedTotalCache.bytes = total
storageUsedTotalCache.at = time.Now()
storageUsedTotalCache.Unlock()
return total
}
// storageUsedBytes 统计当前用户(或其情侣空间)已用存储字节数。
// 组成:情侣空间共享文件(couples/{space})+ 相关用户(本人,或情侣双方)的头像(avatars/{user_id})与个人上传文件(users/{id})。
func storageUsedBytes(c *httpapi.Ctx, uid, coupleID int64) int64 {
+3 -3
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
<text x="50%" y="50%" dominant-baseline="central" text-anchor="middle" font-size="52">💗</text>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
<text x="50%" y="50%" dominant-baseline="central" text-anchor="middle" font-size="52">💗</text>
</svg>

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 194 B

+24 -14
View File
@@ -28,6 +28,15 @@ const CONTENT_LINK: Record<string, string> = {
timeline: "timeline", diaries: "diary", albums: "album", photos: "photo", songs: "song", checkins: "checkin", checkin_logs: "checkin",
}
function formatBytes(n?: number): string {
if (!n || n <= 0) return "0 B"
const units = ["B", "KB", "MB", "GB", "TB"]
let i = 0
let v = n
while (v >= 1024 && i < units.length - 1) { v /= 1024; i++ }
return `${v >= 100 || i === 0 ? Math.round(v) : v.toFixed(1)} ${units[i]}`
}
export default function Dashboard() {
const navigate = useNavigate()
const stats = useQuery({ queryKey: ["admin_stats"], queryFn: () => api("adminStats", null, "GET") })
@@ -42,6 +51,21 @@ export default function Dashboard() {
return (
<div className="space-y-5">
<Card>
<CardHeader><CardTitle className="text-base">用户注册统计</CardTitle></CardHeader>
<CardContent>
{today.isPending ? <Loading rows={1} /> : today.isError ? <ErrorBox error={today.error} /> : (
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5">
<StatCard label="今日新注册" value={today.data.today_registers} tone="pink" />
<StatCard label="本月新注册" value={today.data.month_registers} tone="violet" />
<StatCard label="总用户数" value={today.data.total_users} tone="green" />
<StatCard label="总情侣数" value={today.data.total_couples} tone="blue" />
<StatCard label="所有用户已用存储" value={formatBytes(today.data.total_storage_used)} tone="amber" />
</div>
)}
</CardContent>
</Card>
<div className="dashboard-intro"><div><PageTitle>空间动态</PageTitle><p>用户、关系与生活记录,一览即知。</p></div><Button variant="outline" onClick={() => navigate("/unbind")}>查看解绑请求 <ArrowUpRight size={16}/></Button></div>
{stats.isPending ? <Loading rows={2} /> : stats.isError ? <ErrorBox error={stats.error} /> : (
@@ -68,20 +92,6 @@ export default function Dashboard() {
</div>
)}
<Card>
<CardHeader><CardTitle className="text-base">用户注册统计</CardTitle></CardHeader>
<CardContent>
{today.isPending ? <Loading rows={1} /> : today.isError ? <ErrorBox error={today.error} /> : (
<div className="grid grid-cols-2 gap-3 md:grid-cols-4">
<StatCard label="今日新注册" value={today.data.today_registers} tone="pink" />
<StatCard label="本月新注册" value={today.data.month_registers} tone="violet" />
<StatCard label="总用户数" value={today.data.total_users} tone="green" />
<StatCard label="总情侣数" value={today.data.total_couples} tone="blue" />
</div>
)}
</CardContent>
</Card>
<Card>
<CardHeader><CardTitle className="text-base">按日期查询</CardTitle></CardHeader>
<CardContent className="space-y-4">
+3 -3
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M15 18l-6-6 6-6"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M15 18l-6-6 6-6"/>
</svg>

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 201 B

+4 -4
View File
@@ -1,4 +1,4 @@
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18" stroke="#FF6B81" stroke-width="2.5" stroke-linecap="round"/>
<path d="M6 6L18 18" stroke="#FF6B81" stroke-width="2.5" stroke-linecap="round"/>
</svg>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18" stroke="#FF6B81" stroke-width="2.5" stroke-linecap="round"/>
<path d="M6 6L18 18" stroke="#FF6B81" stroke-width="2.5" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 248 B

After

Width:  |  Height:  |  Size: 252 B

+2 -2
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#999" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#999" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
</svg>

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 235 B

+2 -2
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ff4d4f">
<path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ff4d4f">
<path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>
</svg>

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 176 B

+2 -2
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#666">
<path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#666">
<path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/>
</svg>

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 245 B

+4 -4
View File
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#FFFFFF" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="6" x2="12" y2="18"/>
<line x1="6" y1="12" x2="18" y2="12"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#FFFFFF" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="6" x2="12" y2="18"/>
<line x1="6" y1="12" x2="18" y2="12"/>
</svg>

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 249 B

+1 -9
View File
@@ -12,23 +12,15 @@ Page(withDataCache(withListPagination({
myName: '我', partnerName: 'TA',
weekBoth: 0, weekMy: 0, weekPartner: 0,
todayMy: 0, todayPartner: 0,
smokingVisible: true,
loading: true
},
onLoad: function() {
this.setData(getLayout());
this.refreshSmokingVisible();
this.loadCoupleInfo();
this.loadData();
},
onShow: function() { this.refreshSmokingVisible(); this.loadCoupleInfo(); this.loadData(); },
// 读取本地设置:抽烟打卡默认事件是否显示(默认显示)
refreshSmokingVisible: function() {
var v = wx.getStorageSync('smokingVisible');
this.setData({ smokingVisible: (v === '' || v == null) ? true : !!v });
},
onShow: function() { this.loadCoupleInfo(); this.loadData(); },
onSmokingUpdated: function() { this.loadData(); },
+1 -1
View File
@@ -25,7 +25,7 @@
</view>
</view>
<smoking-card id="smoking" wx:if="{{smokingVisible}}" bind:updated="onSmokingUpdated" />
<smoking-card id="smoking" bind:updated="onSmokingUpdated" />
<!-- 打卡列表 -->
<view class="checkin-cards" wx:if="{{!loading && !loadError && checkins.length > 0}}">
+1 -18
View File
@@ -26,9 +26,6 @@ Page({
subscribeItems: [],
subscribeLoading: false,
// 打卡:抽烟打卡默认事件是否显示
smokingVisible: true,
// 我们past
showAboutModal: false,
// 联系我们
@@ -36,15 +33,13 @@ Page({
},
onLoad: function() {
this.setData(getLayout());
this.refreshSmokingVisible();},
this.setData(getLayout());},
onPullDownRefresh: function() {
wx.stopPullDownRefresh();
},
onShow: async function() {
this.refreshSmokingVisible();
this.setData({ bindingKnown: false, bindingError:false });
try {
var info = await api.coupleInfo();
@@ -87,18 +82,6 @@ Page({
noop: function() {},
// ===== 抽烟打卡默认事件显示开关 =====
refreshSmokingVisible: function() {
var v = wx.getStorageSync('smokingVisible');
this.setData({ smokingVisible: (v === '' || v == null) ? true : !!v });
},
toggleSmoking: function(e) {
var visible = !!e.detail.value;
this.setData({ smokingVisible: visible });
wx.setStorageSync('smokingVisible', visible);
wx.showToast({ title: visible ? '已显示抽烟打卡' : '已隐藏抽烟打卡', icon: 'none' });
},
// ===== 消息通知管理(统一使用一个模板) =====
showSubscribeModal: async function() {
this.setData({ showSubscribeModal: true, subscribeLoading: true });
-9
View File
@@ -24,15 +24,6 @@
<text class="j-link">›</text>
</view>
<!-- 抽烟打卡默认事件 -->
<view class="j-profile-setting">
<view class="setting-info">
<view class="j-small-title">抽烟打卡</view>
<view class="j-caption">在打卡页显示「抽烟记录」默认事件</view>
</view>
<switch checked="{{smokingVisible}}" bindchange="toggleSmoking" color="#B74768" style="transform:scale(0.75);" />
</view>
<view class="section-heading">关系与账号</view>
<!-- 操作记录 -->
<view class="j-profile-setting" bindtap="goToHistory">
+67 -67
View File
@@ -1,68 +1,68 @@
{
"compileType": "miniprogram",
"appid": "wxdc40d0c51cf8fe1e",
"projectname": "couple-space",
"description": "情侣空间小程序",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"bundle": false,
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"compileWorklet": false,
"minifyWXML": true,
"localPlugins": false,
"disableUseStrict": false,
"useCompilerPlugins": false,
"condition": false,
"swc": false,
"disableSWC": true
},
"condition": {
"miniprogram": {
"list": []
}
},
"editorSetting": {
"tabIndent": "auto",
"tabSize": 2
},
"libVersion": "3.16.0",
"simulatorPluginLibVersion": {},
"packOptions": {
"ignore": [
{
"value": "tests",
"type": "folder"
}
],
"include": []
}
{
"compileType": "miniprogram",
"appid": "wxdc40d0c51cf8fe1e",
"projectname": "couple-space",
"description": "情侣空间小程序",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"bundle": false,
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"compileWorklet": false,
"minifyWXML": true,
"localPlugins": false,
"disableUseStrict": false,
"useCompilerPlugins": false,
"condition": false,
"swc": false,
"disableSWC": true
},
"condition": {
"miniprogram": {
"list": []
}
},
"editorSetting": {
"tabIndent": "auto",
"tabSize": 2
},
"libVersion": "3.16.0",
"simulatorPluginLibVersion": {},
"packOptions": {
"ignore": [
{
"value": "tests",
"type": "folder"
}
],
"include": []
}
}
+23 -23
View File
@@ -1,24 +1,24 @@
{
"libVersion": "3.16.0",
"projectname": "couple-space",
"condition": {},
"setting": {
"urlCheck": false,
"coverView": true,
"lazyloadPlaceholderEnable": false,
"skylineRenderEnable": false,
"preloadBackgroundData": false,
"autoAudits": false,
"useApiHook": true,
"showShadowRootInWxmlPanel": true,
"useStaticServer": false,
"useLanDebug": false,
"showES6CompileOption": false,
"compileHotReLoad": true,
"useGlassEaselForWxml": false,
"checkInvalidKey": true,
"ignoreDevUnusedFiles": true,
"bigPackageSizeSupport": false,
"useIsolateContext": true
}
{
"libVersion": "3.16.0",
"projectname": "couple-space",
"condition": {},
"setting": {
"urlCheck": false,
"coverView": true,
"lazyloadPlaceholderEnable": false,
"skylineRenderEnable": false,
"preloadBackgroundData": false,
"autoAudits": false,
"useApiHook": true,
"showShadowRootInWxmlPanel": true,
"useStaticServer": false,
"useLanDebug": false,
"showES6CompileOption": false,
"compileHotReLoad": true,
"useGlassEaselForWxml": false,
"checkInvalidKey": true,
"ignoreDevUnusedFiles": true,
"bigPackageSizeSupport": false,
"useIsolateContext": true
}
}