feat(local): 左栏改为图标操作栏,本地端 IDE 式文件树 + 预览

侧栏底部原来的整行用户区换成四个图标:会话 / 文件树 / 预览 / 设置,
当前生效的那一项高亮;设置与预览图标都是开关(再点一次关闭)。
去掉顶部「会话/文件」分段切换,改用底部图标切换互斥面板。

- local-files.js(新增):只读文件树,懒加载单层、展开才请求、忽略大目录,
  点文件进右侧预览;支持在 Finder / 终端中打开
- routes/local.js:新增 /tree(单层、越界双重校验)、/reveal、/terminal
- preview.js:记录最后预览的文件,预览图标可重开上次文件;开合时同步图标高亮
- files.js:底部操作栏接线,设置图标点击切换开合
- settings.js:打开设置不再折叠左栏;图标选中态同步
- 纯前端 + local 路由(AGENT_LOCAL_PICK 门控),服务器/手机形态行为不变
This commit is contained in:
2026-11-11 14:49:57 +08:00
parent 80e9dcb0aa
commit 2d5467203b
8 changed files with 522 additions and 50 deletions
+17 -7
View File
@@ -234,11 +234,20 @@
</div>
</div>
<div class="drawer-list" id="drawer-list"></div>
<div class="drawer-user" id="drawer-user">
<div class="avatar" id="drawer-avatar">A</div>
<div class="user-name" id="drawer-user-name">Agent 用户</div>
<button class="user-more" id="user-more-btn" title="更多设置" aria-label="更多设置">
<svg class="ic sm" viewBox="0 0 24 24"><circle cx="5" cy="12" r="1.4" fill="currentColor" stroke="none"></circle><circle cx="12" cy="12" r="1.4" fill="currentColor" stroke="none"></circle><circle cx="19" cy="12" r="1.4" fill="currentColor" stroke="none"></circle></svg>
<div class="files-tree hidden" id="files-tree"></div>
<!-- 底部图标操作栏:会话 / 文件树 / 预览 / 设置(文件树仅本地模式出现)。选中项高亮。 -->
<div class="drawer-actions" id="drawer-actions">
<button class="drawer-act active" id="da-sessions" type="button" title="会话" aria-label="会话">
<svg viewBox="0 0 24 24"><path d="M21 11.5a8.5 8.5 0 0 1-11.8 7.8L4 21l1.7-5.2A8.5 8.5 0 1 1 21 11.5z"></path></svg>
</button>
<button class="drawer-act hidden" id="da-files" type="button" title="文件树" aria-label="文件树">
<svg viewBox="0 0 24 24"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path></svg>
</button>
<button class="drawer-act" id="da-preview" type="button" title="预览" aria-label="预览">
<svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"></rect><path d="M14 4v16"></path></svg>
</button>
<button class="drawer-act" id="da-settings" type="button" title="设置" aria-label="设置">
<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="3.2"></circle><path d="M19.4 13.5a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.9-.3 1.7 1.7 0 0 0-1 1.6 2 2 0 1 1-4 0 1.7 1.7 0 0 0-1-1.6 1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.9 1.7 1.7 0 0 0-1.6-1 2 2 0 1 1 0-4 1.7 1.7 0 0 0 1.6-1 1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.9.3 1.7 1.7 0 0 0 1-1.6 2 2 0 1 1 4 0 1.7 1.7 0 0 0 1 1.6 1.7 1.7 0 0 0 1.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9 1.7 1.7 0 0 0 1.6 1 2 2 0 1 1 0 4 1.7 1.7 0 0 0-1.6 1z"></path></svg>
</button>
</div>
</aside>
@@ -548,17 +557,18 @@
<script src="/js/files.js"></script>
<script src="/js/voice.js"></script>
<script src="/js/preview.js"></script>
<script src="/js/local-files.js"></script>
<script src="/js/settings.js"></script>
<script>
// 启动自愈:外部工具改前端文件是非原子写入,极端时机下浏览器可能拿到半截或重复拼接的 HTML
// (脚本缺半 → 白屏裸首页;重复注入 → 每个文件报 duplicate variable 后 JS 全挂)。
// 这里检测关键脚本数量与入口全局,不对就自动整页重载一次(sessionStorage 防循环)。
// 注意:js/ 脚本增减时需同步改这里的期望数 9。
// 注意:js/ 脚本增减时需同步改这里的期望数 10。
(function () {
var ok = false;
try {
var n = document.querySelectorAll('script[src^="/js/"]').length;
ok = n === 9 && typeof state !== 'undefined' &&
ok = n === 10 && typeof state !== 'undefined' &&
typeof openFilePreview === 'function' && typeof restartNow === 'function';
} catch (_) {}
if (ok) { try { sessionStorage.removeItem('boot-heal'); } catch (_) {} return; }