Skip to content

Commit e44b5a7

Browse files
committed
Add dynamic platformMeta to Worker API (Python edit, no sed)
1 parent 4a42f09 commit e44b5a7

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

web/strategy-switch-console/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ <h2 data-i18n="summary">切换摘要</h2>
14871487
binance: "QuantStrategyLab/BinancePlatform",
14881488
};
14891489

1490-
const platformMeta = {
1490+
let platformMeta = {
14911491
longbridge: { label: "LongBridge", code: "LB", accent: "var(--lb)" },
14921492
ibkr: { label: "IBKR", code: "IB", accent: "var(--ib)" },
14931493
schwab: { label: "Schwab", code: "SW", accent: "var(--sw)" },
@@ -4039,6 +4039,7 @@ <h2 data-i18n="summary">切换摘要</h2>
40394039
if (!response.ok) throw new Error("no strategy profiles");
40404040
const payload = await response.json();
40414041
applyStrategyProfiles(payload.strategyProfiles || []);
4042+
if (payload.platformMeta) platformMeta = payload.platformMeta;
40424043
for (const platform of Object.keys(platformMeta)) syncStrategyForAccount(platform);
40434044
render();
40444045
} catch {
@@ -4059,6 +4060,7 @@ <h2 data-i18n="summary">切换摘要</h2>
40594060
if (payload.accountOptions) {
40604061
applyStrategyProfiles(payload.strategyProfiles || defaultStrategyProfiles);
40614062
state.accountOptions = normalizeAccountOptions(payload.accountOptions);
4063+
if (payload.platformMeta) platformMeta = payload.platformMeta;
40624064
state.repositories = normalizePlatformRepositories(payload.platformRepositories || {});
40634065
state.currentStrategies = normalizeCurrentStrategies(payload.currentStrategies || {});
40644066
state.configSource = "private";

web/strategy-switch-console/page_asset.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/strategy-switch-console/worker.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,24 @@ async function renderAdminPage(state) {
534534
</html>`;
535535
}
536536

537+
const PLATFORM_META = {
538+
longbridge: { label: "LongBridge", code: "LB", accent: "var(--lb)" },
539+
ibkr: { label: "IBKR", code: "IB", accent: "var(--ib)" },
540+
schwab: { label: "Schwab", code: "SW", accent: "var(--sw)" },
541+
firstrade: { label: "Firstrade", code: "FT", accent: "var(--ft)" },
542+
qmt: { label: "QMT", code: "QM", accent: "var(--qmt)" },
543+
binance: { label: "Binance", code: "BN", accent: "var(--bn)" },
544+
};
545+
537546
async function configPayload(request, env) {
538547
const session = await readSession(request, env);
539-
if (!session?.allowed) return { accountOptions: null };
548+
if (!session?.allowed) return { accountOptions: null, platformMeta: PLATFORM_META };
540549
const accountConfig = await loadAccountOptionsConfig(env);
541550
const strategyProfiles = await loadStrategyProfilesConfig(env);
542551
return {
543552
accountOptions: accountConfig.options,
544553
platformRepositories: platformRepositories(env),
554+
platformMeta: PLATFORM_META,
545555
strategyProfiles,
546556
currentStrategies: await loadCurrentStrategiesSafely(accountConfig.options, env),
547557
};
@@ -550,6 +560,7 @@ async function configPayload(request, env) {
550560
async function strategyProfilesPayload(env) {
551561
return {
552562
strategyProfiles: await loadStrategyProfilesConfig(env),
563+
platformMeta: PLATFORM_META,
553564
};
554565
}
555566

0 commit comments

Comments
 (0)