/* 画布标签条(自 app.js Workbench 收编,阶段一组件化 2026-11-07) * * 纯展示组件:数据与回调全部经 props 传入,不读任何 Workbench 局部状态。 * props.I 图标工厂 * props.tabIds 打开的标签(画布 id 数组,顺序即显示顺序) * props.workspaces 画布列表(取 name) * props.activeWsId 当前画布 id * props.shellView 'landing' | 'home' | 'canvas' * props.genRuns Map(只读,用于"生成中"圆点) * props.wsDoneHints { [wsId]: 'ok' | 'err' } 完成态提示(内存态) * props.goHome / switchWs / closeTab / newWs 回调 * * 约定:只读 refs 的**快照值**(genRuns / wsDoneHints 由宿主传入),不持有 refs 整体, * 避免组件与 Workbench 内部结构耦合。 */ ;(function (global) { 'use strict' const React = global.React || {} const el = (type, prop, ...children) => React.createElement(type, prop, ...children) function IWBUIWorkspaceTabs (props) { const I = props.I const tabIds = props.tabIds || [] const workspaces = props.workspaces || [] const activeWsId = props.activeWsId const shellView = props.shellView const genRuns = props.genRuns const wsDoneHints = props.wsDoneHints || {} const goHome = props.goHome const switchWs = props.switchWs const closeTab = props.closeTab const newWs = props.newWs return el('div', { className: 'iwb-tabstrip' }, // 品牌 logo(v3.25.65:从一级导航移到标签条最左;纯展示,不参与点击) el('span', { className: 'iwb-tab-logo', title: '无限画布', 'aria-hidden': 'true' }, el('span', { className: 'iwb-tab-logotext' }, 'IW'), ), el('span', { className: 'iwb-tab-sep', 'aria-hidden': 'true' }, null), // v3.25.62:旧「首页」房子按钮已删(画布库入口只保留一级导航的「首页」) // 画布标签(ti>0 前插一条分隔线) tabIds.map((wsId, ti) => { const w = workspaces.find((x) => x.id === wsId) if (!w) return null const isActive = wsId === activeWsId && shellView === 'canvas' // 非激活标签若有运行中任务显示小圆点 let hasRun = false try { for (const [, r] of (genRuns || new Map())) { if (r && r.workspaceId === wsId && r.status === 'running') { hasRun = true; break } } } catch (e) { /* ignore */ } // 完成态圆点(会话内内存态,不持久化):生成完成=绿、失败/中断=红;运行中优先显示蓝色。 // 清除时机:切到该画布(switchWs/openCanvasEditor)或该画布再次启动生成。 const dotHint = !hasRun ? (wsDoneHints[wsId] || null) : null const dotCls = hasRun ? 'iwb-tab-dot' : (dotHint === 'ok' ? 'iwb-tab-dot iwb-tab-dot-ok' : dotHint === 'err' ? 'iwb-tab-dot iwb-tab-dot-err' : null) return [ ti > 0 ? el('span', { key: wsId + '::sep', className: 'iwb-tab-sep', 'aria-hidden': 'true' }, null) : null, el('button', { key: wsId, className: 'iwb-tab' + (isActive ? ' iwb-tab-active' : ''), title: (w.name || '未命名画布') + (hasRun ? '(生成中)' : dotHint === 'ok' ? '(生成完成)' : dotHint === 'err' ? '(生成失败)' : ''), onClick: () => { if (!isActive) switchWs(wsId) }, }, el('span', { className: 'iwb-tab-label' }, w.name || '未命名画布'), dotCls ? el('span', { className: dotCls }) : null, // 关闭按钮(hover 显示) el('button', { className: 'iwb-tab-close', title: '关闭标签', onClick: (e) => { e.stopPropagation(); closeTab(wsId) } }, I('x')) ), ] }), // 画布标签组与「+ 新建」分隔(0 个标签时不加,避免与首页线叠成双线) tabIds.length ? el('span', { key: '__sep-new__', className: 'iwb-tab-sep', 'aria-hidden': 'true' }, null) : null, // + 新建 el('button', { className: 'iwb-tab iwb-tab-new', title: '新建画布', onClick: () => newWs() }, '+'), el('span', { className: 'iwb-tab-spacer' }, null), props.actions || null ) } global.IWBUIWorkspaceTabs = IWBUIWorkspaceTabs })(typeof window !== 'undefined' ? window : globalThis)