fix: 注册 user-rules 和 shensheshou 路由,修复规则配置保存失败

- 将 /api/db/user-rules 的 GET/POST/PUT/DELETE 路由注册到 db 组
- 将 /api/admin/shensheshou/* 的 4 个路由注册到 admin 组
- 包含上次对话的头像 URL 修复(normalizeImageUrl 全栈)

Made-with: Cursor
This commit is contained in:
卡若
2026-03-15 19:31:07 +08:00
parent 708547d0dd
commit 64db4927ea
116 changed files with 1969 additions and 435 deletions

View File

@@ -6,6 +6,7 @@
const app = getApp()
const { trackClick } = require('../../utils/trackClick')
const { checkAndExecute } = require('../../utils/ruleEngine')
// 默认匹配类型配置
// 找伙伴:真正的匹配功能,匹配数据库中的真实用户
@@ -512,6 +513,17 @@ Page({
}
}
})
// 记录匹配行为到 user_tracks
const uid = app.globalData.userInfo?.id
if (uid) {
app.request('/api/miniprogram/track', {
method: 'POST',
data: { userId: uid, action: 'match', target: matchedUser?.id || '', extraData: { matchType: this.data.selectedType } },
silent: true
}).catch(() => {})
}
// 匹配后规则:引导填写 MBTI/行业信息
checkAndExecute('after_match', this)
} catch (e) {
console.log('上报匹配失败:', e)
}

View File

@@ -1,6 +1,7 @@
import accessManager from '../../utils/chapterAccessManager'
const app = getApp()
const { trackClick } = require('../../utils/trackClick')
const { checkAndExecute } = require('../../utils/ruleEngine')
Page({
data: {
@@ -128,6 +129,17 @@ Page({
if (typeof p.initUserStatus === 'function') p.initUserStatus()
else if (typeof p.updateUserStatus === 'function') p.updateUserStatus()
})
// 记录购买行为到 user_tracks
const uid = app.globalData.userInfo?.id
if (uid) {
app.request('/api/miniprogram/track', {
method: 'POST',
data: { userId: uid, action: 'purchase', target: 'vip_annual', extraData: { amount: this.data.price } },
silent: true
}).catch(() => {})
}
// 购买后规则:引导填写完整信息
checkAndExecute('after_pay', this)
} catch (e) {
console.error('[VIP] 支付后同步失败:', e)
}

View File

@@ -151,6 +151,15 @@ const hideLoading = () => {
wx.hideLoading()
}
// 修复图片 URL 中 protocol 缺少冒号的问题(如 "https//..." → "https://..."
const normalizeImageUrl = (url) => {
if (!url || typeof url !== 'string') return ''
let s = url.trim()
if (!s) return ''
s = s.replace(/^(https?)\/\//, '$1://')
return s
}
// 显示确认框
const showConfirm = (title, content) => {
return new Promise((resolve) => {
@@ -174,6 +183,7 @@ module.exports = {
isValidWechat,
deepClone,
getQueryParams,
normalizeImageUrl,
storage,
showToast,
showLoading,