diff --git a/preview/check-v024.mjs b/preview/check-v024.mjs new file mode 100644 index 0000000..859b29f --- /dev/null +++ b/preview/check-v024.mjs @@ -0,0 +1,40 @@ +import { spawn } from 'node:child_process' +import { mkdtemp, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join, dirname } from 'node:path' +import { fileURLToPath } from 'node:url' +const url = process.argv[2] +const EDGE = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe' +const dir = dirname(fileURLToPath(import.meta.url)) +const profile = await mkdtemp(join(tmpdir(), 'ss-v024-')) +const out = {} +const sleep = ms => new Promise(r => setTimeout(r, ms)) +let browser, ws +try { + browser = spawn(EDGE, ['--headless=new','--disable-gpu','--no-first-run','--no-default-browser-check','--remote-debugging-port=0','--user-data-dir=' + profile, 'about:blank'], { stdio: ['ignore','ignore','pipe'] }) + const endpoint = await new Promise((resolve, reject) => { let log=''; const t=setTimeout(()=>reject(Error('timeout')),20000); browser.stderr.on('data', b=>{ log+=b; const m=log.match(/DevTools listening on (.+)/); if(m){clearTimeout(t);resolve(m[1].trim())} }); browser.on('error',reject) }) + ws = new WebSocket(endpoint); await new Promise((r,j)=>{ws.onopen=r;ws.onerror=j}) + let n=0; const pend=new Map() + ws.onmessage = e => { const m=JSON.parse(e.data); if(m.id){const p=pend.get(m.id);pend.delete(m.id);m.error?p.reject(Error(JSON.stringify(m.error))):p.resolve(m.result)} } + const cdp=(method,params={},sid)=>new Promise((res,rej)=>{const id=++n;pend.set(id,{resolve:res,reject:rej});ws.send(JSON.stringify({id,method,params,...(sid?{sessionId:sid}:{})}))}) + const { targetId } = await cdp('Target.createTarget', { url: 'about:blank' }) + const { sessionId } = await cdp('Target.attachToTarget', { targetId, flatten: true }) + const call=(m,p={})=>cdp(m,p,sessionId) + await call('Page.enable'); await call('Runtime.enable') + const ev = async x => { const r=await call('Runtime.evaluate',{expression:x,returnByValue:true,awaitPromise:true}); if(r.exceptionDetails) throw Error(r.exceptionDetails.exception?.description||r.exceptionDetails.text); return r.result.value } + const waitFor = async (x,t=45000)=>{ const end=Date.now()+t; while(Date.now() { const r=await call('Page.captureScreenshot',{format:'png',captureBeyondViewport:false}); await writeFile(join(dir,name),Buffer.from(r.data,'base64')) } + const setPane = async (w) => ev("(() => { const root=document.querySelector('.ssw-root'); let el=root; let cell=null; for(let i=0;i<8&⪙i++){ if(/tabCell|tabHost_123xe_164|pane_123xe_211/.test((el.className||'').toString())) cell=el; el=el.parentElement } const t=cell||root.parentElement; t.style.flex='0 0 "+w+"px'; t.style.width='"+w+"px'; return true })()") + await call('Emulation.setDeviceMetricsOverride',{width:1440,height:900,deviceScaleFactor:1,mobile:false}) + await call('Page.navigate',{url}) + await waitFor("document.readyState === 'complete'",30000) + try { await ev("(() => { const b=[...document.querySelectorAll('button')].find(x=>(x.innerText||'').trim()==='继续'); if(b)b.click(); return !!b })()") } catch {} + await waitFor("!!document.querySelector('.ssw-nav-hit')",60000) + await ev("document.querySelector('.ssw-nav-hit').click(); true") + await waitFor("!!document.querySelector('.ssw-root')",20000) + await sleep(2200) + out.removed = await ev("(() => ({ enableBlocks: document.querySelectorAll('.ssw-enable').length, hasCurrentLabel: (document.body.innerText||'').includes('当前项目'), hasAllDuties: (document.body.innerText||'').includes('全部汇报职责'), projectTitle: document.querySelector('.ssw-project-title')?.innerText ?? null }))()") + await setPane(520); await sleep(700); out.w520 = await ev("getComputedStyle(document.querySelector('.ssw-court')).gridTemplateColumns"); await shot('v024-520.png') + await setPane(800); await sleep(700); out.w800 = await ev("getComputedStyle(document.querySelector('.ssw-court')).gridTemplateColumns"); await shot('v024-800.png') +} catch(e) { out.fatal = String(e?.stack ?? e) } finally { try{ws?.close()}catch{}; try{browser?.kill()}catch{} } +console.log(JSON.stringify(out, null, 2)) \ No newline at end of file diff --git a/preview/v024-520.png b/preview/v024-520.png new file mode 100644 index 0000000..b7890a4 Binary files /dev/null and b/preview/v024-520.png differ diff --git a/preview/v024-800.png b/preview/v024-800.png new file mode 100644 index 0000000..c6490b6 Binary files /dev/null and b/preview/v024-800.png differ diff --git a/sansheng/client.js b/sansheng/client.js index 93a4266..773a919 100644 --- a/sansheng/client.js +++ b/sansheng/client.js @@ -517,6 +517,8 @@ body[data-ds-dark-theme] .ssw-float,html[data-theme=dark] .ssw-float{background: .ssw-seat-icon{width:15px;height:15px} .ssw-detail{min-height:0} } +.ssw-project-line{align-items:baseline;margin-bottom:10px} +.ssw-project-title{margin:0} .ssw-tab-body{height:100%;min-height:0;display:flex;flex-direction:column} .ssw-tab-body .ssw-root{flex:1;min-height:0} .ssw-tab-title{font-size:13px} @@ -1517,22 +1519,10 @@ function apply(ctx) { (0, import_react.createElement)( "div", { className: "ssw-project-line" }, - (0, import_react.createElement)("span", { className: "ssw-eyebrow" }, (0, import_react.createElement)(FolderIcon), "当前项目"), + (0, import_react.createElement)("span", { className: "ssw-project-title" }, wb.projectTitle || "未命名项目"), (0, import_react.createElement)("span", { className: "ssw-count" }, wb.project.seatCount + " 个角色 · " + wb.project.sessionCount + " 个会话") - ), - (0, import_react.createElement)("div", { className: "ssw-project-title" }, wb.projectTitle || "未命名项目") + ) ); - const enableBlock = !wb.ready ? (0, import_react.createElement)( - "div", - { className: "ssw-enable" }, - (0, import_react.createElement)("p", { className: "ssw-enable-note" }, "这个项目还没有启用十席。启用会建立十个独立会话,但不会自动运行模型。"), - (0, import_react.createElement)("button", { - type: "button", - className: "ssw-primary", - disabled: busy, - onClick: enableSeats - }, busy ? "正在启用…" : "启用此项目的十席") - ) : null; const detailActions = (0, import_react.createElement)( "div", { className: "ssw-detail-actions" }, @@ -1736,13 +1726,12 @@ function apply(ctx) { ), (0, import_react.createElement)("p", { className: "ssw-detail-text" }, wb.selected.responsibility), detailActions, - config, - report + config ); const courtView = (0, import_react.createElement)( "section", { className: "ssw-court" }, - (0, import_react.createElement)("div", { className: "ssw-org" }, enableBlock, tree), + (0, import_react.createElement)("div", { className: "ssw-org" }, tree), detail ); let body; diff --git a/sansheng/package.json b/sansheng/package.json index 2faa89d..747de4b 100644 --- a/sansheng/package.json +++ b/sansheng/package.json @@ -1,6 +1,6 @@ { "name": "dsh-sansheng-liubu", - "version": "0.2.3", + "version": "0.2.4", "description": "三省六部:每个项目固定十席角色与独立会话的 DSH 插件(第一版)。", "keywords": [ "dsh-plugin", diff --git a/sansheng/src/client/index.js b/sansheng/src/client/index.js index 887f2b6..8e21d53 100644 --- a/sansheng/src/client/index.js +++ b/sansheng/src/client/index.js @@ -564,21 +564,11 @@ export function apply(ctx) { const projectInfo = h('div', { className: 'ssw-project' }, h('div', { className: 'ssw-project-line' }, - h('span', { className: 'ssw-eyebrow' }, h(FolderIcon), '当前项目'), + h('span', { className: 'ssw-project-title' }, wb.projectTitle || '未命名项目'), h('span', { className: 'ssw-count' }, wb.project.seatCount + ' 个角色 · ' + wb.project.sessionCount + ' 个会话'), ), - h('div', { className: 'ssw-project-title' }, wb.projectTitle || '未命名项目'), ) - const enableBlock = !wb.ready - ? h('div', { className: 'ssw-enable' }, - h('p', { className: 'ssw-enable-note' }, '这个项目还没有启用十席。启用会建立十个独立会话,但不会自动运行模型。'), - h('button', { - type: 'button', className: 'ssw-primary', disabled: busy, onClick: enableSeats, - }, busy ? '正在启用…' : '启用此项目的十席'), - ) - : null - const detailActions = h('div', { className: 'ssw-detail-actions' }, wb.ready ? h('button', { @@ -726,10 +716,9 @@ export function apply(ctx) { h('p', { className: 'ssw-detail-text' }, wb.selected.responsibility), detailActions, config, - report, ) const courtView = h('section', { className: 'ssw-court' }, - h('div', { className: 'ssw-org' }, enableBlock, tree), + h('div', { className: 'ssw-org' }, tree), detail, ) diff --git a/sansheng/src/client/styles.js b/sansheng/src/client/styles.js index dd76144..dcd3a23 100644 --- a/sansheng/src/client/styles.js +++ b/sansheng/src/client/styles.js @@ -149,6 +149,8 @@ body[data-ds-dark-theme] .ssw-float,html[data-theme=dark] .ssw-float{background: .ssw-seat-icon{width:15px;height:15px} .ssw-detail{min-height:0} } +.ssw-project-line{align-items:baseline;margin-bottom:10px} +.ssw-project-title{margin:0} .ssw-tab-body{height:100%;min-height:0;display:flex;flex-direction:column} .ssw-tab-body .ssw-root{flex:1;min-height:0} .ssw-tab-title{font-size:13px}