vitepress-plugin-filelist 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/README.md +66 -66
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -1,29 +1,27 @@
1
1
  # vitepress-plugin-filelist
2
2
 
3
- OpenList file browser for VitePress — tree view, batch ZIP download, folder password and token support.
3
+ 面向 VitePress 的 OpenList 文件浏览组件:树形展开、勾选批量打包、目录密码、token,直接调用 OpenList 接口。
4
4
 
5
- VitePress 的 OpenList 文件浏览组件:树形展开、勾选批量打包、目录密码、token,直接调用 OpenList 接口。
5
+ ## 功能
6
6
 
7
- ## Features
7
+ - 📁 树形目录,文件夹按需加载
8
+ - ✅ 勾选文件;选中文件夹会连带其已加载的子项
9
+ - 📦 批量打包 ZIP(基于 `fflate`),带进度
10
+ - ⬇️ 单文件下载与预览(`/d/`、`/p/`、`fs/get` 的 `raw_url`)
11
+ - 🔐 目录密码输入,可选只读 token
12
+ - 🔎 当前树过滤,按名称 / 大小 / 日期排序
13
+ - 🌐 使用 `/api/fs/list`、`/api/fs/get`、`/api/public/settings`
14
+ - 🧪 `base` 为空时使用内置演示数据
15
+ - SSR 安全(网络请求只在客户端执行)
8
16
 
9
- - 📁 Tree view with lazy-loaded folders
10
- - ✅ Checkbox selection, folder selects its loaded children
11
- - 📦 Batch download as ZIP (via `fflate`), with progress
12
- - ⬇️ Single file download and preview (`/d/`, `/p/`, `fs/get` raw URL)
13
- - 🔐 Folder password prompt, optional read-only token
14
- - 🔎 Filter current tree, sortable name / size / date
15
- - 🌐 Uses `/api/fs/list`, `/api/fs/get`, `/api/public/settings`
16
- - 🧪 Demo mode with built-in fake data when `base` is empty
17
- - SSR safe (network requests only run on the client)
18
-
19
- ## Install
17
+ ## 安装
20
18
 
21
19
  ```bash
22
20
  pnpm add -D vitepress-plugin-filelist
23
- # or: npm i -D vitepress-plugin-filelist
21
+ # 或:npm i -D vitepress-plugin-filelist
24
22
  ```
25
23
 
26
- ## Usage with vitepress-tuck
24
+ ## 在 vitepress-tuck 中使用
27
25
 
28
26
  ```ts
29
27
  // .vitepress/config.ts
@@ -53,7 +51,7 @@ export default {
53
51
  <FileList base="https://pan.example.com" path="/课程资料" />
54
52
  ```
55
53
 
56
- ## Usage with plain VitePress
54
+ ## 在普通 VitePress 中使用
57
55
 
58
56
  ```ts
59
57
  // .vitepress/theme/index.ts
@@ -69,27 +67,27 @@ export default {
69
67
  }
70
68
  ```
71
69
 
72
- ## Props
70
+ ## 组件属性
73
71
 
74
- | Prop | Type | Default | Description |
72
+ | 属性 | 类型 | 默认值 | 说明 |
75
73
  | --- | --- | --- | --- |
76
- | `base` | `string` | `''` | OpenList base URL. Empty = demo mode |
77
- | `path` | `string` | `'/'` | Initial directory |
78
- | `token` | `string` | `''` | Optional read-only token (guest when omitted) |
79
- | `password` | `string` | `''` | Folder password; can also be entered at runtime |
80
- | `title` | `string` | `''` | Toolbar title; falls back to OpenList `site_title` |
81
- | `locale` | `'zh-CN' \| 'en-US'` | `'zh-CN'` | Built-in label preset |
82
- | `labels` | `Partial<FileListLabels>` | `undefined` | Per-key label overrides |
74
+ | `base` | `string` | `''` | OpenList 站点地址;为空时进入演示模式 |
75
+ | `path` | `string` | `'/'` | 初始目录 |
76
+ | `token` | `string` | `''` | 可选只读 token;不传则以游客身份请求 |
77
+ | `password` | `string` | `''` | 目录密码,也可以在运行时输入 |
78
+ | `title` | `string` | `''` | 工具栏标题;为空时回退到 OpenList 的 `site_title` |
79
+ | `locale` | `'zh-CN' \| 'en-US'` | `'zh-CN'` | 内置文案预设 |
80
+ | `labels` | `Partial<FileListLabels>` | `undefined` | 按 key 覆盖单条文案 |
83
81
 
