From 4511997d6d75e3e4d20a9ad06402317cb91d69f0 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 7 Aug 2026 14:49:50 +0800 Subject: [PATCH] Add draggable swimlane kanban template --- app/data/kanban-board.json | 60 +++++++++ app/kanban/KanbanBoard.module.css | 28 +++++ app/kanban/README.md | 16 +++ app/kanban/page.tsx | 198 ++++++++++++++++++++++++++++++ app/page.module.css | 50 ++------ app/page.tsx | 7 +- 6 files changed, 317 insertions(+), 42 deletions(-) create mode 100644 app/data/kanban-board.json create mode 100644 app/kanban/KanbanBoard.module.css create mode 100644 app/kanban/README.md create mode 100644 app/kanban/page.tsx diff --git a/app/data/kanban-board.json b/app/data/kanban-board.json new file mode 100644 index 0000000..b0dbff2 --- /dev/null +++ b/app/data/kanban-board.json @@ -0,0 +1,60 @@ +{ + "id": "BOARD-2026-08", + "name": "官网 3.0 迭代看板", + "description": "产品、设计与研发协同泳道", + "updatedAt": "2026-08-07 15:10", + "lanes": [ + { + "id": "backlog", + "title": "需求池", + "color": "gray", + "limit": 8, + "cards": [ + { "id": "WEB-142", "title": "补充客户案例筛选能力", "description": "支持按行业、区域与合作类型组合筛选", "priority": "中", "tags": ["需求", "官网"], "owner": { "name": "许言", "initial": "许", "tone": "orange" }, "dueDate": "08-18", "checklist": { "done": 1, "total": 5 }, "comments": 3, "attachments": 1 }, + { "id": "WEB-148", "title": "增加暗色主题品牌素材", "description": "整理深色背景下可使用的 Logo 与插图", "priority": "低", "tags": ["设计", "品牌"], "owner": { "name": "林知夏", "initial": "林", "tone": "blue" }, "dueDate": "08-22", "checklist": { "done": 0, "total": 4 }, "comments": 1, "attachments": 2 }, + { "id": "WEB-151", "title": "SEO 元数据管理入口", "description": "为运营提供页面级标题与描述配置", "priority": "高", "tags": ["运营", "SEO"], "owner": { "name": "陈序", "initial": "陈", "tone": "purple" }, "dueDate": "08-16", "checklist": { "done": 2, "total": 6 }, "comments": 5, "attachments": 0 } + ] + }, + { + "id": "planned", + "title": "已排期", + "color": "purple", + "limit": 5, + "cards": [ + { "id": "WEB-136", "title": "移动端导航结构调整", "description": "减少一级入口并优化触控区域", "priority": "高", "tags": ["交互", "移动端"], "owner": { "name": "林知夏", "initial": "林", "tone": "blue" }, "dueDate": "08-12", "checklist": { "done": 3, "total": 7 }, "comments": 7, "attachments": 3 }, + { "id": "WEB-139", "title": "内容卡片组件开发", "description": "覆盖文章、案例与活动三类内容", "priority": "中", "tags": ["React", "组件"], "owner": { "name": "唐可", "initial": "唐", "tone": "green" }, "dueDate": "08-14", "checklist": { "done": 2, "total": 5 }, "comments": 2, "attachments": 1 } + ] + }, + { + "id": "doing", + "title": "进行中", + "color": "blue", + "limit": 4, + "cards": [ + { "id": "WEB-128", "title": "首页首屏性能优化", "description": "压缩关键资源并减少布局偏移", "priority": "高", "tags": ["性能", "研发"], "owner": { "name": "唐可", "initial": "唐", "tone": "green" }, "dueDate": "今天", "checklist": { "done": 5, "total": 8 }, "comments": 9, "attachments": 2 }, + { "id": "WEB-132", "title": "统一按钮与标签视觉规范", "description": "同步设计变量并完成存量页面迁移", "priority": "中", "tags": ["设计系统"], "owner": { "name": "周屿", "initial": "周", "tone": "purple" }, "dueDate": "08-10", "checklist": { "done": 7, "total": 9 }, "comments": 4, "attachments": 4 }, + { "id": "WEB-134", "title": "埋点事件校对", "description": "与数据团队确认转化漏斗事件", "priority": "中", "tags": ["数据", "埋点"], "owner": { "name": "许言", "initial": "许", "tone": "orange" }, "dueDate": "08-11", "checklist": { "done": 4, "total": 6 }, "comments": 6, "attachments": 1 } + ] + }, + { + "id": "review", + "title": "待验收", + "color": "orange", + "limit": 4, + "cards": [ + { "id": "WEB-119", "title": "客户案例详情页", "description": "完成内容模型、视觉和响应式开发", "priority": "高", "tags": ["验收", "内容"], "owner": { "name": "林知夏", "initial": "林", "tone": "blue" }, "dueDate": "08-09", "checklist": { "done": 8, "total": 8 }, "comments": 12, "attachments": 5 }, + { "id": "WEB-123", "title": "站点页脚信息更新", "description": "更新办公地址、备案信息与社交链接", "priority": "低", "tags": ["内容"], "owner": { "name": "陈序", "initial": "陈", "tone": "purple" }, "dueDate": "08-08", "checklist": { "done": 4, "total": 4 }, "comments": 2, "attachments": 0 } + ] + }, + { + "id": "done", + "title": "已完成", + "color": "green", + "limit": 99, + "cards": [ + { "id": "WEB-108", "title": "全局字体加载优化", "description": "使用系统字体回退并调整字重范围", "priority": "中", "tags": ["性能"], "owner": { "name": "唐可", "initial": "唐", "tone": "green" }, "dueDate": "08-04", "checklist": { "done": 6, "total": 6 }, "comments": 3, "attachments": 1 }, + { "id": "WEB-112", "title": "404 页面视觉升级", "description": "增加快捷导航与搜索入口", "priority": "低", "tags": ["UI"], "owner": { "name": "周屿", "initial": "周", "tone": "purple" }, "dueDate": "08-05", "checklist": { "done": 3, "total": 3 }, "comments": 1, "attachments": 2 } + ] + } + ] +} diff --git a/app/kanban/KanbanBoard.module.css b/app/kanban/KanbanBoard.module.css new file mode 100644 index 0000000..609bfc8 --- /dev/null +++ b/app/kanban/KanbanBoard.module.css @@ -0,0 +1,28 @@ +.shell { --navy:#111b2e; --ink:#1b2638; --text:#435168; --muted:#8893a4; --line:#e5e9ef; --blue:#3276f6; --blueSoft:#edf4ff; --green:#20a26a; --greenSoft:#eaf8f1; --orange:#e58a20; --orangeSoft:#fff5e7; --purple:#7a57d4; --purpleSoft:#f1edfc; min-width:1040px; min-height:100vh; background:#f2f4f8; color:var(--text); font-family:Inter,"PingFang SC","Microsoft YaHei",system-ui,sans-serif; } +.sidebar { position:fixed; inset:0 auto 0 0; z-index:30; width:210px; display:flex; flex-direction:column; background:var(--navy); color:#adb8ca; } +.brand { height:70px; display:flex; align-items:center; gap:10px; padding:0 22px; color:#fff; text-decoration:none; } +.brand strong { font-size:18px; } .brand strong span { color:#72a0ff; } +.brandMark { position:relative; width:24px; height:24px; display:block; transform:rotate(-11deg); } +.brandMark i { position:absolute; bottom:1px; width:6px; border-radius:4px; background:#fff; } +.brandMark i:nth-child(1){left:0;height:12px;background:#72a0ff}.brandMark i:nth-child(2){left:8px;height:21px}.brandMark i:nth-child(3){left:16px;height:15px;background:#3276f6} +.sidebar nav { flex:1; padding:11px 13px; overflow-y:auto; } +.sidebar nav p { margin:17px 10px 7px; color:#65738b; font-size:8px; font-weight:750; letter-spacing:.8px; } +.sidebar nav a { min-height:40px; display:flex; align-items:center; gap:9px; padding:7px 10px; border-radius:8px; color:#aab5c7; cursor:pointer; text-decoration:none; font-size:10px; } +.sidebar nav a:hover{background:rgba(255,255,255,.05);color:#fff}.sidebar nav a.active{background:#2c64d7;color:#fff;box-shadow:0 5px 14px rgba(26,74,177,.25)} +.sidebar nav a>span{width:19px;text-align:center;font-size:15px}.sidebar nav a b{margin-left:auto;padding:2px 6px;border-radius:8px;background:rgba(255,255,255,.18);font-size:7px} +.sidebarProject { min-height:66px; display:flex; align-items:center; gap:9px; padding:11px 15px; border-top:1px solid #263249; } +.sidebarProject>span{width:31px;height:31px;display:grid;place-items:center;border-radius:7px;background:#2d64d8;color:#fff;font-size:10px;font-weight:800}.sidebarProject div{flex:1;display:flex;flex-direction:column;gap:3px}.sidebarProject strong{color:#dce3ef;font-size:9px}.sidebarProject small{color:#708098;font-size:7px}.sidebarProject button{border:0;background:none;color:#7c899d} +.main{min-height:100vh;margin-left:210px}.topbar{height:66px;display:flex;align-items:center;justify-content:space-between;padding:0 25px;border-bottom:1px solid var(--line);background:#fff} +.boardIdentity>div{display:flex;align-items:center;gap:10px}.boardIcon{width:34px;height:34px;display:grid;place-items:center;border-radius:8px;background:var(--blueSoft);color:var(--blue);font-size:16px}.boardIdentity div>div{display:flex;flex-direction:column;gap:3px}.boardIdentity input{width:230px;padding:0;border:0;outline:0;background:transparent;color:var(--ink);font-size:12px;font-weight:750}.boardIdentity small{color:#929baa;font-size:8px}.boardIdentity b{padding:3px 7px;border-radius:5px;background:#eef6f1;color:#438067;font-size:7px} +.topActions{display:flex;align-items:center;gap:7px}.topActions button{height:32px;padding:0 10px;border:1px solid #dce1e8;border-radius:6px;background:#fff;color:#647085;cursor:pointer;font-size:8px}.avatar,.ownerAvatar,.memberStack span{display:grid;place-items:center;border-radius:50%;font-weight:700}.avatar{width:31px;height:31px;margin-left:4px;background:#dce7fd;color:#2d61bd;font-size:9px} +.content{height:calc(100vh - 66px);display:flex;flex-direction:column;padding:24px 25px 0;overflow:hidden}.heading{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:17px}.heading p{margin:0;color:var(--blue);font-size:8px;font-weight:800;letter-spacing:.8px}.heading h1{margin:4px 0 5px;color:var(--ink);font-size:23px;letter-spacing:-.5px}.heading>div:first-child>span{color:#7f8a9c;font-size:9px}.heading>div:last-child{display:flex;gap:7px}.primaryButton,.secondaryButton{min-height:35px;padding:0 12px;border-radius:7px;cursor:pointer;font-size:8px;font-weight:650}.primaryButton{border:1px solid var(--blue);background:var(--blue);color:#fff;box-shadow:0 5px 12px rgba(50,118,246,.2)}.secondaryButton{border:1px solid #dce1e8;background:#fff;color:#627086} +.boardStats{min-height:55px;display:flex;align-items:center;gap:16px;padding:0 16px;margin-bottom:12px;border:1px solid var(--line);border-radius:9px;background:#fff}.boardStats>div:not(.memberStack){display:flex;align-items:baseline;gap:6px}.boardStats strong{color:var(--ink);font-size:15px}.boardStats div>span{color:#8691a2;font-size:8px}.boardStats>i{width:1px;height:22px;background:#e6e9ee}.memberStack{margin-left:auto;display:flex;align-items:center;padding-left:7px}.memberStack span{width:27px;height:27px;margin-left:-7px;border:2px solid #fff;font-size:7px}.memberStack b{margin-left:6px;color:#7c8798;font-size:8px} +.blue{background:var(--blueSoft)!important;color:var(--blue)!important}.purple{background:var(--purpleSoft)!important;color:var(--purple)!important}.orange{background:var(--orangeSoft)!important;color:var(--orange)!important}.green{background:var(--greenSoft)!important;color:var(--green)!important}.gray{background:#edf0f4!important;color:#687589!important} +.toolbar{min-height:48px;display:flex;align-items:center;gap:7px;padding:8px 11px;margin-bottom:12px;border:1px solid var(--line);border-radius:8px;background:#fff}.toolbar label{width:220px;height:31px;display:flex;align-items:center;gap:7px;padding:0 9px;border:1px solid #dfe3e9;border-radius:6px;color:#929baa}.toolbar label span{font-size:15px;transform:rotate(-20deg)}.toolbar input{min-width:0;flex:1;border:0;outline:0;color:#46536a;font-size:8px}.toolbar select,.toolbar button{height:31px;padding:0 9px;border:1px solid #dfe3e9;border-radius:6px;background:#fff;color:#647085;font-size:8px}.toolbar button{cursor:pointer}.toolbar>span{margin-left:auto;color:#99a1ae;font-size:7px} +.boardScroller{min-height:0;flex:1;overflow:auto;padding-bottom:20px}.board{min-width:max-content;display:flex;align-items:flex-start;gap:11px;height:100%;padding-bottom:15px}.lane{width:276px;min-height:100%;padding:0 8px 12px;border:1px solid #e1e5eb;border-radius:9px;background:#e9edf3;transition:border-color .15s,background .15s}.lane.dropActive{border:2px solid #82a6f7;background:#edf3ff}.lane>header{height:49px;display:flex;align-items:center;justify-content:space-between;padding:0 5px}.lane>header>div{display:flex;align-items:center;gap:7px}.laneDot{width:8px;height:8px;border-radius:50%}.lane>header strong{color:#344158;font-size:10px}.lane>header b{min-width:20px;padding:2px 5px;border-radius:8px;background:#d9dee7;color:#6e7a8c;font-size:7px;text-align:center}.lane>header em{padding:3px 5px;border-radius:4px;background:#feeeee;color:#dc5555;font-size:6px;font-style:normal}.lane>header button{border:0;background:none;color:#8c96a6;cursor:pointer;font-size:8px}.laneLimit{display:flex;align-items:center;gap:7px;margin:-4px 5px 9px}.laneLimit>span{flex:1;height:3px;overflow:hidden;border-radius:2px;background:#d9dee6}.laneLimit i{display:block;height:100%;border-radius:inherit;background:#8596b1}.laneLimit small{color:#8e98a8;font-size:6px}.cards{display:flex;flex-direction:column;gap:8px} +.card{padding:12px;border:1px solid #dde2e8;border-radius:8px;background:#fff;box-shadow:0 3px 8px rgba(35,48,78,.045);cursor:grab;transition:transform .15s,box-shadow .15s,opacity .15s}.card:hover{transform:translateY(-1px);box-shadow:0 8px 18px rgba(35,48,78,.09)}.card.dragging{opacity:.42;transform:rotate(2deg);cursor:grabbing}.cardTop{display:flex;align-items:center;justify-content:space-between}.cardTop button{border:0;background:none;color:#99a1ae;cursor:pointer;font-size:7px}.priority{display:inline-flex;padding:3px 6px;border-radius:4px;font-size:7px;font-weight:700}.priority_高{background:#feeeee;color:#dc5050}.priority_中{background:#fff5e8;color:#d77d15}.priority_低{background:#eef6f1;color:#438067}.cardId{display:block;margin-top:8px;color:#9da5b2;font-size:7px;font-weight:700}.card h3{margin:5px 0 6px;color:#2f3d53;font-size:10px;line-height:1.5}.card>p{margin:0 0 9px;color:#8791a1;font-size:8px;line-height:1.5}.tags{display:flex;flex-wrap:wrap;gap:4px}.tags span{padding:3px 6px;border-radius:4px;background:#f1f3f6;color:#718096;font-size:6px}.checklist{margin-top:11px;padding-top:9px;border-top:1px solid #edf0f3}.checklist>div{display:flex;justify-content:space-between;margin-bottom:5px;color:#8d96a5;font-size:7px}.checklist>span{height:4px;display:block;overflow:hidden;border-radius:3px;background:#e8ecf1}.checklist i{display:block;height:100%;border-radius:inherit;background:var(--blue)}.card footer{display:flex;align-items:center;gap:5px;margin-top:10px}.ownerAvatar{width:22px;height:22px;flex:0 0 auto;font-size:7px}.card footer strong{flex:1;color:#657187;font-size:7px;font-weight:550}.card footer>span:not(.ownerAvatar),.card footer>i{color:#929baa;font-size:6px;font-style:normal}.card footer .today{color:#dc5555!important;font-weight:700}.emptyLane{min-height:90px;display:grid;place-items:center;border:1px dashed #c4ccd8;border-radius:7px;color:#919baa;font-size:8px}.addCard{width:100%;min-height:34px;border:1px dashed #c2cad6;border-radius:7px;background:rgba(255,255,255,.4);color:#7e899a;cursor:pointer;font-size:8px}.addCard:hover{border-color:#8eaff2;color:var(--blue)}.addLane{width:155px;min-height:48px;display:flex;align-items:center;justify-content:center;gap:6px;border:1px dashed #b9c3d1;border-radius:8px;background:rgba(255,255,255,.55);color:#748195;cursor:pointer;font-size:8px}.addLane span{font-size:14px} +.drawerBackdrop,.modalBackdrop{position:fixed;inset:0;z-index:70;background:rgba(16,25,42,.45);backdrop-filter:blur(3px)}.drawer{position:absolute;inset:0 0 0 auto;width:430px;display:flex;flex-direction:column;background:#fff;box-shadow:-20px 0 60px rgba(15,24,40,.18)}.drawer header{min-height:84px;display:flex;align-items:flex-start;justify-content:space-between;padding:20px;border-bottom:1px solid var(--line)}.drawer header small{color:#9ba3b0;font-size:7px}.drawer h2{margin:5px 0 0;color:var(--ink);font-size:15px}.drawer header>button,.modal header>button{width:28px;height:28px;border:0;border-radius:50%;background:#f2f4f7;color:#778296;cursor:pointer;font-size:16px}.drawerBody{flex:1;padding:18px;overflow-y:auto}.moveSelect{display:flex;flex-direction:column;gap:7px;padding:12px;border:1px solid #dbe5fa;border-radius:8px;background:#f6f9ff;color:#526078;font-size:8px;font-weight:700}.moveSelect select{height:34px;padding:0 9px;border:1px solid #bfd0f4;border-radius:6px;background:#fff;color:#3f4d62;font-size:8px}.drawer section{margin-top:21px}.drawer section h3{margin:0 0 9px;color:#4b586d;font-size:9px}.descriptionBox{margin:0;padding:11px;border:1px solid var(--line);border-radius:7px;background:#fafbfc;color:#6d798c;font-size:8px;line-height:1.7}.drawer dl{margin:0;padding:2px 11px;border:1px solid var(--line);border-radius:8px}.drawer dl>div{min-height:42px;display:grid;grid-template-columns:88px 1fr;align-items:center;border-bottom:1px solid #edf0f4}.drawer dl>div:last-child{border-bottom:0}.drawer dt{color:#929baa;font-size:8px}.drawer dd{display:flex;align-items:center;gap:6px;margin:0;color:#566378;font-size:8px}.checkItem{min-height:36px;display:flex;align-items:center;gap:7px;border-bottom:1px solid #edf0f4;color:#5e6b7e;font-size:8px}.checkItem input{accent-color:var(--blue)}.activityItem{display:flex;gap:8px}.activityItem p{display:flex;flex-direction:column;gap:3px;margin:0;color:#6c788b;font-size:8px}.activityItem p strong{color:#435168}.activityItem p small{color:#9ca4b1;font-size:7px}.drawer>footer{display:flex;justify-content:flex-end;gap:7px;padding:13px 18px;border-top:1px solid var(--line)}.drawer>footer button,.modal footer button{min-height:34px;padding:0 12px;border:1px solid #dce1e8;border-radius:6px;background:#fff;color:#647085;cursor:pointer;font-size:8px}.drawer>footer button:last-child,.modal footer button:last-child{border-color:var(--blue);background:var(--blue);color:#fff} +.activityDrawer{width:370px}.moveActivity{display:flex;gap:10px;padding:12px 0;border-bottom:1px solid #edf0f4}.moveActivity>span{width:27px;height:27px;display:grid;place-items:center;flex:0 0 auto;border-radius:50%;background:var(--blueSoft);color:var(--blue)}.moveActivity p{display:flex;flex-direction:column;gap:4px;margin:0;color:#687589;font-size:8px;line-height:1.5}.moveActivity strong{color:#3f4d62}.moveActivity small{color:#9aa3b1;font-size:7px}.modalBackdrop{display:grid;place-items:center;padding:20px}.modal{width:480px;padding:21px;border-radius:12px;background:#fff;box-shadow:0 25px 70px rgba(15,24,40,.25)}.modal header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:20px}.modal h2{margin:0 0 4px;color:var(--ink);font-size:15px}.modal header p{margin:0;color:#929baa;font-size:8px}.modal>label{display:flex;flex-direction:column;gap:7px;margin-bottom:14px;color:#566378;font-size:8px;font-weight:650}.modal input,.modal select{width:100%;height:36px;padding:0 10px;border:1px solid #dde2e8;border-radius:6px;outline:0;background:#fff;color:#46536a;font-size:9px}.modal input:focus,.modal select:focus{border-color:#8fb0f7;box-shadow:0 0 0 3px rgba(50,118,246,.08)}.modal fieldset{display:flex;gap:18px;margin:0 0 15px;padding:12px;border:1px solid #e0e4ea;border-radius:7px}.modal legend{padding:0 4px;color:#566378;font-size:8px;font-weight:650}.modal fieldset label{display:flex;align-items:center;gap:5px;color:#687589;font-size:8px}.modal fieldset input{width:13px;height:13px;accent-color:var(--blue)}.modal footer{display:flex;justify-content:flex-end;gap:7px;padding-top:15px;border-top:1px solid var(--line)} +.toast{position:fixed;right:22px;bottom:22px;z-index:90;min-width:220px;display:flex;align-items:center;gap:8px;padding:11px 13px;border:1px solid #dce3eb;border-radius:8px;background:#fff;box-shadow:0 15px 35px rgba(23,35,58,.16);color:#4c596d;font-size:8px;animation:toastIn .2s ease-out}.toast span{width:18px;height:18px;display:grid;place-items:center;border-radius:50%;background:var(--greenSoft);color:var(--green);font-weight:800}@keyframes toastIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}} +@media(max-width:1180px){.content{padding-right:17px;padding-left:17px}.heading{align-items:flex-start;flex-direction:column}.toolbar{overflow-x:auto}.toolbar>span{display:none}} +@media(prefers-reduced-motion:reduce){.card,.lane,.toast{transition:none;animation:none}} diff --git a/app/kanban/README.md b/app/kanban/README.md new file mode 100644 index 0000000..d387dc4 --- /dev/null +++ b/app/kanban/README.md @@ -0,0 +1,16 @@ +# 泳道看板模板 + +访问 `/kanban` 查看看板。初始数据来自 `app/data/kanban-board.json`,卡片和泳道变更会保存到浏览器的 `orbit-kanban-board` 本地存储项。 + +包含功能: + +- 卡片在泳道之间拖放 +- 详情侧栏中的“移动到”选择器 +- 泳道 WIP 卡片上限与超限提示 +- 新建卡片和自定义泳道 +- 搜索、优先级和负责人筛选 +- 检查项、评论、附件和负责人信息 +- 卡片移动动态记录 +- 一键恢复 JSON 示例数据 + +接入真实业务时,可保留 `Lane`、`Card` 数据结构并将状态更新替换为接口调用。 diff --git a/app/kanban/page.tsx b/app/kanban/page.tsx new file mode 100644 index 0000000..8b8c815 --- /dev/null +++ b/app/kanban/page.tsx @@ -0,0 +1,198 @@ +"use client"; + +import Link from "next/link"; +import { useEffect, useMemo, useState } from "react"; +import boardData from "../data/kanban-board.json"; +import styles from "./KanbanBoard.module.css"; + +type Card = { + id: string; + title: string; + description: string; + priority: string; + tags: string[]; + owner: { name: string; initial: string; tone: string }; + dueDate: string; + checklist: { done: number; total: number }; + comments: number; + attachments: number; +}; + +type Lane = { id: string; title: string; color: string; limit: number; cards: Card[] }; +type Board = { id: string; name: string; description: string; updatedAt: string; lanes: Lane[] }; +type Activity = { id: number; card: string; from: string; to: string; time: string }; + +const initialBoard = boardData as Board; + +export default function KanbanPage() { + const [board, setBoard] = useState(initialBoard); + const [dragging, setDragging] = useState<{ cardId: string; laneId: string } | null>(null); + const [dropLane, setDropLane] = useState(null); + const [search, setSearch] = useState(""); + const [priority, setPriority] = useState("全部优先级"); + const [owner, setOwner] = useState("全部成员"); + const [selectedCard, setSelectedCard] = useState<{ card: Card; laneId: string } | null>(null); + const [createOpen, setCreateOpen] = useState(false); + const [laneOpen, setLaneOpen] = useState(false); + const [activityOpen, setActivityOpen] = useState(false); + const [toast, setToast] = useState(""); + const [activities, setActivities] = useState([ + { id: 1, card: "WEB-119", from: "进行中", to: "待验收", time: "今天 14:26" }, + { id: 2, card: "WEB-108", from: "待验收", to: "已完成", time: "今天 11:08" }, + ]); + + useEffect(() => { + const saved = window.localStorage.getItem("orbit-kanban-board"); + if (saved) { + try { setBoard(JSON.parse(saved)); } + catch { window.localStorage.removeItem("orbit-kanban-board"); } + } + }, []); + + useEffect(() => { + window.localStorage.setItem("orbit-kanban-board", JSON.stringify(board)); + }, [board]); + + const allCards = useMemo(() => board.lanes.flatMap((lane) => lane.cards.map((card) => ({ card, laneId: lane.id }))), [board]); + const owners = useMemo(() => Array.from(new Set(allCards.map(({ card }) => card.owner.name))), [allCards]); + const completed = board.lanes.find((lane) => lane.id === "done")?.cards.length ?? 0; + + const notify = (message: string) => { + setToast(message); + window.setTimeout(() => setToast(""), 2300); + }; + + const moveCard = (cardId: string, fromLaneId: string, targetLaneId: string) => { + if (fromLaneId === targetLaneId) { setDragging(null); setDropLane(null); return; } + const target = board.lanes.find((lane) => lane.id === targetLaneId); + if (!target) return; + if (target.cards.length >= target.limit) { + notify(`“${target.title}”已达到 ${target.limit} 张卡片上限`); + setDragging(null); setDropLane(null); return; + } + const from = board.lanes.find((lane) => lane.id === fromLaneId); + const card = from?.cards.find((item) => item.id === cardId); + if (!card || !from) return; + setBoard((current) => ({ + ...current, + updatedAt: new Date().toLocaleString("zh-CN", { hour12: false }), + lanes: current.lanes.map((lane) => { + if (lane.id === fromLaneId) return { ...lane, cards: lane.cards.filter((item) => item.id !== cardId) }; + if (lane.id === targetLaneId) return { ...lane, cards: [...lane.cards, card] }; + return lane; + }), + })); + setActivities((current) => [{ id: Date.now(), card: card.id, from: from.title, to: target.title, time: "刚刚" }, ...current].slice(0, 8)); + setSelectedCard((current) => current?.card.id === cardId ? { card, laneId: targetLaneId } : current); + setDragging(null); setDropLane(null); + notify(`已将 ${card.id} 移动到“${target.title}”`); + }; + + const createCard = (title: string, laneId: string, cardPriority: string) => { + const lane = board.lanes.find((item) => item.id === laneId); + if (!lane || lane.cards.length >= lane.limit) return notify("目标泳道已达到卡片上限"); + const card: Card = { id: `WEB-${String(Date.now()).slice(-3)}`, title, description: "点击卡片可继续补充任务说明", priority: cardPriority, tags: ["新任务"], owner: { name: "林知夏", initial: "林", tone: "blue" }, dueDate: "08-21", checklist: { done: 0, total: 4 }, comments: 0, attachments: 0 }; + setBoard((current) => ({ ...current, lanes: current.lanes.map((item) => item.id === laneId ? { ...item, cards: [...item.cards, card] } : item) })); + setCreateOpen(false); notify("新卡片已添加"); + }; + + const createLane = (title: string, limit: number) => { + const colors = ["blue", "purple", "orange", "green", "gray"]; + setBoard((current) => ({ ...current, lanes: [...current.lanes, { id: `lane-${Date.now()}`, title, limit, color: colors[current.lanes.length % colors.length], cards: [] }] })); + setLaneOpen(false); notify("新泳道已创建"); + }; + + const resetBoard = () => { + setBoard(initialBoard); + window.localStorage.removeItem("orbit-kanban-board"); + notify("已恢复 JSON 示例看板"); + }; + + return ( +
+ + +
+
+
setBoard((current) => ({ ...current, name: event.target.value }))} aria-label="看板名称" />{board.description}
团队可见
+
+
+ +
+
+

