fix: 修复主站自动刷新内存泄漏,并完善 chan_tv 图表体验

主站重建前完整 dispose、去掉重复 sync 监听,自动刷新默认增量更新;顺带消除首屏重复 analyze、复用 ChanMACD,以及全版 TV 指标/未完成中枢/布局本地缓存。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-06 16:09:48 +08:00
co-authored by Cursor
parent 6b0f3b5837
commit 9f1e7361b6
14 changed files with 457 additions and 669 deletions
+52 -31
View File
@@ -981,19 +981,41 @@ function findBiCenters(biList) {
var lows = biList_for_zs.map(function(bi) { return Math.min(bi.p0, bi.p1) })
gg = Math.max.apply(null, highs)
dd = Math.min.apply(null, lows)
endBiIdx = startIdx + addedAfterLeave.length
endBiIdx = startIdx + 2 + addedAfterLeave.length
}
var lastBiInCenter = biList_for_zs[biList_for_zs.length - 1]
// 是否已离开中枢:之后出现完全在 ZG 之上或 ZD 之下的确认笔 → 中枢完成
var zsSure = false
var lastInListIdx = -1
for (var li = 0; li < biList.length; li++) {
if (biList[li] === lastBiInCenter || (biList[li].t0 === lastBiInCenter.t0 && biList[li].t1 === lastBiInCenter.t1)) {
lastInListIdx = li
break
}
}
if (lastInListIdx < 0) lastInListIdx = endBiIdx
for (var j = lastInListIdx + 1; j < biList.length; j++) {
var leaveBi = biList[j]
if (!leaveBi.sure) break
var lbh = Math.max(leaveBi.p0, leaveBi.p1)
var lbl = Math.min(leaveBi.p0, leaveBi.p1)
if (lbl > zg || lbh < zd) {
zsSure = true
break
}
}
var zs = {
t0: bi1.t0,
t1: biList_for_zs[biList_for_zs.length - 1].t1,
t1: lastBiInCenter.t1,
high: zg, low: zd,
zg: zg, zd: zd,
gg: gg, dd: dd,
is_sure: biList_for_zs[biList_for_zs.length - 1].sure,
is_sure: zsSure,
bi_count: biList_for_zs.length,
bi_list: biList_for_zs, // 中枢内的笔列表(按序)
start_bi_idx: startIdx, // 中枢首笔在总列表中的索引
bi_list: biList_for_zs,
start_bi_idx: startIdx,
dir: zsDir,
pre: lastZs,
next: null,
@@ -1008,28 +1030,6 @@ function findBiCenters(biList) {
startIdx = startIdx + 4 + (addedAfterLeave.length > 0 ? addedAfterLeave.length : 0)
}
// 末中枢确认
if (lastZs && !lastZs.is_sure) {
var lastBiInZs = lastZs.bi_count > 0 ? biList_for_zs[biList_for_zs.length - 1] : null
if (lastBiInZs) {
var hasLeave = false
var lastBiIdx = biList.indexOf(lastBiInZs)
if (lastBiIdx >= 0) {
for (var i = lastBiIdx + 1; i < biList.length; i++) {
var bi = biList[i]
if (bi.sure) {
var bh = Math.max(bi.p0, bi.p1), bl = Math.min(bi.p0, bi.p1)
var leave = (bl > lastZs.zg && bh > lastZs.zg) || (bh < lastZs.zd && bl < lastZs.zd)
if (leave) { hasLeave = true; break }
}
}
}
if (hasLeave && lastBiInZs.sure) {
lastZs.t1 = lastBiInZs.t1
}
}
}
return zsList
}
@@ -1119,16 +1119,37 @@ function findSegCenters(segs) {
endSegIdx = startIdx + 2 + addedSegs.length
}
var lastSegInCenter = segList_for_zs[segList_for_zs.length - 1]
var zsSure = false
var lastSegListIdx = -1
for (var lsi = 0; lsi < segs.length; lsi++) {
if (segs[lsi] === lastSegInCenter || (segs[lsi].t0 === lastSegInCenter.t0 && segs[lsi].t1 === lastSegInCenter.t1)) {
lastSegListIdx = lsi
break
}
}
if (lastSegListIdx < 0) lastSegListIdx = endSegIdx
for (var sj = lastSegListIdx + 1; sj < segs.length; sj++) {
var leaveSeg = segs[sj]
if (!leaveSeg.sure) break
var lsh = Math.max(leaveSeg.p0, leaveSeg.p1)
var lsl = Math.min(leaveSeg.p0, leaveSeg.p1)
if (lsl > zg || lsh < zd) {
zsSure = true
break
}
}
var zs = {
t0: s1.t0,
t1: segs[endSegIdx].t1,
t1: lastSegInCenter.t1,
high: zg, low: zd,
zg: zg, zd: zd,
gg: gg, dd: dd,
is_sure: segs[endSegIdx].sure,
is_sure: zsSure,
seg_count: segList_for_zs.length,
seg_list: segList_for_zs, // 中枢内的段列表(按序)
start_seg_idx: startIdx, // 中枢首段在总列表中的索引
seg_list: segList_for_zs,
start_seg_idx: startIdx,
dir: zsDir,
pre: lastZs,
next: null,