vvvfs 0.2.1 → 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,41 @@ 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
+
99
140
  ### 0.2.1
100
141
 
101
142
  - 新增 `setHide` 方法,用于设置文件或文件夹的隐藏属性
@@ -199,6 +240,14 @@ A lightweight and simple Linux virtual file system in the browser, based on Inde
199
240
 
200
241
  GitHub repository: https://github.com/IFTC-XLKJ/vvvfs
201
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
+
202
251
  ## Quick Start
203
252
 
204
253
  1. Install the dependency
@@ -288,8 +337,41 @@ Using the `VVVFS.File` class:
288
337
  // The usage is equivalent to vvvfs
289
338
  ```
290
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
+
291
366
  ## Changelog
292
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
+
293
375
  ### 0.2.1
294
376
 
295
377
  - Added the `setHide` method to set the hidden attribute of a file or directory