84
- Both `<FileList>` and `<VPFileList>` are registered.
82
+ 同时注册了 `<FileList>` 和 `<VPFileList>` 两个组件名。
85
83
 
86
- ## i18n
84
+ ## 国际化
87
85
 
88
86
  ```md
89
87
  <FileList locale="en-US" base="https://pan.example.com" />
90
88
  ```
91
89
 
92
- Override individual labels on top of the preset:
90
+ 在预设基础上覆盖单条文案:
93
91
 
94
92
  ```md
95
93
  <FileList
@@ -98,74 +96,76 @@ Override individual labels on top of the preset:
98
96
  />
99
97
  ```
100
98
 
101
- Available presets: `zh-CN`, `en-US`. Placeholders use `{count}`, `{percent}`, `{message}`, `{name}` and are replaced by `formatLabel()`. The full key list is exported as `FileListLabels`:
99
+ 内置预设:`zh-CN`、`en-US`。占位符支持 `{count}`、`{percent}`、`{message}`、`{name}`,由 `formatLabel()` 替换。完整 key 列表通过 `FileListLabels` 导出:
102
100
 
103
101
  ```ts
104
102
  import type { FileListLabels } from 'vitepress-plugin-filelist/client'
105
103
  import { fileListLocales, formatLabel, resolveLabels } from 'vitepress-plugin-filelist/client'
106
104
  ```
107
105
 
108
- ## OpenList requirements
106
+ ## OpenList 要求
109
107
 
110
- 1. **Guest read access** — enable the guest user, or pass a read-only `token`.
111
- 2. **CORS** — OpenList's `cors.allow_origins` must include your site origin (default `*`).
112
- 3. **Same protocol** — an HTTPS page cannot call an HTTP OpenList (mixed content).
113
- 4. **Token is public** — only ship a read-only token that can be revoked.
108
+ 1. **游客只读权限**:开启游客用户,或传入只读 `token`
109
+ 2. **CORS**:OpenList 的 `cors.allow_origins` 必须包含站点来源(默认 `*`)
110
+ 3. **同协议**:HTTPS 页面不能请求 HTTP 的 OpenList(混合内容)
111
+ 4. **token 是公开的**:只放可撤销的只读 token,不要放管理 token
114
112
 
115
- The component calls:
113
+ 组件会调用:
116
114
 
117
- | Endpoint | Purpose |
115
+ | 接口 | 用途 |
118
116
  | --- | --- |
119
- | `POST /api/fs/list` | Directory listing (`per_page: 0`) |
120
- | `POST /api/fs/get` | `raw_url` for download / preview / ZIP; falls back to `/d/...?sign=` |
121
- | `GET /api/public/settings` | `site_title` fallback |
122
- | `GET /d/...` `GET /p/...` | Download / preview links generated by OpenList |
117
+ | `POST /api/fs/list` | 目录列表(`per_page: 0`) |
118
+ | `POST /api/fs/get` | 获取下载 / 预览 / 打包用的 `raw_url`;失败时回退到 `/d/...?sign=` |
119
+ | `GET /api/public/settings` | 获取 `site_title` |
120
+ | `GET /d/...`、`GET /p/...` | OpenList 生成的下载 / 预览链接 |
123
121
 
124
- ## Exports
122
+ ## 导出
125
123
 
126
- | Entry | Contents |
124
+ | 入口 | 内容 |
127
125
  | --- | --- |
128
- | `vitepress-plugin-filelist` | `fileList` plugin (default export) |
129
- | `vitepress-plugin-filelist/client` | `FileList`, `VPFileList`, `enhanceAppWithFileList`, types |
130
- | `vitepress-plugin-filelist/style.css` | Component styles |
126
+ | `vitepress-plugin-filelist` | `fileList` 插件(默认导出) |
127
+ | `vitepress-plugin-filelist/client` | `FileList`、`VPFileList`、`enhanceAppWithFileList`、类型 |
128
+ | `vitepress-plugin-filelist/style.css` | 组件样式 |
131
129
 
