vitepress-plugin-filelist 0.3.0 → 0.4.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 +21 -4
- package/dist/client/browser/index.d.ts +45 -0
- package/dist/client/browser/index.js +701 -43
- package/dist/client/ssr/index.d.ts +45 -0
- package/dist/client/ssr/index.js +514 -22
- package/dist/client/style.css +253 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
- 📁 树形目录,文件夹按需加载
|
|
8
8
|
- ✅ 勾选文件;选中文件夹会自动加载并选中其下所有层级的文件
|
|
9
9
|
- 📦 批量打包 ZIP(基于 `fflate`),带进度;保留目录结构,不同目录的同名文件不会互相覆盖
|
|
10
|
-
- ⬇️
|
|
10
|
+
- ⬇️ 单文件下载(`fs/get` 的 `raw_url`,回退 `/d/`)
|
|
11
|
+
- 👁️ 弹窗预览(不跳转):图片、音视频、文本、PDF;Office 等其它类型显示文件信息与下载
|
|
11
12
|
- 🔐 目录密码输入,可选只读 token
|
|
12
13
|
- 🔎 当前树过滤,按名称 / 大小 / 日期排序
|
|
13
14
|
- 🎨 紧凑表格:按文件类型着色的扩展名标签、层级引导线,跟随 VitePress 亮 / 暗主题
|
|
@@ -132,6 +133,22 @@ interface FileListSource {
|
|
|
132
133
|
}
|
|
133
134
|
```
|
|
134
135
|
|
|
136
|
+
## 预览
|
|
137
|
+
|
|
138
|
+
点击预览按钮在当前页面的弹窗(原生 `<dialog>`)中显示,不跳转、不打开新标签页。只有能在页面内显示的类型才有预览按钮;点击文件名仍是下载。
|
|
139
|
+
|
|
140
|
+
| 类型 | 扩展名(节选) | 方式 |
|
|
141
|
+
| --- | --- | --- |
|
|
142
|
+
| 图片 | png、jpg、gif、webp、svg、avif | `<img>`,可旋转、切换原始大小 |
|
|
143
|
+
| 视频 / 音频 | mp4、webm、mov / mp3、m4a、flac、wav | 原生播放器(格式以浏览器支持为准) |
|
|
144
|
+
| 文本 | txt、md、json、csv、yaml、日志与常见代码 | 只读取前 1 MB(Range 请求),纯文本显示 |
|
|
145
|
+
| PDF | pdf | 优先使用 OpenList `iframe_previews` 中配置的 PDF 查看器;未配置时用浏览器自带阅读器(下载后以 Blob 显示,上限 50 MB) |
|
|
146
|
+
| 其它(含 Office、压缩包) | — | 弹窗内显示文件信息和下载按钮 |
|
|
147
|
+
|
|
148
|
+
- 弹窗内 ← / → 切换当前列表中的可预览文件,Esc 或点击遮罩关闭
|
|
149
|
+
- 读取文本和浏览器 PDF 需要文件地址允许跨域:经 OpenList 代理(`/p/`)时由 OpenList 的 CORS 设置决定;网盘直链由网盘决定。失败时显示“无法在页面内预览”和下载按钮
|
|
150
|
+
- `iframe_previews` 来自 `/api/public/settings`,与 OpenList 网页端使用同一配置,占位符 `$url`、`$e_url`、`$b_url`、`$durl`、`$name` 的含义一致
|
|
151
|
+
|
|
135
152
|
## 国际化
|
|
136
153
|
|
|
137
154
|
```md
|
|
@@ -167,8 +184,8 @@ import { fileListLocales, formatLabel, resolveLabels } from 'vitepress-plugin-fi
|
|
|
167
184
|
| --- | --- |
|
|
168
185
|
| `POST /api/fs/list` | 目录列表(`per_page: 0`) |
|
|
169
186
|
| `POST /api/fs/get` | 获取下载 / 预览 / 打包用的 `raw_url`;失败时回退到 `/d/...?sign=` |
|
|
170
|
-
| `GET /api/public/settings` | 获取 `site_title` |
|
|
171
|
-
| `GET /d/...`、`GET /p/...` |
|
|
187
|
+
| `GET /api/public/settings` | 获取 `site_title`、`iframe_previews` |
|
|
188
|
+
| `GET /d/...`、`GET /p/...` | 下载与预览读取的文件地址 |
|
|
172
189
|
|
|
173
190
|
## 导出
|
|
174
191
|
|
|
@@ -201,7 +218,7 @@ Deno 可以安装 npm 依赖,但目前用 Deno 构建 VitePress 会在 rolldow
|
|
|
201
218
|
## 说明
|
|
202
219
|
|
|
203
220
|
- 批量 ZIP 通过 `raw_url`(OpenList `/p/` 代理)下载,CORS 保持在 OpenList 源上
|
|
204
|
-
-
|
|
221
|
+
- 表头全选只统计已加载的文件;勾选单个文件夹则会递归加载其全部子目录(目录很深或很多时会逐个请求,可能较慢)
|
|
205
222
|
- 目录以 `per_page: 0` 请求全部条目;超大目录可能较慢,暂未实现分页
|
|
206
223
|
|
|
207
224
|
## 开发
|
|
@@ -25,12 +25,14 @@ interface FileListLabels {
|
|
|
25
25
|
download: string;
|
|
26
26
|
loaded: string;
|
|
27
27
|
selected: string;
|
|
28
|
+
/** @deprecated No longer shown; the footer only shows loaded files and size. */
|
|
28
29
|
unloaded: string;
|
|
29
30
|
folderFailed: string;
|
|
30
31
|
demoDownload: string;
|
|
31
32
|
demoPreview: string;
|
|
32
33
|
demoBatch: string;
|
|
33
34
|
downloadFailed: string;
|
|
35
|
+
/** @deprecated Preview errors are shown in the dialog (`previewUnavailable`). */
|
|
34
36
|
previewFailed: string;
|
|
35
37
|
batchFailed: string;
|
|
36
38
|
defaultZip: string;
|
|
@@ -51,6 +53,23 @@ interface FileListLabels {
|
|
|
51
53
|
expand: string;
|
|
52
54
|
/** Accessible name of the collapse button, `{name}`. */
|
|
53
55
|
collapse: string;
|
|
56
|
+
/** Preview dialog: close button. */
|
|
57
|
+
close: string;
|
|
58
|
+
/** Preview dialog: previous / next previewable file. */
|
|
59
|
+
previous: string;
|
|
60
|
+
next: string;
|
|
61
|
+
/** Preview dialog: rotate image by 90°. */
|
|
62
|
+
rotate: string;
|
|
63
|
+
/** Preview dialog: toggle the image between fit-to-window and actual size. */
|
|
64
|
+
actualSize: string;
|
|
65
|
+
/** Preview dialog: file type that is not previewed (Office and others). */
|
|
66
|
+
previewUnsupported: string;
|
|
67
|
+
/** Preview dialog: preview failed (network, CORS, unsupported codec). */
|
|
68
|
+
previewUnavailable: string;
|
|
69
|
+
/** Preview dialog: PDF larger than the in-page limit, `{size}`. */
|
|
70
|
+
previewTooLarge: string;
|
|
71
|
+
/** Preview dialog: only the first `{size}` of a text file is shown. */
|
|
72
|
+
textTruncated: string;
|
|
54
73
|
}
|
|
55
74
|
interface FileListSource {
|
|
56
75
|
/** OpenList path, directory or single file. */
|
|
@@ -212,6 +231,32 @@ export declare function totalSize(items: Array<{
|
|
|
212
231
|
size?: number;
|
|
213
232
|
}>): number;
|
|
214
233
|
export declare function compareNodes(a: SortableNode, b: SortableNode, key: SortKey, ascending?: boolean): number;
|
|
234
|
+
export type PreviewKind = 'image' | 'video' | 'audio' | 'text' | 'pdf' | 'none';
|
|
235
|
+
/**
|
|
236
|
+
* How a file is shown in the preview dialog. Office documents and anything
|
|
237
|
+
* else the browser cannot render are `none` (info + download).
|
|
238
|
+
*/
|
|
239
|
+
export declare function previewKind(name: string): PreviewKind;
|
|
240
|
+
export interface IframePreview {
|
|
241
|
+
label: string;
|
|
242
|
+
scheme: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Viewers from OpenList's public `iframe_previews` setting that match a file,
|
|
246
|
+
* in the order OpenList lists them. Keys are comma-separated extensions or a
|
|
247
|
+
* `/regex/flags` tested against the extension, as in OpenList's frontend.
|
|
248
|
+
*/
|
|
249
|
+
export declare function iframePreviewsFor(name: string, setting: string | undefined): IframePreview[];
|
|
250
|
+
/**
|
|
251
|
+
* Fill an OpenList preview scheme: `$name`, `$url` (raw URL) and `$durl`
|
|
252
|
+
* (signed download URL), each optionally prefixed with `e` (URI-encode) or
|
|
253
|
+
* `b` (base64), e.g. `$e_url`, `$b_url`, `$e_durl`.
|
|
254
|
+
*/
|
|
255
|
+
export declare function fillPreviewUrl(scheme: string, args: {
|
|
256
|
+
name: string;
|
|
257
|
+
rawUrl: string;
|
|
258
|
+
downloadUrl: string;
|
|
259
|
+
}): string;
|
|
215
260
|
/**
|
|
216
261
|
* Register `<FileList>` and `<VPFileList>` globally.
|
|
217
262
|
*
|