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';