feat: add dashboard restart action and improve text button contrast

This commit is contained in:
liuwei
2026-04-07 13:14:13 +08:00
parent 4423f64272
commit 7cdda82e39
3 changed files with 78 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
<div class="page-hero-actions">
<el-button type="primary" plain @click="reloadIframe"><i class="el-icon-refresh"></i> 刷新面板</el-button>
<el-button type="primary" @click="openInNewTab"><i class="el-icon-top-right"></i> 新窗口打开</el-button>
<el-button type="danger" @click="confirmRestart"><i class="el-icon-refresh-left"></i> 重启服务</el-button>
</div>
</div>
@@ -40,7 +41,8 @@
return {
currentView: '14',
showTimeRangeSelector: false,
frameUrl: '{{ src_url }}'
frameUrl: '{{ src_url }}',
restarting: false
}
},
mounted() {
@@ -54,6 +56,31 @@
},
openInNewTab() {
window.open(this.frameUrl, '_blank');
},
confirmRestart() {
this.$confirm('确认执行 ./restart.sh 重启服务吗?这会中断当前服务几秒钟。', '重启确认', {
confirmButtonText: '确认重启',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.triggerRestart();
}).catch(() => {});
},
async triggerRestart() {
if (this.restarting) return;
this.restarting = true;
try {
const response = await axios.post('/api/restart_service');
if (response.data.success) {
this.$message.success(response.data.message || '已触发重启');
} else {
this.$message.error(response.data.message || '重启失败');
}
} catch (error) {
this.$message.error(error.response?.data?.message || '触发重启失败');
} finally {
this.restarting = false;
}
}
}
});