feat(ui): 预览分栏挪到文件树右侧,底部操作栏收成三个按钮
IDE 式三栏:文件树 | 预览 | 会话。点文件后内容就在旁边,不用横跨会话区。 - 预览分栏从窗口右缘移到文件树右侧:侧栏展开时 left=--sidebar-w,折叠时贴窗口最左; 会话区改成往右让位;拖拽手柄随之换到预览右缘,拖动方向取反 - .pv-head 定死高度 49px:预览头有地址条、文件树头只有图标钮,靠内容撑会差几像素, 两栏下边框对不齐 - 文件树头部去掉地址条(280px 里路径必然截断,没有信息量),只留右侧操作钮 - 底部操作栏收成三个按钮(文件树 / 预览 / 设置):「文件树」现在是 会话列表 ↔ 文件树的切换开关,当前在文件页时高亮 - 窄屏不再误藏文件树按钮(只藏预览,因为窄屏没有右侧分栏);窄屏点文件后收起抽屉 - 切会话不再自动关预览:中间这一列是常驻参考区,关掉会让人反复重开 - 打开预览时无条件把侧栏切到文件树(已在文件页则空操作)
This commit is contained in:
@@ -872,21 +872,19 @@ body.voice-active .scroll-bottom-btn { display: none; }
|
|||||||
width: 20px; height: 20px; fill: none; stroke: currentColor;
|
width: 20px; height: 20px; fill: none; stroke: currentColor;
|
||||||
stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
|
stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
|
||||||
}
|
}
|
||||||
/* 手机/窄屏没有右侧预览栏(预览走全屏浮层),也没有左栏文件树(窄屏不适合) */
|
/* 窄屏没有右侧预览分栏(预览改走全屏 #fs-viewer),所以只藏这一个钮;
|
||||||
@media (max-width: 959px) { #da-preview, #da-files { display: none !important; } }
|
文件树只是抽屉里的一个面板,任何宽度都能用,不藏。 */
|
||||||
|
@media (max-width: 959px) { #da-preview { display: none !important; } }
|
||||||
|
|
||||||
.files-tree { display: none; flex: 1; min-height: 0; flex-direction: column; }
|
.files-tree { display: none; flex: 1; min-height: 0; flex-direction: column; }
|
||||||
#drawer.drawer-mode-files .drawer-search,
|
#drawer.drawer-mode-files .drawer-search,
|
||||||
#drawer.drawer-mode-files .drawer-list { display: none; }
|
#drawer.drawer-mode-files .drawer-list { display: none; }
|
||||||
#drawer.drawer-mode-files .files-tree { display: flex; }
|
#drawer.drawer-mode-files .files-tree { display: flex; }
|
||||||
|
|
||||||
/* 左栏树头部复用预览栏的 .pv-head/.pv-addr/.pv-actions/.icon-btn:
|
/* 左栏树头部复用预览栏的 .pv-head / .pv-actions / .icon-btn:
|
||||||
它俩在桌面上左右并排,高一点点或图标小一号都会明显错位。 */
|
它俩在桌面上左右并排,高一点点或图标小一号都会明显错位。
|
||||||
.tree-head .pv-actions { gap: 4px; margin-left: 6px; } /* 侧栏窄,4 个按钮也塞得下 */
|
不放地址条:侧栏只有 280px,路径必然被截断,没有信息量。 */
|
||||||
.tree-path {
|
.tree-head .pv-actions { gap: 4px; margin-left: auto; } /* 靠右,与预览栏的操作钮同一侧 */
|
||||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
/* 头部图标的「开启中」态(如显示隐藏文件) */
|
/* 头部图标的「开启中」态(如显示隐藏文件) */
|
||||||
.pv-actions .icon-btn.active { color: var(--active); background: var(--active-soft); }
|
.pv-actions .icon-btn.active { color: var(--active); background: var(--active-soft); }
|
||||||
|
|
||||||
@@ -1519,23 +1517,33 @@ label.icon-btn { cursor: pointer; }
|
|||||||
body.drawer-open #toast { left: calc(50% + var(--sidebar-w) / 2); }
|
body.drawer-open #toast { left: calc(50% + var(--sidebar-w) / 2); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- 文档预览右栏(桌面端≥960px;移动端 office 走全屏 #fs-viewer,本栏隐藏) ---------- */
|
/* ---------- 文档预览分栏(桌面端≥960px;紧贴左侧文件树,移动端 office 走全屏 #fs-viewer,本栏隐藏) ---------- */
|
||||||
#pv-pane { display: none; }
|
#pv-pane { display: none; }
|
||||||
@media (min-width: 960px) {
|
@media (min-width: 960px) {
|
||||||
body.pv-open #pv-pane {
|
body.pv-open #pv-pane {
|
||||||
display: flex; flex-direction: column;
|
display: flex; flex-direction: column;
|
||||||
position: fixed; top: 0; right: 0; bottom: 0;
|
position: fixed; top: 0; left: 0; right: auto; bottom: 0;
|
||||||
width: var(--pv-w, min(50vw, 900px)); min-width: 320px;
|
width: var(--pv-w, min(50vw, 900px)); min-width: 320px;
|
||||||
background: var(--page); border-left: 1px solid var(--border);
|
background: var(--page); border-right: 1px solid var(--border);
|
||||||
z-index: 55;
|
z-index: 55;
|
||||||
}
|
}
|
||||||
body.pv-open.pv-max #pv-pane { left: 0; width: auto; border-left: none; z-index: 120; }
|
/* 侧栏展开时预览紧贴文件树右侧:文件树 | 预览 | 会话(IDE 习惯,点文件后内容就在旁边) */
|
||||||
/* 挤压式分栏:打开右栏时会话列让位;左栏不再自动折叠(本地端左栏是文件树,需要与预览并排) */
|
body.pv-open.drawer-open #pv-pane { left: var(--sidebar-w); }
|
||||||
body.pv-open #app { width: calc(100% - var(--pv-w, min(50vw, 900px))); margin-left: 0; }
|
body.pv-open.pv-max #pv-pane { left: 0; right: 0; width: auto; border-right: none; z-index: 120; }
|
||||||
body.pv-open.drawer-open #app { width: calc(100% - var(--sidebar-w) - var(--pv-w, min(50vw, 900px))); margin-left: var(--sidebar-w); }
|
/* 挤压式分栏:会话列往右让位 */
|
||||||
body.pv-open.pv-max #app { width: 100%; margin-left: 0; }
|
body.pv-open #app { width: calc(100% - var(--pv-w, min(50vw, 900px))); margin-left: var(--pv-w, min(50vw, 900px)); }
|
||||||
|
body.pv-open.drawer-open #app {
|
||||||
|
width: calc(100% - var(--sidebar-w) - var(--pv-w, min(50vw, 900px)));
|
||||||
|
margin-left: calc(var(--sidebar-w) + var(--pv-w, min(50vw, 900px)));
|
||||||
}
|
}
|
||||||
.pv-head { flex: none; position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border); background: var(--drawer-bg); }
|
body.pv-open.pv-max #app { width: 100%; margin-left: 0; }
|
||||||
|
/* toast 相对会话列居中(预览开着时会话列被挤到右边) */
|
||||||
|
body.pv-open.drawer-open #toast { left: calc(50% + (var(--sidebar-w) + var(--pv-w, min(50vw, 900px))) / 2); }
|
||||||
|
}
|
||||||
|
/* 头部高度定死:预览栏里有地址条(内容更高)、文件树只有 32px 图标钮,
|
||||||
|
靠内容撑会让两栏的头部差几像素、下边框对不齐。
|
||||||
|
49 = 32 控件 + 上下各 8 内边距 + 1 下边框(全局 box-sizing:border-box)。 */
|
||||||
|
.pv-head { flex: none; position: relative; display: flex; align-items: center; gap: 8px; height: 49px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border); background: var(--drawer-bg); }
|
||||||
/* 地址条胶囊:路径 input + 内嵌动作钮,模拟浏览器地址栏 */
|
/* 地址条胶囊:路径 input + 内嵌动作钮,模拟浏览器地址栏 */
|
||||||
.pv-addr { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid transparent; border-radius: 10px; padding: 2px 2px 2px 4px; }
|
.pv-addr { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid transparent; border-radius: 10px; padding: 2px 2px 2px 4px; }
|
||||||
.pv-addr:focus-within { border-color: var(--border); background: var(--page); }
|
.pv-addr:focus-within { border-color: var(--border); background: var(--page); }
|
||||||
@@ -1562,7 +1570,8 @@ label.icon-btn { cursor: pointer; }
|
|||||||
@keyframes pvspin { to { transform: rotate(360deg); } }
|
@keyframes pvspin { to { transform: rotate(360deg); } }
|
||||||
|
|
||||||
/* ---------- preview pane v2: drag resize / info card / plain text ---------- */
|
/* ---------- preview pane v2: drag resize / info card / plain text ---------- */
|
||||||
.pv-resizer { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 6; touch-action: none; }
|
/* 拖拽调宽的手柄:预览在左半侧,所以手柄在它的右缘(与会话列的分界) */
|
||||||
|
.pv-resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 6; touch-action: none; }
|
||||||
.pv-resizer:hover, .pv-resizer:active { background: var(--active); opacity: .3; }
|
.pv-resizer:hover, .pv-resizer:active { background: var(--active); opacity: .3; }
|
||||||
body.pv-resizing { cursor: col-resize; user-select: none; }
|
body.pv-resizing { cursor: col-resize; user-select: none; }
|
||||||
body.pv-resizing #pv-pane iframe { pointer-events: none; }
|
body.pv-resizing #pv-pane iframe { pointer-events: none; }
|
||||||
|
|||||||
@@ -235,11 +235,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="drawer-list" id="drawer-list"></div>
|
<div class="drawer-list" id="drawer-list"></div>
|
||||||
<div class="files-tree" id="files-tree"></div>
|
<div class="files-tree" id="files-tree"></div>
|
||||||
<!-- 底部图标操作栏:会话 / 文件树 / 预览 / 设置(文件树仅桌面端出现)。选中项高亮。 -->
|
<!-- 底部图标操作栏:文件树 / 预览 / 设置(文件树按钮是「会话 ↔ 文件」的切换开关;
|
||||||
|
窄屏没有预览分栏,预览钮由 CSS 隐藏)。选中项高亮。 -->
|
||||||
<div class="drawer-actions" id="drawer-actions">
|
<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" id="da-files" type="button" title="文件树" aria-label="文件树">
|
<button class="drawer-act" 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>
|
<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>
|
||||||
@@ -493,7 +491,7 @@
|
|||||||
<span id="img-count" class="hidden"></span>
|
<span id="img-count" class="hidden"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ================= 文档预览右栏(桌面端≥960px;office/全部文档类型统一承载;移动端走全屏 #fs-viewer,本栏隐藏) -->
|
<!-- ================= 文档预览分栏(桌面端≥960px;紧贴左侧文件树:文件树 | 预览 | 会话;office/全部文档类型统一承载;移动端走全屏 #fs-viewer,本栏隐藏) -->
|
||||||
<aside id="pv-pane" aria-label="文档预览">
|
<aside id="pv-pane" aria-label="文档预览">
|
||||||
<header class="pv-head">
|
<header class="pv-head">
|
||||||
<!-- 地址条胶囊:路径 input(点击全选可复制) + 内嵌 刷新/新窗口,模拟浏览器地址栏 -->
|
<!-- 地址条胶囊:路径 input(点击全选可复制) + 内嵌 刷新/新窗口,模拟浏览器地址栏 -->
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// 桌面端左栏文件树:会话文件的唯一浏览入口(服务器形态与 local 形态共用)。
|
// 桌面端左栏文件树:会话文件的唯一浏览入口(服务器形态与 local 形态共用)。
|
||||||
// · 懒加载:一次只请求一层目录,展开才拉下一层;node_modules 这类大目录后端只回标记、不展开,
|
// · 懒加载:一次只请求一层目录,展开才拉下一层;node_modules 这类大目录后端只回标记、不展开,
|
||||||
// 避免旧的整棵递归接口在单线程 core 上卡死;
|
// 避免旧的整棵递归接口在单线程 core 上卡死;
|
||||||
// · 点文件 → 右侧预览;行内 hover 出「下载 / 删除 / 在 Finder 中显示」;
|
// · 点文件 → 中间预览栏(文件树 | 预览 | 会话);行内 hover 出「下载 / 删除 / 在 Finder 中显示」;
|
||||||
// · 「在 Finder / 终端中打开」只在 local 启动器下可用(服务器上这些动作没有意义),
|
// · 「在 Finder / 终端中打开」只在 local 启动器下可用(服务器上这些动作没有意义),
|
||||||
// 靠 /api/local/info 探测,拿不到就隐藏这两个按钮。
|
// 靠 /api/local/info 探测,拿不到就隐藏这两个按钮。
|
||||||
// 手机端不启用(收纳在抽屉里体验太差),仍走输入行右侧的旧文件面板。
|
// 手机端不启用(收纳在抽屉里体验太差),仍走输入行右侧的旧文件面板。
|
||||||
@@ -25,7 +25,6 @@
|
|||||||
let cache = new Map(); // rel -> /tree 响应
|
let cache = new Map(); // rel -> /tree 响应
|
||||||
let loading = new Map(); // rel -> Promise(并发去重)
|
let loading = new Map(); // rel -> Promise(并发去重)
|
||||||
let gen = 0; // 会话切换/刷新时自增,防止旧请求回填到新树的缓存
|
let gen = 0; // 会话切换/刷新时自增,防止旧请求回填到新树的缓存
|
||||||
let rootPath = ''; // 会话根绝对路径(后端回的),显示在头部
|
|
||||||
|
|
||||||
// 失效缓存。gen 自增让在飞的旧请求回来时不再写缓存(否则切会话会闪旧目录)。
|
// 失效缓存。gen 自增让在飞的旧请求回来时不再写缓存(否则切会话会闪旧目录)。
|
||||||
function invalidate(keepExpanded) {
|
function invalidate(keepExpanded) {
|
||||||
@@ -116,7 +115,6 @@
|
|||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
const data = await openDir(rel);
|
const data = await openDir(rel);
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
if (!rel && data.root) rootPath = data.root;
|
|
||||||
const frag = document.createDocumentFragment();
|
const frag = document.createDocumentFragment();
|
||||||
const list = data.entries || [];
|
const list = data.entries || [];
|
||||||
if (!list.length) tip(frag, '(空目录)');
|
if (!list.length) tip(frag, '(空目录)');
|
||||||
@@ -133,20 +131,10 @@
|
|||||||
container.appendChild(frag);
|
container.appendChild(frag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPathLabel() {
|
|
||||||
const el = $('tree-path');
|
|
||||||
if (!el) return;
|
|
||||||
// 根路径太长时只留末两段,完整路径放 title(地址条的直觉:能看个大概,悬停能看全)
|
|
||||||
const parts = String(rootPath || '').split('/').filter(Boolean);
|
|
||||||
const short = parts.length > 2 ? '.../' + parts.slice(-2).join('/') : (rootPath || '会话文件');
|
|
||||||
el.textContent = short;
|
|
||||||
el.title = rootPath || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
async function renderBody() {
|
async function renderBody() {
|
||||||
const body = $('tree-body');
|
const body = $('tree-body');
|
||||||
if (!body) return;
|
if (!body) return;
|
||||||
if (!sid()) { body.innerHTML = ''; rootPath = ''; renderPathLabel(); tip(body, '尚未开始会话'); return; }
|
if (!sid()) { body.innerHTML = ''; tip(body, '尚未开始会话'); return; }
|
||||||
const sc = body.scrollTop;
|
const sc = body.scrollTop;
|
||||||
body.innerHTML = '';
|
body.innerHTML = '';
|
||||||
const root = document.createElement('div');
|
const root = document.createElement('div');
|
||||||
@@ -157,7 +145,6 @@
|
|||||||
root.innerHTML = '';
|
root.innerHTML = '';
|
||||||
tip(root, '加载失败:' + e.message);
|
tip(root, '加载失败:' + e.message);
|
||||||
}
|
}
|
||||||
renderPathLabel();
|
|
||||||
body.scrollTop = sc;
|
body.scrollTop = sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +196,8 @@
|
|||||||
renderBody();
|
renderBody();
|
||||||
} else if (typeof openFilePreview === 'function') {
|
} else if (typeof openFilePreview === 'function') {
|
||||||
openFilePreview(rel, '');
|
openFilePreview(rel, '');
|
||||||
|
// 窄屏的预览是全屏浮层:点完把抽屉收起(同点会话的行为),否则关预览后还压在抽屉上
|
||||||
|
if (typeof openDrawer === 'function' && !window.matchMedia('(min-width: 960px)').matches) openDrawer(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,12 +215,12 @@
|
|||||||
box.dataset.ready = '1';
|
box.dataset.ready = '1';
|
||||||
box.innerHTML = '';
|
box.innerHTML = '';
|
||||||
|
|
||||||
// 头部直接复用预览栏的 .pv-head / .pv-addr / .pv-actions / .icon-btn:
|
// 头部直接复用预览栏的 .pv-head / .pv-actions / .icon-btn:
|
||||||
// 两者在桌面上左右并排,尺寸/描边/内边距必须一模一样,否则一眼就看出错位。
|
// 两者在桌面上左右并排,尺寸/描边/内边距必须一模一样,否则一眼就看出错位。
|
||||||
|
// 不放地址条(路径在 280px 里必然截断,没有信息量),所以只剩右侧操作钮。
|
||||||
const head = document.createElement('header');
|
const head = document.createElement('header');
|
||||||
head.className = 'pv-head tree-head';
|
head.className = 'pv-head tree-head';
|
||||||
head.innerHTML =
|
head.innerHTML =
|
||||||
'<span class="pv-addr"><span class="pv-title tree-path" id="tree-path"></span></span>' +
|
|
||||||
'<span class="pv-actions">' +
|
'<span class="pv-actions">' +
|
||||||
'<button class="icon-btn" type="button" id="tree-hidden" title="显示隐藏文件" aria-label="显示隐藏文件">' + SVG_EYE + '</button>' +
|
'<button class="icon-btn" type="button" id="tree-hidden" title="显示隐藏文件" aria-label="显示隐藏文件">' + SVG_EYE + '</button>' +
|
||||||
'<button class="icon-btn" type="button" id="tree-refresh" title="刷新" aria-label="刷新">' + SVG_REFRESH + '</button>' +
|
'<button class="icon-btn" type="button" id="tree-refresh" title="刷新" aria-label="刷新">' + SVG_REFRESH + '</button>' +
|
||||||
|
|||||||
@@ -1233,26 +1233,24 @@
|
|||||||
document.addEventListener('touchcancel', e => endDrag(e, false), { passive: true });
|
document.addEventListener('touchcancel', e => endDrag(e, false), { passive: true });
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// 抽屉底部图标操作栏:会话 / 文件树 / 预览 / 设置。
|
// 抽屉底部图标操作栏:文件树 / 预览 / 设置。
|
||||||
// 会话与文件树是侧栏的两个互斥面板,所以这两个的 active 由 setDrawerPane 维护;
|
// 「文件树」是侧栏两个互斥面板的切换开关:不在文件页 → 切到文件树(高亮),
|
||||||
// 预览与设置不占用侧栏(各自是右侧面板/覆盖层),高亮由 preview.js / settings.js 自己同步。
|
// 再点一次 → 回会话列表(不亮)。预览与设置不占用侧栏,高亮由 preview.js / settings.js 同步。
|
||||||
function setDrawerPane(mode) {
|
function setDrawerPane(files) {
|
||||||
const drawer = $('drawer');
|
// 文件树模块没加载成功时不要把一个空面板切出来
|
||||||
const files = mode === 'files';
|
|
||||||
// 文件树只在本地模式存在;服务器形态下这个按钮是 hidden 的,这里再做一层兜底
|
|
||||||
if (files && typeof window.showFileTree !== 'function') return;
|
if (files && typeof window.showFileTree !== 'function') return;
|
||||||
|
const drawer = $('drawer');
|
||||||
const changed = drawer.classList.contains('drawer-mode-files') !== files;
|
const changed = drawer.classList.contains('drawer-mode-files') !== files;
|
||||||
drawer.classList.toggle('drawer-mode-files', files);
|
drawer.classList.toggle('drawer-mode-files', files);
|
||||||
$('da-sessions').classList.toggle('active', !files);
|
|
||||||
$('da-files').classList.toggle('active', files);
|
$('da-files').classList.toggle('active', files);
|
||||||
// 重复点当前项不重干活(不重拉列表/不重渲树),避免白掉请求和滚动位置
|
// 重复点当前项不重干活(不重拉列表/不重渲树),避免白掉请求和滚动位置
|
||||||
if (changed) {
|
if (!changed) return;
|
||||||
if (files) window.showFileTree();
|
if (files) window.showFileTree();
|
||||||
else loadSessionList();
|
else loadSessionList();
|
||||||
}
|
}
|
||||||
}
|
$('da-files').addEventListener('click', () => {
|
||||||
$('da-sessions').addEventListener('click', () => setDrawerPane('sessions'));
|
setDrawerPane(!$('drawer').classList.contains('drawer-mode-files'));
|
||||||
$('da-files').addEventListener('click', () => setDrawerPane('files'));
|
});
|
||||||
// 预览:同一个按钮开/关右侧面板
|
// 预览:同一个按钮开/关右侧面板
|
||||||
$('da-preview').addEventListener('click', () => {
|
$('da-preview').addEventListener('click', () => {
|
||||||
if (typeof pvTogglePane === 'function') pvTogglePane();
|
if (typeof pvTogglePane === 'function') pvTogglePane();
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// 通用文档预览窗(桌面右侧 #pv-pane / 移动端全屏 #fs-viewer)
|
// 通用文档预览窗(桌面分栏 #pv-pane:文件树 | 预览 | 会话 / 移动端全屏 #fs-viewer)
|
||||||
// —— 文件列表的点击一律进预览窗:office 走 /preview 预览网关(固定格式前端自拼);
|
// —— 文件列表的点击一律进预览窗:office 走 /preview 预览网关(固定格式前端自拼);
|
||||||
// md/txt/代码/json/csv 等文本渲染;html/pdf/图片专用渲染;其余类型显示文件信息占位 + 下载。
|
// md/txt/代码/json/csv 等文本渲染;html/pdf/图片专用渲染;其余类型显示文件信息占位 + 下载。
|
||||||
// 桌面端与左栏并排(不再自动折叠左栏让位);左右边界可拖拽调宽(记忆在 localStorage)。
|
// 桌面端紧贴左栏文件树右侧:点文件后内容就在旁边,不用横跨整个会话区看。
|
||||||
|
// 右边界可拖拽调宽(记忆在 localStorage)。
|
||||||
// 依赖(core.js/chat.js/stream.js/files.js 顶层声明):state $ esc toast mdHtml decorateCodePre
|
// 依赖(core.js/chat.js/stream.js/files.js 顶层声明):state $ esc toast mdHtml decorateCodePre
|
||||||
// rewriteHtmlDocSrcs rewriteMdImageSrcs openFullscreen setFsSource closeFullscreen
|
// rewriteHtmlDocSrcs rewriteMdImageSrcs openFullscreen setFsSource closeFullscreen
|
||||||
// openImageViewer downloadFile openDrawer
|
// openImageViewer downloadFile openDrawer
|
||||||
@@ -119,10 +120,13 @@ function pvInfoNode(name, sizeText, hint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pvOpenPane() {
|
function pvOpenPane() {
|
||||||
// 不自动折叠左侧栏:本地端左栏是文件树,打开预览时保持可见(左侧树 + 右侧预览并排)。
|
// 不自动折叠左侧栏:左栏是文件树,打开预览时保持可见(文件树 | 预览 | 会话)。
|
||||||
if (!document.body.classList.contains('pv-open')) {
|
if (!document.body.classList.contains('pv-open')) {
|
||||||
document.body.classList.add('pv-open');
|
document.body.classList.add('pv-open');
|
||||||
}
|
}
|
||||||
|
// 开预览就把侧栏切到文件树:预览就贴在它旁边,切了才能顺手换文件看。
|
||||||
|
// 已经在文件页时 setDrawerPane 内部会因「没变化」而直接返回,不会重复拉树。
|
||||||
|
if (typeof setDrawerPane === 'function') setDrawerPane(true);
|
||||||
pvSyncBtn();
|
pvSyncBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +139,7 @@ function pvCloseDoc() {
|
|||||||
pvSyncBtn();
|
pvSyncBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 侧栏底部「预览」图标:开/关右侧预览面板(桌面端)。图标随开合高亮。
|
// 侧栏底部「预览」图标:开/关预览分栏(桌面端)。图标随开合高亮。
|
||||||
function pvSyncBtn() {
|
function pvSyncBtn() {
|
||||||
const b = document.getElementById('da-preview');
|
const b = document.getElementById('da-preview');
|
||||||
if (b) b.classList.toggle('active', document.body.classList.contains('pv-open'));
|
if (b) b.classList.toggle('active', document.body.classList.contains('pv-open'));
|
||||||
@@ -143,7 +147,7 @@ function pvSyncBtn() {
|
|||||||
|
|
||||||
// 同一个图标开/关预览:已开 → 关;未开 → 优先重开上次看过的文件,没有就开空面板给个提示。
|
// 同一个图标开/关预览:已开 → 关;未开 → 优先重开上次看过的文件,没有就开空面板给个提示。
|
||||||
function pvTogglePane() {
|
function pvTogglePane() {
|
||||||
if (!pvDesktop()) return; // 移动端预览走全屏 #fs-viewer,不维护右栏
|
if (!pvDesktop()) return; // 移动端预览走全屏 #fs-viewer,不维护分栏
|
||||||
if (document.body.classList.contains('pv-open')) { pvCloseDoc(); return; }
|
if (document.body.classList.contains('pv-open')) { pvCloseDoc(); return; }
|
||||||
if (pvState.lastName) { openFilePreview(pvState.lastName); return; }
|
if (pvState.lastName) { openFilePreview(pvState.lastName); return; }
|
||||||
pvOpenPane(); pvClearBody(); pvHeader('', '');
|
pvOpenPane(); pvClearBody(); pvHeader('', '');
|
||||||
@@ -592,17 +596,18 @@ window.addEventListener('popstate', () => {
|
|||||||
const fs = document.getElementById('fs-viewer');
|
const fs = document.getElementById('fs-viewer');
|
||||||
if (!fs.classList.contains('hidden') && fs.querySelector('.fs-html-frame[src^="/preview/"]')) closeFullscreen();
|
if (!fs.classList.contains('hidden') && fs.querySelector('.fs-html-frame[src^="/preview/"]')) closeFullscreen();
|
||||||
});
|
});
|
||||||
// Esc 关闭右栏(未开全屏查看器时)
|
// Esc 关闭预览分栏(未开全屏查看器时)
|
||||||
window.addEventListener('keydown', (e) => {
|
window.addEventListener('keydown', (e) => {
|
||||||
if (e.key !== 'Escape') return;
|
if (e.key !== 'Escape') return;
|
||||||
if (document.activeElement && document.activeElement.id === 'pv-title') { document.activeElement.blur(); return; } // 地址条聚焦时:先退框不关栏
|
if (document.activeElement && document.activeElement.id === 'pv-title') { document.activeElement.blur(); return; } // 地址条聚焦时:先退框不关栏
|
||||||
if (!document.getElementById('fs-viewer').classList.contains('hidden')) return;
|
if (!document.getElementById('fs-viewer').classList.contains('hidden')) return;
|
||||||
pvCloseDoc();
|
pvCloseDoc();
|
||||||
});
|
});
|
||||||
// 窗口收窄到移动端宽度:右栏收起
|
// 窗口收窄到移动端宽度:预览栏收起
|
||||||
window.matchMedia('(min-width: 960px)').addEventListener('change', () => { if (!pvDesktop()) pvCloseDoc(); });
|
window.matchMedia('(min-width: 960px)').addEventListener('change', () => { if (!pvDesktop()) pvCloseDoc(); });
|
||||||
|
|
||||||
// ---------- 左缘拖拽调宽(预览/会话列边界):双击复位默认宽度,宽度记在 localStorage ----------
|
// ---------- 右缘拖拽调宽(预览/会话列边界):双击复位默认宽度,宽度记在 localStorage ----------
|
||||||
|
// 预览现在贴在文件树右侧(文件树 | 预览 | 会话),所以手柄在它自己的右缘,往右拖变宽。
|
||||||
(function bindPvResize() {
|
(function bindPvResize() {
|
||||||
const pane = document.getElementById('pv-pane');
|
const pane = document.getElementById('pv-pane');
|
||||||
const saved = Number(localStorage.getItem('pv-w') || 0);
|
const saved = Number(localStorage.getItem('pv-w') || 0);
|
||||||
@@ -619,7 +624,7 @@ window.matchMedia('(min-width: 960px)').addEventListener('change', () => { if (!
|
|||||||
});
|
});
|
||||||
h.addEventListener('pointermove', (e) => {
|
h.addEventListener('pointermove', (e) => {
|
||||||
if (!st) return;
|
if (!st) return;
|
||||||
document.documentElement.style.setProperty('--pv-w', clamp(st.w + (st.x - e.clientX)) + 'px');
|
document.documentElement.style.setProperty('--pv-w', clamp(st.w + (e.clientX - st.x)) + 'px');
|
||||||
});
|
});
|
||||||
function end() {
|
function end() {
|
||||||
if (!st) return;
|
if (!st) return;
|
||||||
|
|||||||
@@ -188,9 +188,8 @@
|
|||||||
closeStream();
|
closeStream();
|
||||||
removeTyping();
|
removeTyping();
|
||||||
setFilesPanel(false); // 会话切换,收起文件面板防旧列表残留
|
setFilesPanel(false); // 会话切换,收起文件面板防旧列表残留
|
||||||
if (typeof pvCloseDoc === 'function') pvCloseDoc(); // 同上:收起文档预览右栏,防旧会话内容残留
|
// 预览分栏故意不关:它现在是「随手看参考」的第三列,切会话时关掉会让用户反复重开。
|
||||||
// 预览图标会「重开上次看过的文件」,跨会话重开会指向别的会话的路径,逐会话清掉
|
// 保留已渲染的内容(静态文件,不存在跨会话越权),点新会话的文件会自然覆盖。
|
||||||
if (typeof pvState === 'object' && pvState) pvState.lastName = null;
|
|
||||||
state.sessionId = id;
|
state.sessionId = id;
|
||||||
state.status = '';
|
state.status = '';
|
||||||
state.modelId = '';
|
state.modelId = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user