Fix turbo nav for settings and stats pages.
Extract settings.js, preserve inline scripts from raw HTML (DOMParser strips them), and load trade config via JSON script tag. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+22
-6
@@ -3,8 +3,7 @@
|
||||
* 详见 LICENSE.zh-CN.txt
|
||||
*/
|
||||
(function () {
|
||||
var sizingMode = window.TRADE_SIZING_MODE || 'fixed';
|
||||
if (sizingMode === 'risk') sizingMode = 'amount';
|
||||
var sizingMode = 'fixed';
|
||||
var list = document.getElementById('position-live-list');
|
||||
var orderList = document.getElementById('order-live-list');
|
||||
var syncBadge = document.getElementById('sync-badge');
|
||||
@@ -33,7 +32,7 @@
|
||||
var hasSlTpMonitoring = false;
|
||||
var ctpConnected = false;
|
||||
var ctpConnecting = false;
|
||||
var ctpAutoConnectEnabled = window.CTP_AUTO_CONNECT !== false;
|
||||
var ctpAutoConnectEnabled = true;
|
||||
var positionsRendered = false;
|
||||
var selectedMaxLots = null;
|
||||
var recommendMaxByProduct = {};
|
||||
@@ -45,10 +44,26 @@
|
||||
var REC_SORT_CACHE = 'qihuo_rec_sort_v2';
|
||||
var REC_INDUSTRY_CACHE = 'qihuo_rec_industry_v1';
|
||||
var REC_COLSPAN = 18;
|
||||
var marketNavEnabled = !!window.MARKET_NAV_ENABLED;
|
||||
var productCategories = window.PRODUCT_CATEGORIES || [];
|
||||
var marketNavEnabled = false;
|
||||
var productCategories = [];
|
||||
var POS_CACHE_KEY = 'qihuo_trading_live_v5';
|
||||
|
||||
function loadTradeConfig() {
|
||||
var el = document.getElementById('trade-page-data');
|
||||
if (!el) return;
|
||||
try {
|
||||
var cfg = JSON.parse(el.textContent);
|
||||
sizingMode = cfg.sizing_mode || 'fixed';
|
||||
if (sizingMode === 'risk') sizingMode = 'amount';
|
||||
ctpAutoConnectEnabled = cfg.ctp_auto_connect !== false;
|
||||
marketNavEnabled = !!cfg.market_nav_enabled;
|
||||
productCategories = cfg.product_categories || [];
|
||||
window.TRADE_FIXED_LOTS = cfg.fixed_lots;
|
||||
window.TRADE_FIXED_AMOUNT = cfg.fixed_amount;
|
||||
window.__RECOMMEND_ROWS__ = cfg.recommend_rows || [];
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
function fmtNum(v, digits) {
|
||||
if (v === null || v === undefined) return '--';
|
||||
return Number(v).toFixed(digits === undefined ? 2 : digits);
|
||||
@@ -1607,6 +1622,7 @@
|
||||
}
|
||||
|
||||
function bootTradePage() {
|
||||
loadTradeConfig();
|
||||
if (!list && !orderList) return;
|
||||
updateCtpConnectButtonState();
|
||||
setPriceType('limit');
|
||||
@@ -1648,7 +1664,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
if (window.qihuoPageBoot) window.qihuoPageBoot(bootTradePage, '#position-live-list, #order-live-list');
|
||||
if (window.qihuoPageBoot) window.qihuoPageBoot(bootTradePage, '.trade-page');
|
||||
else if (window.qihuoOnPageLoad) window.qihuoOnPageLoad(bootTradePage);
|
||||
else bootTradePage();
|
||||
if (window.qihuoOnPageLeave) window.qihuoOnPageLeave(cleanupTradePage);
|
||||
|
||||
Reference in New Issue
Block a user