diff --git a/README.md b/README.md index 673658e..7a9b16d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,67 @@ -# Hearth_Server +# Hearth Server 示例 +Hearth 启动器的 webAPP / 卡片下发服务端示例。**本质是纯静态文件**,无需后端逻辑。 + +## 目录结构 + +``` +Hearth_Server/ +├── manifest.json # webAPP 清单(客户端启动时拉取) +├── apps//index.html # 各 webAPP 入口页 +├── icons/.svg # 图标 +├── offlines/.zip # 可选离线包(整站资源打成 zip) +└── cards/ + ├── catalog.json # 首页卡片目录 + └── /card.html # 单个卡片 +``` + +## 快速启动(测试用) + +```bash +cd ~/Project/Hearth_Server +python3 -m http.server 8080 +``` + +然后在 Hearth 设置页 →「webAPP 服务器地址」填 `http://<本机IP>:8080`。 + +## 正式部署 + +- nginx:`location / { root /path/to/Hearth_Server; }` +- 或传云对象存储(OSS/COS)+ CDN,整个目录原样上传 + +## 更新流程 + +1. 改 webAPP 资源(`apps/` 下的文件) +2. 改 `manifest.json` 的 `version`(+1) +3. 客户端「检查更新」或重启即可拉取 + +## manifest.json 字段 + +| 字段 | 说明 | +|---|---| +| `version` | 清单版本号,客户端据此判断更新 | +| `apps[].id` | 唯一 id | +| `apps[].name` | 显示名 | +| `apps[].icon` | 图标地址(建议 SVG) | +| `apps[].url` | 入口页地址(相对地址即可) | +| `apps[].offline.package` | 可选离线包 zip 路径 | +| `apps[].offline.version` | 离线包版本 | + +## 离线包 + +- 把某个 webAPP 的**全部资源**(`apps//` 下所有文件,含子目录)打成 zip,放 `offlines/.zip` +- zip 内需**包含 index.html**(作为离线入口) +- 生成示例:`cd apps/demo && zip -r ../../offlines/demo.zip .` + +## 离线包使用与版本管理 + +- **下载时机**:客户端拉取清单时**只同步列表,不自动下载程序包**;只有首次点开某 webAPP 时才下载(显示进度覆盖层)。 +- **本地优先**:下载后解压到本地目录,之后点开直接本地加载;**服务端删除该离线包不影响本地运行**。 +- **手动导入**:长按 webAPP 卡片 →「导入离线包」→ 选择本地 zip(适用于无服务器或离线分发场景)。 +- **版本更新**: + - `manifest.json` 里把 `offline.version` 升版本后,客户端列表该 webAPP 显示「**可更新**」标签(**不强制**,点开仍运行本地旧版)。 + - 长按卡片弹出菜单: + - `更新离线包`(删除本地并重新下载,显示版本 x → y) + - `删除本地包` + - `属性`(查看本地 / 云端版本号) + - 云端版本号 ≤ 本地版本号时不提示更新。 diff --git a/apps/demo/index.html b/apps/demo/index.html new file mode 100644 index 0000000..9e11985 --- /dev/null +++ b/apps/demo/index.html @@ -0,0 +1,57 @@ + + + + + +示例应用 + + + +
🎨
+

示例应用

+
+
来源远程服务器
+
当前时间--:--:--
+
+

这是 Hearth 服务端的示例 webapp
用于演示远程下发 / 加载进度 / 离线包

+ + + diff --git a/cards/catalog.json b/cards/catalog.json new file mode 100644 index 0000000..7a1a415 --- /dev/null +++ b/cards/catalog.json @@ -0,0 +1,10 @@ +{ + "cards": [ + { + "id": "weather", + "name": "天气", + "priority": 2, + "entry": "cards/weather/card.html" + } + ] +} diff --git a/cards/weather/card.html b/cards/weather/card.html new file mode 100644 index 0000000..1bd1c13 --- /dev/null +++ b/cards/weather/card.html @@ -0,0 +1,24 @@ + + + + + + + +
+
+
+
26°
+
+
+
+ + diff --git a/icons/cloudmusic.svg b/icons/cloudmusic.svg new file mode 100644 index 0000000..5e9fb37 --- /dev/null +++ b/icons/cloudmusic.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/icons/demo.svg b/icons/demo.svg new file mode 100644 index 0000000..5eaeb7b --- /dev/null +++ b/icons/demo.svg @@ -0,0 +1,4 @@ + + + H + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..ce989c0 --- /dev/null +++ b/manifest.json @@ -0,0 +1,22 @@ +{ + "version": 1, + "updatedAt": 1723785600, + "apps": [ + { + "id": "demo", + "name": "示例应用", + "icon": "icons/demo.svg", + "url": "apps/demo/index.html", + "offline": { + "package": "offlines/demo.zip", + "version": "1.0.0" + } + }, + { + "id": "cloudmusic", + "name": "网易云音乐", + "icon": "icons/cloudmusic.svg", + "url": "https://music.163.com/st/webplayer" + } + ] +} diff --git a/offlines/demo.zip b/offlines/demo.zip new file mode 100644 index 0000000..015ae20 Binary files /dev/null and b/offlines/demo.zip differ