fix: market install button feedback - always show toast

This commit is contained in:
2026-07-27 08:44:53 +08:00
parent 7e3456d208
commit 3ffee330a5
+4 -7
View File
@@ -128,7 +128,7 @@ const PageMarket = {
const id = (btnInstall || btnScene)?.dataset.id; const id = (btnInstall || btnScene)?.dataset.id;
const file = (btnInstall || btnScene)?.dataset.file; const file = (btnInstall || btnScene)?.dataset.file;
if (!id || !file) return; if (!id || !file) { Toast.show('安装失败:数据不完整', 'error'); return; }
const isScene = !!btnScene; const isScene = !!btnScene;
const url = isScene ? `/api/market/scenes/install?id=${encodeURIComponent(id)}&filename=${encodeURIComponent(file)}` const url = isScene ? `/api/market/scenes/install?id=${encodeURIComponent(id)}&filename=${encodeURIComponent(file)}`
: `/api/market/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 res = await fetch(url);
const data = await res.json(); const data = await res.json();
if (data.ok) { if (data.ok) {
let msg = '安装成功'; Toast.show('安装成功!请在仪表盘页面查看', 'success', 4000);
if (data.missing_dashboards && data.missing_dashboards.length > 0)
msg += ',缺少 ' + data.missing_dashboards.length + ' 个依赖仪表盘';
Toast.show(msg, 'success');
} else { } 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', () => { document.getElementById('tab-dashboards')?.addEventListener('click', () => {
this._tab = 'dashboards'; this._tab = 'dashboards';