Files
Nginx-Fancyindex-Theme/.workbuddy/memory/2026-07-17.md
T
condor b46270264b init
2026-07-24 19:05:07 +08:00

14 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 2026-07-17 工作记录
- 修复搜索结果表格显示异常:
- 问题:搜索只显示文件名(如 SimHei.ttf),缺少 Size、Last modified 列,且点击后 404。
- 根因:`render()` 直接把抓取到的 `tr.outerHTML` 拼进新表格,浏览器解析时 `<tr>` 不能作为 `<div>` 子元素,导致 `div.firstChild` 是文本节点,`href` 未正确替换,最终只渲染出孤立文件名。
- 修复:在 `theme/header.html``theme-preview.html``crawl()` 中改为提取结构化数据 `{ name, full, isDir, size, date }``render()` 手动生成完整 4 列表格行,并用 `escapeHtml()` 处理输出;链接统一用绝对路径 `full`,兼容 href 已以 `/` 开头的情况。
- 修复搜索结果中目录名双斜杠:原 `render()` 对目录无条件追加 `/`,而 fancyindex 的链接文本本身已带 `/`,导致 `client-v1.3.7//`。改为仅在 `e.name` 不以 `/` 结尾时才追加 `/`。同步更新 `theme/header.html``theme-preview.html`
- 说明:Directory 面包屑显示的是当前页面 URL 路径,搜索时 URL 不变,所以面包屑保持当前目录路径是正确行为;点击搜索结果进入子目录后才会更新。
- 新增「返回根目录」按钮:位于搜索框右侧,`.search-form` 改为 flex 布局,`.home-btn`accent 色胶囊按钮 + home 图标 + 文字),href="/";窄屏 (<=480px) 只显示图标。改动在 `theme/header.html``theme-preview.html``theme/css/styles.css`
- 新增「返回上一级目录」按钮:位于搜索框左侧,`initUpBtn()` 用 JS 根据 `location.pathname` 计算父目录并写入 `href`(如 /a/b/ -> /a/)。`.up-btn` 用 outline 风格(透明底 + border)与根目录实心按钮区分;窄屏只显示图标。改动同上三文件。
- 修复「上一级」按钮不显示:`initUpBtn()` 原在 `file://` 预览或站点根目录时 `display:none`,导致预览和根目录页看不到按钮。改为始终显示:预览时 `href="#"` 仅展示;http(s) 下根目录 `href="/"`、子目录指向上级 `path.slice(0, idx+1)`
- 关键部署修正:`theme/header.html` 第 1 行的 CSS 链接原本指向远程 `https://repo.52or.com/fancyindex/styles.css`,导致本地 `theme/css/styles.css` 的样式(含 `.up-btn`/`.home-btn`)在服务器上不生效。已改为 `/theme/css/styles.css`,与 `fancyindex.conf``/theme/...` 约定一致,主题自包含。
- 修复按钮被旧 CSS 缓存导致换行:截图显示「上一级」与「根目录」垂直堆叠、且输入框未同行,说明浏览器仍在用旧的(或未同步的)CSS,`.search-form {display:flex}` 未生效。给 CSS 链接加 `?v=3` 缓存戳,并在 `<form>` 上内联 `style="display:flex;justify-content:center;align-items:center;gap:10px;"` 作为兜底。同步更新 `theme/header.html``theme-preview.html`