From 3ffee330a5bed3ce85d218a7a4e5ad229b43a187 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 27 Jul 2026 08:44:53 +0800 Subject: [PATCH] fix: market install button feedback - always show toast --- static/js/pages/market.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/static/js/pages/market.js b/static/js/pages/market.js index 917da6f..5c7c430 100644 --- a/static/js/pages/market.js +++ b/static/js/pages/market.js @@ -128,7 +128,7 @@ const PageMarket = { const id = (btnInstall || btnScene)?.dataset.id; const file = (btnInstall || btnScene)?.dataset.file; - if (!id || !file) return; + if (!id || !file) { Toast.show('安装失败:数据不完整', 'error'); return; } const isScene = !!btnScene; const url = isScene ? `/api/market/scenes/install?id=${encodeURIComponent(id)}&filename=${encodeURIComponent(file)}` : `/api/market/install?id=${encodeURIComponent(id)}&filename=${encodeURIComponent(file)}`; @@ -136,14 +136,11 @@ const PageMarket = { const res = await fetch(url); const data = await res.json(); if (data.ok) { - let msg = '安装成功'; - if (data.missing_dashboards && data.missing_dashboards.length > 0) - msg += ',缺少 ' + data.missing_dashboards.length + ' 个依赖仪表盘'; - Toast.show(msg, 'success'); + Toast.show('安装成功!请在仪表盘页面查看', 'success', 4000); } else { - Toast.show('安装失败: ' + (data.error||''), 'error'); + Toast.show('安装失败: ' + (data.error||'请求异常'), 'error'); } - } catch (e) { Toast.show('安装失败', 'error'); } + } catch (e) { Toast.show('安装失败:网络错误', 'error'); } }); document.getElementById('tab-dashboards')?.addEventListener('click', () => { this._tab = 'dashboards';