SPRINT 08 · 8 月 4 日 — 8 月 18 日

产品迭代泳道

拖动卡片即可更新工作状态,所有变更自动保存在浏览器。
+
+
+ +
+
{allCards.length}全部卡片
{board.lanes.find((lane) => lane.id === "doing")?.cards.length ?? 0}进行中
{completed}已完成
{Math.round((completed / allCards.length) * 100)}%迭代完成率
+
+5
+
+ +
+ + + + + 最近更新:{board.updatedAt} +
+ +
+
+ {board.lanes.map((lane) => { + const visible = lane.cards.filter((card) => (!search || `${card.title}${card.id}`.toLowerCase().includes(search.toLowerCase())) && (priority === "全部优先级" || card.priority === priority) && (owner === "全部成员" || card.owner.name === owner)); + const atLimit = lane.cards.length >= lane.limit; + return ( +
{ event.preventDefault(); setDropLane(lane.id); }} onDragLeave={(event) => { if (!event.currentTarget.contains(event.relatedTarget as Node)) setDropLane(null); }} onDrop={(event) => { event.preventDefault(); if (dragging) moveCard(dragging.cardId, dragging.laneId, lane.id); }}> +
{lane.title}{lane.cards.length}{atLimit && lane.limit < 90 && 已达上限}
+
WIP {lane.cards.length} / {lane.limit}
+
+ {visible.map((card) => setDragging({ cardId: card.id, laneId: lane.id })} onDragEnd={() => { setDragging(null); setDropLane(null); }} onOpen={() => setSelectedCard({ card, laneId: lane.id })} />)} + {visible.length === 0 &&
{dragging ? "松开鼠标移动到这里" : "暂无匹配卡片"}
} + +
+
+ ); + })} + +
+
+
+
+ + {selectedCard && setSelectedCard(null)} onMove={(target) => moveCard(selectedCard.card.id, selectedCard.laneId, target)} notify={notify} />} + {createOpen && setCreateOpen(false)} onCreate={createCard} />} + {laneOpen && setLaneOpen(false)} onCreate={createLane} />} + {activityOpen && setActivityOpen(false)} />} + {toast &&
{toast}
} +
+ ); +} + +function KanbanCard({ card, laneId, dragging, onDragStart, onDragEnd, onOpen }: { card: Card; laneId: string; dragging: boolean; onDragStart: () => void; onDragEnd: () => void; onOpen: () => void }) { + const percent = Math.round((card.checklist.done / card.checklist.total) * 100); + return
{ event.dataTransfer.effectAllowed = "move"; event.dataTransfer.setData("text/plain", `${laneId}:${card.id}`); onDragStart(); }} onDragEnd={onDragEnd} onClick={onOpen}>
{card.priority === "高" ? "↑ 高" : card.priority === "低" ? "↓ 低" : "= 中"}
{card.id}

