diff --git a/src/api/config.ts b/src/api/config.ts index e85f1bf6..605732cd 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -2,8 +2,11 @@ import axios from 'axios'; import type { Config } from '#/config'; export async function setConfig(newConfig: Config) { - const { data } = await axios.post('api/v1/updateConfig', newConfig); - return data; + const { data } = await axios.post<{ + message: 'Success' | 'Failed to update config'; + }>('api/v1/updateConfig', newConfig); + + return data.message === 'Success'; } export async function getConfig() { diff --git a/src/api/program.ts b/src/api/program.ts index 0309a323..21aa334d 100644 --- a/src/api/program.ts +++ b/src/api/program.ts @@ -1,7 +1,10 @@ import axios from 'axios'; /** 重启 */ -export const appRestart = () => axios.get('api/v1/restart'); +export async function appRestart() { + const { data } = await axios.get<{ status: 'ok' }>('api/v1/restart'); + return data.status === 'ok'; +} /** 启动 */ export const appStart = () => axios.get('api/v1/start'); diff --git a/src/pages/bangumi/index.vue b/src/pages/bangumi/index.vue index 7d0f9974..31568bf6 100644 --- a/src/pages/bangumi/index.vue +++ b/src/pages/bangumi/index.vue @@ -15,13 +15,13 @@ import BangumiData from './components/BangumiData.vue'; - + - + diff --git a/src/pages/debug/index.vue b/src/pages/debug/index.vue index 9904595d..4d565a42 100644 --- a/src/pages/debug/index.vue +++ b/src/pages/debug/index.vue @@ -25,10 +25,10 @@ function restart() { ElMessageBox.confirm('该操作将重启程序!', { type: 'warning', }) - .then(async () => { + .then(() => { appRestart() - .then(({ data }) => { - if (data.status === 'success') { + .then((res) => { + if (res) { ElMessage({ message: '正在重启, 请稍后刷新页面...', type: 'success', @@ -38,7 +38,7 @@ function restart() { .catch((error) => { console.error('🚀 ~ file: index.vue:41 ~ .then ~ error:', error); ElMessage({ - message: '操作失败, 请重试!', + message: '操作失败, 请手动重启容器!', type: 'error', }); }); @@ -51,7 +51,7 @@ function restart() {
- +