chore: complete stage 19 regression hardening
This commit is contained in:
+22
-14
@@ -204,6 +204,14 @@ const elements = {
|
||||
stockPreviewChart: document.querySelector("#stockPreviewChart"),
|
||||
};
|
||||
|
||||
function openModalDialog(dialog) {
|
||||
if (!(dialog instanceof HTMLDialogElement)) return;
|
||||
document.querySelectorAll("dialog[open]").forEach((openDialog) => {
|
||||
if (openDialog !== dialog) openDialog.close();
|
||||
});
|
||||
if (!dialog.open) dialog.showModal();
|
||||
}
|
||||
|
||||
const metricAnimationFrames = new WeakMap();
|
||||
const stockPreviewCache = new Map();
|
||||
const STOCK_PREVIEW_DELAY = 380;
|
||||
@@ -3076,7 +3084,7 @@ function openWatchlistDialog(item = null) {
|
||||
document.querySelector("#watchlistSearchInput").value = "";
|
||||
document.querySelector("#watchlistSearchResults").innerHTML = "";
|
||||
syncWatchlistSelection(Boolean(item));
|
||||
if (!elements.watchlistDialog.open) elements.watchlistDialog.showModal();
|
||||
openModalDialog(elements.watchlistDialog);
|
||||
requestAnimationFrame(() => (item ? document.querySelector("#watchlistRemark") : document.querySelector("#watchlistSearchInput")).focus());
|
||||
}
|
||||
|
||||
@@ -3240,7 +3248,7 @@ function populateJournalForm() {
|
||||
|
||||
function openTradeLogDialog() {
|
||||
resetTradeLogForm();
|
||||
if (!elements.tradeLogDialog.open) elements.tradeLogDialog.showModal();
|
||||
openModalDialog(elements.tradeLogDialog);
|
||||
requestAnimationFrame(() => document.querySelector("#tradeLogCode").focus());
|
||||
}
|
||||
|
||||
@@ -3311,7 +3319,7 @@ function editTradeLog(id) {
|
||||
document.querySelector("#tradeLogExecution").value = item.execution || "";
|
||||
setText("tradeLogDialogTitle", "编辑交易日志");
|
||||
setText("saveTradeLog", "保存修改");
|
||||
if (!elements.tradeLogDialog.open) elements.tradeLogDialog.showModal();
|
||||
openModalDialog(elements.tradeLogDialog);
|
||||
requestAnimationFrame(() => document.querySelector("#tradeLogCode").focus());
|
||||
}
|
||||
|
||||
@@ -4067,7 +4075,7 @@ function renderScreenerProgress() {
|
||||
|
||||
function openStrategyDrawer(target = "editor") {
|
||||
const drawer = document.querySelector("#strategyDrawer");
|
||||
if (!drawer.open) drawer.showModal();
|
||||
openModalDialog(drawer);
|
||||
requestAnimationFrame(() => {
|
||||
const focusTarget = target === "library"
|
||||
? document.querySelector("#strategyList .strategy-item.active") || document.querySelector("#strategyList .strategy-item")
|
||||
@@ -5889,7 +5897,7 @@ function openHeavenReading(mode, options = {}) {
|
||||
? Boolean(options.loading)
|
||||
: false;
|
||||
renderHeavenReadingDialog();
|
||||
if (!elements.heavenReadingDialog.open) elements.heavenReadingDialog.showModal();
|
||||
openModalDialog(elements.heavenReadingDialog);
|
||||
requestAnimationFrame(() => {
|
||||
syncHeavenReadingAnimation();
|
||||
document.querySelector("#closeHeavenReadingDialog").focus();
|
||||
@@ -5901,7 +5909,7 @@ async function openHeavenHistory(mode) {
|
||||
state.heavenReadingTab = "history";
|
||||
state.heavenReadingSelectedId = 0;
|
||||
renderHeavenReadingDialog();
|
||||
if (!elements.heavenReadingDialog.open) elements.heavenReadingDialog.showModal();
|
||||
openModalDialog(elements.heavenReadingDialog);
|
||||
await loadHeavenReadingHistory(mode);
|
||||
}
|
||||
|
||||
@@ -7570,7 +7578,7 @@ async function loadAlerts(openDialog = false) {
|
||||
state.alerts = payload.items || [];
|
||||
state.alertUnreadCount = number(payload.unread_count);
|
||||
renderAlerts();
|
||||
if (openDialog && !elements.alertsDialog.open) elements.alertsDialog.showModal();
|
||||
if (openDialog) openModalDialog(elements.alertsDialog);
|
||||
} catch (error) {
|
||||
if (openDialog) showToast(error.message || "提醒加载失败");
|
||||
}
|
||||
@@ -7580,7 +7588,7 @@ function openAlerts() {
|
||||
toggleHeaderCommandMenu(false);
|
||||
toggleAccountDropdown(false);
|
||||
document.querySelector("#alertDate").value ||= todayString();
|
||||
elements.alertsDialog.showModal();
|
||||
openModalDialog(elements.alertsDialog);
|
||||
loadAlerts();
|
||||
}
|
||||
|
||||
@@ -7688,7 +7696,7 @@ function renderAlerts() {
|
||||
async function openReviewAssistant() {
|
||||
toggleHeaderCommandMenu(false);
|
||||
toggleAccountDropdown(false);
|
||||
if (!elements.assistantDialog.open) elements.assistantDialog.showModal();
|
||||
openModalDialog(elements.assistantDialog);
|
||||
updateAssistantControls();
|
||||
if (!hasMemberAccess()) {
|
||||
document.querySelector("#closeAssistantDialog").focus();
|
||||
@@ -7841,7 +7849,7 @@ function updateAssistantControls() {
|
||||
function openGlobalSearch() {
|
||||
if (!state.user) return;
|
||||
toggleHeaderCommandMenu(false);
|
||||
if (!elements.globalSearchDialog.open) elements.globalSearchDialog.showModal();
|
||||
openModalDialog(elements.globalSearchDialog);
|
||||
requestAnimationFrame(() => {
|
||||
elements.globalSearchInput.focus();
|
||||
elements.globalSearchInput.select();
|
||||
@@ -7984,7 +7992,7 @@ async function openEntityDetail(item) {
|
||||
setText("entityDetailDate", "正在加载行情");
|
||||
document.querySelector("#entityDetailChange").className = "";
|
||||
document.querySelector("#entityDetailMetrics").innerHTML = '<div class="empty-state">正在加载交易数据</div>';
|
||||
if (!elements.entityDetailDialog.open) elements.entityDetailDialog.showModal();
|
||||
openModalDialog(elements.entityDetailDialog);
|
||||
clearEntityDetailChart("正在加载日 K 数据");
|
||||
try {
|
||||
const params = new URLSearchParams({ type: item.type, id: item.id, trade_date: elements.tradeDate.value });
|
||||
@@ -8209,7 +8217,7 @@ async function openStock(code, fallback = null) {
|
||||
document.querySelector("#stockNotePlan").value = "";
|
||||
document.querySelector("#stockNotes").innerHTML = '<div class="empty-state">正在加载笔记</div>';
|
||||
updateWatchButton();
|
||||
if (!elements.stockDialog.open) elements.stockDialog.showModal();
|
||||
openModalDialog(elements.stockDialog);
|
||||
clearPriceChart("正在加载日 K 数据");
|
||||
try {
|
||||
const query = new URLSearchParams({ trade_date: elements.tradeDate.value });
|
||||
@@ -8508,7 +8516,7 @@ async function openSettings(panel = "profile") {
|
||||
const status = document.querySelector("#connectionStatus");
|
||||
status.className = "connection-status";
|
||||
status.textContent = "正在读取账号状态";
|
||||
if (!elements.settingsDialog.open) elements.settingsDialog.showModal();
|
||||
openModalDialog(elements.settingsDialog);
|
||||
try {
|
||||
const payload = await apiRequest("/api/account/status");
|
||||
const access = payload.llm_access || {};
|
||||
@@ -8587,7 +8595,7 @@ async function switchAccount() {
|
||||
|
||||
async function openAdminSettings(refreshOnly = false) {
|
||||
if (state.user?.role !== "admin") return;
|
||||
if (!refreshOnly && !elements.adminDialog.open) elements.adminDialog.showModal();
|
||||
if (!refreshOnly) openModalDialog(elements.adminDialog);
|
||||
const status = document.querySelector("#adminConnectionStatus");
|
||||
status.textContent = "正在读取系统状态";
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user