Epic: E0 - 项目基础设施
Story ID: E0-S6
版本: 1.0.0
日期: 2025-01-11
优先级: 中
预计工时: 5-7 天
作为个人投资者,
我希望在手机上也能查看和管理我的资产配置,
以便随时随地了解资产状况,不受设备限制。
| 方面 | 现状 | 问题 |
| 窗口尺寸 | 固定 1440×900,最小 1280×720 | 不支持移动端 |
| 侧边栏 | 固定 220px 宽度 | 小屏幕占用过多空间 |
| 布局方式 | 内联样式,固定像素值 | 无响应式断点 |
| 导航模式 | 左侧固定侧边栏 | 移动端需要底部导航或抽屉 |
| 设备类型 | 屏幕宽度 | 导航模式 | 布局特点 |
| 桌面端 | ≥1024px | 左侧固定侧边栏 | 多列布局,保持现有体验 |
| 平板端 | 768-1023px | 可折叠侧边栏 | 自适应列数 |
| 移动端 | <768px | 底部导航栏 | 单列布局,卡片堆叠 |
#![allow(unused)]
fn main() {
// src/utils/responsive.rs
/// 响应式断点
pub enum Breakpoint {
Mobile, // < 768px
Tablet, // 768-1023px
Desktop, // ≥ 1024px
}
/// 根据窗口宽度获取当前断点
pub fn get_breakpoint(width: u32) -> Breakpoint {
match width {
w if w < 768 => Breakpoint::Mobile,
w if w < 1024 => Breakpoint::Tablet,
_ => Breakpoint::Desktop,
}
}
}
#![allow(unused)]
fn main() {
// src/components/layout/app_layout.rs
#[component]
pub fn AppLayout() -> Element {
let window_size = use_window_size(); // 需要实现
let breakpoint = get_breakpoint(window_size.width);
rsx! {
div {
class: "app-container",
style: "display: flex; flex-direction: column; height: 100vh;",
match breakpoint {
Breakpoint::Desktop | Breakpoint::Tablet => rsx! {
div {
style: "display: flex; flex: 1;",
Sidebar { collapsible: breakpoint == Breakpoint::Tablet }
main {
style: "flex: 1; overflow: auto;",
Outlet::<Route> {}
}
}
},
Breakpoint::Mobile => rsx! {
main {
style: "flex: 1; overflow: auto; padding-bottom: 60px;",
Outlet::<Route> {}
}
BottomNavBar {}
}
}
}
}
}
}
#![allow(unused)]
fn main() {
// src/components/layout/bottom_nav.rs
#[component]
pub fn BottomNavBar() -> Element {
rsx! {
nav {
style: r#"
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 60px;
background: #1e1e2e;
display: flex;
justify-content: space-around;
align-items: center;
border-top: 1px solid #313244;
z-index: 1000;
"#,
BottomNavItem { to: Route::HomePage {}, icon: "📊", label: "首页" }
BottomNavItem { to: Route::AssetsPage {}, icon: "💰", label: "资产" }
BottomNavItem { to: Route::HistoryPage {}, icon: "📅", label: "历史" }
BottomNavItem { to: Route::PlansPage {}, icon: "🎯", label: "配置" }
BottomNavItem { to: Route::AnalysisPage {}, icon: "📈", label: "收益" }
}
}
}
}
| 组件 | 文件路径 | 改造内容 | 优先级 |
| Sidebar | layout/sidebar.rs | 支持折叠、移动端隐藏 | P0 |
| AppLayout | layout/mod.rs | 添加断点检测、切换布局 | P0 |
| BottomNavBar | layout/bottom_nav.rs | 新建 移动端导航 | P0 |
| 组件 | 文件路径 | 改造内容 | 优先级 |
| StatCard | dashboard/stat_card.rs | 移动端全宽显示 | P1 |
| PieChart | dashboard/pie_chart.rs | 调整图表尺寸 | P1 |
| DeviationTable | dashboard/deviation_table.rs | 移动端改为卡片列表 | P1 |
| QuickActions | dashboard/quick_actions.rs | 移动端网格布局 | P2 |
| 组件 | 文件路径 | 改造内容 | 优先级 |
| AssetList | asset/asset_list.rs | 移动端单列 | P1 |
| AssetItem | asset/asset_item.rs | 紧凑布局 | P1 |
| AssetForm | asset/asset_form.rs | 全屏弹窗/页面 | P1 |
| CategoryGroup | asset/category_group.rs | 折叠卡片 | P2 |
| 组件 | 文件路径 | 改造内容 | 优先级 |
| SnapshotTimeline | snapshot/snapshot_timeline.rs | 垂直时间线 | P1 |
| SnapshotCard | snapshot/snapshot_card.rs | 全宽卡片 | P1 |
| SnapshotDetail | snapshot/snapshot_detail.rs | 堆叠布局 | P1 |
| InventoryMode | snapshot/inventory_mode.rs | 移动端优化 | P2 |
| 组件 | 文件路径 | 改造内容 | 优先级 |
| PlanList | plan/plan_list.rs | 卡片列表 | P1 |
| PlanCard | plan/plan_card.rs | 紧凑布局 | P1 |
| PlanEditor | plan/plan_editor.rs | 全屏编辑 | P1 |
| 组件 | 文件路径 | 改造内容 | 优先级 |
| PeriodSelector | analysis/period_selector.rs | 下拉选择 | P1 |
| ReturnCard | analysis/return_card.rs | 全宽显示 | P1 |
| TrendChart | analysis/trend_chart.rs | 自适应宽度 | P1 |
| AttributionTable | analysis/attribution_table.rs | 卡片化 | P2 |
| 组件 | 文件路径 | 改造内容 | 优先级 |
| Modal | common/modal.rs | 移动端全屏 | P0 |
| Card | common/card.rs | 响应式内边距 | P1 |
| Button | common/button.rs | 移动端更大触控区 | P2 |
| Input | common/input.rs | 移动端更大输入框 | P2 |
| 任务 ID | 任务描述 | 文件/路径 | 预计工时 |
| T6-1-1 | 创建响应式工具模块 | src/utils/responsive.rs | 0.25d |
| T6-1-2 | 实现窗口尺寸监听 Hook | src/utils/use_window_size.rs | 0.5d |
| T6-1-3 | 更新 Dioxus.toml 移除最小窗口限制 | Dioxus.toml | 0.1d |
| T6-1-4 | 创建 AppLayout 组件 | src/components/layout/app_layout.rs | 0.5d |
| T6-1-5 | 创建 BottomNavBar 组件 | src/components/layout/bottom_nav.rs | 0.5d |
| T6-1-6 | 改造 Sidebar 支持折叠 | src/components/layout/sidebar.rs | 0.5d |
| T6-1-7 | 改造 Modal 移动端全屏 | src/components/common/modal.rs | 0.25d |
| 任务 ID | 任务描述 | 文件/路径 | 预计工时 |
| T6-2-1 | 首页 Dashboard 响应式 | src/pages/home.rs + dashboard/* | 0.5d |
| T6-2-2 | 资产页响应式 | src/pages/assets.rs + asset/* | 0.5d |
| T6-2-3 | 历史页响应式 | src/pages/history.rs + snapshot/* | 0.5d |
| T6-2-4 | 配置页响应式 | src/pages/plans.rs + plan/* | 0.5d |
| T6-2-5 | 收益页响应式 | src/pages/analysis.rs + analysis/* | 0.5d |
| 任务 ID | 任务描述 | 文件/路径 | 预计工时 |
| T6-3-1 | 通用组件触控优化 | src/components/common/* | 0.5d |
| T6-3-2 | 表格移动端卡片化 | 各表格组件 | 0.5d |
| T6-3-3 | 多设备测试与调整 | - | 0.5d |
[application]
name = "asset-light"
default_platform = "desktop"
[desktop]
title = "asset-light - 个人资产管理"
[desktop.window]
title = "asset-light"
width = 1440
height = 900
# 移除最小尺寸限制以支持窗口缩放测试
# min_width = 1280
# min_height = 720
resizable = true
decorations = true
┌────────────────────────────────────┐
│ 📊 💰 📅 🎯 📈 │
│ 首页 资产 历史 配置 收益 │
└────────────────────────────────────┘
┌──────────────────────┐
│ 总资产: ¥1,234,567 │
├──────────────────────┤
│ ┌────┐ ┌────┐ │
│ │现金│ │权益│ ... │ ← 统计卡片横向滚动
│ └────┘ └────┘ │
├──────────────────────┤
│ [饼图 - 资产分布] │
├──────────────────────┤
│ 配置偏离 ▼ │
│ ├ 现金类 +5.2% │
│ ├ 权益类 -3.1% │
│ └ 固收类 -2.1% │
├──────────────────────┤
│ 📊 💰 📅 🎯 📈 │ ← 底部导航
└──────────────────────┘
完成响应式改造后,可进一步:
- iOS/Android 打包:使用 Dioxus Mobile 或 Tauri 2.0
- PWA 支持:编译为 Web 版本,支持离线使用
- 手势交互:左滑删除、下拉刷新等移动端交互
| 版本 | 日期 | 作者 | 变更说明 |
| 1.0.0 | 2025-01-11 | Leon | 创建响应式设计用户故事 |