From bd214cc1172c8c073abbfa6fb137fbc4c4a42eee Mon Sep 17 00:00:00 2001 From: jingrow Date: Sun, 2 Nov 2025 13:28:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=87=8D=E5=90=AF=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jingrow/frontend/src/locales/zh-CN.json | 6 +++ .../jingrow/frontend/src/shared/api/system.ts | 33 ++++++++++-- apps/jingrow/frontend/src/views/Settings.vue | 48 +++++++++++++++-- apps/jingrow/jingrow/api/system.py | 53 +++++++++++++++++++ 4 files changed, 132 insertions(+), 8 deletions(-) diff --git a/apps/jingrow/frontend/src/locales/zh-CN.json b/apps/jingrow/frontend/src/locales/zh-CN.json index 5b8ed97..d496462 100644 --- a/apps/jingrow/frontend/src/locales/zh-CN.json +++ b/apps/jingrow/frontend/src/locales/zh-CN.json @@ -935,6 +935,12 @@ "Environment configuration saved": "环境配置已保存", "Failed to load environment configuration": "加载环境配置失败", "Failed to save environment configuration": "保存环境配置失败", + "Restart Environment": "重启环境", + "Restart": "重启", + "Only system administrators can restart environment": "仅系统管理员可以重启环境", + "Are you sure you want to restart the environment? This operation may cause service interruption.": "您确定要重启环境吗?此操作可能导致服务中断。", + "Environment restart request submitted. The system will restart shortly.": "环境重启请求已提交,系统将在稍后重启。", + "Failed to restart environment": "重启环境失败", "Publish App": "发布应用", "Active": "活跃", "View detailed information about the application": "查看应用的详细信息", diff --git a/apps/jingrow/frontend/src/shared/api/system.ts b/apps/jingrow/frontend/src/shared/api/system.ts index 4f3f0d6..ca63d4f 100644 --- a/apps/jingrow/frontend/src/shared/api/system.ts +++ b/apps/jingrow/frontend/src/shared/api/system.ts @@ -1,8 +1,6 @@ import axios from 'axios' import { get_session_api_headers } from './auth' -const jingrowServerUrl = import.meta.env.VITE_JINGROW_SERVER_URL || '' - export interface EnvironmentConfig { jingrow_server_url: string jingrow_api_key: string @@ -34,7 +32,7 @@ export interface EnvironmentConfig { export const getEnvironmentConfig = async (): Promise<{ success: boolean; data?: EnvironmentConfig; message?: string }> => { try { const response = await axios.get( - `${jingrowServerUrl}/jingrow/system/environment-config`, + `/jingrow/system/environment-config`, { headers: get_session_api_headers(), withCredentials: true @@ -60,7 +58,7 @@ export const getEnvironmentConfig = async (): Promise<{ success: boolean; data?: export const updateEnvironmentConfig = async (config: Partial): Promise<{ success: boolean; message?: string }> => { try { const response = await axios.post( - `${jingrowServerUrl}/jingrow/system/environment-config`, + `/jingrow/system/environment-config`, config, { headers: get_session_api_headers(), @@ -83,3 +81,30 @@ export const updateEnvironmentConfig = async (config: Partial } } +// 重启环境 +export const restartEnvironment = async (): Promise<{ success: boolean; message?: string }> => { + try { + const response = await axios.post( + `/jingrow/system/restart-environment`, + {}, + { + headers: get_session_api_headers(), + withCredentials: true + } + ) + + if (response.data?.success) { + return { success: true, message: response.data.message || '环境重启请求已提交' } + } + return { success: false, message: response.data?.message || '重启环境失败' } + } catch (error: any) { + if (error.response?.status === 403) { + return { success: false, message: '仅系统管理员可以访问此功能' } + } + if (error.response?.status === 401) { + return { success: false, message: '认证失败,请重新登录' } + } + return { success: false, message: error.response?.data?.detail || error.message || '重启环境失败' } + } +} + diff --git a/apps/jingrow/frontend/src/views/Settings.vue b/apps/jingrow/frontend/src/views/Settings.vue index 8b0bf32..a28a761 100644 --- a/apps/jingrow/frontend/src/views/Settings.vue +++ b/apps/jingrow/frontend/src/views/Settings.vue @@ -165,6 +165,12 @@ {{ t('Refresh') }} + + + {{ t('Restart Environment') }} +