migrate-v1-to-v2
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese从 v1 迁移到 v2 技能
Skill for Migrating from v1 to v2
职责边界
Scope of Responsibilities
- 扫描 v1 用法、替换包名/路径、迁移组件 API、迁移表单校验体系、修复不兼容变更。
- 不负责新建业务页面或重构业务逻辑,仅做最小必要的兼容性替换。
- 不负责安装依赖,由用户自行在终端执行。
- Scan for v1 usage, replace package names/paths, migrate component APIs, migrate form validation systems, and fix incompatible changes.
- Not responsible for creating new business pages or refactoring business logic; only perform minimal necessary compatibility replacements.
- Not responsible for dependency installation; users shall execute this in the terminal on their own.
首次交互确认
Initial Interaction Confirmation
在开始任何操作前,先向用户确认以下三点(如果上下文已可推断则跳过对应问题):
- 安装方式:npm 还是 uni_modules?(影响导入路径和 easycom 配置)
- 目标:
- A. 全量迁移(项目尚未升级)→ 按阶段一~七执行
- B. 升级后修错误(已升级但遇到编译/运行时报错)→ 先读 定位问题
errors.md
- 目标平台:H5 / 微信小程序 / 支付宝小程序?(影响样式隔离和 easycom 验证方式)
Before starting any operation, confirm the following three points with the user (skip corresponding questions if inferable from context):
- Installation Method: npm or uni_modules? (Affects import paths and easycom configuration)
- Objective:
- A. Full Migration (Project not upgraded yet) → Execute Phase 1 to 7
- B. Fix Errors After Upgrade (Upgraded but encountered compilation/runtime errors) → Locate issues by reading first
errors.md
- Target Platform: H5 / WeChat Mini Program / Alipay Mini Program? (Affects style isolation and easycom verification methods)
快速通道
Quick Access
根据用户描述的问题,直接加载对应子文件:
| 关键词 | 子文件 |
|---|---|
| 错误信息 / 编译报错 / 找不到模块 / is not defined / 升级后异常 | |
| 表单 / Form / schema / zodAdapter / FormRules / 校验 / 必填星号 | |
| 包名 / easycom / Volar / vite 插件 / 国际化 / 路径替换 / uni_modules | |
| Sass / 主题 / Design Token / CSS 变量 / 样式覆盖 / 深色模式 / ConfigProvider | |
| Dialog / MessageBox / Empty / StatusTip / Cascader / ColPicker / Keyboard / NumberKeyboard / Button / Tag / Radio / Checkbox / Search / Grid / Fab / Badge / Slider / Tabs / Steps / Swiper / Tooltip / Popover / Collapse / Cell / Input / Textarea / PickerView / ImgCropper / CountTo / Segmented | |
Load corresponding sub-files directly based on the user's described issues:
| Keywords | Sub-file |
|---|---|
| Error message / Compilation error / Module not found / is not defined / Abnormal after upgrade | |
| Form / Form / schema / zodAdapter / FormRules / Validation / Required asterisk | |
| Package name / easycom / Volar / vite plugin / Internationalization / Path replacement / uni_modules | |
| Sass / Theme / Design Token / CSS variable / Style override / Dark mode / ConfigProvider | |
| Dialog / MessageBox / Empty / StatusTip / Cascader / ColPicker / Keyboard / NumberKeyboard / Button / Tag / Radio / Checkbox / Search / Grid / Fab / Badge / Slider / Tabs / Steps / Swiper / Tooltip / Popover / Collapse / Cell / Input / Textarea / PickerView / ImgCropper / CountTo / Segmented | |
核心变更速查表
Quick Reference for Core Changes
| 类型 | v1 | v2 |
|---|---|---|
| npm 包名 | | |
| uni_modules 目录 | | |
| 弹框组件 | | |
| 弹框 Hook | | |
| 缺省提示 | | |
| 多列选择器 | | |
| 数字键盘 | | |
| 表单校验 | | |
| 按钮变体 | | |
| 按钮危险色 | | |
| 标签变体 | | |
| 单选/复选形态 | | |
| 搜索框浅色样式 | | |
| GridItem 点击 | | |
| 工具函数路径 | | |
| Type | v1 | v2 |
|---|---|---|
| npm package name | | |
| uni_modules directory | | |
| Dialog component | | |
| Dialog Hook | | |
| Empty state tip | | |
| Multi-column picker | | |
| Numeric keyboard | | |
| Form validation | | |
| Button variants | | |
| Button danger color | | |
| Tag variants | | |
| Radio/Checkbox forms | | |
| Light-style search box | | |
| GridItem click event | | |
| Utility function path | | |
迁移流程
Migration Process
推荐顺序:依赖升级 → 路径替换 → Form 页面 → 高影响组件 → 中低影响组件 → 样式与主题 → 回归测试。
每完成一个阶段后与用户确认再进入下一阶段。
Recommended order: Dependency upgrade → Path replacement → Form pages → High-impact components → Medium-low impact components → Styles & themes → Regression testing.
Confirm with the user after completing each phase before proceeding to the next.
阶段一:扫描与诊断
Phase 1: Scanning & Diagnosis
-
确定用户的安装方式(还是
npm)。uni_modules -
确认项目配置:easycom、
pages.json类型声明、Vite 插件自动导入。tsconfig.json -
搜索 v1 旧用法:bash
rg "wot-design-uni|wd-message-box|useMessage|wd-status-tip|wd-col-picker|wd-number-keyboard|@itemclick|shape=|inline|\scell\b|\slight\b|type=\"error\"|type=\"icon\"|type=\"text\"|\splain\b|classPrefix|components/common/util|hide-label|hide-min-max|autoLineWidth|disabled-color|setRoate|useContentSlot|useMoreSlot|\bshow=" -
如果项目有表单,额外搜索:bash
rg "wd-form|FormRules|:rules=|rules=|errorType|resetOnChange" -
向用户汇报发现的清单,按影响程度排序:
- 高影响:Form(结构+校验体系)、Dialog(原 MessageBox)、ColPicker、NumberKeyboard
- 中影响:Button、Tag、Radio/Checkbox、Search、Grid、Fab
- 低影响:camelCase 属性名、Badge/Slider/Tabs/Steps/Swiper 等属性微调
-
Determine the user's installation method (or
npm).uni_modules -
Confirm project configurations:easycom,
pages.jsontype declarations, Vite plugin auto-import.tsconfig.json -
Search for v1 legacy usage:bash
rg "wot-design-uni|wd-message-box|useMessage|wd-status-tip|wd-col-picker|wd-number-keyboard|@itemclick|shape=|inline|\scell\b|\slight\b|type=\"error\"|type=\"icon\"|type=\"text\"|\splain\b|classPrefix|components/common/util|hide-label|hide-min-max|autoLineWidth|disabled-color|setRoate|useContentSlot|useMoreSlot|\bshow=" -
If the project has forms, additionally search:bash
rg "wd-form|FormRules|:rules=|rules=|errorType|resetOnChange" -
Report the discovered list to the user, sorted by impact level:
- High Impact: Form (structure + validation system), Dialog (formerly MessageBox), ColPicker, NumberKeyboard
- Medium Impact: Button, Tag, Radio/Checkbox, Search, Grid, Fab
- Low Impact: camelCase property names, minor property adjustments for Badge/Slider/Tabs/Steps/Swiper, etc.
阶段二:依赖与路径替换
Phase 2: Dependency & Path Replacement
详见 (包名、easycom、Volar、Vite 插件、国际化)和 (Sass 升级)。读完后回到阶段三继续。
infra.mdstyles.mdSee (package name, easycom, Volar, Vite plugin, internationalization) and (Sass upgrade). Return to Phase 3 after reading.
infra.mdstyles.md阶段三:高影响组件迁移
Phase 3: Migrate High-Impact Components
详见 (MessageBox→Dialog、StatusTip→Empty、ColPicker→Cascader、NumberKeyboard→Keyboard)。
components.mdForm 表单体系详见 。读完后回到阶段四继续。
form.mdSee (MessageBox→Dialog, StatusTip→Empty, ColPicker→Cascader, NumberKeyboard→Keyboard).
components.mdFor Form system migration, see . Return to Phase 4 after reading.
form.md阶段四:中影响组件迁移
Phase 4: Migrate Medium-Impact Components
详见 (Button、Tag、Radio/Checkbox、Search、Grid、Fab)。读完后回到阶段五继续。
components.mdSee (Button, Tag, Radio/Checkbox, Search, Grid, Fab). Return to Phase 5 after reading.
components.md阶段五:低影响属性迁移
Phase 5: Migrate Low-Impact Properties
详见 (Badge、Slider、Tabs、Steps、Swiper、Tooltip、Popover、Collapse、DatetimePickerView、ImgCropper、CountTo、Segmented、PickerView、camelCase 属性名)。读完后回到阶段六继续。
components.mdSee (Badge, Slider, Tabs, Steps, Swiper, Tooltip, Popover, Collapse, DatetimePickerView, ImgCropper, CountTo, Segmented, PickerView, camelCase property names). Return to Phase 6 after reading.
components.md阶段六:样式与主题迁移
Phase 6: Migrate Styles & Themes
详见 (主题文件引入、全局变量覆盖、ConfigProvider、样式覆盖优先级、深色模式)。读完后进入阶段七回归验证。
styles.mdSee (theme file import, global variable override, ConfigProvider, style override priority, dark mode). Proceed to Phase 7 regression verification after reading.
styles.md阶段七:回归验证
Phase 7: Regression Verification
- H5 和目标小程序端是否能正常编译
- 是否能正确解析所有
easycom组件wd-* - 、
Toast、Dialog等函数式调用是否已在页面中声明实例Notify - 表单提交、单字段校验、重置、隐藏字段和异步校验是否正常
- 选择器类表单项的回显文本和提交值是否正确
- 的
Button、type、variant和高度是否符合预期round - 的
Tag是否已从variant迁移plain - /
Radio的Checkbox、shape、inline是否已迁移cell - 的
Search是否已迁移为lightvariant="light" - 点击事件是否已从
GridItem迁移到itemclickclick - 、
Cell、Input的表单相关属性是否已迁移到Textareawd-form-item - 、
PickerView、ImgCropper等实例方法是否仍可正常调用CountTo - 、
Badge、Slider、Tabs、Steps等旧属性是否已迁移Swiper - 点击遮罩关闭、Prompt 返回值和按钮配置是否符合预期
Dialog - 深色模式、主题变量、品牌色覆盖是否生效
- 弹层在小程序端是否存在样式隔离问题
- 自定义覆盖样式是否仍然生效
- 图标名称是否仍然存在,按钮高度变化是否影响页面布局
- Can it compile normally on H5 and target mini program platforms?
- Can correctly parse all
easycomcomponents?wd-* - Have functional calls like ,
Toast,Dialogbeen declared as instances in pages?Notify - Are form submission, single-field validation, reset, hidden fields and asynchronous validation working normally?
- Are the echo text and submission value of picker-type form items correct?
- Do 's
Button,type,variantand height meet expectations?round - Has 's
Tagbeen migrated fromvariant?plain - Have /
Radio'sCheckbox,shape,inlinebeen migrated?cell - Has 's
Searchbeen migrated tolight?variant="light" - Has 's click event been migrated from
GridItemtoitemclick?click - Have form-related properties of ,
Cell,Inputbeen migrated toTextarea?wd-form-item - Can instance methods like ,
PickerView,ImgCropperstill be called normally?CountTo - Have old properties of ,
Badge,Slider,Tabs,Stepsbeen migrated?Swiper - Does 's mask click to close, Prompt return value and button configuration meet expectations?
Dialog - Are dark mode, theme variables, and brand color override taking effect?
- Are there style isolation issues with pop-ups on mini program platforms?
- Do custom override styles still take effect?
- Do icon names still exist, and does button height change affect page layout?