vitepress-plugin-filelist 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,9 +9,10 @@
9
9
  - 📦 批量打包 ZIP(基于 `client-zip`),带进度、可取消;Chrome / Edge 边下载边写入磁盘,不受大小限制;保留目录结构,不同目录的同名文件不会互相覆盖
10
10
  - 📄 大目录每个文件夹先显示 200 条,可“显示更多 / 全部显示”
11
11
  - ⬇️ 单文件下载(`fs/get` 的 `raw_url`,回退 `/d/`):交给浏览器下载;OpenList 自己的 `/p/`、`/d/` 链接在当前页直接下载、不打开新标签页,存储直链在新标签页打开
12
- - 👁️ 弹窗预览(不跳转):图片、音视频、文本、PDF;Office 等其它类型显示文件信息与下载
12
+ - 👁️ 弹窗预览(不跳转):图片、音视频、文本、PDF;Markdown / HTML 可在源码与渲染之间切换;Office 等其它类型显示文件信息与下载
13
13
  - 🔐 目录密码输入,可选只读 token
14
- - 🔎 当前树过滤,按名称 / 大小 / 日期排序
14
+ - 🔎 筛选并高亮关键词;“深度搜索”读取未展开的子目录,结果直接出现在原位置
15
+ - ↕️ 按名称 / 大小 / 日期排序;名称排序跟随界面语言(中文按拼音、英文按字母),数字按自然顺序
15
16
  - 🎨 紧凑表格:按文件类型着色的扩展名标签、层级引导线,跟随 VitePress 亮 / 暗主题
16
17
  - 📱 窄容器(< 560px)自动切换为双行列表与 44px 触控区,勾选后工具栏变为吸顶操作条
17
18
  - 🌐 使用 `/api/fs/list`、`/api/fs/get`、`/api/public/settings`