132
- ## Compatibility
130
+ ## 兼容性
133
131
 
134
- Peer dependency allows VitePress 1.x and 2.0 alpha: `^1.0.0 || ^2.0.0-alpha.0`.
132
+ peerDependencies 同时支持 VitePress 1.x 与 2.0 alpha:`^1.0.0 || ^2.0.0-alpha.0`。
135
133
 
136
- Tested locally against VitePress `2.0.0-alpha.21` on Node 22:
134
+ 在 Node 22 下针对 VitePress `2.0.0-alpha.21` 本地实测:
137
135
 
138
- | Package manager | Install | Build |
136
+ | 包管理器 | 安装 | 构建 |
139
137
  | --- | --- | --- |
140
138
  | npm 10 | ✅ | ✅ |
141
139
  | pnpm 11.25 | ✅ | ✅ |
142
- | yarn 1.22 (classic) | ✅ | ✅ |
140
+ | yarn 1.22(classic) | ✅ | ✅ |
143
141
  | bun 1.4 | ✅ | ✅ |
144
- | deno 2.9 | ✅ `deno install` | ❌ fails while Vite/rolldown loads the config |
142
+ | deno 2.9 | ✅ `deno install` | ❌ Vite/rolldown 加载配置时失败 |
145
143
 
146
- Deno can install the npm dependency, but building a VitePress site with Deno currently fails inside rolldown (`stream did not contain valid UTF-8`). Use Node for builds.
144
+ Deno 可以安装 npm 依赖,但目前用 Deno 构建 VitePress 会在 rolldown 里报 `stream did not contain valid UTF-8`;构建请使用 Node。
147
145
 
148
- ## Release
146
+ ## 发布
149
147
 
150
- Published to npm from GitHub Actions via Trusted Publishing (OIDC) with provenance.
148
+ 通过 GitHub Actions 的 Trusted Publishing(OIDC)发布到 npm,带 provenance。
151
149
 
152
- ## Notes
150
+ ## 说明
153
151
 
154
- - Batch ZIP downloads files through `raw_url` (OpenList `/p/` proxy), which keeps CORS on the OpenList origin.
155
- - Select-all only counts already-loaded files; the footer reports how many folders are still collapsed.
156
- - Directory listings are requested with `per_page: 0` (all entries). Very large folders may be slow; pagination is not implemented yet.
152
+ - 批量 ZIP 通过 `raw_url`(OpenList `/p/` 代理)下载,CORS 保持在 OpenList 源上
153
+ - 全选只统计已加载的文件;页脚会显示还有多少文件夹未展开
154
+ - 目录以 `per_page: 0` 请求全部条目;超大目录可能较慢,暂未实现分页
157
155
 
158
- ## Development
156
+ ## 开发
159
157
 
160
158
  ```bash
161
- npm install
162
- npm run build # dist/node, dist/client/ssr, dist/client/browser, style.css
163
- npm run typecheck
164
- npm test # Vitest: utils + locale helpers
165
- npm run pack:check
159
+ pnpm install
160
+ pnpm run build # 生成 dist/node、dist/client/ssr、dist/client/browser、style.css
161
+ pnpm run typecheck
162
+ pnpm test # Vitest:utils + locale helpers
163
+ pnpm run pack:check
166
164
  ```
167
165
 
168
- The demo site in `demo/` installs the package through `file:..`:
166
+ 仓库统一使用 pnpm(`pnpm-lock.yaml`),CI 与发布流程执行 `pnpm install --frozen-lockfile`。
167
+
168
+ `demo/` 下的演示站通过 `file:..` 安装本地包:
169
169
 
170
170
  ```bash
171
171
  cd demo
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "vitepress-plugin-filelist",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
+ "packageManager": "pnpm@11.25.0",
4
5
  "type": "module",
5
6
  "description": "OpenList file browser for VitePress: tree view, batch ZIP download, i18n, password and token support.",
6
7
  "author": "nrjycyd",