{card.title}

{card.description}

{card.tags.map((tag) => {tag})}
检查项{card.checklist.done}/{card.checklist.total}
{card.owner.initial}{card.owner.name}◷ {card.dueDate}☵ {card.comments}⌕ {card.attachments}
; +} + +function CardDrawer({ selected, lanes, onClose, onMove, notify }: { selected: { card: Card; laneId: string }; lanes: Lane[]; onClose: () => void; onMove: (laneId: string) => void; notify: (message: string) => void }) { + const { card, laneId } = selected; + return
; +} + +function CardModal({ lanes, onClose, onCreate }: { lanes: Lane[]; onClose: () => void; onCreate: (title: string, laneId: string, priority: string) => void }) { + const [title, setTitle] = useState(""); const [laneId, setLaneId] = useState(lanes[0]?.id ?? ""); const [priority, setPriority] = useState("中"); + return
event.stopPropagation()} onSubmit={(event) => { event.preventDefault(); if (title.trim()) onCreate(title.trim(), laneId, priority); }}>

新建看板卡片

创建后可直接拖动到其他泳道。

优先级{["高", "中", "低"].map((value) => )}
; +} + +function LaneModal({ onClose, onCreate }: { onClose: () => void; onCreate: (title: string, limit: number) => void }) { + const [title, setTitle] = useState(""); const [limit, setLimit] = useState(5); + return
event.stopPropagation()} onSubmit={(event) => { event.preventDefault(); if (title.trim()) onCreate(title.trim(), limit); }}>

