feat: 新增举报详情功能及相关接口、页面

新增举报详情页面路由与配置
新增举报详情接口及路由规则
新增举报列表状态筛选功能
新增错误信息标准化处理方法
优化举报列表页面UI交互
完善微信登录异常提示处理
这个提交包含在:
2026-11-19 09:16:58 +08:00
父节点 7e22a66de0
当前提交 134267fcd9
共有 31 个文件被更改,包括 2849 次插入 和 572 次删除

查看文件

@@ -68,6 +68,8 @@ export const postApi = {
comment: (id, payload) => post(`/post/${id}/comment`, payload, { silent: true }),
/** 发布者回复评价 */
replyComment: (commentId, payload) => post(`/post/comment/${commentId}/reply`, payload, { silent: true }),
/** 删除自己的评价 */
deleteComment: (commentId) => post(`/post/comment/${commentId}/delete`, {}, { silent: true }),
/** 评价列表(详情页「用户评价」,替代前端写死的假评价) */
comments: (id) => get(`/post/${id}/comments`, {}, { silent: true }),
}

查看文件

@@ -1,8 +1,9 @@
/**
* 接口模块 · 举报(用户端)
* 对应接口契约:
* - POST /report 提交举报 {targetType:'post'|'comment', targetId, reason, detail?, images?} → {reportId}
* - GET /report/my 查询我的举报记录 {page, size} → 分页列表
* - POST /report 提交举报 {targetType:'post'|'comment', targetId, reason, detail?, images?} → {reportId}
* - GET /report/my 查询我的举报记录 {page, size} → 分页列表
* - GET /report/:id 查询单条举报记录详情 → 举报详情对象
*/
import { post, get } from '../utils/request.js'
import { REPORT_REASONS } from '../constants/report.js'
@@ -29,6 +30,13 @@ export const reportApi = {
*/
my: (params = {}) => get('/report/my', params, { silent: true }),
/**
* 查询单条举报记录详情
* @param {number|string} id 举报记录 ID
* @returns {Promise<Object>}
*/
detail: (id) => get(`/report/${id}`, {}, { silent: true }),
/** 举报原因默认清单 */
reasons: REPORT_REASONS,
}

查看文件

@@ -141,7 +141,8 @@ export function request(options = {}) {
if (body.code === 0 || body.code === 200) {
resolve(body.data !== undefined ? body.data : body)
} else {
const err = toErr(body.message || body.msg || '请求失败', body.code)
const msg = normalizeErrorMessage(body.message || body.msg, '请求失败,请稍后重试')
const err = toErr(msg, body.code)
if (!silent) runtime.showToast({ title: err.message, icon: 'none' })
reject(err)
}
@@ -153,6 +154,38 @@ export function request(options = {}) {
})
}
/**
* 将底层英文网络或系统错误消息转换为用户可理解的中文提示
* @param {string} raw 原始错误消息
* @param {string} fallback 默认中文兜底文案
* @returns {string} 中文错误提示
*/
function normalizeErrorMessage(raw, fallback = '网络请求失败,请稍后重试') {
const text = typeof raw === 'string' ? raw.trim() : ''
if (!text) return fallback
const lower = text.toLowerCase()
if (lower.includes('timeout') || lower.includes('timed out')) {
return '网络请求超时,请稍后重试'
}
if (lower.includes('domain list')) {
return '服务域名配置异常,请联系管理员'
}
if (lower.includes('ssl') || lower.includes('certificate')) {
return '安全连接异常,请稍后重试'
}
if (lower.startsWith('request:fail') || lower.includes('network error') || lower.includes('failed to fetch')) {
return '网络连接失败,请检查网络后重试'
}
// 若包含中文且不含常见底层技术报错特征,直接展示
if (/[\u4e00-\u9fa5]/.test(text) && !/sqlstate|curl error|exception/i.test(text)) {
return text
}
return fallback
}
/**
* 失败处理:抛出异常(必要时弹 toast 提示)
* @param {Object} err 错误对象
@@ -160,7 +193,8 @@ export function request(options = {}) {
*/
function handleFail(err, ctx) {
const { silent, runtime, reject } = ctx
const e = toErr(err && (err.errMsg || err.message) ? err.errMsg || err.message : '网络请求失败')
const rawMsg = err && (err.errMsg || err.message) ? err.errMsg || err.message : ''
const e = toErr(normalizeErrorMessage(rawMsg, '网络请求失败,请检查网络后重试'))
if (!silent) runtime.showToast({ title: e.message, icon: 'none' })
reject(e)
}