vvvfs 0.2.0 → 0.2.2

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
@@ -4,6 +4,14 @@
4
4
 
5
5
  GitHub仓库: https://github.com/IFTC-XLKJ/vvvfs
6
6
 
7
+ ## 赞助
8
+
9
+ 如果这个项目对你有帮助,欢迎通过爱发电支持我们:
10
+
11
+ [![爱发电](https://img.shields.io/badge/爱发电-支持我们-ff69b4.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBmaWxsPSIjZmY2OWI0IiBkPSJNOCAxNS41cy03LTQuNS03LTkgQTEuNSAxLjUgMCAwIDAgOCAwYTEuNSAxLjUgMCAwIDAgNyA2LjVjMCA0LjUtNyA5LTcgOXoiLz48L3N2Zz4=)](https://afdian.com/a/IFTCCEO)
12
+
13
+ **爱发电主页:** https://afdian.com/a/IFTCCEO
14
+
7
15
  ## 快速开始
8
16
 
9
17
  1. 安装依赖
@@ -94,8 +102,48 @@ const vvvfs = new VVVFS("vvvfs", {
94
102
  // 用法与 vvvfs 相当
95
103
  ```
96
104
 
105
+ ### 使用 `<fs-img>` 自定义元素
106
+
107
+ 库加载后会自动注册 `<fs-img>` 元素,可直接显示 vvvfs 中的图片文件:
108
+
109
+ ```html
110
+ <fs-img src="/home/user/Pictures/logo.png" alt="Logo" width="120"></fs-img>
111
+ ```
112
+
113
+ ```javascript
114
+ // 也可通过 JS 动态创建
115
+ const img = document.createElement("fs-img");
116
+ img.src = "/home/user/Pictures/logo.png";
117
+ document.body.appendChild(img);
118
+ ```
119
+
120
+ 属性:
121
+
122
+ - `src` / `path`:图片在 vvvfs 中的路径(`src` 优先)
123
+ - `dbname`:数据库名,默认 `vvvfs`;未指定且存在全局 `vvvfs` 实例时直接使用该实例
124
+ - `alt` / `width` / `height`:透传到内部 `<img>` 元素
125
+ - `watch`:存在时,文件内容发生变化后自动刷新
126
+
127
+ 事件:`load`(加载完成)、`error`(加载失败),`detail` 中包含 `path` 与 `file`(或 `message`)。元素上还会写入 `data-state` 属性(`loading` / `loaded` / `error`),便于 CSS 定制。
128
+
129
+ 内部使用 Shadow DOM 渲染:图片暴露为 `part="img"`,可用 `fs-img::part(img) { ... }` 定制样式;默认插槽内容会在加载失败或未设置路径时显示(如 `<fs-img src="/a.png">加载失败</fs-img>`)。
130
+
97
131
  ## 更新日志
98
132
 
133
+ ### 0.2.2
134
+
135
+ - 新增 `<fs-img>` 自定义元素,可直接显示 vvvfs 中的图片文件
136
+ - `<fs-img>` 新增 `src` / `path` / `dbname` / `alt` / `width` / `height` / `watch` 属性
137
+ - `<fs-img>` 新增 `load` / `error` 事件与 `data-state` 状态属性
138
+ - `<fs-img>` 使用 Shadow DOM 渲染,支持 `::part(img)` 样式定制与默认插槽回退内容
139
+
140
+ ### 0.2.1
141
+
142
+ - 新增 `setHide` 方法,用于设置文件或文件夹的隐藏属性
143
+ - 新增 `getHide` 方法,用于获取文件或文件夹的隐藏属性
144
+ - `FileRecord` 新增 `hidden` 字段
145
+ - 数据库新增 version 3 迁移,自动为已有记录填充 `hidden: false`
146
+
99
147
  ### 0.2.0
100
148
 
101
149
  - 新增 `registerMIMEType` 静态方法,用于注册自定义MIME类型
@@ -192,6 +240,14 @@ A lightweight and simple Linux virtual file system in the browser, based on Inde
192
240
 
193
241
  GitHub repository: https://github.com/IFTC-XLKJ/vvvfs
194
242
 
243
+ ## Sponsor
244
+
245
+ If this project is helpful to you, please consider supporting us on Afdian:
246
+
247
+ [![Afdian](https://img.shields.io/badge/Afdian-Support%20us-ff69b4.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBmaWxsPSIjZmY2OWI0IiBkPSJNOCAxNS41cy03LTQuNS03LTkgQTEuNSAxLjUgMCAwIDAgOCAwYTEuNSAxLjUgMCAwIDAgNyA2LjVjMCA0LjUtNyA5LTcgOXoiLz48L3N2Zz4=)](https://afdian.com/a/IFTCCEO)
248
+
249
+ **Afdian homepage:** https://afdian.com/a/IFTCCEO
250
+
195
251
  ## Quick Start
196
252
 
197
253
  1. Install the dependency
@@ -281,8 +337,48 @@ Using the `VVVFS.File` class:
281
337
  // The usage is equivalent to vvvfs
282
338
  ```
283
339
 
340
+ ### Using the `<fs-img>` Custom Element
341
+
342
+ Once the library is loaded, the `<fs-img>` element is registered automatically and can display image files stored in vvvfs directly:
343
+
344
+ ```html
345
+ <fs-img src="/home/user/Pictures/logo.png" alt="Logo" width="120"></fs-img>
346
+ ```
347
+
348
+ ```javascript
349
+ // It can also be created dynamically
350
+ const img = document.createElement("fs-img");
351
+ img.src = "/home/user/Pictures/logo.png";
352
+ document.body.appendChild(img);
353
+ ```
354
+
355
+ Attributes:
356
+
357
+ - `src` / `path`: path of the image inside vvvfs (`src` takes precedence)
358
+ - `dbname`: database name, defaults to `vvvfs`; when omitted and a global `vvvfs` instance exists, that instance is used directly
359
+ - `alt` / `width` / `height`: passed through to the inner `<img>` element
360
+ - `watch`: when present, the image is refreshed automatically after the file content changes
361
+
362
+ Events: `load` (image loaded) and `error` (loading failed); `detail` contains `path` plus `file` (or `message`). A `data-state` attribute (`loading` / `loaded` / `error`) is also written to the element for CSS customization.
363
+
364
+ Rendering happens inside a Shadow DOM: the image is exposed as `part="img"`, so it can be styled with `fs-img::part(img) { ... }`; the default slot content is shown when loading fails or no path is set (e.g. `<fs-img src="/a.png">failed</fs-img>`).
365
+
284
366
  ## Changelog
285
367
 
368
+ ### 0.2.2
369
+
370
+ - Added the `<fs-img>` custom element to display image files stored in vvvfs directly
371
+ - Added the `src` / `path` / `dbname` / `alt` / `width` / `height` / `watch` attributes to `<fs-img>`
372
+ - Added the `load` / `error` events and the `data-state` attribute to `<fs-img>`
373
+ - `<fs-img>` renders inside a Shadow DOM, supporting `::part(img)` styling and a default slot fallback
374
+
375
+ ### 0.2.1
376
+
377
+ - Added the `setHide` method to set the hidden attribute of a file or directory
378
+ - Added the `getHide` method to get the hidden attribute of a file or directory
379
+ - Added the `hidden` field to `FileRecord`
380
+ - Added database version 3 migration to automatically fill `hidden: false` for existing records
381
+
286
382
  ### 0.2.0
287
383
 
288
384
  - Added the `registerMIMEType` static method for registering custom MIME types