修复中控

This commit is contained in:
dekun
2026-05-30 12:19:05 +08:00
parent c882a5e565
commit 26004fb0e7
3 changed files with 32 additions and 2 deletions
+29
View File
@@ -21,6 +21,32 @@
/** @type {{ exchangeId: string, nextPath: string, title: string } | null} */ /** @type {{ exchangeId: string, nextPath: string, title: string } | null} */
let instanceFrameCtx = null; let instanceFrameCtx = null;
function isHubEmbedded() {
try {
return window.self !== window.top;
} catch (_) {
return true;
}
}
function delegateInstanceToParent(url, title, exchangeId, nextPath) {
try {
window.parent.postMessage(
{
type: "hub:open-instance",
url,
title: title || "实例",
exchangeId: String(exchangeId),
nextPath: nextPath || "/",
},
"*"
);
return true;
} catch (_) {
return false;
}
}
async function fetchInstanceOpenUrl(exchangeId, nextPath) { async function fetchInstanceOpenUrl(exchangeId, nextPath) {
const next = nextPath || "/"; const next = nextPath || "/";
const q = new URLSearchParams({ exchange_id: String(exchangeId), next }); const q = new URLSearchParams({ exchange_id: String(exchangeId), next });
@@ -45,6 +71,9 @@
const row = lastMonitorRows.find((x) => String(x.id) === String(exchangeId)); const row = lastMonitorRows.find((x) => String(x.id) === String(exchangeId));
const title = row ? row.name : exchangeId; const title = row ? row.name : exchangeId;
instanceFrameCtx = { exchangeId: String(exchangeId), nextPath: next, title }; instanceFrameCtx = { exchangeId: String(exchangeId), nextPath: next, title };
if (isHubEmbedded() && delegateInstanceToParent(url, title, exchangeId, next)) {
return;
}
openInstanceFrame(url, title); openInstanceFrame(url, title);
} catch (e) { } catch (e) {
showToast(String(e), true); showToast(String(e), true);
+1 -1
View File
@@ -120,6 +120,6 @@
</div> </div>
<div id="toast"></div> <div id="toast"></div>
<script src="/assets/app.js?v=20260530-hub-sso-fix"></script> <script src="/assets/app.js?v=20260530-hub-nav-delegate"></script>
</body> </body>
</html> </html>
+2 -1
View File
@@ -227,7 +227,8 @@ HUB_PUBLIC_ORIGIN=http://192.168.8.6
2. `HUB_BRIDGE_TOKEN` 与四实例 `.env` 不一致。 2. `HUB_BRIDGE_TOKEN` 与四实例 `.env` 不一致。
3. `hub_settings` 里该户 `key` 与实例 `install_on_app(exchange=...)` 不一致(如 `okx``gate_bot`)。 3. `hub_settings` 里该户 `key` 与实例 `install_on_app(exchange=...)` 不一致(如 `okx``gate_bot`)。
4. **HTTPS 跨域 iframe**:中控与实例不同域名时,四实例须 `APP_COOKIE_SECURE=true`(使 session Cookie 为 `SameSite=None`),否则 SSO 成功仍跳 `/login` 4. **HTTPS 跨域 iframe**:中控与实例不同域名时,四实例须 `APP_COOKIE_SECURE=true`(使 session Cookie 为 `SameSite=None`),否则 SSO 成功仍跳 `/login`
5. 浏览器仍用旧书签直链首页,未从中控点「实例」(直链本来就要登录)。 5. **经本地导航打开中控**LocalNav → 中控 iframe → 点实例):旧版会在中控内再嵌一层实例 iframe,Cookie 易失效。请升级 **LocalNav + 中控** 最新代码:点实例后由导航页直接打开实例,工具栏有「← 中控」;须配置 `NAV_HUB_USERNAME` / `NAV_HUB_PASSWORD`,四实例 `HUB_EMBED_PARENT_ORIGINS` 含本地导航地址(如 `http://192.168.8.6:5070`)。
6. 浏览器仍用旧书签直链首页,未从中控点「实例」(直链本来就要登录)。
**直链**`http://IP:端口``https://实例域名` → 使用各实例 **`APP_USERNAME` / `APP_PASSWORD`**(四所建议统一)。 **直链**`http://IP:端口``https://实例域名` → 使用各实例 **`APP_USERNAME` / `APP_PASSWORD`**(四所建议统一)。