feat: 新增举报详情功能及相关接口、页面
新增举报详情页面路由与配置 新增举报详情接口及路由规则 新增举报列表状态筛选功能 新增错误信息标准化处理方法 优化举报列表页面UI交互 完善微信登录异常提示处理
这个提交包含在:
@@ -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)
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户