chore(log): 清理联调排障日志,生产静默化 http 响应打印

- http/client.ts 响应日志仅在 development 打印,移除 Message/token
  两条 console.log
- 登录流程(wxLoginFlow/登录页)移除全部 [login] 调试日志
- 设备图标未匹配的 [ICON] 核对日志已确认完毕,移除
- 家庭圈添加关爱对象卡达上限改整卡隐藏,上限信息由"关爱对象 n/N"
  标题计数表达,删除灰化态样式
This commit is contained in:
ozh 2026-09-28 16:18:45 +08:00
parent 82aa7d6925
commit da86294fde
6 changed files with 44 additions and 51 deletions

View File

@ -94,7 +94,10 @@ export async function request<T>(
throw new ApiError(raw || '网络异常') throw new ApiError(raw || '网络异常')
} }
console.log(`[http] ${method} ${url} ←`, res.statusCode, res.data) // 开发期联调日志:dev 才打印响应体,生产静默(网络失败/踢登录仍走 console.error 保留)
if (process.env.NODE_ENV === 'development') {
console.log(`[http] ${method} ${url} ←`, res.statusCode, res.data)
}
if (res.statusCode !== 200) { if (res.statusCode !== 200) {
if (res.statusCode === 401) { if (res.statusCode === 401) {
@ -121,13 +124,11 @@ export async function request<T>(
// 200 成功内的子状态(Message 携带,如 needUserInfo/noMobile),附到返回值供调用方分支处理 // 200 成功内的子状态(Message 携带,如 needUserInfo/noMobile),附到返回值供调用方分支处理
const subState = body.Message const subState = body.Message
if (subState && subState !== '') { if (subState && subState !== '') {
console.log(`[http] ${url} 响应 Message=${subState}`, body.Content)
;(body.Content as Record<string, unknown>).message = subState ;(body.Content as Record<string, unknown>).message = subState
} }
// 后端把登录 token 放响应头 Token(仅登录接口返回;Content.code 恒为 null)——附到返回值供登录流程落地 // 后端把登录 token 放响应头 Token(仅登录接口返回;Content.code 恒为 null)——附到返回值供登录流程落地
const resToken = pickResponseToken(res.header) const resToken = pickResponseToken(res.header)
if (resToken) { if (resToken) {
console.log(`[http] ${url} 响应头携带 token`)
;(body.Content as Record<string, unknown>).token = resToken ;(body.Content as Record<string, unknown>).token = resToken
} }
return body.Content return body.Content

View File

@ -27,13 +27,6 @@ const pickDeviceIcon = (device: HomeDevice): string | null => {
if (model === 'EB15') return eb15Icon if (model === 'EB15') return eb15Icon
if (model === 'ED713') return ed713Icon if (model === 'ED713') return ed713Icon
if (model === 'ED719') return ed719Icon if (model === 'ED719') return ed719Icon
// 调试:未匹配时打印设备型号字段,方便核对后端实际值(确认后移除)
console.log('[ICON] no match', {
installId: device.installId,
deviceModel: device.deviceModel,
subDeviceType: device.subDeviceType,
name: device.name
})
return null return null
} }

View File

@ -15,7 +15,7 @@
padding: 24px; padding: 24px;
} }
// 添加关爱对象虚线卡:与列表页底部加号卡同款式 // 添加关爱对象虚线卡:与列表页底部加号卡同款式(达上限时整卡隐藏,不渲染灰化态)
.addCared { .addCared {
margin-top: 0; margin-top: 0;
padding: 48px 32px; padding: 48px 32px;
@ -27,11 +27,6 @@
align-items: center; align-items: center;
} }
// 达上限态:灰化降级,明确"不可点"
.addCaredDisabled {
border-color: $color-border;
}
.addCaredIcon { .addCaredIcon {
width: 96px; width: 96px;
height: 96px; height: 96px;
@ -43,29 +38,17 @@
margin-bottom: 16px; margin-bottom: 16px;
} }
.addCaredIconDisabled {
background: $color-bg-disabled;
}
.addCaredIconText { .addCaredIconText {
font-size: 48px; font-size: 48px;
font-weight: 300; font-weight: 300;
color: #ffffff; color: #ffffff;
} }
.addCaredIconTextDisabled {
color: $color-text-tertiary;
}
.addCaredText { .addCaredText {
font-size: 26px; font-size: 26px;
color: $color-text-secondary; color: $color-text-secondary;
} }
.addCaredTextDisabled {
color: $color-text-tertiary;
}
.addCaredPressed { .addCaredPressed {
opacity: 0.85; opacity: 0.85;
} }
@ -118,6 +101,27 @@
margin: 8px 8px 16px; margin: 8px 8px 16px;
} }
// 标题行:左标题 + n/N 计数(满员时由计数表达上限,替代灰化占位卡)
.sectionTitleRow {
display: flex;
align-items: center;
margin: 8px 8px 16px;
}
.sectionTitleRow .sectionTitle {
margin: 0;
}
.sectionCount {
margin-left: 12px;
padding: 2px 16px;
background: $color-primary-light-bg;
border-radius: $radius-pill;
font-size: 22px;
font-weight: 500;
color: $color-primary-deep;
}
.sectionEmpty { .sectionEmpty {
display: block; display: block;
padding: 32px 8px; padding: 32px 8px;

View File

@ -224,26 +224,27 @@ export default function FamilyDetail() {
<View className={styles.body}> <View className={styles.body}>
<FamilyCard family={family} /> <FamilyCard family={family} />
{/* 添加关爱对象卡:达上限后灰化静态 */} {/* 添加关爱对象卡:达上限后整卡隐藏(占位无意义),上限信息改由标题计数表达 */}
<View {canAdd && (
className={`${styles.addCared} ${canAdd ? '' : styles.addCaredDisabled}`} <View
hoverClass={canAdd ? styles.addCaredPressed : 'none'} className={styles.addCared}
onClick={canAdd ? addCared : undefined} hoverClass={styles.addCaredPressed}
> onClick={addCared}
<View className={`${styles.addCaredIcon} ${canAdd ? '' : styles.addCaredIconDisabled}`}> >
<Text <View className={styles.addCaredIcon}>
className={`${styles.addCaredIconText} ${canAdd ? '' : styles.addCaredIconTextDisabled}`} <Text className={styles.addCaredIconText}>+</Text>
> </View>
+ <Text className={styles.addCaredText}>+ 最多可添加 {MAX_CARED_PER_FAMILY} 人</Text>
</Text>
</View> </View>
<Text className={`${styles.addCaredText} ${canAdd ? '' : styles.addCaredTextDisabled}`}> )}
{canAdd ? `+ 最多可添加 ${MAX_CARED_PER_FAMILY} 人` : '已达上限'}
</Text>
</View>
<View className={styles.section}> <View className={styles.section}>
<Text className={styles.sectionTitle}>关爱对象</Text> <View className={styles.sectionTitleRow}>
<Text className={styles.sectionTitle}>关爱对象</Text>
<Text className={styles.sectionCount}>
{caredCount}/{MAX_CARED_PER_FAMILY}
</Text>
</View>
{caredCount === 0 ? ( {caredCount === 0 ? (
<Text className={styles.sectionEmpty}>暂无关爱对象,点击上方卡片添加</Text> <Text className={styles.sectionEmpty}>暂无关爱对象,点击上方卡片添加</Text>
) : ( ) : (

View File

@ -51,7 +51,6 @@ export default function Login() {
const applyResult = async (result: Awaited<ReturnType<typeof performWxLogin>>) => { const applyResult = async (result: Awaited<ReturnType<typeof performWxLogin>>) => {
const state = getLoginSubState(result) const state = getLoginSubState(result)
if (state !== 'complete') { if (state !== 'complete') {
console.log('[login-page] 注册未完成,推进到', state)
if (state === 'noMobile') { if (state === 'noMobile') {
// 手机号授权暂缓(后端字段未定):提示并保持当前态,等后端确认后接续 // 手机号授权暂缓(后端字段未定):提示并保持当前态,等后端确认后接续
throw new Error('后端要求绑定手机号,该流程暂未开通') throw new Error('后端要求绑定手机号,该流程暂未开通')
@ -68,7 +67,6 @@ export default function Login() {
// token 优先取响应头落地(http 层附到 token 字段);Content.code 后端恒返 null 仅作兼容 // token 优先取响应头落地(http 层附到 token 字段);Content.code 后端恒返 null 仅作兼容
const token = result.token ?? result.code const token = result.token ?? result.code
if (!token || !result.userInfo) throw new Error('登录响应缺少凭证') if (!token || !result.userInfo) throw new Error('登录响应缺少凭证')
console.log('[login-page] 登录完成,token 已落地')
setNeedAuth(false) setNeedAuth(false)
dispatch(setAuth({ token, userInfo: result.userInfo })) dispatch(setAuth({ token, userInfo: result.userInfo }))
await reLaunch(afterLoginUrl()) await reLaunch(afterLoginUrl())

View File

@ -35,10 +35,8 @@ export async function performWxLogin(): Promise<WxMiniappLoginResponse> {
} }
if (!code) throw new Error('获取微信登录凭证失败') if (!code) throw new Error('获取微信登录凭证失败')
const openId = storage.get<string>(WX_OPENID_STORAGE_KEY) ?? undefined const openId = storage.get<string>(WX_OPENID_STORAGE_KEY) ?? undefined
console.log('[login] performWxLogin 请求', { appId: resolveAppId(), code, openId })
const result = await wxMiniappLogin({ appId: resolveAppId(), code, openId }) const result = await wxMiniappLogin({ appId: resolveAppId(), code, openId })
if (result.openId) storage.set(WX_OPENID_STORAGE_KEY, result.openId) if (result.openId) storage.set(WX_OPENID_STORAGE_KEY, result.openId)
console.log('[login] performWxLogin 结果', getLoginSubState(result), result)
return result return result
} }
@ -55,10 +53,8 @@ async function reloginWith(
throw new Error('获取微信登录凭证失败,请重试') throw new Error('获取微信登录凭证失败,请重试')
} }
const params = { appId: resolveAppId(), code, openId, ...extra } const params = { appId: resolveAppId(), code, openId, ...extra }
console.log('[login] 重调登录接口', params)
const result = await wxMiniappLogin(params) const result = await wxMiniappLogin(params)
if (result.openId) storage.set(WX_OPENID_STORAGE_KEY, result.openId) if (result.openId) storage.set(WX_OPENID_STORAGE_KEY, result.openId)
console.log('[login] 重调结果', getLoginSubState(result), result)
return result return result
} }