From 5c972b70c4fb919fa2339d16cbf235d5655b42b8 Mon Sep 17 00:00:00 2001 From: kim Date: Sat, 31 Oct 2026 00:08:04 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=91=EC=97=85=EC=8B=A4=EC=97=90=20PCB=20?= =?UTF-8?q?=ED=83=AD=20=E2=80=94=20=EC=9E=91=EC=97=85=EC=8B=A4=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EC=A0=9D=ED=8A=B8=EC=97=90=20=EC=97=B0=EA=B2=B0?= =?UTF-8?q?=EB=90=9C=20PCB=20=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8=EB=A5=BC?= =?UTF-8?q?=20iframe=EC=9C=BC=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PCB 프로젝트 목록(`/api/pcb/projects`)에 workshopId를 포함(project.json의 workshopId). - 작업실 화면에 "🔌 PCB" 탭: 이 작업실 프로젝트와 workshopId가 같은 PCB 프로젝트가 있으면 그걸(`?p=`), 없으면 마지막으로 연 것을 pcb-app.html로 띄운다. Co-Authored-By: Claude Sonnet 5.5 --- src/tools/pcb/projects.ts | 8 ++++---- web-ui/html/workshop-app.html | 3 +++ web-ui/js/app/workshop-core.js | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/tools/pcb/projects.ts b/src/tools/pcb/projects.ts index 113cca8..05a14ad 100644 --- a/src/tools/pcb/projects.ts +++ b/src/tools/pcb/projects.ts @@ -23,17 +23,17 @@ export class PcbProjects { return d; } - list(): { name: string; updated: number; parts: number; nets: number; routed: boolean; gcode: boolean }[] { + list(): { name: string; updated: number; parts: number; nets: number; routed: boolean; gcode: boolean; workshopId: string }[] { if (!fs.existsSync(this.root)) return []; const out = []; for (const e of fs.readdirSync(this.root, { withFileTypes: true })) { if (!e.isDirectory() || e.name.startsWith('.')) continue; const f = path.join(this.root, e.name, 'project.json'); if (!fs.existsSync(f)) continue; - let parts = 0, nets = 0, routed = false; - try { const j = JSON.parse(fs.readFileSync(f, 'utf8')); parts = j.parts?.length || 0; nets = j.nets?.length || 0; routed = !!(j.routed && j.routed.traces?.length); } catch { /* 깨진 파일은 목록에서 0으로 */ } + let parts = 0, nets = 0, routed = false, workshopId = ''; + try { const j = JSON.parse(fs.readFileSync(f, 'utf8')); parts = j.parts?.length || 0; nets = j.nets?.length || 0; routed = !!(j.routed && j.routed.traces?.length); workshopId = String(j.workshopId || ''); } catch { /* 깨진 파일은 목록에서 0으로 */ } const g = path.join(this.root, e.name, 'gcode'); - out.push({ name: e.name, updated: fs.statSync(f).mtimeMs, parts, nets, routed, gcode: fs.existsSync(g) && fs.readdirSync(g).length > 0 }); + out.push({ name: e.name, updated: fs.statSync(f).mtimeMs, parts, nets, routed, workshopId, gcode: fs.existsSync(g) && fs.readdirSync(g).length > 0 }); } return out.sort((a, b) => b.updated - a.updated); } diff --git a/web-ui/html/workshop-app.html b/web-ui/html/workshop-app.html index 870511c..5dbf8e9 100644 --- a/web-ui/html/workshop-app.html +++ b/web-ui/html/workshop-app.html @@ -53,6 +53,7 @@
+ @@ -92,6 +93,8 @@
+
+
diff --git a/web-ui/js/app/workshop-core.js b/web-ui/js/app/workshop-core.js index 72ac90b..158627f 100644 --- a/web-ui/js/app/workshop-core.js +++ b/web-ui/js/app/workshop-core.js @@ -463,6 +463,20 @@ function showSaveIndicator(msg){ saveTimer=setTimeout(()=>{el.textContent='';},2000); } +// PCB 탭: PCB 앱을 iframe으로 띄운다. 이 작업실 프로젝트에 연결된(workshopId) PCB 프로젝트가 있으면 그걸, 없으면 마지막으로 연 것을 연다. +let pcbPaneFor=''; +async function loadPcbPane(){ + const pane=document.getElementById('pane-pcb'),proj=currentProject(); + if(!pane||!proj||pcbPaneFor===proj.id)return; + let q=''; + try{ + const r=await fetch('/api/pcb/projects',{headers:authH()}); + if(r.ok){const m=((await r.json()).projects||[]).find(x=>x.workshopId===proj.id);if(m)q='?p='+encodeURIComponent(m.name);} + }catch(e){} + pcbPaneFor=proj.id; + pane.innerHTML=''; +} + // ── Tabs ────────────────────────────────────────────────────────────────────── function switchTab(tab){ document.querySelectorAll('.rb-tab-btn').forEach(b=>b.classList.toggle('active',b.dataset.tab===tab)); @@ -473,6 +487,7 @@ function switchTab(tab){ else if(typeof stopEquipTimers==='function')stopEquipTimers(); if(tab==='files')loadFiles(); if(tab==='assembly')refreshAssemblyPane(true); + if(tab==='pcb')loadPcbPane(); // 콘솔 탭(지연 로딩 workshop-console.js): 열 때 터미널 준비, 나갈 때는 세션을 유지한 채 숨김 if(tab==='console')withLazyModule('console','pane-console',()=>openConsole()); else if(typeof closeConsoleTab==='function')closeConsoleTab();