Skip to content

Commit 57e32cf

Browse files
committed
Make strategy switch console Worker-only
1 parent 8f70032 commit 57e32cf

13 files changed

Lines changed: 68 additions & 262 deletions

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
set -euo pipefail
2525
python3 scripts/sync_strategy_switch_page_asset.py
2626
git diff --exit-code -- web/strategy-switch-console/page_asset.js
27-
sed -n '/<script>/,/<\/script>/p' docs/index.html | sed '1d;$d' | node --check --input-type=commonjs
27+
sed -n '/<script>/,/<\/script>/p' web/strategy-switch-console/index.html | sed '1d;$d' | node --check --input-type=commonjs
2828
node --check --input-type=module < web/strategy-switch-console/page_asset.js
2929
node --check --input-type=module < web/strategy-switch-console/worker.js

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ Notes:
6868

6969
## Useful docs
7070

71-
- [Strategy switch GitHub Pages console](docs/index.html)
72-
- [GitHub Pages strategy switch design](docs/github_pages_strategy_switch.md)
73-
- [Authenticated strategy switch console Worker](web/strategy-switch-console/README.md)
71+
- [Strategy switch console Worker](web/strategy-switch-console/README.md)
7472
- [Strategy switch admin backend](docs/strategy_switch_admin_backend.md)
7573
- [Manual strategy switch permission-control plan](docs/manual_strategy_switch_permission_control.zh-CN.md)
7674

README.zh-CN.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ confirm_apply=APPLY_AND_SYNC
6868

6969
## 延伸文档
7070

71-
- [策略切换控制台 GitHub Pages 首页](docs/index.html)
72-
- [GitHub Pages 策略切换网页设计](docs/github_pages_strategy_switch.zh-CN.md)
73-
- [登录版策略切换控制台 Worker](web/strategy-switch-console/README.zh-CN.md)
71+
- [策略切换控制台 Worker](web/strategy-switch-console/README.zh-CN.md)
7472
- [策略切换登录权限后台方案](docs/strategy_switch_admin_backend.zh-CN.md)
7573
- [手动策略切换权限控制方案](docs/manual_strategy_switch_permission_control.zh-CN.md)
7674

docs/github_pages_strategy_switch.md

Lines changed: 0 additions & 110 deletions
This file was deleted.

docs/github_pages_strategy_switch.zh-CN.md

Lines changed: 0 additions & 110 deletions
This file was deleted.

docs/manual_strategy_switch_web.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

scripts/sync_strategy_switch_page_asset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
"""Embed docs/index.html as a Cloudflare Worker module asset."""
2+
"""Embed the strategy switch Worker HTML as a module asset."""
33

44
from __future__ import annotations
55

@@ -8,7 +8,7 @@
88

99

1010
ROOT = Path(__file__).resolve().parents[1]
11-
SOURCE = ROOT / "docs" / "index.html"
11+
SOURCE = ROOT / "web" / "strategy-switch-console" / "index.html"
1212
TARGET = ROOT / "web" / "strategy-switch-console" / "page_asset.js"
1313

1414

web/strategy-switch-console/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ Without the KV binding, `/admin` is read-only and the Worker falls back to `ALLO
6464

6565
## Page Asset
6666

67-
`worker.js` serves the same UI as `docs/index.html` through `page_asset.js`.
67+
`worker.js` serves `web/strategy-switch-console/index.html` through `page_asset.js`.
6868

69-
After editing `docs/index.html`, regenerate the asset:
69+
After editing `web/strategy-switch-console/index.html`, regenerate the asset:
7070

7171
```bash
7272
python3 scripts/sync_strategy_switch_page_asset.py
@@ -76,7 +76,7 @@ Deploy `worker.js` and `page_asset.js` together.
7676

7777
## Account Dropdowns
7878

79-
The public page only ships sample targets. After sign-in, switching stays disabled until the Worker loads private account options; the Worker also rejects dispatches without matching private account config. Copy the example and fill in your real target/account routes:
79+
The Worker page ships sample targets as a fallback. After sign-in, switching stays disabled until the Worker loads configured account options; the Worker also rejects dispatches without matching account config. Copy the example and fill in your real target/account routes:
8080

8181
```bash
8282
cp web/strategy-switch-console/account-options.example.json /tmp/strategy-switch-accounts.json
@@ -101,7 +101,8 @@ Each account item supports:
101101
"account_selector": "U15998061",
102102
"deployment_selector": "live-u1599-tqqq",
103103
"account_scope": "live-u1599-tqqq",
104-
"service_name": "interactive-brokers-live-u1599-tqqq-service"
104+
"service_name": "interactive-brokers-live-u1599-tqqq-service",
105+
"default_strategy_profile": "tqqq_growth_income"
105106
}
106107
```
107108

web/strategy-switch-console/README.zh-CN.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ audit_log
6767
## 文件结构
6868

6969
```text
70+
index.html
7071
worker.js
7172
page_asset.js
7273
wrangler.toml.example
7374
```
7475

75-
`worker.js` 会复用 `docs/index.html` 的同一套页面。改完页面后运行:
76+
`worker.js` 会通过 `page_asset.js` 发布 `web/strategy-switch-console/index.html`。改完页面后运行:
7677

7778
```bash
7879
python3 scripts/sync_strategy_switch_page_asset.py
@@ -82,7 +83,7 @@ python3 scripts/sync_strategy_switch_page_asset.py
8283

8384
## 账号下拉配置
8485

85-
公开页面只带示例 target,登录后如果没有加载私有账号配置,“一键切换”仍会保持禁用,Worker 后端也会拒绝 dispatch,避免账号不匹配。复制示例文件后填入你的真实 target/account route:
86+
Worker 页面内置示例 target 作为兜底。登录后如果没有加载账号配置,“一键切换”仍会保持禁用,Worker 后端也会拒绝 dispatch,避免账号不匹配。复制示例文件后填入你的真实 target/account route:
8687

8788
```bash
8889
cp web/strategy-switch-console/account-options.example.json /tmp/strategy-switch-accounts.json
@@ -107,7 +108,8 @@ wrangler secret put STRATEGY_SWITCH_ACCOUNT_OPTIONS_JSON < /tmp/strategy-switch-
107108
"account_selector": "U15998061",
108109
"deployment_selector": "live-u1599-tqqq",
109110
"account_scope": "live-u1599-tqqq",
110-
"service_name": "interactive-brokers-live-u1599-tqqq-service"
111+
"service_name": "interactive-brokers-live-u1599-tqqq-service",
112+
"default_strategy_profile": "tqqq_growth_income"
111113
}
112114
```
113115

0 commit comments

Comments
 (0)