Skip to content

Commit 5cf0952

Browse files
committed
移除旧的 Steam 状态 (不安全) \
+ `status_list` 加载时自动补全 `id`
1 parent 9281dfc commit 5cf0952

File tree

8 files changed

+14
-84
lines changed

8 files changed

+14
-84
lines changed

.env.example

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,8 @@ sleepy_status_not_using = "未在使用"
6464
sleepy_util_metrics = true
6565
# 是否启用自动切换状态
6666
sleepy_util_auto_switch_status = true
67-
# 是否启用旧版 Steam 状态 (文字显示, 需要填写 key 和 ids, 不建议使用)
68-
sleepy_util_steam_legacy_enabled = false
6967
# 是否启用新版 Steam 状态 (iframe 框架显示, 只需要填写 ids)
7068
sleepy_util_steam_enabled = false
71-
# Steam API 密钥
72-
sleepy_util_steam_key = ""
7369
# Steam 用户 ID
7470
sleepy_util_steam_ids = ""
7571
# Steam 状态刷新间隔 (毫秒)

doc/env.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@
6464

6565
## (util) 可选功能
6666

67-
| 环境变量 | 类型 | 默认值 | 说明与提示 |
68-
| ------------------------------------ | ---- | ------ | -------------------------------------------------------------------------------------------------------------------- |
69-
| `sleepy_util_metrics` | bool | true | 控制是否启用内置的访问计数功能,并启用 `/metrics` 接口 |
70-
| `sleepy_util_auto_switch_status` | bool | true | 是否启用自动切换状态 *(当状态为 `0` (活着) 且所有设备都未在使用时自动切换为 `1` (似了))* |
71-
| `sleepy_util_steam_legacy_enabled` | bool | false | 是否启用旧版 Steam 状态 *(纯文字显示,需同时配置 `sleepy_util_steam_key``sleepy_util_steam_ids`)* **不建议使用** |
72-
| `sleepy_util_steam_enabled` | bool | false | 是否启用新版 Steam 状态 *(iframe 卡片显示,只需配置 `sleepy_util_steam_ids`)* **(推荐使用)** |
73-
| `sleepy_util_steam_key` | str | ` ` | Steam Web API 密钥,可在 [这里](https://steamcommunity.com/dev/apikey) 申请 |
74-
| `sleepy_util_steam_ids` | str | ` ` | 你的 Steam 账号 ID *(应为一串数字)* |
75-
| `sleepy_util_steam_refresh_interval` | int | 20000 | 刷新 Steam 状态的频率 (**毫秒***建议至少设置为 10000ms,过低可能触发速率限制*) |
67+
| 环境变量 | 类型 | 默认值 | 说明与提示 |
68+
| ------------------------------------ | ---- | ------ | ---------------------------------------------------------------------------------------- |
69+
| `sleepy_util_metrics` | bool | true | 控制是否启用内置的访问计数功能,并启用 `/metrics` 接口 |
70+
| `sleepy_util_auto_switch_status` | bool | true | 是否启用自动切换状态 *(当状态为 `0` (活着) 且所有设备都未在使用时自动切换为 `1` (似了))* |
71+
| `sleepy_util_steam_enabled` | bool | false | 是否启用新版 Steam 状态 *(iframe 卡片显示,需配置 `sleepy_util_steam_ids`)* |
72+
| `sleepy_util_steam_ids` | str | ` ` | 你的 Steam 账号 ID *(应为一串数字)* |
73+
| `sleepy_util_steam_refresh_interval` | int | 20000 | 刷新 Steam 状态的频率 (**毫秒***建议至少设置为 10000ms,过低可能触发速率限制*) |

env.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ class _util:
7474
'''
7575
metrics: bool = getenv('sleepy_util_metrics', True, bool)
7676
auto_switch_status: bool = getenv('sleepy_util_auto_switch_status', True, bool)
77-
steam_legacy_enabled: bool = getenv('sleepy_util_steam_legacy_enabled', False, bool)
7877
steam_enabled: bool = getenv('sleepy_util_steam_enabled', False, bool)
79-
steam_key: str = getenv('sleepy_util_steam_key', '', str)
8078
steam_ids: str = getenv('sleepy_util_steam_ids', '', str)
8179
steam_refresh_interval: int = getenv('sleepy_util_steam_refresh_interval', 20000, int)
8280

server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ def get_status_list():
241241
- 无需鉴权
242242
- Method: **GET**
243243
'''
244-
stlst = status_list
245-
return u.format_dict(stlst), 200
244+
return u.format_dict(status_list), 200
246245

247246

248247
# --- Status API

setting.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def load(self, filename: str):
3434
status_list: list = setting('status_list').content
3535
metrics_list: list = setting('metrics_list').content
3636

37+
# status_list 中自动补全 id
38+
for i in range(len(status_list)):
39+
status_list[i]['id'] = i
40+
3741
# metrics_list 中 [static] 处理
3842
if '[static]' in metrics_list:
3943
metrics_list.remove('[static]')

templates/index.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,9 @@ <h3><i><b>{{ env.page.user }}'s</b></i> Status:<br><a id="status">{{ status['nam
3131
<p id="additional-info">{{ status['desc'] | safe }}</p>
3232
<p id="device-status">[设备状态列表]</p>
3333

34-
{% if env.util.steam_legacy_enabled %}
35-
<!-- (steam-legacy) 旧版 Steam 状态模块 (文字) -->
36-
{% include "steam-legacy.html" %}
37-
{% endif %}
38-
3934
{% if env.util.steam_enabled %}
40-
<!-- (steam-new) 新版 Steam 状态模块 (iframe) -->
41-
{% include "steam-new.html" %}
35+
<!-- (steam) Steam 状态模块 (iframe) -->
36+
{% include "steam.html" %}
4237
{% endif %}
4338

4439
<p id="last-updated">最后更新: {{ last_updated }}</p>

templates/steam-legacy.html

Lines changed: 0 additions & 60 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)