Skip to content

Enhance error handling, navigation, and theme management#29

Merged
Sealt merged 8 commits into
mainfrom
fix/hide-refresh-token-error
Jul 3, 2026
Merged

Enhance error handling, navigation, and theme management#29
Sealt merged 8 commits into
mainfrom
fix/hide-refresh-token-error

Conversation

@Sealt

@Sealt Sealt commented Jul 3, 2026

Copy link
Copy Markdown
Member

This pull request includes several improvements and adjustments across the codebase, mainly focusing on localization of user-facing messages, API parameter enhancements, UI consistency, and minor bug fixes. The most significant changes are grouped and summarized below.

Localization and User-Facing Message Updates:

  • Changed error and toast messages throughout the app to use more concise and localized (Chinese) language, improving clarity and user experience. This affects API error handling (e.g., missing parameters) and various toast notifications in GPA calculator and group chat pages. [1] [2] [3] [4] [5] [6] [7]

API and Logic Enhancements:

  • Updated authentication API methods to include new options (handleAuthFailure and silent) for more granular control over authentication behavior. [1] [2]

UI and Page Configuration Adjustments:

Code and Logic Simplification:

  • Simplified the useThemePage composable by removing unnecessary initialization logic, returning the theme store directly.
  • Updated logic in final-review/detail to use Taro.getWindowInfo() instead of Taro.getSystemInfoSync() for obtaining window height, improving reliability.

UI Bug Fixes and Improvements:

  • Fixed layout issue in the GPA calculator's scroll view by adjusting padding and structure for better display. [1] [2]

These changes collectively improve localization, user experience, code maintainability, and UI consistency across the application.

Sealt added 8 commits July 3, 2026 23:41
- 新增 errorMessage.js 工具模块,提供 getSafeErrorMessage / isTechnicalErrorMessage / getSafeRequestErrorMessage
- request.js:使用安全错误消息替换原生错误信息,优化请求错误弹窗队列逻辑
- image.js / config.js / courseTable.js:错误信息中文化,移除技术细节
- auth.js:login/refreshToken 接口增加 handleAuthFailure 和 silent 选项
- auth.js:使用 getSafeErrorMessage 过滤技术错误信息,优化 expireToken 标题处理
- countdown.js / study-tasks.js:错误消息统一为中文友好提示
- utils/index.js:新增 safeNavigateBack,栈深度 > 1 时正常返回,否则跳转 fallback
- notifications/detail、organization/detail、schedule-bind:统一使用 safeNavigateBack
- theme.js:移除原生主题 API 调用 (setNavigationBarColor/setTabBarStyle 等),
  改用 CSS 变量 + theme.json 控制;getSystemInfoSync → getAppBaseInfo
- useThemePage.js:移除 initTheme() 调用,仅返回 store 实例
enablePageMeta 已废弃,统一移除,改用 theme.json 全局配置
Taro.getSystemInfoSync() 已废弃,改用 getWindowInfo() 获取窗口尺寸
- teacher-reviews:统一 class 属性缩进格式,修复 scroll-view 滚动属性写法
- gpa-calculator:调整 scroll-view 内部 padding 结构,修复内容两侧间距问题
@Sealt
Sealt requested a review from AEnjoy as a code owner July 3, 2026 16:23

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several improvements to the application, including the removal of redundant page meta configurations, the simplification of user-facing toast messages, and the cleanup of theme store actions. It also introduces a new errorMessage utility to sanitize technical errors and a safeNavigateBack helper to prevent navigation issues when the history stack is empty. Additionally, modern Taro APIs like getWindowInfo and getAppBaseInfo are adopted. Feedback on these changes suggests passing the original error message to expireToken() in request.js to preserve user-friendly server messages, and wrapping Taro.getWindowInfo() in a try-catch block with a fallback to ensure compatibility with older WeChat clients.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/utils/request.js
useAuthStore().expireToken(finalError.message || '请重新登录')
if (finalError?.isAuthError) {
if (handleAuthFailure) {
useAuthStore().expireToken()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Calling expireToken() without any arguments discards finalError?.message entirely. This means the user will always see the default '请重新登录' toast, even if the server returned a specific, user-friendly message (e.g., '您的账号在其他设备登录').

By passing finalError?.message to expireToken(), we allow normalizeExpireTokenTitle to sanitize and display the specific message if it is not a technical error, while still falling back to '请重新登录' if it is technical or empty.

Suggested change
useAuthStore().expireToken()
useAuthStore().expireToken(finalError?.message)

Comment on lines +1136 to +1137
const windowInfo = Taro.getWindowInfo()
chartWidth.value = Math.max(280, Math.floor((windowInfo.windowWidth || 375) - 56))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Calling Taro.getWindowInfo() directly without a try-catch block or a fallback check can cause runtime crashes on older WeChat clients or non-WeChat platforms where this API is not supported.

To ensure maximum compatibility and robustness, wrap the call in a try-catch block and fall back to Taro.getSystemInfoSync() or a default value if Taro.getWindowInfo is unavailable.

    let windowWidth = 375
    try {
      if (typeof Taro.getWindowInfo === 'function') {
        windowWidth = Taro.getWindowInfo().windowWidth || 375
      } else if (typeof Taro.getSystemInfoSync === 'function') {
        windowWidth = Taro.getSystemInfoSync().windowWidth || 375
      }
    } catch (error) {
      console.warn('Failed to get window width:', error)
    }
    chartWidth.value = Math.max(280, Math.floor(windowWidth - 56))

@Sealt
Sealt merged commit 99f3dd5 into main Jul 3, 2026
4 checks passed
@Sealt
Sealt deleted the fix/hide-refresh-token-error branch July 3, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant