refactor(ResultPage): v16 适配#3493
Conversation
WalkthroughResultPage 的类型、主题变量、样式、示例、文档和迁移说明都被更新,并新增 Popup/Dialog 内嵌示例。Button 的 loading 图标改为固定 ChangesResultPage 更新
Button 调整
Sequence Diagram(s)sequenceDiagram
participant Cell
participant Demo6
participant Popup
participant ResultPage
participant Button
participant Demo7
participant Dialog
Cell->>Demo6: click
Demo6->>Popup: visible = true
Popup->>ResultPage: render success content
ResultPage->>Button: render actions
Button-->>Demo6: onClick closes Popup
Demo6->>Popup: visible = false
Cell->>Demo7: click
Demo7->>Dialog: visible = true
Dialog->>ResultPage: render success content
ResultPage->>Button: render actions
Button-->>Demo7: onClick closes Dialog
Demo7->>Dialog: visible = false
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat_v4.x #3493 +/- ##
=============================================
+ Coverage 88.33% 88.44% +0.10%
=============================================
Files 295 296 +1
Lines 19747 19812 +65
Branches 3117 3135 +18
=============================================
+ Hits 17443 17522 +79
+ Misses 2298 2284 -14
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/packages/resultpage/doc.md`:
- Around line 84-96: `ResultPageAction.size` is documented but not actually
honored because `ResultPage` hardcodes `size="large"` on the `Button`,
overriding any action-level value. Update `resultpage.tsx` in the
`ResultPage`/`ResultPageAction` rendering path so the action’s `size` prop is
passed through instead of being fixed, or remove `size` from the
`ResultPageAction` docs if the API should stay unsupported. Make sure the
`Button` usage and the `ResultPageAction` type/docs stay consistent.
In `@src/sites/sites-react/doc/docs/react/migrate-from-v3.en-US.md`:
- Around line 112-120: The migration doc’s ResultPageProps import guidance is
wrong because `@/types` does not export that public alias; update the text in the
React migrate-from-v3 docs to point readers to the component package entry for
ResultPageProps, or to the platform-specific alias used there. Use the existing
ResultPageProps, WebResultPageProps, TaroResultPageProps, and `@nutui/resultpage`
symbols to clarify the correct import source and avoid suggesting a symbol that
TypeScript cannot resolve.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: fd4a0e2c-427a-4267-9b96-02bff30b3e48
⛔ Files ignored due to path filters (1)
src/packages/resultpage/__test__/__snapshots__/resultpage.spec.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (36)
src/config.jsonsrc/packages/button/button.taro.tsxsrc/packages/configprovider/types.tssrc/packages/resultpage/__test__/resultpage.spec.tsxsrc/packages/resultpage/demo.taro.tsxsrc/packages/resultpage/demo.tsxsrc/packages/resultpage/demos/h5/demo1.tsxsrc/packages/resultpage/demos/h5/demo2.tsxsrc/packages/resultpage/demos/h5/demo3.tsxsrc/packages/resultpage/demos/h5/demo4.tsxsrc/packages/resultpage/demos/h5/demo5.tsxsrc/packages/resultpage/demos/h5/demo6.tsxsrc/packages/resultpage/demos/h5/demo7.tsxsrc/packages/resultpage/demos/taro/demo1.tsxsrc/packages/resultpage/demos/taro/demo2.tsxsrc/packages/resultpage/demos/taro/demo3.tsxsrc/packages/resultpage/demos/taro/demo4.tsxsrc/packages/resultpage/demos/taro/demo5.tsxsrc/packages/resultpage/demos/taro/demo6.tsxsrc/packages/resultpage/demos/taro/demo7.tsxsrc/packages/resultpage/doc.en-US.mdsrc/packages/resultpage/doc.mdsrc/packages/resultpage/doc.taro.mdsrc/packages/resultpage/doc.zh-TW.mdsrc/packages/resultpage/resultpage.scsssrc/packages/resultpage/resultpage.taro.tsxsrc/packages/resultpage/resultpage.tsxsrc/packages/resultpage/types.tssrc/sites/sites-react/doc/docs/react/migrate-from-v3.en-US.mdsrc/sites/sites-react/doc/docs/react/migrate-from-v3.mdsrc/sites/sites-react/doc/docs/taro/migrate-from-v3.en-US.mdsrc/sites/sites-react/doc/docs/taro/migrate-from-v3.mdsrc/styles/variables-daojia.scsssrc/styles/variables-jmapp.scsssrc/styles/variables-jrkf.scsssrc/styles/variables.scss
💤 Files with no reviewable changes (1)
- src/packages/resultpage/types.ts
| | icon | 自定义图标 | `ReactNode` | `-` | | ||
| | actions | 底部操作按钮 | `ResultPageAction[]` | `[]` | | ||
|
|
||
| ### ResultPageAction | ||
|
|
||
| | 属性 | 说明 | 类型 | 默认值 | | ||
| | --- | --- | --- | --- | | ||
| | text | 按钮文案 | `ReactNode` | `-` | | ||
| | type | 按钮类型 | `UIType` | `default` | | ||
| | size | 按钮尺寸 | `UISize` | `large` | | ||
| | fill | 填充模式 | `UIFill` | `outline` | | ||
| | disabled | 是否禁用 | `boolean` | `false` | | ||
| | onClick | 点击回调 | `() => void` | `-` | |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
ResultPageAction.size 现在是死字段。
src/packages/resultpage/resultpage.tsx 里 Button 在展开 ...rest 后又写死了 size="large",会覆盖这里新增的 size 文档字段。这样四份 ResultPage 文档都在暗示一个实际上不生效的 API。请要么把 size 从文档里移除,要么先改组件实现把 action 的 size 真正透传出去。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/packages/resultpage/doc.md` around lines 84 - 96, `ResultPageAction.size`
is documented but not actually honored because `ResultPage` hardcodes
`size="large"` on the `Button`, overriding any action-level value. Update
`resultpage.tsx` in the `ResultPage`/`ResultPageAction` rendering path so the
action’s `size` prop is passed through instead of being fixed, or remove `size`
from the `ResultPageAction` docs if the API should stay unsupported. Make sure
the `Button` usage and the `ResultPageAction` type/docs stay consistent.
| - **Type entry change**: | ||
| - Removed `src/packages/resultpage/types.ts`; import `ResultPageStatus`, `ResultPageAction`, and `ResultPageProps` from `@/types`. | ||
| - **Visual spec aligned with JD APP 16.0**: | ||
| - Description text is centered by default; H5 error icon color aligns with `$color-primary` (`#ff2159`). | ||
| - 4px below icon; 4px between title and description; 12px above actions; 12px between buttons (`margin: 0 6px`). | ||
| - Title: `$font-size-md` / line height 24px; description line height 22px. | ||
| - **Theme variable updates**: | ||
| - Added `--nutui-resultpage-title-line-height`. | ||
| - `--nutui-resultpage-icon-margin-bottom` default `12px` → `4px`; `--nutui-resultpage-title-margin-bottom` `12px` → `4px`; `--nutui-resultpage-title-font-size` `$font-size-xl` → `$font-size-md`; `--nutui-resultpage-description-line-height` `20px` → `22px`; `--nutui-resultpage-actions-margin-top` `16px` → `12px`. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n --hidden '\b(ResultPageProps|WebResultPageProps|TaroResultPageProps)\b' src/types src/packages/resultpage src/sites/sites-react/doc/docsRepository: jdf2e/nutui-react
Length of output: 1850
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect index.ts and index.taro.ts to confirm how ResultPageProps is exported
echo "=== src/packages/resultpage/index.ts ==="
cat -n src/packages/resultpage/index.ts
echo ""
echo "=== src/packages/resultpage/index.taro.ts ==="
cat -n src/packages/resultpage/index.taro.tsRepository: jdf2e/nutui-react
Length of output: 723
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check the types entry point to see what is exported from `@/types`
echo "=== src/types/index.ts (if exists) ==="
cat src/types/index.ts 2>/dev/null || echo "File not found, checking exports in src/types"
# Aggregative check
echo "=== Checking if ResultPageProps is exported from src/types root ==="
rg -n "export.*ResultPageProps" src/types --no-heading || echo "No direct export of ResultPageProps found in src/types"Repository: jdf2e/nutui-react
Length of output: 10161
🏁 Script executed:
cat src/packages/resultpage/package.jsonRepository: jdf2e/nutui-react
Length of output: 224
🏁 Script executed:
pwd
find . -name "package.json" -maxdepth 1 -exec cat {} \;Repository: jdf2e/nutui-react
Length of output: 10448
🏁 Script executed:
cat src/packages/nutui/index.ts | head -50Repository: jdf2e/nutui-react
Length of output: 215
🏁 Script executed:
cat src/packages/nutui/index.tsx 2>/dev/null | head -50 || cat src/packages/nutui.tsx | head -50Repository: jdf2e/nutui-react
Length of output: 155
🏁 Script executed:
find src -name "*.ts" -o -name "*.tsx" | xargs grep -l "export.*ResultPage" | head -5Repository: jdf2e/nutui-react
Length of output: 341
🏁 Script executed:
# Check whether the main entry point (nutui.tsx or similar) exports ResultPageProps
find src/packages -maxdepth 2 \( -name "index.ts" -o -name "index.tsx" -o -name "nutui.ts" -o -name "nutui.tsx" \) -exec echo "=== {} ===" \; -exec head -n 20 {} \; 2>/dev/null | grep -A 10 "ResultPage"Repository: jdf2e/nutui-react
Length of output: 640
修正 ResultPageProps 的引用来源
验证确认 ResultPageProps 并未直接在 @/types 中作为公共别名导出。它仅在组件入口文件(如 src/packages/resultpage/index.ts 和 index.taro.ts)中被分别定义为 WebResultPageProps 和 TaroResultPageProps 的别名。
文档中指示从 @/types 直接导入 ResultPageProps 会导致 TypeScript 报错(找不到符号)。请将迁移说明中的导入语句修正为从组件包入口导入,或明确指定平台化类型名称。
代码片段修改建议
原写法(错误):
- 从 `@/types` 引入 `ResultPageStatus`、`ResultPageAction` 和 `ResultPageProps`建议修改为(React 环境):
import { ResultPageProps } from '`@nutui/resultpage`'; // 或从 packages/resultpage/index.ts 导入或在无法解析包路径时显式使用完整类型名:
import { ResultPageStatus, ResultPageAction, WebResultPageProps as ResultPageProps } from '`@/types`';请参照上述逻辑更新 src/sites/sites-react/doc/docs/react/migrate-from-v3.md 和相关英文文档。
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - **Type entry change**: | |
| - Removed `src/packages/resultpage/types.ts`; import `ResultPageStatus`, `ResultPageAction`, and `ResultPageProps` from `@/types`. | |
| - **Visual spec aligned with JD APP 16.0**: | |
| - Description text is centered by default; H5 error icon color aligns with `$color-primary` (`#ff2159`). | |
| - 4px below icon; 4px between title and description; 12px above actions; 12px between buttons (`margin: 0 6px`). | |
| - Title: `$font-size-md` / line height 24px; description line height 22px. | |
| - **Theme variable updates**: | |
| - Added `--nutui-resultpage-title-line-height`. | |
| - `--nutui-resultpage-icon-margin-bottom` default `12px` → `4px`; `--nutui-resultpage-title-margin-bottom` `12px` → `4px`; `--nutui-resultpage-title-font-size` `$font-size-xl` → `$font-size-md`; `--nutui-resultpage-description-line-height` `20px` → `22px`; `--nutui-resultpage-actions-margin-top` `16px` → `12px`. | |
| - **Type entry change**: | |
| - Removed `src/packages/resultpage/types.ts`; import `ResultPageStatus` and `ResultPageAction` from `@/types`, and use `WebResultPageProps as ResultPageProps` for React. | |
| - **Visual spec aligned with JD APP 16.0**: | |
| - Description text is centered by default; H5 error icon color aligns with `$color-primary` (`#ff2159`). | |
| - 4px below icon; 4px between title and description; 12px above actions; 12px between buttons (`margin: 0 6px`). | |
| - Title: `$font-size-md` / line height 24px; description line height 22px. | |
| - **Theme variable updates**: | |
| - Added `--nutui-resultpage-title-line-height`. | |
| - `--nutui-resultpage-icon-margin-bottom` default `12px` → `4px`; `--nutui-resultpage-title-margin-bottom` `12px` → `4px`; `--nutui-resultpage-title-font-size` `$font-size-xl` → `$font-size-md`; `--nutui-resultpage-description-line-height` `20px` → `22px`; `--nutui-resultpage-actions-margin-top` `16px` → `12px`. |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/sites/sites-react/doc/docs/react/migrate-from-v3.en-US.md` around lines
112 - 120, The migration doc’s ResultPageProps import guidance is wrong because
`@/types` does not export that public alias; update the text in the React
migrate-from-v3 docs to point readers to the component package entry for
ResultPageProps, or to the platform-specific alias used there. Use the existing
ResultPageProps, WebResultPageProps, TaroResultPageProps, and `@nutui/resultpage`
symbols to clarify the correct import source and avoid suggesting a symbol that
TypeScript cannot resolve.
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit
New Features
Bug Fixes