vitepress-plugin-filelist 0.4.0 → 0.5.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 +13 -2
- package/dist/client/browser/index.d.ts +26 -0
- package/dist/client/browser/index.js +948 -233
- package/dist/client/ssr/index.d.ts +26 -0
- package/dist/client/ssr/index.js +378 -74
- package/dist/client/style.css +310 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,7 @@ export default {
|
|
|
80
80
|
| `expanded` | `boolean` | `false` | 目录根是否默认展开 |
|
|
81
81
|
| `token` | `string` | `''` | 可选只读 token;不传则以游客身份请求 |
|
|
82
82
|
| `password` | `string` | `''` | 目录密码,也可以在运行时输入 |
|
|
83
|
+
| `rememberPassword` | `boolean` | `true` | 输入密码时是否提供“在此标签页中记住”开关;`false` 时不写入 sessionStorage |
|
|
83
84
|
| `title` | `string` | `''` | 工具栏标题;为空时回退到 OpenList 的 `site_title` |
|
|
84
85
|
| `locale` | `'zh-CN' \| 'en-US'` | `'zh-CN'` | 内置文案预设 |
|
|
85
86
|
| `labels` | `Partial<FileListLabels>` | `undefined` | 按 key 覆盖单条文案 |
|
|
@@ -103,7 +104,7 @@ export default {
|
|
|
103
104
|
- 目录路径挂载为根文件夹,默认折叠;`expanded` 可为全局或单个 source 打开
|
|
104
105
|
- 文件路径挂载为一条文件记录,直接预览/下载
|
|
105
106
|
- 勾选根目录会加载并选中其下所有文件;ZIP 内以根节点名称(`title` 或路径末段)作为顶层文件夹,文件根保留原文件名
|
|
106
|
-
- 每个 source 可单独设置 `title`、`password`;未设置 `password` 的 source 使用组件的 `password`
|
|
107
|
+
- 每个 source 可单独设置 `title`、`password`;未设置 `password` 的 source 使用组件的 `password` 或运行时输入的密码,遇到需要密码的目录会在该行原地显示密码输入框(见下文)
|
|
107
108
|
- 根节点顺序按 `sources` 顺序,子项仍按名称/大小/日期排序
|
|
108
109
|
|
|
109
110
|
```ts
|
|
@@ -125,6 +126,16 @@ interface FileListSource {
|
|
|
125
126
|
- 勾选后操作条吸附在组件顶部,位于 VitePress 导航栏 / “On this page” 栏下方,只在本组件范围内吸附
|
|
126
127
|
- 颜色全部取自 VitePress 主题变量,暗色模式自动适配
|
|
127
128
|
|
|
129
|
+
## 刷新与目录密码
|
|
130
|
+
|
|
131
|
+
- **刷新**:保留当前列表并调暗,表头下方显示进度条;完成后整体替换,已展开的目录和仍存在的勾选会保留。刷新失败时保留旧数据并提示。刷新只重新读取 OpenList 的目录缓存(游客没有写权限,无法强制刷新存储)
|
|
132
|
+
- **目录密码**:点击加锁目录(或勾选包含它的目录)时,密码输入框直接出现在该行的大小 / 日期位置,行高不变,下方文件不会移动;勾选在遇到加锁子目录时停下并请求密码
|
|
133
|
+
- Enter 提交,Esc 取消;密码错误时在原位提示“密码不正确或无权访问”(OpenList 无法区分密码错误和无权限)
|
|
134
|
+
- 钥匙按钮可开启“在此标签页中记住(关闭标签页后失效)”,密码存在 sessionStorage,按 OpenList 地址和目录区分,也覆盖子目录;已记住的目录显示“已记住 · 忘记”
|
|
135
|
+
- 保存的密码失效时自动删除,并提示重新输入
|
|
136
|
+
- 本次页面中输入过的密码(即使没有记住)在刷新后仍然有效
|
|
137
|
+
- 单一 `path` 本身需要密码时,在列表位置显示密码输入框
|
|
138
|
+
|
|
128
139
|
吸顶偏移默认根据 `.VPNav`、`.VPLocalNav` 的实际高度自动计算;自定义主题可手动指定:
|
|
129
140
|
|
|
130
141
|
```css
|
|
@@ -174,7 +185,7 @@ import { fileListLocales, formatLabel, resolveLabels } from 'vitepress-plugin-fi
|
|
|
174
185
|
## OpenList 要求
|
|
175
186
|
|
|
176
187
|
1. **游客只读权限**:开启游客用户,或传入只读 `token`
|
|
177
|
-
2. **CORS**:OpenList 的 `cors.allow_origins` 必须包含站点来源(默认
|
|
188
|
+
2. **CORS**:OpenList 的 `cors.allow_origins` 必须包含站点来源(默认 `*`);使用 OpenList-Worker 时设置 `ALLOW_URLS`(逗号分隔,完整来源,如 `https://docs.example.com,http://localhost:5173`,不支持通配符)。出现“Failed to fetch”时组件会提示检查这两项。GET 请求不带 `Content-Type`,避免多余的预检
|
|
178
189
|
3. **同协议**:HTTPS 页面不能请求 HTTP 的 OpenList(混合内容)
|
|
179
190
|
4. **token 是公开的**:只放可撤销的只读 token,不要放管理 token
|
|
180
191
|
|
|
@@ -70,6 +70,26 @@ interface FileListLabels {
|
|
|
70
70
|
previewTooLarge: string;
|
|
71
71
|
/** Preview dialog: only the first `{size}` of a text file is shown. */
|
|
72
72
|
textTruncated: string;
|
|
73
|
+
/** Refresh button while refreshing. */
|
|
74
|
+
refreshing: string;
|
|
75
|
+
/** Refresh failed; the old rows stay. `{message}` */
|
|
76
|
+
refreshFailed: string;
|
|
77
|
+
cancel: string;
|
|
78
|
+
/** Placeholder / accessible name of a folder's password input. `{name}` */
|
|
79
|
+
passwordFor: string;
|
|
80
|
+
/** OpenList cannot tell a wrong password from missing permission. */
|
|
81
|
+
passwordWrong: string;
|
|
82
|
+
/** A password remembered in this tab no longer works. */
|
|
83
|
+
passwordStale: string;
|
|
84
|
+
/** The key toggle next to a password input. */
|
|
85
|
+
rememberPassword: string;
|
|
86
|
+
/** Tag on a folder whose password is remembered. */
|
|
87
|
+
remembered: string;
|
|
88
|
+
forgetPassword: string;
|
|
89
|
+
/** Lock button on a folder that needs a password. `{name}` */
|
|
90
|
+
unlockFolder: string;
|
|
91
|
+
/** Appended to failure toasts for browser network errors (usually CORS). */
|
|
92
|
+
networkHint: string;
|
|
73
93
|
}
|
|
74
94
|
interface FileListSource {
|
|
75
95
|
/** OpenList path, directory or single file. */
|
|
@@ -96,6 +116,11 @@ interface FileListProps {
|
|
|
96
116
|
password?: string;
|
|
97
117
|
/** Toolbar title. Falls back to `site_title` from `/api/public/settings`. */
|
|
98
118
|
title?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Offer to remember folder passwords in this browser tab (sessionStorage,
|
|
121
|
+
* cleared when the tab closes). Defaults to `true`; `false` hides the option.
|
|
122
|
+
*/
|
|
123
|
+
rememberPassword?: boolean;
|
|
99
124
|
/** Built-in locale. Defaults to `zh-CN`. */
|
|
100
125
|
locale?: FileListLocale;
|
|
101
126
|
/** Per-key label overrides on top of the locale preset. */
|
|
@@ -120,6 +145,7 @@ declare const _default: import("vue").DefineComponent<FileListProps, {}, {}, {},
|
|
|
120
145
|
token: string;
|
|
121
146
|
password: string;
|
|
122
147
|
title: string;
|
|
148
|
+
rememberPassword: boolean;
|
|
123
149
|
locale: FileListLocale;
|
|
124
150
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
125
151
|
declare global {
|