Feat/1.4.0#27
Conversation
fix: 番茄钟排行文本显示
There was a problem hiding this comment.
Code Review
This pull request introduces several new features, including a Pomodoro timer card, GPA backup/restore functionality, and new pages for competitions, exchange programs, major transfers, and organizations. It also refactors the API layer to use a unified request utility with robust token refresh and error handling, while removing legacy admin pages and endpoints. The code review feedback suggests moving page-level lifecycles from the nested Pomodoro component to its parent page, simplifying a redundant conditional check in the hexToRgba helper, and removing an unused formatDateTime function.
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.
| Taro.useDidShow(() => { | ||
| restoreState() | ||
| }) | ||
|
|
||
| Taro.useDidHide(() => { | ||
| stopTimer() | ||
| if (isRunning.value) { | ||
| syncRemainingFromTimestamp() | ||
| } | ||
| persistState() | ||
| }) |
There was a problem hiding this comment.
In Taro, page lifecycle hooks like useDidShow and useDidHide are designed for Page components. When used inside nested custom components (like PomodoroCard.vue), they may not trigger reliably or at all depending on the Taro version and platform.
It is safer to manage these page-level lifecycles in the parent Page component (src/pages/home/index.vue) and trigger the corresponding methods on this component via template refs or props.
// TODO: Move page-level lifecycles (useDidShow/useDidHide) to the parent Page component and call component methods via refs.
| const hexToRgba = (hex, alpha) => { | ||
| if (!hex) { | ||
| return `rgba(148, 163, 184, ${alpha})` | ||
| } | ||
|
|
||
| const normalized = hex.replace('#', '') | ||
| const length = normalized.length === 3 ? 1 : 2 | ||
| const values = normalized.length === 3 | ||
| ? normalized.split('').map((item) => parseInt(item.repeat(2), 16)) | ||
| : [ | ||
| parseInt(normalized.slice(0, 2), 16), | ||
| parseInt(normalized.slice(2, 4), 16), | ||
| parseInt(normalized.slice(4, 6), 16), | ||
| ] | ||
|
|
||
| if (length === 1) { | ||
| return `rgba(${values[0]}, ${values[1]}, ${values[2]}, ${alpha})` | ||
| } | ||
|
|
||
| return `rgba(${values[0]}, ${values[1]}, ${values[2]}, ${alpha})` | ||
| } |
There was a problem hiding this comment.
The hexToRgba function contains a redundant conditional check if (length === 1) where both branches return the exact same string template. We can simplify this by removing the redundant length variable and the if statement.
const hexToRgba = (hex, alpha) => {
if (!hex) {
return `rgba(148, 163, 184, ${alpha})`
}
const normalized = hex.replace('#', '')
const values = normalized.length === 3
? normalized.split('').map((item) => parseInt(item.repeat(2), 16))
: [
parseInt(normalized.slice(0, 2), 16),
parseInt(normalized.slice(2, 4), 16),
parseInt(normalized.slice(4, 6), 16),
]
return `rgba(${values[0]}, ${values[1]}, ${values[2]}, ${alpha})`
}
| const formatDateTime = (value) => { | ||
| if (!value) { | ||
| return '' | ||
| } | ||
|
|
||
| const date = new Date(value) | ||
|
|
||
| if (Number.isNaN(date.getTime())) { | ||
| return value | ||
| } | ||
|
|
||
| return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}` | ||
| } |
No description provided.