From 2c97bac0923dfd01d8f346c481a3faf1c03a3158 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 11 Sep 2026 13:02:11 +0800 Subject: [PATCH] =?utf8?q?=E7=AB=99=E7=82=B9=E5=88=97=E8=A1=A8=E8=A1=A8?= =?utf8?q?=E6=A0=BC=E5=90=84=E5=88=97=E6=94=AF=E6=8C=81=E6=89=8B=E5=8A=A8?= =?utf8?q?=E6=8B=96=E5=8A=A8=E8=B0=83=E6=95=B4=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- app/globals.css | 6 ++++++ app/page.tsx | 29 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/globals.css b/app/globals.css index 2bcb140..e2bdc19 100644 --- a/app/globals.css +++ b/app/globals.css @@ -76,6 +76,12 @@ .data-table input:focus,.data-table select:focus,.data-table textarea:focus{border-color:var(--blue);outline:none} .data-table .number{width:100%;text-align:right} .data-table input::placeholder{color:#b9bfc3} +/* 站点列表:列宽可手动拖动调整(拖拽表头右缘的分隔条) */ +.data-table.resizable-cols{table-layout:fixed;width:100%} +.data-table.resizable-cols th{position:relative} +.data-table .col-resizer{position:absolute;top:0;right:0;width:6px;height:100%;cursor:col-resize;z-index:2;user-select:none} +.data-table .col-resizer::after{content:"";position:absolute;top:0;right:2px;width:2px;height:100%;background:transparent} +.data-table .col-resizer:hover::after,.data-table .col-resizer.active::after{background:var(--blue)} /* 可编辑表格使用固定列宽,避免输入框在自动布局下被压窄(设备类型框变窄的 BUG) */ .data-table.editable{table-layout:fixed} .data-table.editable th:nth-child(1){width:40%} diff --git a/app/page.tsx b/app/page.tsx index 67135cf..de8d92a 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -740,6 +740,33 @@ function Projects({view,setView,sites,loading,go,loadSite,notify,onDelete,onCrea const batchDelete = async ()=>{ await onDelete([...selected]); setSelected(new Set()); }; const statusText=(status:string)=>status==="generated"?"生成完成":status==="partial"?"部分失败":status==="running"?"生成中":"草稿"; const openProject=(row:SiteSummary)=>go("siteEdit",row.id); + const [colWidths,setColWidths]=useState<(number|null)[]>([34,null,110,90,90,90,90,150,90]); + const resizing=useRef<{idx:number;startX:number;startW:number}|null>(null); + const startResize=(idx:number)=>(e:React.MouseEvent)=>{ + e.preventDefault(); e.stopPropagation(); + const th=e.currentTarget.parentElement as HTMLTableCellElement|null; + if(!th) return; + const startW=th.getBoundingClientRect().width; + resizing.current={idx,startX:e.clientX,startW}; + const onMove=(ev:MouseEvent)=>{ + if(!resizing.current) return; + const dx=ev.clientX-resizing.current.startX; + const newW=Math.max(40, Math.round(resizing.current.startW+dx)); + const i=resizing.current.idx; + setColWidths(prev=>{ const n=[...prev]; n[i]=newW; return n; }); + }; + const onUp=()=>{ + resizing.current=null; + document.removeEventListener("mousemove",onMove); + document.removeEventListener("mouseup",onUp); + document.body.style.userSelect=""; + (document.querySelector(".data-table .col-resizer.active") as HTMLElement|null)?.classList.remove("active"); + }; + document.addEventListener("mousemove",onMove); + document.addEventListener("mouseup",onUp); + document.body.style.userSelect="none"; + (e.currentTarget as HTMLElement).classList.add("active"); + }; const [collapsed,setCollapsed]=useState>(new Set()); const toggleCollapse=(id:number)=>setCollapsed(prev=>{ const n=new Set(prev); if(n.has(id)) n.delete(id); else n.add(id); return n; }); const childMap=useMemo(()=>{ @@ -809,7 +836,7 @@ function Projects({view,setView,sites,loading,go,loadSite,notify,onDelete,onCrea
{selected.size>0&&}
- {buildRows(0,0)}
站点名称所属领域设备数量MU 页面Cube 页面状态最近修改操作
+ {colWidths.map((w,i)=>)}{["站点名称","所属领域","设备数量","MU 页面","Cube 页面","状态","最近修改"].map((label,i)=>)}{buildRows(0,0)}
{label}操作
{visibleIds.size===0&&
没有符合条件的站点
}
{visibleIds.size} / 总数
-- 2.43.0