34 lines
26 KiB
HTML
34 lines
26 KiB
HTML
<!doctype html>
|
||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>三省六部 · 前端预览</title>
|
||
<style>
|
||
:root{color-scheme:light;--bg:#fff;--side:#f8f9fa;--rail:#f7f9fc;--card:#fff;--line:#e3e8ef;--strong:#c7d8f5;--ink:#0f172a;--muted:#667085;--faint:#98a2b3;--blue:#3b82f6;--wash:#eff6ff;--wire:#c9d6ea;--rail-width:374px;font-family:Inter,"Segoe UI","Microsoft YaHei",sans-serif;font-size:14px}
|
||
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink)}button,input,select,textarea{font:inherit;color:inherit}button{cursor:pointer}button:disabled{cursor:default;opacity:.55}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,[tabindex]:focus-visible{outline:2px solid var(--blue);outline-offset:3px}button{background:transparent;border:0}svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex:none}.app{height:100dvh;min-height:580px;display:flex;overflow:hidden}.left{width:260px;flex-shrink:0;background:var(--side);border-right:1px solid var(--line);display:flex;flex-direction:column;padding:14px 12px}.brand{display:flex;align-items:center;gap:7px;padding:0 7px 18px;color:var(--ink)}.brand strong{font-size:23px;letter-spacing:-1px}.brand .tag{font:9px monospace;letter-spacing:.4px;background:var(--ink);color:var(--bg);padding:2px 4px;border-radius:2px}.whale{width:26px;height:24px;stroke-width:1.9}.new{height:38px;width:100%;display:flex;align-items:center;justify-content:center;gap:7px;background:var(--card);border:1px solid #dedfe2;border-radius:9px;margin-bottom:13px;font-size:13px}.navitem{width:100%;height:35px;display:flex;align-items:center;gap:9px;padding:0 10px;border-radius:7px;text-align:left;font-size:13px;color:var(--ink)}.navitem svg{width:16px;height:16px}.navitem.active{color:#2563eb;background:#eaf1fe;font-weight:600}.navitem .newmark{margin-left:auto;font-size:9px;font-weight:500;color:#7b9bc9;border:1px solid #ccdff9;border-radius:4px;padding:1px 4px}.preserved{flex:1;margin-top:22px;border-top:1px solid var(--line);position:relative;min-height:150px}.preserved-label{display:flex;align-items:center;gap:7px;color:var(--muted);font-size:12px;padding:18px 9px}.placeholder{position:absolute;inset:74px 12px 65px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:var(--faint);font-size:12px;line-height:1.9;border:1px dashed var(--line);border-radius:9px;padding:12px}.placeholder span{font-size:11px}.preview-tools{display:flex;align-items:center;justify-content:space-between;padding:9px 5px 0;color:var(--muted);font-size:11px;border-top:1px solid var(--line)}.icon-btn{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:6px;color:var(--muted)}.icon-btn:hover{background:var(--wash);color:var(--blue)}.center{min-width:0;flex:1;display:flex;flex-direction:column;background:var(--bg)}.chat-head{height:58px;flex:none;border-bottom:1px solid var(--line);display:flex;align-items:center;padding:0 24px;gap:10px}.crumb{font-size:12px;color:var(--muted)}.slash{color:var(--faint)}.chat-head strong{font-size:13px;font-weight:600}.session-tag{font-size:10px;border:1px solid var(--line);color:var(--muted);padding:3px 6px;border-radius:4px}.head-actions{display:flex;gap:5px;margin-left:auto}.mobile-menu{display:none}.chat-body{flex:1;overflow:auto;padding:28px max(24px,calc((100% - 720px)/2));display:flex;flex-direction:column}.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding-bottom:45px;text-align:center}.empty-mark{width:50px;height:50px;display:grid;place-items:center;border-radius:15px;background:var(--wash);color:var(--blue);font-size:21px;margin-bottom:18px;border:1px solid var(--strong)}.empty h1{font-size:22px;font-weight:600;letter-spacing:1px;margin:0 0 10px}.empty p{font-size:13px;color:var(--muted);margin:0;line-height:1.8}.native-note{font-size:11px!important;color:var(--faint)!important;margin-top:22px!important}.message{margin:14px 0 8px;padding:13px 16px;border:1px solid var(--line);border-radius:12px;background:var(--side);align-self:flex-end;max-width:90%;white-space:pre-wrap;overflow-wrap:anywhere}.message-note{font-size:11px;color:var(--faint);text-align:right}.composer-wrap{padding:16px 26px 14px;flex:none}.composer{max-width:780px;margin:auto;border:1px solid #d9dde4;border-radius:14px;box-shadow:0 2px 10px #10182804;background:var(--card);padding:14px}.composer textarea{width:100%;height:56px;min-height:40px;max-height:160px;border:0;outline:0;background:transparent;resize:vertical;font-size:14px;line-height:1.7}.composer textarea::placeholder{color:var(--faint)}.composer-bottom{display:flex;justify-content:space-between;align-items:center;margin-top:6px}.composer-meta{font-size:11px;color:var(--muted);display:flex;align-items:center;gap:8px;min-width:0;overflow-wrap:anywhere}.send{width:29px;height:29px;border-radius:8px;background:var(--ink);color:var(--bg);display:grid;place-items:center}.composer-caption{text-align:center;font-size:10px;letter-spacing:.2px;color:var(--faint);margin-top:9px}.resize{flex:none;width:5px;position:relative;cursor:col-resize;border-left:1px solid var(--line);background:var(--rail);touch-action:none}.resize:hover,.resize:focus-visible{background:var(--blue)}.right{flex:0 0 var(--rail-width);width:var(--rail-width);min-width:0;display:flex;flex-direction:column;background:var(--rail);overflow:auto}.rail-head{height:58px;flex:none;display:flex;align-items:center;padding:0 18px;border-bottom:1px solid var(--line);gap:8px}.rail-head strong{font-size:13px}.rail-head .icon-btn{margin-left:auto}.rail-content{padding:20px 17px}.project-line{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px}.eyebrow{font-size:11px;color:var(--muted);display:flex;gap:6px;align-items:center}.eyebrow svg{width:14px;height:14px}.count{color:var(--faint);font-size:10px}.project-title{font-size:17px;font-weight:600;margin-bottom:23px;letter-spacing:.5px}.tree{position:relative}.lead-row{width:144px;margin:auto;position:relative}.lead-row:after{content:"";position:absolute;left:50%;top:100%;height:23px;border-left:1px solid var(--wire)}.trio{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px;margin-top:40px;position:relative}.trio:before{content:"";position:absolute;left:16.66%;right:16.66%;top:-18px;border-top:1px solid var(--wire)}.trio .role:before{content:"";position:absolute;left:50%;bottom:100%;height:18px;border-left:1px solid var(--wire)}.role{position:relative;width:100%;padding:11px 9px 9px;border:1px solid var(--line);border-radius:10px;background:var(--card);text-align:left;box-shadow:0 1px 2px #10182808;transition:border-color .15s,box-shadow .15s,transform .15s;min-height:78px}.role:hover{border-color:var(--strong);transform:translateY(-1px);box-shadow:0 3px 8px #10182809}.role[aria-pressed=true]{border-color:var(--blue);box-shadow:0 0 0 2px #3b82f612;background:var(--wash)}.role-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px}.role-name{font-weight:600;font-size:14px;letter-spacing:2px}.role-dot{height:5px;width:5px;border:1px solid #b4c0ce;border-radius:50%;flex:none}.role[aria-pressed=true] .role-dot{background:var(--blue);border-color:var(--blue)}.role-duty{font-size:10px;color:var(--muted);line-height:1.5}.lead-row .role{border-color:var(--strong)}.lead-row .role[aria-pressed=true]{border-color:var(--blue)}.ministries{position:relative;border:1px dashed var(--wire);border-radius:12px;margin-top:29px;padding:14px 8px 9px}.ministries:before{content:"";position:absolute;bottom:100%;height:29px;border-left:1px solid var(--wire);left:50%}.group-label{position:absolute;top:-8px;left:10px;background:var(--rail);font-size:10px;color:var(--faint);padding:0 5px}.six{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.six .role{min-height:75px;padding:10px 8px}.tree-note{font-size:10px;color:var(--faint);margin:14px 0 24px;text-align:center}.current{padding:14px;border:1px solid var(--line);border-radius:11px;background:var(--card)}.current-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.current-top span{font-size:10px;color:var(--faint)}.current-name{font-size:13px;font-weight:600}.current p{font-size:12px;line-height:1.8;color:var(--muted);margin:0}.config{margin-top:11px;border:1px solid var(--line);border-radius:10px;background:var(--card);overflow:hidden}.config-toggle{display:flex;align-items:center;width:100%;padding:13px;gap:7px;font-size:12px}.config-toggle .chevron{margin-left:auto;transition:transform .2s;width:14px}.config-toggle[aria-expanded=true] .chevron{transform:rotate(180deg)}.config-body{padding:0 13px 14px}.config-body label{display:block;font-size:11px;color:var(--muted);margin:14px 0 6px}.field{width:100%;border:1px solid var(--line);background:var(--bg);border-radius:6px;padding:8px;font-size:12px;line-height:1.5}.config-body textarea{resize:vertical;min-height:86px}.scope-note{font-size:10px;color:var(--faint);line-height:1.6;margin:10px 0}.save-row{display:flex;align-items:center;gap:10px}.primary{background:var(--blue);color:white;border-radius:6px;padding:8px 13px;font-size:11px}.save-status{font-size:10px;color:var(--muted)}.rail-footer{margin-top:auto;padding:14px 18px;font-size:10px;color:var(--faint);border-top:1px solid var(--line);display:flex;align-items:center;gap:5px}.rail-footer svg{width:13px;height:13px}.toast{position:fixed;bottom:26px;left:50%;transform:translateX(-50%);padding:11px 18px;border:1px solid var(--line);background:var(--card);box-shadow:0 6px 25px #0001;border-radius:9px;font-size:12px;z-index:10;max-width:90vw}.app.workbench-hidden .right,.app.workbench-hidden .resize{display:none}[hidden]{display:none!important}
|
||
:root[data-theme=dark]{color-scheme:dark;--bg:#14171c;--side:#171b21;--rail:#161a20;--card:#1e232b;--line:#2c333d;--strong:#3b4a63;--ink:#e6ebf2;--muted:#a9b4c2;--faint:#7b8797;--blue:#6ea8ff;--wash:#1d2b40;--wire:#3a4350}:root[data-theme=dark] .navitem.active{background:#1d2b40;color:#91bafa}:root[data-theme=dark] .new{border-color:var(--line)}:root[data-theme=dark] .composer{border-color:var(--line)}
|
||
@media(max-width:1100px){.left{width:220px}.right{flex-basis:340px;width:340px}.chat-head{padding:0 18px}.session-tag{display:none}.composer-wrap{padding:14px}}
|
||
@media(max-width:800px){.left{display:none}.mobile-menu{display:inline-flex}.right{position:absolute;right:0;top:58px;bottom:0;z-index:4;box-shadow:-12px 0 28px #0002;width:min(374px,100vw);border-left:1px solid var(--line)}.resize{display:none}.right .rail-head{height:48px}.chat-head{padding:0 12px}.center{width:100%}.chat-body{padding:20px}.composer-caption{font-size:9px}.app{min-height:400px}.empty h1{font-size:20px}}
|
||
</style></head><body>
|
||
<svg aria-hidden="true" style="display:none"><defs><symbol id="i-grid" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></symbol><symbol id="i-plus" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/><path d="M8 12h8M12 8v8"/></symbol><symbol id="i-clock" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 6v6l4 2"/></symbol><symbol id="i-board" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18M10 9v11"/></symbol><symbol id="i-brain" viewBox="0 0 24 24"><path d="M12 4c-4-5-8 1-6 4-5 1-4 8 0 8-1 6 6 6 6 2V4Zm0 0c4-5 8 1 6 4 5 1 4 8 0 8 1 6-6 6-6 2M6 8l3 2m9-2-3 2M6 16l3-2m9 2-3-2"/></symbol><symbol id="i-plug" viewBox="0 0 24 24"><path d="M9 3h6v5c5-2 7 5 1 5v3h-4c2 5-5 7-5 1H3v-6h5c-3-5 4-7 4-3"/></symbol><symbol id="i-tree" viewBox="0 0 24 24"><rect x="9" y="2" width="6" height="5" rx="1"/><path d="M12 7v5M5 16v-4h14v4"/><rect x="2" y="16" width="6" height="5" rx="1"/><rect x="16" y="16" width="6" height="5" rx="1"/></symbol><symbol id="i-folder" viewBox="0 0 24 24"><path d="M3 7V5a2 2 0 0 1 2-2h5l2 3h7a2 2 0 0 1 2 2v11H3Z"/></symbol><symbol id="i-chevron" viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></symbol><symbol id="i-settings" viewBox="0 0 24 24"><path d="M4 6h16M4 12h16M4 18h16"/><circle cx="9" cy="6" r="2" fill="var(--card)"/><circle cx="16" cy="12" r="2" fill="var(--card)"/><circle cx="8" cy="18" r="2" fill="var(--card)"/></symbol><symbol id="i-panel" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M15 4v16"/></symbol><symbol id="i-close" viewBox="0 0 24 24"><path d="m6 6 12 12M6 18 18 6"/></symbol><symbol id="i-moon" viewBox="0 0 24 24"><path d="M20 15A9 9 0 0 1 9 4a9 9 0 1 0 11 11Z"/></symbol><symbol id="i-arrow" viewBox="0 0 24 24"><path d="M12 19V5m-6 6 6-6 6 6"/></symbol></defs></svg>
|
||
<div class="app" id="app"><aside class="left" aria-label="宿主导航示意"><div class="brand"><svg class="whale" viewBox="0 0 30 24"><path d="M3 9c3-6 12-7 17 0l5-5-1 7 4 2-7 1c-2 8-13 9-18 2-2-3-2-5 0-7Z"/><path d="M4 9c3 2 7 3 11 2M19 8l3-6"/></svg><strong>deepseek</strong><span class="tag">HARNESS</span></div><button class="new host-action"><svg><use href="#i-plus"/></svg>新会话</button><nav><button class="navitem host-action"><svg><use href="#i-plug"/></svg>插件</button><button class="navitem host-action"><svg><use href="#i-clock"/></svg>自动化任务</button><button class="navitem host-action"><svg><use href="#i-board"/></svg>任务看板</button><button class="navitem host-action"><svg><use href="#i-brain"/></svg>记忆系统</button><button class="navitem active" id="entry" aria-expanded="true"><svg><use href="#i-tree"/></svg>三省六部<span class="newmark">新增入口</span></button><button class="navitem host-action"><svg><use href="#i-grid"/></svg>更多</button></nav><div class="preserved"><div class="preserved-label"><svg><use href="#i-folder"/></svg>原有工作区区域</div><div class="placeholder">工作区、项目与会话列表<br>保持现在的内容和交互<span>此处仅占位,不重新设计</span></div></div><div class="preview-tools"><span>布局预览 · 未连接宿主</span><button id="theme" class="icon-btn" title="切换深浅色预览" aria-label="切换深浅色预览"><svg><use href="#i-moon"/></svg></button></div></aside>
|
||
<main class="center"><header class="chat-head"><span class="crumb">三省六部</span><span class="slash">/</span><strong id="chat-name">丞相</strong><span class="session-tag">独立会话</span><div class="head-actions"><button id="panel-toggle" class="icon-btn" aria-label="切换工作台" aria-expanded="true" title="切换工作台"><svg><use href="#i-panel"/></svg></button></div></header><div class="chat-body" id="chat-body" aria-live="polite"></div><div class="composer-wrap"><form class="composer" id="composer"><textarea id="message" aria-label="消息" placeholder="向丞相发送消息…"></textarea><div class="composer-bottom"><span class="composer-meta"><svg><use href="#i-plus"/></svg><span id="composer-model">请选择模型</span></span><button class="send" type="submit" aria-label="发送演示消息"><svg><use href="#i-arrow"/></svg></button></div></form><div class="composer-caption">会话框为布局示意 · 正式接入复用 DSH 原生会话组件</div></div></main>
|
||
<div class="resize" id="resize" role="separator" tabindex="0" aria-label="调整工作台宽度" aria-orientation="vertical" aria-valuemin="330" aria-valuemax="540" aria-valuenow="374"></div>
|
||
<aside class="right" id="workbench" aria-label="三省六部工作台"><header class="rail-head"><svg><use href="#i-tree"/></svg><strong>工作台</strong><button class="icon-btn" id="close-panel" aria-label="收起工作台"><svg><use href="#i-close"/></svg></button></header><div class="rail-content"><div class="project-line"><span class="eyebrow"><svg><use href="#i-folder"/></svg>当前项目</span><span class="count">10 个角色 · 10 个会话</span></div><div class="project-title">三省六部</div><section class="tree" aria-label="切换角色"><div class="lead-row" id="lead"></div><div class="trio" id="trio"></div><div class="ministries"><span class="group-label">六部 · 尚书统筹</span><div class="six" id="six"></div></div></section><div class="tree-note">点击角色,切换到对应的独立会话</div><section class="current"><div class="current-top"><strong class="current-name" id="current-name">丞相</strong><span>角色职责</span></div><p id="responsibility"></p></section><section class="config"><button class="config-toggle" id="config-toggle" aria-expanded="false" aria-controls="config-body"><svg><use href="#i-settings"/></svg><span id="config-label">配置丞相</span><svg class="chevron"><use href="#i-chevron"/></svg></button><form id="config-body" class="config-body" hidden><label for="model">会话模型</label><select class="field" id="model"><option value="" disabled>请选择模型</option><option value="demo-a">模型 A(示例)</option><option value="demo-b">模型 B(示例)</option><option value="custom">指定模型(演示填写)</option></select><div id="custom-model-wrap" hidden><label for="custom-model">模型名称</label><input id="custom-model" class="field" placeholder="输入模型名称(仅演示)" maxlength="100"></div><label for="role-note">角色补充说明</label><textarea class="field" id="role-note" placeholder="补充该角色在当前项目中的工作要求"></textarea><p class="scope-note">每个角色会话单独选择模型,只影响当前项目的此角色。预览配置保存在本浏览器,未写入真实会话。</p><div class="save-row"><button type="submit" class="primary">保存配置</button><span class="save-status" id="save-status" role="status"></span></div></form></section></div><footer class="rail-footer"><svg><use href="#i-panel"/></svg>工作台位于右侧 sidebar,可收起、调整宽度</footer></aside></div><div id="toast" class="toast" role="status" hidden></div>
|
||
<script>
|
||
const roles=[{id:'lead',name:'丞相',duty:'接需求 · 协调汇报',description:'面向用户承接想法:判断是否需要开工、必要时派给具体部门,并把各部门结果汇总成对用户的一次交付。'},{id:'zhongshu',name:'中书',duty:'调查 · 澄清 · 规划',description:'先把问题问清、把材料看全,再给出可执行的方案与验收标准草案,不直接产出最终交付物。'},{id:'shangshu',name:'尚书',duty:'分工 · 组织交付',description:'把已经明确的方案拆成部门分工并组织交付;六部直属于尚书这一同级分组,六部之间不是上下级。'},{id:'menxia',name:'门下',duty:'审议 · 整体审核',description:'对方案和交付做独立审议,指出风险与不达标处。首版没有门下审核的任务必须如实标注“未审核”。'},{id:'libu',name:'吏部',duty:'角色 · 技能配置',description:'对角色、技能与编制给出建议;职责不含绕过用户授权去改权限或其他项目设置。'},{id:'hubu',name:'户部',duty:'数据 · 表格计算',description:'处理数据、表格与计算,结论应可复算。'},{id:'lipu',name:'礼部',duty:'文档 · 内容呈现',description:'负责文档、内容与呈现形式,产出可编辑的源文件。'},{id:'bingbu',name:'兵部',duty:'环境 · 调试部署',description:'负责环境、调试与部署;部署/发布等外部副作用仍服从用户授权与宿主审批。'},{id:'xingbu',name:'刑部',duty:'测试 · 风险检查',description:'做测试与风险检查,给出可追溯的检查结果,而不是一句“已通过”。'},{id:'gongbu',name:'工部',duty:'代码 · 工程产出',description:'负责代码实现与工程产出,交付可编辑源文件与真实检查结果。'}];
|
||
const $=id=>document.getElementById(id);const storageKey='sansheng-preview:project-demo:v1';let stored={};try{stored=JSON.parse(localStorage.getItem(storageKey)||'{}')||{}}catch{};let active=roles.some(r=>r.id===stored.active)?stored.active:'lead';const configs=stored.configs&&typeof stored.configs==='object'?stored.configs:{};const chats={};const drafts={};let configDirty=false;let toastTimer;
|
||
function persist(){try{localStorage.setItem(storageKey,JSON.stringify({active,configs}))}catch{notify('当前浏览器不允许保存,配置仅在本次预览有效。')}}
|
||
function notify(text){$('toast').textContent=text;$('toast').hidden=false;clearTimeout(toastTimer);toastTimer=setTimeout(()=>$('toast').hidden=true,3000)}
|
||
function modelName(){const c=configs[active];return c?.model==='custom'&&c.custom?c.custom:c?.model==='demo-a'?'模型 A(示例)':c?.model==='demo-b'?'模型 B(示例)':'请选择模型'}
|
||
function renderChat(){const r=roles.find(r=>r.id===active);$('chat-name').textContent=r.name;$('message').placeholder='向'+r.name+'发送消息…';$('message').value=drafts[active]||'';$('composer-model').textContent=modelName();const body=$('chat-body');body.replaceChildren();if(!(chats[active]?.length)){const el=document.createElement('div');el.className='empty';const mark=document.createElement('div');mark.className='empty-mark';mark.textContent=r.name[0];const title=document.createElement('h1');title.textContent='向'+r.name+'发送消息';const duty=document.createElement('p');duty.textContent=r.duty;const note=document.createElement('p');note.className='native-note';note.textContent='中间区域沿用现有会话体验';el.append(mark,title,duty,note);body.append(el)}else{for(const text of chats[active]){const el=document.createElement('div');el.className='message';el.textContent=text;body.append(el)}const note=document.createElement('p');note.className='message-note';note.textContent='演示消息 · 未调用模型';body.append(note)}body.scrollTop=body.scrollHeight}
|
||
function loadConfig(){const c=configs[active]||{};$('model').value=['custom','demo-a','demo-b'].includes(c.model)?c.model:'';$('model').querySelector('[value=custom]').textContent=c.model==='custom'&&c.custom?c.custom:'指定模型(演示填写)';$('custom-model').value=c.custom||'';$('custom-model-wrap').hidden=$('model').value!=='custom';$('role-note').value=c.note||'';$('save-status').textContent='';configDirty=false}
|
||
function selectRole(id){if(id===active)return;drafts[active]=$('message').value;if(configDirty)notify('未保存的角色配置已放弃。');active=id;renderRoles();loadConfig();renderChat();persist()}
|
||
function renderRoles(){for(const id of ['lead','trio','six'])$(id).replaceChildren();roles.forEach((r,i)=>{const b=document.createElement('button');b.className='role';b.dataset.role=r.id;b.setAttribute('aria-pressed',String(active===r.id));b.setAttribute('aria-label','切换到'+r.name+'会话');const top=document.createElement('div');top.className='role-top';const name=document.createElement('span');name.className='role-name';name.textContent=r.name;const dot=document.createElement('span');dot.className='role-dot';top.append(name,dot);const duty=document.createElement('div');duty.className='role-duty';duty.textContent=r.duty;b.append(top,duty);b.onclick=()=>selectRole(r.id);$(i===0?'lead':i<4?'trio':'six').append(b)});const r=roles.find(r=>r.id===active);$('current-name').textContent=r.name;$('responsibility').textContent=r.description;$('config-label').textContent='配置'+r.name}
|
||
function panel(open){$('app').classList.toggle('workbench-hidden',!open);$('panel-toggle').setAttribute('aria-expanded',String(open));$('entry').setAttribute('aria-expanded',String(open));$('entry').classList.toggle('active',open)}
|
||
$('entry').onclick=()=>panel(true);$('panel-toggle').onclick=()=>panel($('app').classList.contains('workbench-hidden'));$('close-panel').onclick=()=>panel(false);
|
||
$('config-toggle').onclick=()=>{const open=$('config-body').hidden;$('config-body').hidden=!open;$('config-toggle').setAttribute('aria-expanded',String(open))};$('model').onchange=()=>{$('custom-model-wrap').hidden=$('model').value!=='custom';configDirty=true};$('config-body').addEventListener('input',()=>{configDirty=true;$('save-status').textContent='未保存'});
|
||
$('config-body').onsubmit=e=>{e.preventDefault();const custom=$('custom-model').value.trim();if(!$('model').value){$('model').focus();notify('请选择此角色会话的模型。');return}if($('model').value==='custom'&&!custom){$('custom-model').focus();notify('请填写模型名称。');return}configs[active]={model:$('model').value,custom,note:$('role-note').value.trim()};persist();loadConfig();configDirty=false;$('save-status').textContent='已保存到预览';$('composer-model').textContent=modelName()};
|
||
$('message').addEventListener('input',()=>drafts[active]=$('message').value);$('composer').onsubmit=e=>{e.preventDefault();const text=$('message').value.trim();if(!text)return;(chats[active]??=[]).push(text);drafts[active]='';renderChat();notify('已添加演示消息,未调用模型。')};document.querySelectorAll('.host-action').forEach(b=>b.onclick=()=>notify('这是保留的宿主入口,预览不改变原有功能。'));
|
||
$('theme').onclick=()=>{const dark=document.documentElement.dataset.theme==='dark';document.documentElement.dataset.theme=dark?'light':'dark'};
|
||
function setWidth(width){const w=Math.max(330,Math.min(540,width));document.documentElement.style.setProperty('--rail-width',w+'px');$('resize').setAttribute('aria-valuenow',w)}
|
||
$('resize').onpointerdown=e=>{e.preventDefault();const start=e.clientX,width=$('workbench').getBoundingClientRect().width;$('resize').setPointerCapture(e.pointerId);const move=e=>setWidth(width+start-e.clientX);const end=()=>{$('resize').removeEventListener('pointermove',move);$('resize').removeEventListener('pointerup',end);$('resize').removeEventListener('pointercancel',end)};$('resize').addEventListener('pointermove',move);$('resize').addEventListener('pointerup',end);$('resize').addEventListener('pointercancel',end)};$('resize').onkeydown=e=>{if(e.key==='ArrowLeft'||e.key==='ArrowRight'){e.preventDefault();setWidth($('workbench').getBoundingClientRect().width+(e.key==='ArrowLeft'?10:-10))}};
|
||
if(matchMedia('(prefers-color-scheme: dark)').matches)document.documentElement.dataset.theme='dark';if(innerWidth<=800)panel(false);renderRoles();loadConfig();renderChat();
|
||
</script></body></html> |