Files

63 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 移动账户
给自己的中国移动号码看话费余额、当月消费和套餐余量。页面只读,登录后按设定间隔自动刷新。登录可以用短信验证码,也可以用中国移动 App 扫页面上的二维码。
页面没有访问口令,只放在自己的机器上。
## 使用
程序从当前工作目录读取 `config.json` 并写入 `data/`。先进入程序所在目录再启动,浏览器打开它监听的地址。
```json
{
"listen": ":8788",
"pollInterval": "30m",
"jitterMinutes": 0,
"phone": ""
}
```
| 字段 | 作用 |
| --- | --- |
| `listen` | 监听地址,默认 `:8788` |
| `pollInterval` | 登录后的基础刷新间隔,最短 1 分钟 |
| `jitterMinutes` | 每次额外随机增加 0 到这个分钟数,精确到秒。0 表示不加 |
| `phone` | 可选。写上后登录页会预先填好号码 |
环境变量 `CMNET_LISTEN`、`CMNET_POLL`、`CMNET_JITTER`、`CMNET_PHONE` 会覆盖同名字段。`CMNET_POLL` 和 `CMNET_JITTER` 用时长写法,例如 `30m`、`10m`。
间隔和随机分钟在页面里保存后,以 `data/state.json` 为准。
短信登录先填手机号和图形验证码,再获取短信。扫码登录点「扫码」,用中国移动 App 扫二维码。退出后立即清除本次登录状态。重新打开程序不会恢复上次登录,需要重新登录。
## 编译
需要 Go 1.26 或更高。
```bash
go build -trimpath -ldflags="-s -w" -o cmnet-dashboard .
```
交叉编译到 Linux:
```bash
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o cmnet-dashboard .
```
## 流程
```mermaid
flowchart TD
open[打开页面] --> saved{这个号码还有上次的会话?}
saved -->|有| pull[用该会话拉取余额和余量]
pull -->|成功| home[进入主页并按间隔刷新]
pull -->|会话已失效| code[填写图形验证码和短信验证码]
saved -->|没有| code
code --> home
home --> tick[倒计时结束]
tick -->|会话仍有效| home
tick -->|移动要求重新登录| code
home --> logout[退出]
logout --> hold[停在登录页且不再刷新]
```