diff --git a/_doc/前端红点功能接口文档.md b/_doc/前端红点功能接口文档.md index 5250c2b..4268c79 100644 --- a/_doc/前端红点功能接口文档.md +++ b/_doc/前端红点功能接口文档.md @@ -473,7 +473,7 @@ async function safeMarkAsRead(type, ids) { }) } catch (err) { // 标记已读失败不影响用户体验,静默处理 - console.error('标记已读失败:', err) + console.warn('标记已读失败:', err) } } ``` diff --git a/analyze.js b/analyze.js index 3b3453e..d08ba84 100644 --- a/analyze.js +++ b/analyze.js @@ -28,7 +28,7 @@ function formatSize(bytes) { function analyze() { if (!fs.existsSync(DIST_DIR)) { - console.error('dist 目录不存在,请先执行 taro build --type weapp'); + console.warn('dist 目录不存在,请先执行 taro build --type weapp'); return; } diff --git a/scripts/sync-project-config.js b/scripts/sync-project-config.js index 2156f6e..35775b3 100644 --- a/scripts/sync-project-config.js +++ b/scripts/sync-project-config.js @@ -11,7 +11,7 @@ const { envConfigs } = require(envConfigPath); const config = envConfigs[appEnv]; if (!config) { - console.error(`[sync-project-config] Unknown APP_ENV: ${appEnv}`); + console.warn(`[sync-project-config] Unknown APP_ENV: ${appEnv}`); process.exit(1); } diff --git a/src/components/Comments/index.tsx b/src/components/Comments/index.tsx index b470461..21fb5b2 100644 --- a/src/components/Comments/index.tsx +++ b/src/components/Comments/index.tsx @@ -342,7 +342,7 @@ export default forwardRef(function Comments( try { await messageService.markAsRead("comment", [message_id]); } catch (e) { - console.error("标记评论已读失败:", e); + console.warn("标记评论已读失败:", e); } } diff --git a/src/components/DistanceQuickFilterV2/index.tsx b/src/components/DistanceQuickFilterV2/index.tsx index c6aa7a0..0674024 100644 --- a/src/components/DistanceQuickFilterV2/index.tsx +++ b/src/components/DistanceQuickFilterV2/index.tsx @@ -134,7 +134,7 @@ const DistanceQuickFilterV2 = (props) => { throw new Error('获取位置信息失败'); } } catch (error: any) { - console.error('重新定位失败:', error); + console.warn('重新定位失败:', error); (Taro as any).showToast({ title: error?.message || '定位失败,请检查定位权限', icon: 'none', diff --git a/src/components/FollowUserCard/index.tsx b/src/components/FollowUserCard/index.tsx index 864eb00..ba08ebb 100644 --- a/src/components/FollowUserCard/index.tsx +++ b/src/components/FollowUserCard/index.tsx @@ -42,7 +42,7 @@ const FollowUserCard: React.FC = ({ user, tabKey, onFollowC onFollowChange?.(user.id, new_status); } catch (error) { - console.error('关注操作失败:', error); + console.warn('关注操作失败:', error); Taro.showToast({ title: '操作失败', icon: 'none' @@ -67,7 +67,7 @@ const FollowUserCard: React.FC = ({ user, tabKey, onFollowC onBlockSuccess?.(user.id); } } catch (error) { - console.error('删除推荐人员失败:', error); + console.warn('删除推荐人员失败:', error); Taro.showToast({ title: '操作失败', icon: 'none' diff --git a/src/components/HomeNavbar/index.tsx b/src/components/HomeNavbar/index.tsx index 361369b..ce5ce98 100644 --- a/src/components/HomeNavbar/index.tsx +++ b/src/components/HomeNavbar/index.tsx @@ -146,7 +146,7 @@ const HomeNavbar = (props: IProps) => { console.log(`[HomeNavbar] 距离上次选择"继续浏览"还不到2小时,剩余时间: ${Math.ceil((TWO_HOURS_MS - time_diff) / 1000 / 60)}分钟`); return false; } catch (error) { - console.error('[HomeNavbar] 检查定位弹窗显示条件失败:', error); + console.warn('[HomeNavbar] 检查定位弹窗显示条件失败:', error); return true; // 出错时默认显示 } }; @@ -239,7 +239,7 @@ const HomeNavbar = (props: IProps) => { // console.log(`距离上次选择"继续浏览"还不到2小时,剩余时间: ${Math.ceil((TWO_HOURS_MS - time_diff) / 1000 / 60)}分钟`); // return false; // } catch (error) { - // console.error('检查定位弹窗显示条件失败:', error); + // console.warn('检查定位弹窗显示条件失败:', error); // return true; // 出错时默认显示 // } // }; @@ -276,7 +276,7 @@ const HomeNavbar = (props: IProps) => { (Taro as any).setStorageSync(CITY_CHANGE_TIME_KEY, current_time); console.log(`[LocationDialog] 已记录用户切换城市的时间,2小时内不再提示`); } catch (error) { - console.error('保存城市切换时间失败:', error); + console.warn('保存城市切换时间失败:', error); } console.log("切换到用户详情中的位置信息并更新缓存:", detectedProvince); @@ -304,7 +304,7 @@ const HomeNavbar = (props: IProps) => { (Taro as any).setStorageSync(LOCATION_DIALOG_DISMISS_TIME_KEY, current_time); console.log(`[LocationDialog] 已记录用户选择"继续浏览"的时间,2小时内不再提示`); } catch (error) { - console.error('保存定位弹窗关闭时间失败:', error); + console.warn('保存定位弹窗关闭时间失败:', error); } // 关闭弹窗 @@ -409,7 +409,7 @@ const HomeNavbar = (props: IProps) => { (Taro as any).setStorageSync(CITY_CHANGE_TIME_KEY, current_time); console.log("已保存城市到缓存并记录切换时间:", _newArea, current_time); } catch (error) { - console.error("保存城市缓存失败:", error); + console.warn("保存城市缓存失败:", error); } // 先调用列表接口(会使用更新后的 state.area) diff --git a/src/components/ImageUpload/ImageUpload.tsx b/src/components/ImageUpload/ImageUpload.tsx index 88f6f06..553534e 100644 --- a/src/components/ImageUpload/ImageUpload.tsx +++ b/src/components/ImageUpload/ImageUpload.tsx @@ -43,7 +43,7 @@ const ImageUpload: React.FC = ({ onChange([...images, ...newImages]) }, fail: (err) => { - console.error('选择图片失败:', err) + console.warn('选择图片失败:', err) } }) }, [images.length, maxCount, onChange]) diff --git a/src/components/Radar/indexV2.tsx b/src/components/Radar/indexV2.tsx index 62d5e25..e734c5f 100644 --- a/src/components/Radar/indexV2.tsx +++ b/src/components/Radar/indexV2.tsx @@ -256,7 +256,7 @@ const RadarChartV2 = forwardRef( const bgImg = await loadImage(canvas, shareBgUrl); ctx.drawImage(bgImg, 0, 0, width, height); } catch (error) { - console.error("Failed to load background image:", error); + console.warn("Failed to load background image:", error); // 如果加载失败,使用白色背景作为兜底 ctx.fillStyle = "#FFFFFF"; ctx.fillRect(0, 0, width, height); @@ -392,12 +392,12 @@ const RadarChartV2 = forwardRef( ); ctx.restore(); } catch (error) { - console.error("Failed to load docCopy image:", error); + console.warn("Failed to load docCopy image:", error); } currentY += (48 + 20) * scale; // 头像区域高度 + gap } catch (error) { - console.error("Failed to load avatar image:", error); + console.warn("Failed to load avatar image:", error); } } @@ -523,7 +523,7 @@ const RadarChartV2 = forwardRef( iconSize, ); } catch (error) { - console.error("Failed to load icon:", error); + console.warn("Failed to load icon:", error); } // 绘制底部文字 @@ -601,7 +601,7 @@ const RadarChartV2 = forwardRef( // 恢复上下文状态 ctx.restore(); } catch (error) { - console.error("Failed to load QR code:", error); + console.warn("Failed to load QR code:", error); } } diff --git a/src/components/ShareCardCanvas/index.tsx b/src/components/ShareCardCanvas/index.tsx index e1c48fc..17343ed 100644 --- a/src/components/ShareCardCanvas/index.tsx +++ b/src/components/ShareCardCanvas/index.tsx @@ -575,7 +575,7 @@ const ShareCardCanvas: React.FC = ({ setTempImagePath(res.tempFilePath) }, fail: (error: any) => { - console.error('图片生成失败:', error) + console.warn('图片生成失败:', error) setIsDrawing(false) reject(error) } @@ -595,7 +595,7 @@ const ShareCardCanvas: React.FC = ({ console.log('Canvas绘制命令已发送') } catch (error) { - console.error('绘制分享卡片失败:', error) + console.warn('绘制分享卡片失败:', error) setIsDrawing(false) // 绘制失败,重置状态 Taro.showToast({ title: '生成分享卡片失败', diff --git a/src/components/SubscribeNotificationTip/index.tsx b/src/components/SubscribeNotificationTip/index.tsx index 22ec442..8fb1bd6 100644 --- a/src/components/SubscribeNotificationTip/index.tsx +++ b/src/components/SubscribeNotificationTip/index.tsx @@ -16,7 +16,7 @@ const SubscribeNotificationTip: React.FC = ({ navigateTo({ url: '/other_pages/enable_notification/index', }).catch((err) => { - console.error('跳转失败:', err); + console.warn('跳转失败:', err); }); }; diff --git a/src/components/UploadCover/upload-from-wx.tsx b/src/components/UploadCover/upload-from-wx.tsx index 24e849d..d643b2f 100644 --- a/src/components/UploadCover/upload-from-wx.tsx +++ b/src/components/UploadCover/upload-from-wx.tsx @@ -86,9 +86,9 @@ async function onChooseImageSuccess(tempFiles) { ...fileRes, ...(height > IMAGE_MAX_SIZE.height ? { - width: Math.floor(IMAGE_MAX_SIZE.height * image_aspect_ratio), - height: IMAGE_MAX_SIZE.height, - } + width: Math.floor(IMAGE_MAX_SIZE.height * image_aspect_ratio), + height: IMAGE_MAX_SIZE.height, + } : { width: Math.floor(height * image_aspect_ratio), height }), }; } else { @@ -96,9 +96,9 @@ async function onChooseImageSuccess(tempFiles) { ...fileRes, ...(width > IMAGE_MAX_SIZE.width ? { - width: IMAGE_MAX_SIZE.width, - height: Math.floor(IMAGE_MAX_SIZE.width / image_aspect_ratio), - } + width: IMAGE_MAX_SIZE.width, + height: Math.floor(IMAGE_MAX_SIZE.width / image_aspect_ratio), + } : { width, height: Math.floor(width / image_aspect_ratio) }), }; } @@ -119,7 +119,6 @@ export default function UploadFromWx(props: UploadFromWxProps) { sourceType: ["album", "camera"], }).then(async (res) => { const analyzedFiles = await onChooseImageSuccess(res.tempFiles); - // cropping image to standard size const compressedTempFiles = await compressImage(analyzedFiles); let start = Date.now(); @@ -130,19 +129,22 @@ export default function UploadFromWx(props: UploadFromWxProps) { is_public: 1 as unknown as 0 | 1, id: (start++).toString(), })); - const onFileUpdate = uploadApi.batchUpload(files).then((res) => { - return res.map((item) => ({ - id: item.id, - url: item ? item.data.file_url : "", - })); - }); - onAdd( - files.map((item) => ({ - id: item.id, - url: item.filePath, - })), - onFileUpdate - ); + + Taro.showLoading({ title: "上传中..." }); + try { + const uploadRes = await uploadApi.batchUpload(files); + const successful = uploadRes + .filter((item) => item.data != null) + .map((item) => ({ + id: item.id, + url: (item.data as { file_url: string }).file_url, + })); + onAdd(successful, Promise.resolve(successful)); + } catch (e) { + console.warn("批量上传失败:", e); + } finally { + Taro.hideLoading(); + } }); }; return ( diff --git a/src/components/UserInfo/index.tsx b/src/components/UserInfo/index.tsx index 0873a2c..e23774d 100644 --- a/src/components/UserInfo/index.tsx +++ b/src/components/UserInfo/index.tsx @@ -250,7 +250,7 @@ const UserInfoCardComponent: React.FC = ({ icon: "success", }); } catch (error) { - console.error("保存失败:", error); + console.warn("保存失败:", error); Taro.showToast({ title: "保存失败", icon: "error", @@ -293,7 +293,7 @@ const UserInfoCardComponent: React.FC = ({ icon: "success", }); } catch (error) { - console.error("保存失败:", error); + console.warn("保存失败:", error); Taro.showToast({ title: "保存失败", icon: "error", diff --git a/src/game_pages/detail/index.tsx b/src/game_pages/detail/index.tsx index 3644cfe..a6cc222 100644 --- a/src/game_pages/detail/index.tsx +++ b/src/game_pages/detail/index.tsx @@ -86,7 +86,7 @@ function Index() { // handleShare(true); // } } catch (error) { - console.error("用户位置更新失败", error); + console.warn("用户位置更新失败", error); } }; diff --git a/src/home_pages/index.tsx b/src/home_pages/index.tsx index 7af912a..83bde4b 100644 --- a/src/home_pages/index.tsx +++ b/src/home_pages/index.tsx @@ -17,14 +17,14 @@ const HomePage: React.FC = () => { if (loginResult.success) { // 静默登录成功,获取用户信息 fetchUserInfo().catch((error) => { - console.error("获取用户信息失败:", error); + console.warn("获取用户信息失败:", error); }); checkNicknameChangeStatus().catch((error) => { - console.error("检查昵称变更状态失败:", error); + console.warn("检查昵称变更状态失败:", error); }); } } catch (error) { - console.error("静默登录失败:", error); + console.warn("静默登录失败:", error); // 静默登录失败不影响使用 } diff --git a/src/login_pages/verification/index.tsx b/src/login_pages/verification/index.tsx index 3ba0ab0..6269b79 100644 --- a/src/login_pages/verification/index.tsx +++ b/src/login_pages/verification/index.tsx @@ -139,7 +139,7 @@ const VerificationPage: React.FC = () => { }); } } catch (error) { - console.error("发送验证码异常:", error); + console.warn("发送验证码异常:", error); Taro.showToast({ title: "发送失败,请重试", icon: "none", diff --git a/src/main_pages/components/ListPageContent.tsx b/src/main_pages/components/ListPageContent.tsx index 590914e..2ff5572 100644 --- a/src/main_pages/components/ListPageContent.tsx +++ b/src/main_pages/components/ListPageContent.tsx @@ -235,7 +235,7 @@ const ListPageContent: React.FC = ({ if (isActive) { getLocation().catch((error) => { - console.error('获取位置信息失败:', error); + console.warn('获取位置信息失败:', error); }); } }, [isActive, showHomeQrcode]); @@ -309,7 +309,7 @@ const ListPageContent: React.FC = ({ lastLoadedAreaRef.current = [...currentArea] as [string, string]; } } catch (error) { - console.error("重新加载数据失败:", error); + console.warn("重新加载数据失败:", error); } }, delayMs); prevIsActiveRef.current = isActive; @@ -375,7 +375,7 @@ const ListPageContent: React.FC = ({ await updateUserLocation(location.latitude, location.longitude, isFirstCall); hasUpdatedLocationRef.current = true; } catch (error) { - console.error("更新用户位置失败:", error); + console.warn("更新用户位置失败:", error); } } // 先调用列表接口 @@ -462,7 +462,7 @@ const ListPageContent: React.FC = ({ await getMatchesData(); await fetchGetGamesCount(); } catch (error) { - console.error("刷新列表失败:", error); + console.warn("刷新列表失败:", error); } }; @@ -477,7 +477,7 @@ const ListPageContent: React.FC = ({ const { fetchDictionary } = useDictionaryStore.getState(); await fetchDictionary(); } catch (error) { - console.error("初始化字典数据失败:", error); + console.warn("初始化字典数据失败:", error); } }; @@ -616,7 +616,7 @@ const ListPageContent: React.FC = ({ try { await loadMoreMatches(); } catch (error) { - console.error("加载更多失败:", error); + console.warn("加载更多失败:", error); } finally { loadingMoreRef.current = false; } diff --git a/src/main_pages/components/MyselfPageContent.tsx b/src/main_pages/components/MyselfPageContent.tsx index 019344c..a92e38d 100644 --- a/src/main_pages/components/MyselfPageContent.tsx +++ b/src/main_pages/components/MyselfPageContent.tsx @@ -117,7 +117,7 @@ const MyselfPageContent: React.FC = ({ set_game_records(notEndGames); setEndedGameRecords(finishedGames); } catch (error) { - console.error("加载球局数据失败:", error); + console.warn("加载球局数据失败:", error); } }, [active_tab, user_info, classifyGameRecords]); @@ -150,7 +150,7 @@ const MyselfPageContent: React.FC = ({ duration: 1500, }); } catch (error) { - console.error("关注操作失败:", error); + console.warn("关注操作失败:", error); (Taro as any).showToast({ title: "操作失败,请重试", icon: "error", @@ -198,7 +198,7 @@ const MyselfPageContent: React.FC = ({ try { await Promise.all([fetchUserInfo(), load_game_data()]); } catch (error) { - console.error("刷新失败:", error); + console.warn("刷新失败:", error); (Taro as any).showToast({ title: "刷新失败,请重试", icon: "none", diff --git a/src/main_pages/index.tsx b/src/main_pages/index.tsx index 604db95..b0a9ba3 100644 --- a/src/main_pages/index.tsx +++ b/src/main_pages/index.tsx @@ -68,7 +68,7 @@ const MainPage: React.FC = () => { return; } } catch (error) { - console.error("微信授权异常:", error); + console.warn("微信授权异常:", error); setAuthErrorMessage("微信授权失败,请重试"); setShowAuthError(true); return; @@ -81,7 +81,7 @@ const MainPage: React.FC = () => { await fetchUserInfo(); await checkNicknameChangeStatus(); } catch (error) { - console.error("获取用户信息失败:", error); + console.warn("获取用户信息失败:", error); } } }; diff --git a/src/other_pages/comment_reply/index.tsx b/src/other_pages/comment_reply/index.tsx index ef889cd..5bbeae4 100644 --- a/src/other_pages/comment_reply/index.tsx +++ b/src/other_pages/comment_reply/index.tsx @@ -77,7 +77,7 @@ const CommentReply = () => { if (allCommentIds.length > 0) { // 使用统一接口标记已读,传入所有评论ID messageService.markAsRead('comment', allCommentIds).catch(e => { - console.error("标记评论已读失败:", e); + console.warn("标记评论已读失败:", e); }); } } @@ -221,7 +221,7 @@ const CommentReply = () => { if (allCommentIds.length > 0) { messageService.markAsRead('comment', allCommentIds).catch(e => { - console.error("标记评论已读失败:", e); + console.warn("标记评论已读失败:", e); }); } } diff --git a/src/other_pages/enable_notification/index.tsx b/src/other_pages/enable_notification/index.tsx index 4049ad3..3bf7477 100644 --- a/src/other_pages/enable_notification/index.tsx +++ b/src/other_pages/enable_notification/index.tsx @@ -21,7 +21,7 @@ const EnableNotificationPage: React.FC = () => { setQrCodeUrl(res.data.ServiceAccountQRCode); } } catch (error) { - console.error('获取二维码失败:', error); + console.warn('获取二维码失败:', error); } }; fetchQRCode(); diff --git a/src/other_pages/new_follow/index.tsx b/src/other_pages/new_follow/index.tsx index c1932f9..c1ea6a3 100644 --- a/src/other_pages/new_follow/index.tsx +++ b/src/other_pages/new_follow/index.tsx @@ -62,7 +62,7 @@ const NewFollow = () => { if (allFanIds.length > 0) { // 使用统一接口标记已读,传入所有关注者ID messageService.markAsRead('follow', allFanIds).catch(e => { - console.error("标记关注已读失败:", e); + console.warn("标记关注已读失败:", e); }); } } else { @@ -168,7 +168,7 @@ const NewFollow = () => { if (allFanIds.length > 0) { messageService.markAsRead('follow', allFanIds).catch(e => { - console.error("标记关注已读失败:", e); + console.warn("标记关注已读失败:", e); }); } } else { diff --git a/src/other_pages/ntrp-evaluate/index.tsx b/src/other_pages/ntrp-evaluate/index.tsx index 3af9c91..c30a591 100644 --- a/src/other_pages/ntrp-evaluate/index.tsx +++ b/src/other_pages/ntrp-evaluate/index.tsx @@ -99,7 +99,7 @@ function isOnCancelEmpty(onCancelFunc) { const normalized = funcString.replace(/\s/g, ""); return emptyFunctionPatterns.includes(normalized); } catch (error) { - console.error("检查 onCancel 函数时出错:", error); + console.warn("检查 onCancel 函数时出错:", error); return false; } } @@ -531,7 +531,7 @@ function Result() { // setQrCodeUrl(tempFilePath); // } } catch (error) { - console.error("获取二维码失败:", error); + console.warn("获取二维码失败:", error); } } @@ -645,7 +645,7 @@ function Result() { }); return imageUrl; } catch (error) { - console.error("生成图片失败:", error); + console.warn("生成图片失败:", error); throw error; } } diff --git a/src/publish_pages/publishBall/components/AiImportPopup/AiImportPopup.tsx b/src/publish_pages/publishBall/components/AiImportPopup/AiImportPopup.tsx index ddd3d44..5fa4bed 100644 --- a/src/publish_pages/publishBall/components/AiImportPopup/AiImportPopup.tsx +++ b/src/publish_pages/publishBall/components/AiImportPopup/AiImportPopup.tsx @@ -88,7 +88,7 @@ const AiImportPopup: React.FC = ({ }) } } catch (error) { - console.error('获取剪切板失败:', error) + console.warn('获取剪切板失败:', error) Taro.showToast({ title: '读取剪切板失败,请手动输入', icon: 'error', @@ -163,7 +163,7 @@ const AiImportPopup: React.FC = ({ } } } catch (error) { - console.error('选择图片失败:', error) + console.warn('选择图片失败:', error) if (!(typeof error === 'object' && error.errMsg && error.errMsg.includes('fail cancel'))) { setUploadFailCount(prev => prev + 1) Taro.showToast({ diff --git a/src/publish_pages/publishBall/components/SelectStadium/SelectStadium.tsx b/src/publish_pages/publishBall/components/SelectStadium/SelectStadium.tsx index 539da8a..0f6bd0d 100644 --- a/src/publish_pages/publishBall/components/SelectStadium/SelectStadium.tsx +++ b/src/publish_pages/publishBall/components/SelectStadium/SelectStadium.tsx @@ -53,7 +53,7 @@ const SelectStadium: React.FC = ({ } } } catch (error) { - console.error('获取场馆列表失败:', error) + console.warn('获取场馆列表失败:', error) } finally { setLoading(false) } @@ -107,7 +107,7 @@ const SelectStadium: React.FC = ({ setShowDetail(true) }, fail: (err: { errMsg: string }) => { - console.error('选择位置失败:', err) + console.warn('选择位置失败:', err) const { errMsg } = err || {}; if (!errMsg.includes('fail cancel')) { Taro.showToast({ diff --git a/src/publish_pages/publishBall/components/SelectStadium/StadiumDetail.tsx b/src/publish_pages/publishBall/components/SelectStadium/StadiumDetail.tsx index e55c4de..9a41c8b 100644 --- a/src/publish_pages/publishBall/components/SelectStadium/StadiumDetail.tsx +++ b/src/publish_pages/publishBall/components/SelectStadium/StadiumDetail.tsx @@ -152,7 +152,7 @@ const StadiumDetail = forwardRef(({ }) }, fail: (err: { errMsg: string }) => { - console.error('选择位置失败:', err) + console.warn('选择位置失败:', err) const { errMsg } = err || {}; if (!errMsg.includes('fail cancel')) { Taro.showToast({ diff --git a/src/services/followService.ts b/src/services/followService.ts index dafe4a5..786add0 100644 --- a/src/services/followService.ts +++ b/src/services/followService.ts @@ -51,7 +51,7 @@ export class FollowService { throw new Error(response.message || '获取互关列表失败'); } } catch (error) { - console.error('获取互关列表失败:', error); + console.warn('获取互关列表失败:', error); return { list: [], total: 0 }; } } @@ -79,7 +79,7 @@ export class FollowService { throw new Error(response.message || '获取粉丝列表失败'); } } catch (error) { - console.error('获取粉丝列表失败:', error); + console.warn('获取粉丝列表失败:', error); return { list: [], total: 0 }; } } @@ -107,7 +107,7 @@ export class FollowService { throw new Error(response.message || '获取新增粉丝列表失败'); } } catch (error) { - console.error('获取新增粉丝列表失败:', error); + console.warn('获取新增粉丝列表失败:', error); return { list: [], total: 0 }; } } @@ -135,7 +135,7 @@ export class FollowService { throw new Error(response.message || '获取关注列表失败'); } } catch (error) { - console.error('获取关注列表失败:', error); + console.warn('获取关注列表失败:', error); return { list: [], total: 0 }; } } @@ -178,7 +178,7 @@ export class FollowService { throw new Error(response.message || '关注失败'); } } catch (error) { - console.error('关注失败:', error); + console.warn('关注失败:', error); throw error; } } @@ -201,7 +201,7 @@ export class FollowService { throw new Error(response.message || '取消关注失败'); } } catch (error) { - console.error('取消关注失败:', error); + console.warn('取消关注失败:', error); throw error; } } @@ -231,7 +231,7 @@ export class FollowService { throw new Error(response.message || '获取推荐用户失败'); } } catch (error) { - console.error('获取推荐用户失败:', error); + console.warn('获取推荐用户失败:', error); return { list: [], total: 0 }; } } @@ -251,7 +251,7 @@ export class FollowService { return 'none'; } } catch (error) { - console.error('检查关注状态失败:', error); + console.warn('检查关注状态失败:', error); return 'none'; } } @@ -269,7 +269,7 @@ export class FollowService { throw new Error(response.message || '屏蔽推荐用户失败'); } } catch (error) { - console.error('屏蔽推荐用户失败:', error); + console.warn('屏蔽推荐用户失败:', error); throw error; } } diff --git a/src/services/listApi.ts b/src/services/listApi.ts index 7a7cc26..1f37af4 100644 --- a/src/services/listApi.ts +++ b/src/services/listApi.ts @@ -27,7 +27,7 @@ export const getGamesList = async (params?: Record) => { // const fetchApi = isIntegrate ? '/games/integrate_list' : '/games/list' return httpService.post('/games/list', params, { showLoading: false }) } catch (error) { - console.error("列表数据获取失败:", error); + console.warn("列表数据获取失败:", error); throw error; } }; @@ -41,7 +41,7 @@ export const getGamesIntegrateList = async (params?: Record) => { try { return httpService.post('/games/integrate_list', params, { showLoading: false }) } catch (error) { - console.error("列表数据获取失败:", error); + console.warn("列表数据获取失败:", error); throw error; } }; @@ -55,7 +55,7 @@ export const getGamesCount = async (params?: Record) => { try { return httpService.post('/games/count', params, { showLoading: false }) } catch (error) { - console.error("列表数量获取失败:", error); + console.warn("列表数量获取失败:", error); throw error; } }; @@ -71,7 +71,7 @@ export const getSearchHistory = async (params) => { return httpService.post('/games/search_history', params, { showLoading: false }) } catch (error) { // 捕获并打印错误信息 - console.error("历史记录获取失败:", error); + console.warn("历史记录获取失败:", error); // 抛出错误以便上层处理 throw error; } @@ -87,7 +87,7 @@ export const clearHistory = async (params) => { return httpService.post('/games/search_history/delete_all', params, { showLoading: false }) } catch (error) { // 捕获并打印错误信息 - console.error("清除历史记录失败:", error); + console.warn("清除历史记录失败:", error); // 抛出错误以便上层处理 throw error; } @@ -104,7 +104,7 @@ export const searchSuggestion = async (params) => { return httpService.post('/games/search_recommendations', params) } catch (error) { // 捕获并打印错误信息 - console.error("搜索建议获取失败:", error); + console.warn("搜索建议获取失败:", error); // 抛出错误以便上层处理 throw error; } @@ -116,7 +116,7 @@ export const getCities = async () => { return httpService.post('/cities/tree', {}) } catch (error) { // 捕获并打印错误信息 - console.error("城市列表获取失败:", error); + console.warn("城市列表获取失败:", error); // 抛出错误以便上层处理 throw error; } @@ -127,7 +127,7 @@ export const getCityQrCode = async () => { return httpService.post('/hot_city_qr/list', {}) } catch (error) { // 捕获并打印错误信息 - console.error("城市二维码获取失败:", error); + console.warn("城市二维码获取失败:", error); // 抛出错误以便上层处理 throw error; } @@ -140,7 +140,7 @@ export const getDistricts = async (params: { province: string; city: string }) = return httpService.post('/cities/cities', params) } catch (error) { // 捕获并打印错误信息 - console.error("行政区列表获取失败:", error); + console.warn("行政区列表获取失败:", error); // 抛出错误以便上层处理 throw error; } diff --git a/src/services/loginService.ts b/src/services/loginService.ts index 7e91eab..7a4f1c8 100644 --- a/src/services/loginService.ts +++ b/src/services/loginService.ts @@ -122,7 +122,7 @@ export const wechat_auth_login = async ( }; } } catch (error) { - console.error("微信授权登录失败:", error); + console.warn("微信授权登录失败:", error); return { success: false, message: "微信授权失败,请重试", @@ -160,7 +160,7 @@ export const phone_auth_login = async ( await useUser.getState().fetchUserInfo(); await useUser.getState().checkNicknameChangeStatus(); } catch (error) { - console.error("更新用户信息到 store 失败:", error); + console.warn("更新用户信息到 store 失败:", error); } return { @@ -178,7 +178,7 @@ export const phone_auth_login = async ( }; } } catch (error) { - console.error("手机号登录失败:", error); + console.warn("手机号登录失败:", error); return { success: false, message: error.message, @@ -206,7 +206,7 @@ export const send_sms_code = async (phone: string): Promise => { }; } } catch (error) { - console.error("发送短信失败:", error); + console.warn("发送短信失败:", error); return { success: false, message: error.message, @@ -232,7 +232,7 @@ export const verify_sms_code = async ( user_info: response.data?.userInfo, }; } catch (error) { - console.error("验证验证码失败:", error); + console.warn("验证验证码失败:", error); return { success: false, message: error.message, @@ -255,7 +255,7 @@ export const save_login_state = (token: string, user_info: WechatUserInfo) => { Taro.setStorageSync("is_logged_in", true); Taro.setStorageSync("login_time", Date.now()); } catch (error) { - console.error("保存登录状态失败:", error); + console.warn("保存登录状态失败:", error); } }; @@ -270,7 +270,7 @@ export const clear_login_state = () => { Taro.removeStorageSync("is_logged_in"); Taro.removeStorageSync("login_time"); } catch (error) { - console.error("清除登录状态失败:", error); + console.warn("清除登录状态失败:", error); } }; @@ -374,7 +374,7 @@ export const refresh_login_status = async (): Promise => { // 检查本地存储的登录状态 return check_login_status(); } catch (error) { - console.error("刷新登录状态失败:", error); + console.warn("刷新登录状态失败:", error); return false; } }; @@ -385,7 +385,7 @@ export const updateUserPhone = async (payload: ChangePhoneParams) => { const response = await httpService.post("/user/update_phone", payload); return response; } catch (error) { - console.error("更新用户手机号失败:", error); + console.warn("更新用户手机号失败:", error); throw error; } }; @@ -402,7 +402,7 @@ export const getUserInfoById = async (id) => { ); return response; } catch (error) { - console.error("获取用户信息失败:", error); + console.warn("获取用户信息失败:", error); throw error; } }; @@ -415,7 +415,7 @@ export const followUser = async (following_id) => { }); return response; } catch (error) { - console.error("关注失败:", error); + console.warn("关注失败:", error); throw error; } }; @@ -428,7 +428,7 @@ export const unFollowUser = async (following_id) => { }); return response; } catch (error) { - console.error("取消关注失败:", error); + console.warn("取消关注失败:", error); throw error; } }; @@ -464,7 +464,7 @@ export const silentLogin = async (): Promise => { console.log("微信登录结果:", login_result); if (!login_result.code) { - console.error("微信登录失败:未获取到code"); + console.warn("微信登录失败:未获取到code"); return { success: false, message: "微信登录失败", @@ -506,14 +506,14 @@ export const silentLogin = async (): Promise => { user_info, }; } else { - console.error("静默登录失败:", auth_response.message); + console.warn("静默登录失败:", auth_response.message); return { success: false, message: auth_response.message || "静默登录失败", }; } } catch (error) { - console.error("静默登录异常:", error); + console.warn("静默登录异常:", error); return { success: false, message: "静默登录失败,请重试", diff --git a/src/services/uploadFiles.ts b/src/services/uploadFiles.ts index 0bf757a..d0fdb83 100644 --- a/src/services/uploadFiles.ts +++ b/src/services/uploadFiles.ts @@ -39,19 +39,28 @@ export interface uploadFileResponseData { updated_at: string, } +// 从上传错误中取出可展示的文案 +function get_upload_error_msg(error: any): string { + if (!error) return "上传失败"; + const msg = + error?.message || + (typeof error?.error === "string" ? error.error : error?.error?.message) || + (error?.data?.message ?? error?.data?.msg) || + ""; + return (msg && String(msg).trim()) || "上传失败"; +} + // 发布球局类 class UploadApi { async upload(req: UploadFilesData): Promise<{ id: string, data: uploadFileResponseData }> { - - let fullUrl = `${envConfig.apiBaseURL}/api/gallery/upload` - - const authHeader = tokenManager.getAuthHeader() - const { id, ...rest } = req + const fullUrl = `${envConfig.apiBaseURL}/api/gallery/upload`; + const authHeader = tokenManager.getAuthHeader(); + const { id, ...rest } = req; try { const res = await Taro.uploadFile({ url: fullUrl, filePath: rest.filePath, - name: 'file', + name: "file", formData: { description: rest.description, tags: rest.tags, @@ -59,12 +68,17 @@ class UploadApi { }, header: authHeader, }); - return { - id, - data: JSON.parse(res.data).data, + const parsed = JSON.parse(res.data); + if (parsed.code !== 0) { + const msg = get_upload_error_msg(parsed); + Taro.showToast({ title: msg, icon: "none" }); + throw new Error(msg); } + return { id, data: parsed.data }; } catch (error) { - throw { id, error } + const msg = get_upload_error_msg(error); + Taro.showToast({ title: msg, icon: "none" }); + throw { id, error }; } } @@ -103,7 +117,7 @@ class UploadApi { throw new Error(result.message || '上传失败'); } } catch (error) { - console.error('上传图片失败:', error); + console.warn('上传图片失败:', error); throw error; } } diff --git a/src/services/userService.ts b/src/services/userService.ts index fe75426..6761e8e 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -351,7 +351,7 @@ export class UserService { throw new Error(response.message || "获取用户信息失败"); } } catch (error) { - console.error("获取用户信息失败:", error); + console.warn("获取用户信息失败:", error); // 返回默认用户信息 return {} as UserInfo; } @@ -392,7 +392,7 @@ export class UserService { throw new Error(response.message || "更新用户信息失败"); } } catch (error) { - console.error("更新用户信息失败:", error); + console.warn("更新用户信息失败:", error); throw error; } } @@ -417,7 +417,7 @@ export class UserService { throw new Error(response.message || "获取主办球局失败"); } } catch (error) { - console.error("获取主办球局失败:", error); + console.warn("获取主办球局失败:", error); // 返回符合ListContainer data格式的模拟数据 return []; } @@ -443,7 +443,7 @@ export class UserService { throw new Error(response.message || "获取参与球局失败"); } } catch (error) { - console.error("获取参与球局失败:", error); + console.warn("获取参与球局失败:", error); // 返回符合ListContainer data格式的模拟数据 return []; } @@ -485,7 +485,7 @@ export class UserService { throw new Error(response.message || "操作失败"); } } catch (error) { - console.error("关注操作失败:", error); + console.warn("关注操作失败:", error); throw error; } } @@ -543,7 +543,7 @@ export class UserService { throw new Error(response.message || "更新用户信息失败"); } } catch (error) { - console.error("保存用户信息失败:", error); + console.warn("保存用户信息失败:", error); throw error; } } @@ -573,26 +573,16 @@ export class UserService { throw new Error(response.message || "获取用户动态失败"); } } catch (error) { - console.error("获取用户动态失败:", error); + console.warn("获取用户动态失败:", error); return []; } } - // 上传头像 + // 上传头像:仅在上传成功且 save 成功时返回 ossPath;失败则抛出,由调用方处理,避免误调 user/update static async upload_avatar(file_path: string): Promise { - try { - // 先上传文件到服务器 - const result = await uploadFiles.upload_oss_img(file_path); - - await this.save_user_info({ avatar: result.ossPath }); - - // 使用新的响应格式中的file_url字段 - return result.ossPath; - } catch (error) { - console.error("头像上传失败:", error); - // 如果上传失败,返回默认头像 - return require("../static/userInfo/default_avatar.svg"); - } + const result = await uploadFiles.upload_oss_img(file_path); + await this.save_user_info({ avatar: result.ossPath }); + return result.ossPath; } // 解析用户手机号 @@ -612,7 +602,7 @@ export class UserService { throw new Error(response.message || "获取手机号失败"); } } catch (error) { - console.error("获取手机号失败:", error); + console.warn("获取手机号失败:", error); return ""; } } @@ -628,7 +618,7 @@ export class UserService { throw new Error(message || "获取职业树失败"); } } catch (error) { - console.error("获取职业树失败:", error); + console.warn("获取职业树失败:", error); return []; } } @@ -644,7 +634,7 @@ export class UserService { throw new Error(message || "获取城市树失败"); } } catch (error) { - console.error("获取职业树失败:", error); + console.warn("获取职业树失败:", error); return []; } } @@ -665,7 +655,7 @@ export class UserService { throw new Error(message || "注销账户失败"); } } catch (error) { - console.error("注销账户失败:", error); + console.warn("注销账户失败:", error); } } } @@ -680,7 +670,7 @@ export const fetchUserProfile = async (): Promise< const response = await httpService.post("user/detail"); return response; } catch (error) { - console.error("获取用户信息失败:", error); + console.warn("获取用户信息失败:", error); throw error; } }; @@ -695,7 +685,7 @@ export const checkNicknameChangeStatus = async (): Promise< ); return response; } catch (error) { - console.error("获取昵称修改状态失败:", error); + console.warn("获取昵称修改状态失败:", error); throw error; } }; @@ -707,7 +697,7 @@ export const updateNickname = async (nickname: string) => { }); return response; } catch (error) { - console.error("昵称修改失败:", error); + console.warn("昵称修改失败:", error); throw error; } }; @@ -718,7 +708,7 @@ export const updateUserProfile = async (payload: Partial) => { const response = await httpService.post("/user/update", payload); return response; } catch (error) { - console.error("更新用户信息失败:", error); + console.warn("更新用户信息失败:", error); throw error; } }; @@ -737,7 +727,7 @@ export const updateUserLocation = async ( }); return response; } catch (error) { - console.error("更新用户坐标位置失败:", error); + console.warn("更新用户坐标位置失败:", error); throw error; } }; @@ -774,13 +764,13 @@ export const handleCustomerService = async (): Promise => { console.log("打开客服成功:", res); }, fail: (error) => { - console.error("打开客服失败:", error); + console.warn("打开客服失败:", error); // 如果官方客服不可用,显示备用联系方式 showCustomerServiceFallback(customerService); }, }); } catch (error) { - console.error("客服功能异常:", error); + console.warn("客服功能异常:", error); // 备用方案:显示联系信息 showCustomerServiceFallback(); } @@ -810,7 +800,7 @@ const showCustomerServiceFallback = (customerInfo?: any) => { phoneNumber: customerInfo.phoneNumber, }); } catch (error) { - console.error("拨打电话失败:", error); + console.warn("拨打电话失败:", error); Taro.showToast({ title: "拨打电话失败", icon: "none", @@ -827,7 +817,7 @@ const showCustomerServiceFallback = (customerInfo?: any) => { icon: "success", }); } catch (error) { - console.error("复制邮箱失败:", error); + console.warn("复制邮箱失败:", error); Taro.showToast({ title: "复制失败", icon: "none", diff --git a/src/services/walletService.ts b/src/services/walletService.ts index a431003..25ecf88 100644 --- a/src/services/walletService.ts +++ b/src/services/walletService.ts @@ -39,7 +39,7 @@ export class WalletService { throw new Error(response.message || "获取钱包信息失败"); } } catch (error) { - console.error("获取钱包信息失败:", error); + console.warn("获取钱包信息失败:", error); // 返回模拟数据 return { balance: 1588.80, @@ -62,7 +62,7 @@ export class WalletService { throw new Error(response.message || "获取交易记录失败"); } } catch (error) { - console.error("获取交易记录失败:", error); + console.warn("获取交易记录失败:", error); // 返回模拟数据 return [ { @@ -107,7 +107,7 @@ export class WalletService { throw new Error(response.message || "提现申请提交失败"); } } catch (error) { - console.error("提现申请提交失败:", error); + console.warn("提现申请提交失败:", error); throw error; } } diff --git a/src/store/README.md b/src/store/README.md index 341f146..c6d0c9b 100644 --- a/src/store/README.md +++ b/src/store/README.md @@ -93,7 +93,7 @@ function MyComponent() { console.log('请求成功!') } catch (error) { - console.error('请求失败:', error) + console.warn('请求失败:', error) } finally { setLoading(false) } diff --git a/src/store/dictionaryStore.ts b/src/store/dictionaryStore.ts index ef9ff60..b4ab30c 100644 --- a/src/store/dictionaryStore.ts +++ b/src/store/dictionaryStore.ts @@ -76,7 +76,7 @@ export const useDictionaryStore = create()((set, get) => ({ error: errorMessage, isLoading: false }) - console.error('获取字典数据失败:', error) + console.warn('获取字典数据失败:', error) } }, diff --git a/src/store/keyboardStore.ts b/src/store/keyboardStore.ts index 322e25a..71c2362 100644 --- a/src/store/keyboardStore.ts +++ b/src/store/keyboardStore.ts @@ -76,7 +76,7 @@ export const useKeyboardStore = create((set, get) => ({ try { listener(height, true) } catch (error) { - console.error('键盘监听器执行错误:', error) + console.warn('键盘监听器执行错误:', error) } }) }) @@ -92,7 +92,7 @@ export const useKeyboardStore = create((set, get) => ({ try { listener(0, false) } catch (error) { - console.error('键盘监听器执行错误:', error) + console.warn('键盘监听器执行错误:', error) } }) }) diff --git a/src/store/listStore.ts b/src/store/listStore.ts index d5d2392..31252bf 100644 --- a/src/store/listStore.ts +++ b/src/store/listStore.ts @@ -410,7 +410,7 @@ export const useListStore = create()((set, get) => ({ return Promise.resolve(); } catch (error) { - console.error("更新列表数据失败:", error); + console.warn("更新列表数据失败:", error); return Promise.reject(error); } }, @@ -724,7 +724,7 @@ export const useListStore = create()((set, get) => ({ } return []; } catch (error) { - console.error("获取行政区列表失败:", error); + console.warn("获取行政区列表失败:", error); return []; } }, diff --git a/src/store/messageStore.ts b/src/store/messageStore.ts index 6544bde..7eebeac 100644 --- a/src/store/messageStore.ts +++ b/src/store/messageStore.ts @@ -46,7 +46,7 @@ export const useMessageStore = create()((set, get) => ({ set({ loading: false }); } } catch (e) { - console.error("获取红点信息失败:", e); + console.warn("获取红点信息失败:", e); set({ loading: false }); } }, diff --git a/src/store/storage.ts b/src/store/storage.ts index 0b164f7..31eb68e 100644 --- a/src/store/storage.ts +++ b/src/store/storage.ts @@ -5,7 +5,7 @@ export const setStorage = (key: string, data: any) => { try { Taro.setStorageSync(key, JSON.stringify(data)) } catch (error) { - console.error('保存数据失败:', error) + console.warn('保存数据失败:', error) } } @@ -17,7 +17,7 @@ export const getStorage = (key: string): T | null => { } return null } catch (error) { - console.error('读取数据失败:', error) + console.warn('读取数据失败:', error) return null } } @@ -26,7 +26,7 @@ export const removeStorage = (key: string) => { try { Taro.removeStorageSync(key) } catch (error) { - console.error('清除数据失败:', error) + console.warn('清除数据失败:', error) } } @@ -34,6 +34,6 @@ export const clearAllStorage = () => { try { Taro.clearStorageSync() } catch (error) { - console.error('清除所有数据失败:', error) + console.warn('清除所有数据失败:', error) } } \ No newline at end of file diff --git a/src/store/userStore.ts b/src/store/userStore.ts index 4912277..bc32b85 100644 --- a/src/store/userStore.ts +++ b/src/store/userStore.ts @@ -77,7 +77,7 @@ export const useUser = create()((set) => ({ return userData; } catch (error) { - console.error("获取用户信息失败:", error); + console.warn("获取用户信息失败:", error); return undefined; } }, @@ -87,7 +87,7 @@ export const useUser = create()((set) => ({ try { (Taro as any).setStorageSync?.(CITY_CACHE_KEY, newArea); } catch (error) { - console.error("保存城市缓存失败:", error); + console.warn("保存城市缓存失败:", error); } }, @@ -122,7 +122,7 @@ export const useUser = create()((set) => ({ // 只有在更新头像等需要服务器返回新URL的字段时才需要重新获取 // 如果需要确保数据一致性,可以在特定场景下手动调用 fetchUserInfo } catch (error) { - console.error("更新用户信息失败:", error); + console.warn("更新用户信息失败:", error); throw error; } }, @@ -153,7 +153,7 @@ export const useUser = create()((set) => ({ }, }); } catch (error) { - console.error("检查昵称变更状态失败:", error); + console.warn("检查昵称变更状态失败:", error); } finally { isCheckingNicknameStatus = false; } @@ -167,7 +167,7 @@ export const useUser = create()((set) => ({ user: { ...state.user, nickname }, })); } catch (error) { - console.error("更新用户昵称失败:", error); + console.warn("更新用户昵称失败:", error); } }, // NTRP 测试结果缓存 @@ -201,7 +201,7 @@ export const useUser = create()((set) => ({ } return null; } catch (error) { - console.error("获取NTRP测试结果失败:", error); + console.warn("获取NTRP测试结果失败:", error); return null; } finally { isFetchingLastTestResult = false; diff --git a/src/test_pages/index.tsx b/src/test_pages/index.tsx index 16a6f19..c5aaa97 100644 --- a/src/test_pages/index.tsx +++ b/src/test_pages/index.tsx @@ -25,7 +25,7 @@ const TestPage: React.FC = () => { } }, fail(err) { - console.error('订阅失败:', err); + console.warn('订阅失败:', err); Taro.showToast({ title: '订阅失败', icon: 'error', diff --git a/src/user_pages/downloadBill/index.tsx b/src/user_pages/downloadBill/index.tsx index f0b3f5a..417f5bd 100644 --- a/src/user_pages/downloadBill/index.tsx +++ b/src/user_pages/downloadBill/index.tsx @@ -206,11 +206,11 @@ const DownloadBill: React.FC = () => { } }, fail: function (err) { - console.error("文件下载失败:", err); + console.warn("文件下载失败:", err); }, }); } catch (error) { - console.error(error); + console.warn(error); } }; const handleDownloadBill = async () => { @@ -240,11 +240,11 @@ const DownloadBill: React.FC = () => { } }, fail: function (err) { - console.error("文件下载失败:", err); + console.warn("文件下载失败:", err); }, }); } catch (error) { - console.error(error); + console.warn(error); } }; return ( diff --git a/src/user_pages/downloadBillRecords/index.tsx b/src/user_pages/downloadBillRecords/index.tsx index 58ceb4a..e698c39 100644 --- a/src/user_pages/downloadBillRecords/index.tsx +++ b/src/user_pages/downloadBillRecords/index.tsx @@ -82,15 +82,15 @@ const DownloadBillRecords: React.FC = () => { console.log('打开文档成功'); }, fail: (err) => { - console.error('打开文档失败', err); + console.warn('打开文档失败', err); } }); } else { - console.error('下载失败,状态码:', res.statusCode); + console.warn('下载失败,状态码:', res.statusCode); } }, fail: (err) => { - console.error('下载失败', err); + console.warn('下载失败', err); } }); } diff --git a/src/user_pages/edit/index.tsx b/src/user_pages/edit/index.tsx index 9010dff..0461f7e 100644 --- a/src/user_pages/edit/index.tsx +++ b/src/user_pages/edit/index.tsx @@ -142,7 +142,7 @@ const EditProfilePage: React.FC = () => { // city: user_data.city || "", // }); // } catch (error) { - // console.error("加载用户信息失败:", error); + // console.warn("加载用户信息失败:", error); // Taro.showToast({ // title: "加载用户信息失败", // icon: "error", @@ -169,9 +169,9 @@ const EditProfilePage: React.FC = () => { icon: "success", }); } catch (error) { - console.error("头像上传失败:", error); + console.warn("头像上传失败:", error); Taro.showToast({ - title: "头像上传失败", + title: error.message, icon: "none", }); } @@ -246,7 +246,7 @@ const EditProfilePage: React.FC = () => { icon: "success", }); } catch (error) { - console.error("保存失败:", error); + console.warn("保存失败:", error); Taro.showToast({ title: "保存失败", icon: "error", @@ -307,7 +307,7 @@ const EditProfilePage: React.FC = () => { icon: "success", }); } catch (error) { - console.error("保存失败:", error); + console.warn("保存失败:", error); Taro.showToast({ title: "保存失败", icon: "error", @@ -438,7 +438,7 @@ const EditProfilePage: React.FC = () => { const phone = await UserService.parse_phone(e.detail.code); handle_field_edit("phone", phone); } catch (e) { - console.error("解析手机号失败:", e); + console.warn("解析手机号失败:", e); Taro.showToast({ title: "解析手机号失败,请重试", icon: "none", @@ -564,9 +564,8 @@ const EditProfilePage: React.FC = () => { {convert_db_gender_to_display(form_data.gender)} @@ -597,9 +596,8 @@ const EditProfilePage: React.FC = () => { {form_data.birthday || "选择生日"} @@ -628,9 +626,8 @@ const EditProfilePage: React.FC = () => { {form_data.personal_profile.replace(/\n/g, " ") || "介绍一下自己"} @@ -661,17 +658,16 @@ const EditProfilePage: React.FC = () => { {form_data.province || - form_data.city || - form_data.district + form_data.city || + form_data.district ? `${form_data.province} ${form_data.city} ${form_data.district}` : "选择所在地区"} @@ -697,9 +693,8 @@ const EditProfilePage: React.FC = () => { {form_data.ntrp_level || "测测你的 NTRP 水平"} @@ -724,14 +719,12 @@ const EditProfilePage: React.FC = () => { 职业 {form_data.occupation || "填写你的职业"} @@ -771,9 +764,9 @@ const EditProfilePage: React.FC = () => { > {form_data.phone ? form_data.phone.replace( - /(\d{3})(\d{4})(\d{4})/, - "$1 $2 $3" - ) + /(\d{3})(\d{4})(\d{4})/, + "$1 $2 $3" + ) : "未绑定"} { })); } catch (error) { - console.error(`加载${TAB_CONFIG.find(t => t.key === tab)?.label}列表失败:`, error); + console.warn(`加载${TAB_CONFIG.find(t => t.key === tab)?.label}列表失败:`, error); Taro.showToast({ title: '加载失败', icon: 'none' @@ -163,7 +163,7 @@ const FollowPage: React.FC = () => { } } catch (error) { - console.error('关注操作失败:', error); + console.warn('关注操作失败:', error); Taro.showToast({ title: '操作失败', icon: 'none' @@ -202,7 +202,7 @@ const FollowPage: React.FC = () => { try { load_user_list(default_tab, true); } catch (error) { - console.error('初始化加载失败:', error); + console.warn('初始化加载失败:', error); Taro.showToast({ title: '初始化失败', icon: 'none' @@ -243,7 +243,7 @@ const FollowPage: React.FC = () => { // icon: 'success' // }); } catch (error) { - console.error('取消关注失败:', error); + console.warn('取消关注失败:', error); Taro.showToast({ title: '操作失败', icon: 'none' diff --git a/src/user_pages/myself/index.tsx b/src/user_pages/myself/index.tsx index 8426909..f339539 100644 --- a/src/user_pages/myself/index.tsx +++ b/src/user_pages/myself/index.tsx @@ -62,7 +62,7 @@ const MyselfPage: React.FC = () => { // // } // // set_game_records(games_data); // } catch (error) { - // console.error("加载用户数据失败:", error); + // console.warn("加载用户数据失败:", error); // Taro.showToast({ // title: "加载失败,请重试", // icon: "error", @@ -150,7 +150,7 @@ const MyselfPage: React.FC = () => { setEndedGameRecords(finishedGames); // set_game_records(games_data); } catch (error) { - console.error("加载球局数据失败:", error); + console.warn("加载球局数据失败:", error); } }, [active_tab, user_info, classifyGameRecords]); @@ -176,7 +176,7 @@ const MyselfPage: React.FC = () => { duration: 1500, }); } catch (error) { - console.error("关注操作失败:", error); + console.warn("关注操作失败:", error); Taro.showToast({ title: "操作失败,请重试", icon: "error", diff --git a/src/user_pages/other/index.tsx b/src/user_pages/other/index.tsx index 037a915..4f2a3a9 100644 --- a/src/user_pages/other/index.tsx +++ b/src/user_pages/other/index.tsx @@ -117,7 +117,7 @@ const OtherUserPage: React.FC = () => { }); setIsFollowing(userData.is_following || false); } catch (error) { - console.error("加载用户数据失败:", error); + console.warn("加载用户数据失败:", error); Taro.showToast({ title: "加载失败", icon: "none", @@ -169,7 +169,7 @@ const OtherUserPage: React.FC = () => { setGameRecords(notEndGames); setEndedGameRecords(finishedGames); } catch (error) { - console.error("加载球局数据失败:", error); + console.warn("加载球局数据失败:", error); Taro.showToast({ title: "加载失败,请重试", icon: "error", @@ -200,7 +200,7 @@ const OtherUserPage: React.FC = () => { duration: 1500, }); } catch (error) { - console.error("关注操作失败:", error); + console.warn("关注操作失败:", error); Taro.showToast({ title: "操作失败", icon: "none", @@ -235,7 +235,7 @@ const OtherUserPage: React.FC = () => { try { await Promise.all([load_user_data(), load_game_data()]); } catch (error) { - console.error("刷新失败:", error); + console.warn("刷新失败:", error); } finally { setRefreshing(false); } diff --git a/src/user_pages/queryTransactions/index.tsx b/src/user_pages/queryTransactions/index.tsx index 279da06..46d726b 100644 --- a/src/user_pages/queryTransactions/index.tsx +++ b/src/user_pages/queryTransactions/index.tsx @@ -84,7 +84,7 @@ const QueryTransactions = () => { setSearchHistory(response.data); } } catch (e) { - console.error(e); + console.warn(e); } }; /** diff --git a/src/user_pages/wallet/index.tsx b/src/user_pages/wallet/index.tsx index d7d3066..def37a6 100644 --- a/src/user_pages/wallet/index.tsx +++ b/src/user_pages/wallet/index.tsx @@ -195,7 +195,7 @@ const WalletPage: React.FC = () => { const res = await httpService.post("/wallet/check_password_status"); set_password_status(res.data.is_password_set); } catch (e) { - console.error("检查交易密码状态失败:", e); + console.warn("检查交易密码状态失败:", e); } }; @@ -218,7 +218,7 @@ const WalletPage: React.FC = () => { total_withdraw, }); } catch (error: any) { - console.error("加载钱包数据失败:", error); + console.warn("加载钱包数据失败:", error); let errorMessage = "加载失败,请重试"; if ( @@ -262,7 +262,7 @@ const WalletPage: React.FC = () => { set_transactions([]); } } catch (error: any) { - console.error("加载交易记录失败:", error); + console.warn("加载交易记录失败:", error); set_transactions([]); let errorMessage = "加载交易记录失败"; diff --git a/src/user_pages/withdrawal/index.tsx b/src/user_pages/withdrawal/index.tsx index 527c356..ec87155 100644 --- a/src/user_pages/withdrawal/index.tsx +++ b/src/user_pages/withdrawal/index.tsx @@ -135,7 +135,7 @@ const Withdrawal: React.FC = () => { total_withdraw, }); } catch (error: any) { - console.error("加载钱包数据失败:", error); + console.warn("加载钱包数据失败:", error); let errorMessage = "加载失败,请重试"; if ( @@ -171,7 +171,7 @@ const Withdrawal: React.FC = () => { setMapErrorCodes(mapErrorCodes); } } catch (error: any) { - console.error("获取提现错误码失败:", error); + console.warn("获取提现错误码失败:", error); } }; const handleWithdraw = async () => { diff --git a/src/utils/authInit.ts b/src/utils/authInit.ts index 963e63e..f8ba866 100644 --- a/src/utils/authInit.ts +++ b/src/utils/authInit.ts @@ -33,7 +33,7 @@ const initUserAuthCore = async (): Promise => { await fetchUserInfo(); await checkNicknameChangeStatus(); } catch (error) { - console.error("获取用户信息失败:", error); + console.warn("获取用户信息失败:", error); } } else { // 未登录,尝试静默登录 @@ -45,12 +45,12 @@ const initUserAuthCore = async (): Promise => { await checkNicknameChangeStatus(); } } catch (error) { - console.error("静默登录失败:", error); + console.warn("静默登录失败:", error); // 静默登录失败不影响使用 } } } catch (error) { - console.error("初始化用户授权失败:", error); + console.warn("初始化用户授权失败:", error); } finally { isInitializingAuth = false; authInitPromise = null; diff --git a/src/utils/helper.ts b/src/utils/helper.ts index 205d4f8..1e85644 100644 --- a/src/utils/helper.ts +++ b/src/utils/helper.ts @@ -23,7 +23,7 @@ export const sceneRedirectLogic = (options, defaultPage: string) => { url: query ? `/${defaultPage}?${query}` : `/${defaultPage}`, }); } catch (e) { - console.error(e); + console.warn(e); } }; diff --git a/src/utils/share.ts b/src/utils/share.ts index 2fdc1f2..c15629a 100644 --- a/src/utils/share.ts +++ b/src/utils/share.ts @@ -553,7 +553,7 @@ const drawShareCard = async (ctx: any, data: ShareCardData, offscreen: any): Pro console.log('Canvas绘制命令已发送') } catch (error) { - console.error('绘制分享卡片失败:', error) + console.warn('绘制分享卡片失败:', error) Taro.showToast({ title: '生成分享卡片失败', icon: 'none' diff --git a/src/utils/tokenManager.ts b/src/utils/tokenManager.ts index 435cede..332a2cc 100644 --- a/src/utils/tokenManager.ts +++ b/src/utils/tokenManager.ts @@ -16,7 +16,7 @@ class TokenManager { try { return Taro.getStorageSync(TOKEN_KEY) } catch (error) { - console.error('获取访问令牌失败:', error) + console.warn('获取访问令牌失败:', error) return null } } @@ -26,7 +26,7 @@ class TokenManager { try { return Taro.getStorageSync(REFRESH_TOKEN_KEY) } catch (error) { - console.error('获取刷新令牌失败:', error) + console.warn('获取刷新令牌失败:', error) return null } } @@ -36,7 +36,7 @@ class TokenManager { try { return Taro.getStorageSync(TOKEN_EXPIRES_KEY) } catch (error) { - console.error('获取令牌过期时间失败:', error) + console.warn('获取令牌过期时间失败:', error) return null } } @@ -54,7 +54,7 @@ class TokenManager { Taro.setStorageSync(TOKEN_EXPIRES_KEY, tokenInfo.expiresAt) } } catch (error) { - console.error('设置令牌失败:', error) + console.warn('设置令牌失败:', error) } } @@ -65,7 +65,7 @@ class TokenManager { Taro.removeStorageSync(REFRESH_TOKEN_KEY) Taro.removeStorageSync(TOKEN_EXPIRES_KEY) } catch (error) { - console.error('清除令牌失败:', error) + console.warn('清除令牌失败:', error) } } diff --git a/src/utils/wx_helper.ts b/src/utils/wx_helper.ts index 013f9f1..c7f01f1 100644 --- a/src/utils/wx_helper.ts +++ b/src/utils/wx_helper.ts @@ -17,7 +17,7 @@ export function saveImage(url) { await Taro.saveImageToPhotosAlbum({ filePath }) Taro.showToast({ title: "保存成功" }) } catch (e) { - console.error(e) + console.warn(e) Taro.showToast({ title: "图片保存失败", icon: "none" }) } }