Repository navigation
fix: rank detail drawer accounting display - #7959
Conversation
| </el-table-column> | ||
| <el-table-column v-if="activeKind === 'tokens' || activeKind === 'questions'" label="活跃用户" min-width="100"> | ||
| <template #default="{ row }">{{ numberFormat(row.chat_user_count) }}</template> | ||
| </el-table-column> |
There was a problem hiding this comment.
Looking at the diff, here are my observations:
Irregularities / Potential Issues
-
chat_record_countmay beundefinednumberFormat(row.chat_record_count)is called without a fallback. Other columns use?? 0(e.g.,formatTokenNumber(row.total_tokens ?? 0)). If the API can returnnull/undefined,numberFormatwill likely produceNaN,"null", or throw depending on its implementation. Considerrow.chat_record_count ?? 0.
-
Column order change affects UX semantics
- "对话次数" was moved before "占比". Ensure this matches design specs — reordering columns in a rankings table can shift user expectations, especially since "占比" (
el-progress) is typically the visually dominant column placed last.
- "对话次数" was moved before "占比". Ensure this matches design specs — reordering columns in a rankings table can shift user expectations, especially since "占比" (
-
Possible redundant visibility condition
- The new "对话次数" column has no
v-if, so it always shows, whereas neighboring columns are conditional onactiveKind. Verify this is intentional — if the field only makes sense for certain kinds (likequestions), you may need av-if.
- The new "对话次数" column has no
Code Style / Formatting
- Line length regression
- The
canExportchange reverse-wraps a long ternary onto one line (~130 chars). If your project enforces Prettier/ESLintmax-lenorprintWidth: 100/120, this will fail linting. The original multi-line form was more readable. Revert unless a specific style guide requires single-line.
- The
Optimization Suggestions
-
Memoize/inline guard for
numberFormat- Wrap fallback into a helper (or update
numberFormatitself to acceptundefinedand default to0), so all usages are consistent.
- Wrap fallback into a helper (or update
-
computedstill fine- The
canExportbehavior is unchanged; no perf concern. Only formatting matters.
- The
-
Consider
:keystability for reordered columns- When column order changes across versions, users' persisted table preferences (if any) keyed by label/index could break. If column persistence exists, use explicit
prop/column-keyattributes (e.g.,:prop="activeKind + '_chat_count'"style keys or stablecolumn-key) instead of relying on DOM order.
- When column order changes across versions, users' persisted table preferences (if any) keyed by label/index could break. If column persistence exists, use explicit
-
Test coverage
- Add/verify unit test asserting "对话次数" renders
0(not blank/NaN) whenchat_record_countis missing.
- Add/verify unit test asserting "对话次数" renders
Summary
- Must fix:
?? 0fallback forchat_record_count; revert the long single-line ternary if lint rules apply. - Verify: intentional unconditional display of the new column and desired column ordering.
- Nice-to-have: stable
column-key/prop, tests for null-safety.
| <span v-else>—</span> | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column label="均 Tokens/次" min-width="125"> |
There was a problem hiding this comment.
Review of the diff
The change simply swaps the order of two <el-table-column> blocks: the "对话次数 / Tokens 消耗" column now comes before the "占比" (ratio) column. Functionally this is a safe, cosmetic reordering. A few observations:
Potential issues / things to verify
-
No logical dependency broken?
- The second column's content no longer depends on the first — they are independent. Just confirm there's no CSS/
:keyor column-index assumption elsewhere (e.g.,row-class-name, sortable column indices,table.columns[i]references, or tests that assert column order).
- The second column's content no longer depends on the first — they are independent. Just confirm there's no CSS/
-
Sorting behavior
- If either column uses
sortable(not shown here), swapping order changes default sort UX. Not visible in the snippet, but worth checking.
- If either column uses
-
Redundant work — repeated
activeKind === 'userTokens'checks- Both columns compute
activeKind === 'userTokens' ? ... : .... Consider extracting a computed property for readability and consistency:const secondaryLabel = computed(() => activeKind.value === 'userTokens' ? '对话次数' : 'Tokens 消耗' ) const secondaryField = computed(() => activeKind.value === 'userTokens' ? 'questions' : 'userTokens' )
- Then use
:label="secondaryLabel"andformatRankingValue(row, secondaryField).
- Both columns compute
-
Defensive checks in the ratio column
getRankingRatio(row)may return values outside 0–100 (orNaN).el-progress :percentageexpects 0–100; clamp it to avoid rendering warnings:Math.min(100, Math.max(0, getRankingRatio(row)))
- Ensure
getRankingRatiodoesn't divide by zero whenaggregateTotal === 0. You already guardaggregateTotal != null, but0passes that check → potential division-by-zero producingInfinity/NaN.
-
Accessibility / semantics
- The fallback
—is fine, but consider adding a tooltip oraria-labelfor screen readers explaining why the value is unavailable.
- The fallback
-
min-widthinconsistency- New left column uses
125, ratio column150. Purely visual — acceptable, just confirm intended with the design.
- New left column uses
Performance
- No concerns introduced by this diff; swapping columns has negligible cost. For large tables, mark ratio/progress columns with
class-nameminimal re-render or considerfixedwidths to prevent layout thrash during horizontal scroll.
Summary: The reorder itself is harmless. Main follow-ups: confirm nothing depends on column index/order, clamp el-progress percentages, guard against division by zero, and optionally DRY up the repeated ternary logic via computed properties.
【【系统管理】首页排行榜详情弹窗「对话次数」Tab 下,表头「占比」列位置错误,与原型不符】
https://www.tapd.cn/tapd_fe/45245355/bug/detail/1145245355001078070