vitepress-plugin-filelist 0.2.2 → 0.3.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
@@ -5,11 +5,13 @@
5
5
  ## 功能
6
6
 
7
7
  - 📁 树形目录,文件夹按需加载
8
- - ✅ 勾选文件;选中文件夹会连带其已加载的子项
9
- - 📦 批量打包 ZIP(基于 `fflate`),带进度
8
+ - ✅ 勾选文件;选中文件夹会自动加载并选中其下所有层级的文件
9
+ - 📦 批量打包 ZIP(基于 `fflate`),带进度;保留目录结构,不同目录的同名文件不会互相覆盖
10
10
  - ⬇️ 单文件下载与预览(`/d/`、`/p/`、`fs/get` 的 `raw_url`)
11
11
  - 🔐 目录密码输入,可选只读 token
12
12
  - 🔎 当前树过滤,按名称 / 大小 / 日期排序
13
+ - 🎨 紧凑表格:按文件类型着色的扩展名标签、层级引导线,跟随 VitePress 亮 / 暗主题
14
+ - 📱 窄容器(< 560px)自动切换为双行列表与 44px 触控区,勾选后工具栏变为吸顶操作条
13
15
  - 🌐 使用 `/api/fs/list`、`/api/fs/get`、`/api/public/settings`
14
16
  - 🧪 `base` 为空时使用内置演示数据
15
17
  - SSR 安全(网络请求只在客户端执行)