@@ -83,6 +84,7 @@ export default {
83
84
  | `password` | `string` | `''` | 目录密码,也可以在运行时输入 |
84
85
  | `rememberPassword` | `boolean` | `true` | 输入密码时是否提供“在此标签页中记住”开关;`false` 时不写入 sessionStorage |
85
86
  | `pageSize` | `number` | `200` | 每个文件夹先显示的条数,之后显示“显示更多 / 全部显示”;`0` 全部显示 |
87
+ | `deepSearchLimit` | `number` | `500` | 深度搜索每次最多读取的文件夹数,之后可“继续” |
86
88
  | `zipWarnSize` | `number` | `500`(触屏 `200`) | 需在内存中打包的浏览器(Firefox、Safari)超过该大小(MB)先确认;`0` 不提示 |
87
89
  | `zipMaxSize` | `number` | `2048`(触屏 `1024`) | 同上,超过该大小(MB)不打包;`0` 不限制 |
88
90
  | `title` | `string` | `''` | 工具栏标题;为空时回退到 OpenList 的 `site_title` |
@@ -134,7 +136,7 @@ interface FileListSource {
134
136
 
135
137
  - Chrome / Edge(含较新的 Android Chrome):点“下载 ZIP”先弹出系统“另存为”窗口,之后边下载边写入,内存占用很小,不受大小限制
136
138
  - Firefox、Safari、iPhone:浏览器只能先把文件放进内存再打包。按已选总大小判断:超过 `zipWarnSize` 先确认,超过 `zipMaxSize` 不打包并建议分批
137
- - 打包期间操作条显示进度(大小与文件数),可随时取消;勾选暂时锁定。任一文件失败会整体取消并提示文件名
139
+ - 打包期间操作条显示进度(大小与文件数),可随时取消;勾选暂时锁定。任一文件失败会整体取消,并弹窗说明是哪个文件、什么原因
138
140
  - 同时取 4 个文件(顺序不变),减少每个文件的网络等待;进度每 100 ms 更新一次
139
141
  - ZIP 只存储不压缩(网盘文件多为已压缩格式),支持超过 4 GB(Zip64)
140
142
 
@@ -144,6 +146,14 @@ interface FileListSource {
144
146
  - 数据一次全部取回,只减少渲染:排序后再截取,勾选文件夹 / 全选包含未显示的文件,输入筛选词时显示全部匹配
145
147
  - 刷新后保留已展开的条数
146
148
 
149
+ ## 筛选与深度搜索
150
+
151
+ - 输入关键词后立即筛选已加载的内容,显示匹配项及其所在目录,关键词高亮
152
+ - 挂载目录下还有未加载的子文件夹时,列表末尾显示“只筛选了已加载的内容 · 深度搜索”
153
+ - 深度搜索不使用 OpenList 的搜索接口(无需搜索索引):组件逐个读取未加载的子文件夹(同时 4 个,每次最多 `deepSearchLimit` 个),匹配项边找边出现在原位置,可勾选、打包、预览、下载
154
+ - 搜索中可“停止”;达到上限时显示“继续”;加密文件夹跳过并计数,输入密码后再次深度搜索即可包含
155
+ - 清空关键词回到原来的展开状态,已读取的目录不再重复请求
156
+
147
157
  ## 刷新与目录密码
148
158
 
149
159
  - **刷新**:保留当前列表并调暗,表头下方显示进度条;完成后整体替换,已展开的目录和仍存在的勾选会保留。刷新失败时保留旧数据并提示。刷新只重新读取 OpenList 的目录缓存(游客没有写权限,无法强制刷新存储)
@@ -171,9 +181,13 @@ interface FileListSource {
171
181
  | 图片 | png、jpg、gif、webp、svg、avif | `<img>`,可旋转、切换原始大小 |
172
182
  | 视频 / 音频 | mp4、webm、mov / mp3、m4a、flac、wav | 原生播放器(格式以浏览器支持为准) |
173
183
  | 文本 | txt、md、json、csv、yaml、日志与常见代码 | 只读取前 1 MB(Range 请求),纯文本显示 |
184
+ | Markdown / HTML | md、markdown / html、htm | 默认显示源码;可切换为“渲染”(见下) |
174
185
  | PDF | pdf | 优先使用 OpenList `iframe_previews` 中配置的 PDF 查看器;未配置时用浏览器自带阅读器(下载后以 Blob 显示,上限 50 MB) |
175
186
  | 其它(含 Office、压缩包) | — | 弹窗内显示文件信息和下载按钮 |
176
187
 
188
+ - Markdown 渲染:使用 VitePress 正文样式;内容经 DOMPurify 过滤(去掉脚本、事件属性等);只有 http(s) / mailto 链接可点击并在新标签页打开,相对链接显示为文字;相对路径的图片显示为“[图片:替代文字]”。渲染库按需加载
189
+ - HTML 渲染:放在空 `sandbox` 的 iframe 中,禁止脚本、表单和弹窗,无法访问当前页面;网页引用的相对路径资源不会加载
190
+ - 源码 / 渲染的选择在当前页面内记住
177
191
  - 弹窗内 ← / → 切换当前列表中的可预览文件,Esc 或点击遮罩关闭
178
192
  - 读取文本和浏览器 PDF 需要文件地址允许跨域:经 OpenList 代理(`/p/`)时由 OpenList 的 CORS 设置决定;网盘直链由网盘决定。失败时显示“无法在页面内预览”和下载按钮
179
193
  - `iframe_previews` 来自 `/api/public/settings`,与 OpenList 网页端使用同一配置,占位符 `$url`、`$e_url`、`$b_url`、`$durl`、`$name` 的含义一致
@@ -260,6 +274,15 @@ pnpm test # Vitest:工具函数、密码、下载、FileList 组件
260
274
  pnpm run pack:check
261
275
  ```
262
276
 
277
+ 浏览器测试(Playwright,Chromium 桌面 / 手机、WebKit):`demo/e2e` 下的测试站点连接本地模拟 OpenList(`e2e/mock-openlist.mjs`),检查行高与位移、密码、刷新、显示更多、单文件下载、ZIP(内存 / 流式 / 取消 / 失败)等。
278
+
279
+ ```bash
280
+ pnpm run e2e:site # 构建插件和测试站点
281
+ pnpm run test:e2e # 自动启动模拟 OpenList 与站点预览
282
+ ```
283
+
284
+ CI 每次推送和 PR 都会运行,三种环境均为必过项。
285
+
263
286
  源码结构(`src/client`):
264
287
 
265
288
  | 文件 | 职责 |
@@ -92,6 +92,27 @@ interface FileListLabels {
92
92
  unlockFolder: string;
93
93
  /** @deprecated Network failures now append `corsHint`. */
94
94
  networkHint: string;
95
+ /** Deep search: the row at the end of a filtered list. `{count}` where noted */
96
+ deepHint: string;
97
+ deepSearch: string;
98
+ deepRunning: string;
99
+ deepStop: string;
100
+ deepDone: string;
101
+ deepCapped: string;
102
+ deepContinue: string;
103
+ deepSkipped: string;
104
+ deepFailed: string;
105
+ /** Markdown / HTML preview: the source / rendered switch. */
106
+ viewMode: string;
107
+ viewSource: string;
108
+ viewRendered: string;
109
+ /** Above a rendered HTML file. */
110
+ htmlSandboxNote: string;
111
+ /** Stands in for a Markdown image with a relative path. `{alt}` */
112
+ imageOmitted: string;
113
+ /** Title of the dialog when a batch ZIP fails (the reason is the text). */
114
+ batchFailedTitle: string;
115
+ batchFailedHint: string;
95
116
  /** Single file handed to the browser's download manager. `{name}` */
96
117
  downloadStarted: string;
97
118
  /** Batch progress detail. `{done}` `{total}` sizes, `{files}` `{count}` file counts */
@@ -153,6 +174,11 @@ interface FileListProps {
153
174
  * everything. Data is still loaded in full; only rendering is limited.
154
175
  */
155
176
  pageSize?: number;
177
+ /**
178
+ * Deep search loads at most this many folders per click (“Continue” goes on).
179
+ * Defaults to `500`.
180
+ */
181
+ deepSearchLimit?: number;
156
182
  /**
157
183
  * Browsers that must build the ZIP in memory (Firefox, Safari) ask first above
158
184
  * this many MB. Defaults to 500 (200 on touch devices); `0` never asks.
@@ -189,6 +215,7 @@ declare const _default: import("vue").DefineComponent<FileListProps, {}, {}, {},
189
215
  title: string;
190
216
  rememberPassword: boolean;
191
217
  pageSize: number;
218
+ deepSearchLimit: number;
192
219
  locale: FileListLocale;
193
220
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
194
221
  declare global {
@@ -307,7 +334,7 @@ export declare function previewKind(name: string): PreviewKind;
307
334
  export declare function totalSize(items: Array<{
308
335
  size?: number;
309
336
  }>): number;
310
- export declare function compareNodes(a: SortableNode, b: SortableNode, key: SortKey, ascending?: boolean): number;
337
+ export declare function compareNodes(a: SortableNode, b: SortableNode, key: SortKey, ascending?: boolean, locale?: string): number;
311
338
  interface IframePreview {
312
339
  label: string;
313
340
  scheme: string;