init
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
## 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`。
|
||||
@@ -0,0 +1,18 @@
|
||||
# 2026-07-18 工作日志
|
||||
|
||||
## 1. 诊断:部分 .zip 文件不显示
|
||||
- 现象:`Nginx-Fancyindex-Theme.zip` 不显示,`ServerStack.zip` 正常显示。
|
||||
- 根因:`fancyindex.conf` 第 8 行 `fancyindex_ignore "theme";` 本意是隐藏 `/theme/` 资源目录,
|
||||
但 `fancyindex_ignore` 在 PCRE 下是**不区分大小写 + 未锚定的子串正则**(`ngx_http_fancyindex_module.c`
|
||||
用 `NGX_REGEX_CASELESS` 编译,且按裸文件名匹配、无 `^$` 锚点),因此也命中了文件名含 `Theme` 的 zip。
|
||||
- 建议修复(尚未改动配置):改为 `fancyindex_ignore "^theme$";` 精确匹配目录名,避免误伤含 theme 的文件。
|
||||
|
||||
## 2. 修改:列标题改为 File Name / File Size / Date
|
||||
- nginx 的 `ngx-fancyindex` 模块自行生成 `table#list` 的 `<thead>`,主题无法用静态 HTML 改表头文字;
|
||||
且 `styles.css` 的 `thead th { text-transform: uppercase }` 会把标题强制大写。
|
||||
- 方案:在 `theme/header.html` 的 IIFE 中新增 `renameHeaders()`,于 `onReady()` 调用,
|
||||
用 JS 改写 `table#list` 与 `table.results` 的 `<th>` 文本为
|
||||
`['File Name','File Size','Date','']`,并通过内联 `th.style.textTransform='none'` 覆盖大写(内联优先级高于外部 CDN 样式,无需改 CSS 文件)。
|
||||
- 同步更新 `theme-preview.html` 的静态 thead 与脚本,保持预览一致。
|
||||
- 注:`header.html:1` 仍引用外部 `https://repo.52or.com/fancyindex/styles.css?v=3`,本地 `theme/css/styles.css` 不一定线上生效;JS 内联方案不受此影响。
|
||||
- **回退**:用户要求"回退到上一个版本",已将 `theme/header.html` 与 `theme-preview.html` 中本次的列标题改动全部撤销,恢复为 `Name / Size / Last modified`。主题文件当前回到改动前状态。
|
||||
@@ -0,0 +1,10 @@
|
||||
# 项目长期记忆:Nginx-Fancyindex-Theme
|
||||
|
||||
## 部署约定
|
||||
- 主题资源放在 nginx `root` 下的 `theme/`:`/theme/header.html`、`/theme/footer.html`、`/theme/css/styles.css`。
|
||||
- 依赖第三方 `ngx-fancyindex` 模块;未编译则 `fancyindex` 指令报错。
|
||||
- `fancyindex_ignore "theme"` 仅隐藏列表显示,不阻止对 `/theme/...` 的直接访问。
|
||||
|
||||
## 已知坑
|
||||
- 搜索结果显示需手动构建表格行:不可依赖抓取到的 `tr.outerHTML` 直接插入新表格,否则会出现列缺失、链接错误、只显示文件名等问题。应提取 `{ name, full, isDir, size, date }` 结构化数据后重新渲染 4 列表格(Name / Size / Last modified / 空)。
|
||||
- `header.html` 中 CSS 链接、目录路径清理、搜索递归均用前端 JS 实现,修改后刷新页面即可生效,无需 reload nginx。
|
||||
Reference in New Issue
Block a user