新建泳道

设置泳道名称和在制品上限。

; +} + +function ActivityDrawer({ activities, onClose }: { activities: Activity[]; onClose: () => void }) { + return
; +} diff --git a/app/page.module.css b/app/page.module.css index 9b4a9e7..8130b88 100644 --- a/app/page.module.css +++ b/app/page.module.css @@ -1,41 +1,9 @@ -.launcherStack { - position: fixed; - right: 26px; - bottom: 26px; - z-index: 45; - display: flex; - flex-direction: column; - gap: 10px; -} - -.launcher { - width: 208px; - min-height: 61px; - display: flex; - align-items: center; - gap: 11px; - padding: 9px 12px; - border: 1px solid; - border-radius: 12px; - box-shadow: 0 15px 32px rgba(30, 49, 86, .22); - color: white; - text-decoration: none; - transition: transform .18s ease, background .18s ease; -} -.launcher:hover { transform: translateY(-2px); } -.approval { border-color: #295fcf; background: #3276f6; } -.approval:hover { background: #215ecb; } -.worklist { border-color: #273a59; background: #17263d; } -.worklist:hover { background: #223655; } -.launcherIcon { width: 35px; height: 35px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: rgba(255,255,255,.14); font-size: 17px; } -.launcher > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; gap: 3px; } -.launcher strong { font-size: 11px; } -.launcher small { color: rgba(255,255,255,.7); font-size: 8px; } -.launcher b { font-size: 16px; } - -@media (max-width: 620px) { - .launcherStack { right: 14px; bottom: 14px; gap: 8px; } - .launcher { width: 52px; min-height: 52px; padding: 8px; border-radius: 50%; } - .launcher > span:nth-child(2), .launcher b { display: none; } - .launcherIcon { width: 34px; height: 34px; background: transparent; } -} +.launcherStack { position:fixed; right:26px; bottom:26px; z-index:45; display:flex; flex-direction:column; gap:9px; } +.launcher { width:208px; min-height:58px; display:flex; align-items:center; gap:10px; padding:8px 11px; border:1px solid; border-radius:11px; box-shadow:0 14px 30px rgba(30,49,86,.21); color:#fff; text-decoration:none; transition:transform .18s ease,background .18s ease; } +.launcher:hover { transform:translateY(-2px); } +.approval { border-color:#295fcf; background:#3276f6; }.approval:hover{background:#215ecb} +.worklist { border-color:#273a59; background:#17263d; }.worklist:hover{background:#223655} +.kanban { border-color:#47734f; background:#28613e; }.kanban:hover{background:#1d5032} +.launcherIcon { width:34px; height:34px; display:grid; place-items:center; flex:0 0 auto; border-radius:8px; background:rgba(255,255,255,.14); font-size:16px; } +.launcher>span:nth-child(2){display:flex;flex:1;flex-direction:column;gap:3px}.launcher strong{font-size:11px}.launcher small{color:rgba(255,255,255,.7);font-size:8px}.launcher b{font-size:15px} +@media(max-width:620px){.launcherStack{right:14px;bottom:14px;gap:7px}.launcher{width:50px;min-height:50px;padding:8px;border-radius:50%}.launcher>span:nth-child(2),.launcher b{display:none}.launcherIcon{width:32px;height:32px;background:transparent}} diff --git a/app/page.tsx b/app/page.tsx index a9dce37..2be124a 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -2,12 +2,17 @@ import Link from "next/link"; import AdminApp from "./AdminApp"; import styles from "./page.module.css"; -// AdminApp owns the localStorage-backed template interactions. +// Feature routes use localStorage-backed JSON demo data. export default function Home() { return ( <>