项目迁移开始日期: 2026-02-14 策略: 在新脚手架上重构,保留 v4 代码不变
总体进度: 0% (0/85)
src/types/article.ts - 文章类型定义src/types/chat.ts - 聊天类型定义src/types/search.ts - 搜索类型定义src/utils.ts - 工具函数迁移src/request.ts - HTTP 请求封装src/hooks.ts - 自定义 hooks注意事项:
src/store.ts - Store 配置src/reducers/ - 所有 29 个 reducer 文件
注意事项:
theme.ts reducer,需要适配新的主题系统src/Router.tsx - 路由配置src/layouts/anonymous/index.tsx - 匿名布局src/layouts/dashboard/index.tsx - 仪表盘布局注意事项:
BeiAn.tsx - 备案信息EditableLabel.tsx - 可编辑标签ErrorResult.tsx - 错误结果页Feedback.tsx - 反馈组件FileSize.tsx - 文件大小显示LangSelect.tsx - 语言选择器Marked.tsx - Markdown 渲染Mermaid.tsx - Mermaid 图表NetStatus.tsx - 网络状态NissayaCard.tsx & NissayaCardTable.tsx - 卡片组件ParserError.tsx - 解析错误ReadonlyLabel.tsx - 只读标签SearchButton.tsx - 搜索按钮TermTextArea.tsx & TermTextAreaMenu.tsx - 文本区域TextDiff.tsx - 文本差异对比ThemeSelect.tsx - 主题选择器 ⚠️ 需重写TimeShow.tsx - 时间显示UiLangSelect.tsx - UI 语言选择VideoModal.tsx & VideoPlayer.tsx & Video.tsx - 视频组件VisibleObserver.tsx - 可见性观察器迁移优先级:
ThemeSelect.tsx (需要重写)Account.tsx - 账户信息Avatar.tsx - 头像组件LoginAlertModal.tsx & LoginAlert.tsx - 登录提示LoginButton.tsx - 登录按钮SignInAvatar.tsx - 登录头像SoftwareEdition.tsx - 软件版本StudioCard.tsx & Studio.tsx - 工作室ToLibrary.tsx & ToStudio.tsx - 导航组件User.tsx - 用户组件你的项目大量使用 ProComponents,需要特别注意:
src/components/pro-table/* - 自定义 ProTable 组件v4 → v6 ProTable 主要变更:
// v4
<ProTable
rowKey="id"
request={async (params) => { ... }}
columns={columns}
/>
// v6 (主要兼容,但有细节调整)
<ProTable
rowKey="id"
request={async (params, sort, filter) => { ... }} // 参数顺序可能变化
columns={columns}
// 新增: cardProps, polling 等属性
/>
主要变更:
name 和 label 同时存在dependencies 写法优化主要变更:
metas 配置优化ArticleCard.tsx & 相关卡片组件ArticleEdit.tsx & 编辑相关组件ArticleList.tsx & 列表相关组件TocTree.tsx & 目录相关组件❌ v4 方式 (废弃):
/* theme/antd.dark.css */
.ant-btn-primary {
background-color: #1890ff;
}
✅ v6 方式 (使用 Design Token):
import { ConfigProvider, theme } from 'antd';
<ConfigProvider
theme={{
algorithm: theme.darkAlgorithm, // 暗黑主题
token: {
colorPrimary: '#00b96b',
borderRadius: 2,
// ... 其他 token
},
components: {
Button: {
colorPrimary: '#00b96b',
},
// ... 其他组件定制
}
}}
>
<App />
</ConfigProvider>
src/theme/antd.dark.csssrc/theme/antpro.dark.csssrc/components/theme/ThemeProvider.tsx (主题提供者)src/components/general/ThemeSelect.tsx (主题切换器)src/theme/tokens.ts (Design Token 配置)新主题系统特性:
src/assets/font/main.css - 字体样式src/components/article/article.css - 文章样式src/components/dict/style.css - 词典样式src/components/fts/search.css - 搜索样式src/components/general/style.css - 通用样式src/components/chat/style.css - 聊天样式src/components/template/style.css - 模板样式检查要点:
.ant-btn → 可能保持不变)// ✅ 基本兼容,无重大变更
<Button type="primary">Click</Button>
// ✅ 基本兼容
// ⚠️ 注意: closeIcon 属性有调整
<Tag closable onClose={handleClose}>Tag</Tag>
// ✅ 基本兼容
// 新增: classNames, styles 属性用于更细粒度控制
<Card
title="Title"
extra={<Button>More</Button>}
classNames={{ header: 'custom-header' }} // v6 新增
>
Content
</Card>
// ⚠️ 有变更
// v4
<Popover
visible={visible} // ❌ 废弃
onVisibleChange={handleChange} // ❌ 废弃
>
// v6
<Popover
open={open} // ✅ 新属性
onOpenChange={handleChange} // ✅ 新属性
>
// ⚠️ 重要变更
// v4
Modal.confirm({
title: 'Confirm',
visible: true, // ❌ 废弃
})
// v6
const [modal, contextHolder] = Modal.useModal(); // ✅ 推荐用 hook
modal.confirm({
title: 'Confirm',
open: true, // ✅ 新属性
})
// 或使用静态方法(需要包裹 App 组件)
<App>
{contextHolder}
<YourComponent />
</App>
// ⚠️ 重要变更 - 必须使用 hook 方式
// v4 (不推荐)
import { message } from 'antd';
message.success('Success');
// v6 (推荐)
import { message, App } from 'antd';
const MyComponent = () => {
const { message } = App.useApp();
const showMessage = () => {
message.success('Success');
};
return <Button onClick={showMessage}>Show</Button>;
};
// 在根组件包裹
<App>
<MyComponent />
</App>
// ⚠️ 部分 API 调整
// v4
<Form.Item
name="username"
rules={[{ required: true, message: 'Required' }]}
>
<Input />
</Form.Item>
// v6 (基本兼容,但推荐使用新 API)
<Form.Item
name="username"
rules={[{ required: true, message: 'Required' }]}
>
<Input />
</Form.Item>
// v6 新特性: Form.useWatch
const username = Form.useWatch('username', form);
// ⚠️ 分页、筛选 API 有调整
// v4
<ProTable
pagination={{
defaultCurrent: 1,
defaultPageSize: 10,
}}
onChange={(pagination, filters, sorter) => {}}
/>
// v6 (基本兼容,但有新特性)
<ProTable
pagination={{
defaultCurrent: 1,
defaultPageSize: 10,
}}
onChange={(pagination, filters, sorter, extra) => {
// extra.action: 'paginate' | 'sort' | 'filter'
}}
/>
// ⚠️ 重大变更: moment.js → dayjs
// v4
import moment from 'moment';
<DatePicker defaultValue={moment()} />
// v6
import dayjs from 'dayjs';
<DatePicker defaultValue={dayjs()} />
// 需要全局替换所有 moment 引用为 dayjs
// 问题: Property 'visible' does not exist
// 解决: 替换为 'open'
<Modal visible={true} /> // ❌
<Modal open={true} /> // ✅
// 问题: 自定义 CSS 不生效
// 解决: 检查类名是否变化,或使用 ConfigProvider
.ant-btn-custom { ... } // 可能失效
// 改用 Design Token 或 classNames API
// 问题: message.success() 不显示
// 解决: 必须包裹 <App> 组件
<App>
<YourComponent />
</App>
// 问题: @primary-color 不起作用
// 解决: 迁移到 ConfigProvider token
// v4
@primary-color: #1890ff;
// v6
<ConfigProvider theme={{ token: { colorPrimary: '#1890ff' } }}>
在每次迁移组件后,建议记录日志:
### 2026-02-14 - 迁移 ThemeSelect 组件
**迁移内容:**
- [x] 从 v4 CSS 方式改为 v6 ConfigProvider
- [x] 新增 Design Token 配置
- [x] 支持亮色/暗黑主题切换
**遇到的问题:**
1. 问题描述...
解决方案: ...
**测试结果:**
- [x] 功能正常
- [x] 样式正确
- [ ] 待补充单元测试
**备注:**
暗黑模式性能优于 v4,切换无闪烁
components/general/* 第一批组件ThemeSelect.tsx 和主题系统祝迁移顺利!🚀
有任何问题随时在本文件顶部的"迁移日志"区域记录,或咨询 AI 助手。