diff --git a/backend/api/api.go b/backend/api/api.go index 88a99f1d..0457b046 100644 --- a/backend/api/api.go +++ b/backend/api/api.go @@ -3,6 +3,7 @@ package api import ( "s-ui/logger" "s-ui/service" + "s-ui/singbox" "s-ui/util" "strconv" "strings" @@ -20,6 +21,7 @@ type APIHandler struct { service.PanelService service.StatsService service.ServerService + singbox.Controller } func NewAPIHandler(g *gin.RouterGroup) { @@ -89,6 +91,9 @@ func (a *APIHandler) postHandler(c *gin.Context) { case "restartApp": err = a.PanelService.RestartPanel(3) jsonMsg(c, "restartApp", err) + case "restartSb": + err = a.Controller.Restart() + jsonMsg(c, "restartSb", err) case "linkConvert": link := c.Request.FormValue("link") result, _, err := util.GetOutbound(link, 0) diff --git a/frontend/src/components/Main.vue b/frontend/src/components/Main.vue index deacf30c..583d4805 100644 --- a/frontend/src/components/Main.vue +++ b/frontend/src/components/Main.vue @@ -5,7 +5,7 @@ :logType="logModal.logType" @close="closeLogs" /> - + @@ -116,6 +116,12 @@ + + + {{ $t('actions.restartSb') }} + + + {{ $t('main.info.memory') }} @@ -168,6 +174,7 @@ import { computed, onBeforeUnmount, onMounted, ref } from 'vue' import { i18n } from '@/locales' import LogVue from '@/layouts/modals/Logs.vue' +const loading = ref(false) const menu = ref(false) const menuItems = [ { title: i18n.global.t('main.gauges'), value: [ @@ -249,4 +256,10 @@ const closeLogs = () => { logModal.value.logType = "s-ui" logModal.value.visible = false } + +const restartSingbox = async () => { + loading.value = true + await HttpUtils.post('api/restartSb',{}) + loading.value = false +} diff --git a/frontend/src/locales/en.ts b/frontend/src/locales/en.ts index cdcd2457..74162bf7 100644 --- a/frontend/src/locales/en.ts +++ b/frontend/src/locales/en.ts @@ -103,6 +103,7 @@ export default { disable: "Disable", close: "Close", restartApp: "Restart App", + restartSb: "Restart Singbox", }, login: { title: "Login", diff --git a/frontend/src/locales/fa.ts b/frontend/src/locales/fa.ts index 2776e7ad..452d189b 100644 --- a/frontend/src/locales/fa.ts +++ b/frontend/src/locales/fa.ts @@ -102,6 +102,7 @@ export default { disable: "غیرفعال", close: "بستن", restartApp: "ریستارت پنل", + restartSb: "ریستارت سینگ‌باکس", }, login: { title: "ورود", diff --git a/frontend/src/locales/ru.ts b/frontend/src/locales/ru.ts index 42093be4..8ae8b585 100644 --- a/frontend/src/locales/ru.ts +++ b/frontend/src/locales/ru.ts @@ -103,6 +103,7 @@ export default { disable: "Отключить", close: "Закрыть", restartApp: "Перезапустить приложение", + restartSb: "Перезапустить Singbox", }, login: { title: "Вход", diff --git a/frontend/src/locales/vi.ts b/frontend/src/locales/vi.ts index cc822953..166cba48 100644 --- a/frontend/src/locales/vi.ts +++ b/frontend/src/locales/vi.ts @@ -103,6 +103,7 @@ export default { disable: "Vô hiệu hóa", close: "Đóng", restartApp: "Khởi động lại ứng dụng", + restartSb: "Khởi động lại Singbox", }, login: { title: "Đăng nhập", diff --git a/frontend/src/locales/zhcn.ts b/frontend/src/locales/zhcn.ts index 62cb219b..c6fa6087 100644 --- a/frontend/src/locales/zhcn.ts +++ b/frontend/src/locales/zhcn.ts @@ -103,6 +103,7 @@ export default { disable: "禁用", close: "关闭", restartApp: "重启面板", + restartSb: "重启 Singbox", }, login: { title: "登录", diff --git a/frontend/src/locales/zhtw.ts b/frontend/src/locales/zhtw.ts index 5edbba6f..31ca51c3 100644 --- a/frontend/src/locales/zhtw.ts +++ b/frontend/src/locales/zhtw.ts @@ -104,6 +104,7 @@ export default { disable: "禁用", close: "關閉", restartApp: "重啟面板", + restartSb: "重啟 Singbox", }, login: { title: "登錄",