@@ -99,8 +101,8 @@ export default {
99
101
 
100
102
  - 目录路径挂载为根文件夹,默认折叠;`expanded` 可为全局或单个 source 打开
101
103
  - 文件路径挂载为一条文件记录,直接预览/下载
102
- - 根目录复选框与勾选、全选效果一致:选中根目录会选中其已加载的子项
103
- - 每个 source 可单独设置 `title`、`password`
104
+ - 勾选根目录会加载并选中其下所有文件;ZIP 内以根节点名称(`title` 或路径末段)作为顶层文件夹,文件根保留原文件名
105
+ - 每个 source 可单独设置 `title`、`password`;未设置 `password` 的 source 使用组件的 `password` 或运行时输入的密码,遇到需要密码的目录会弹出密码输入框
104
106
  - 根节点顺序按 `sources` 顺序,子项仍按名称/大小/日期排序
105
107
 
106
108
  ```ts
@@ -112,6 +114,24 @@ interface FileListSource {
112
114
  }
113
115
  ```
114
116
 
117
+ ## 界面与布局
118
+
119
+ - 宽容器:表格布局(勾选 / 名称 / 大小 / 修改日期 / 操作),行高 40px;勾选文件后,工具栏原地变为操作条(已选数量、总大小、清除、下载 ZIP)
120
+ - 窄容器(组件宽度 < 560px,基于容器查询而非视口宽度,侧边栏挤压时同样生效):
121
+ - 隐藏“修改日期”列,大小与日期显示在文件名下方
122
+ - 行高 56px,复选框、展开、预览、下载的触控区不小于 44px
123
+ - 表头排序改为下拉选择
124
+ - 勾选后操作条吸附在组件顶部,位于 VitePress 导航栏 / “On this page” 栏下方,只在本组件范围内吸附
125
+ - 颜色全部取自 VitePress 主题变量,暗色模式自动适配
126
+
127
+ 吸顶偏移默认根据 `.VPNav`、`.VPLocalNav` 的实际高度自动计算;自定义主题可手动指定:
128
+
129
+ ```css
130
+ .fl-root {
131
+ --fl-sticky-top: 56px;
132
+ }
133
+ ```
134
+
115
135
  ## 国际化
116
136
 
117
137
  ```md
@@ -181,7 +201,7 @@ Deno 可以安装 npm 依赖,但目前用 Deno 构建 VitePress 会在 rolldow
181
201
  ## 说明
182
202
 
183
203
  - 批量 ZIP 通过 `raw_url`(OpenList `/p/` 代理)下载,CORS 保持在 OpenList 源上
184
- - 全选只统计已加载的文件;页脚会显示还有多少文件夹未展开
204
+ - 表头全选只统计已加载的文件,页脚会显示还有多少文件夹未展开;勾选单个文件夹则会递归加载其全部子目录(目录很深或很多时会逐个请求,可能较慢)
185
205
  - 目录以 `per_page: 0` 请求全部条目;超大目录可能较慢,暂未实现分页
186
206
 
187
207
  ## 开发
@@ -190,7 +210,7 @@ Deno 可以安装 npm 依赖,但目前用 Deno 构建 VitePress 会在 rolldow
190
210
  pnpm install
191
211
  pnpm run build # 生成 dist/node、dist/client/ssr、dist/client/browser、style.css
192
212
  pnpm run typecheck
193
- pnpm test # Vitest:utils + locale helpers
213
+ pnpm test # Vitest:utils、locale helpers、FileList 组件
194
214
  pnpm run pack:check
195
215
  ```
196
216
 
@@ -6,6 +6,7 @@ interface FileListLabels {
6
6
  filter: string;
7
7
  refresh: string;
8
8
  batch: string;
9
+ /** @deprecated No longer shown; the selection count lives in the toolbar. */
9
10
  batchCount: string;
10
11
  batching: string;
11
12
  passwordPrompt: string;
@@ -33,6 +34,23 @@ interface FileListLabels {
33
34
  previewFailed: string;
34
35
  batchFailed: string;
35
36
  defaultZip: string;
37
+ /** Text button that clears the selection (wide layout). */
38
+ clear: string;
39
+ /** Accessible name of the clear-selection button. */
40
+ clearSelection: string;
41
+ /** `{size}` total, used for the selection and the footer. */
42
+ totalSize: string;
43
+ /** `{count}` files inside a loaded folder. */
44
+ folderItems: string;
45
+ /** Label of the compact sort select shown in narrow containers. */
46
+ sortBy: string;
47
+ selectAll: string;
48
+ /** Accessible name of a row checkbox, `{name}`. */
49
+ selectItem: string;
50
+ /** Accessible name of the expand button, `{name}`. */
51
+ expand: string;
52
+ /** Accessible name of the collapse button, `{name}`. */
53
+ collapse: string;
36
54
  }
37
55
  interface FileListSource {
38
56
  /** OpenList path, directory or single file. */
@@ -171,9 +189,28 @@ export interface SortableNode {
171
189
  export type SortKey = 'name' | 'size' | 'modified';
172
190
  export declare function joinPath(parent: string, name: string): string;
173
191
  export declare function encodePath(path: string): string;
192
+ /**
193
+ * Make one path segment safe as a ZIP entry segment: no separators,
194
+ * no `.` / `..` traversal, no empty names.
195
+ */
196
+ export declare function zipSegment(name: string): string;
197
+ /** Join path segments into a ZIP entry name, sanitising each segment. */
198
+ export declare function zipEntryName(segments: string[]): string;
199
+ /**
200
+ * Return `name`, or `name (2)`, `name (3)`... when it is already in `used`.
201
+ * The suffix goes before the extension of the last segment. Adds the result to `used`.
202
+ */
203
+ export declare function uniqueEntryName(name: string, used: Set<string>): string;
174
204
  export declare function formatSize(size: number): string;
175
205
  export declare function formatDate(iso: string): string;
176
206
  export declare function extOf(name: string): string;
207
+ export type FileKind = 'doc' | 'sheet' | 'slide' | 'pdf' | 'image' | 'media' | 'archive' | 'code' | 'other';
208
+ /** Rough file family, used to colour the type badge. */
209
+ export declare function fileKind(name: string): FileKind;
210
+ /** Sum of the `size` of the given entries, ignoring missing or invalid sizes. */
211
+ export declare function totalSize(items: Array<{
212
+ size?: number;
213
+ }>): number;
177
214
  export declare function compareNodes(a: SortableNode, b: SortableNode, key: SortKey, ascending?: boolean): number;
178
215
  /**
179
216
  * Register `<FileList>` and `<VPFileList>` globally.