Skip to content

Commit

Permalink
restart singbox button #328
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Oct 28, 2024
1 parent d255905 commit 50d1177
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions backend/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"s-ui/logger"
"s-ui/service"
"s-ui/singbox"
"s-ui/util"
"strconv"
"strings"
Expand All @@ -20,6 +21,7 @@ type APIHandler struct {
service.PanelService
service.StatsService
service.ServerService
singbox.Controller
}

func NewAPIHandler(g *gin.RouterGroup) {
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:logType="logModal.logType"
@close="closeLogs"
/>
<v-container class="fill-height">
<v-container class="fill-height" :loading="loading">
<v-responsive :class="reloadItems.length>0 ? 'fill-height text-center' : 'align-center'" >
<v-row class="d-flex align-center justify-center">
<v-col cols="auto">
Expand Down Expand Up @@ -116,6 +116,12 @@
</v-tooltip>
<v-icon icon="mdi-list-box-outline" :color="tilesData.sbd?.running ? 'success': 'error'" />
</v-chip>
<v-chip density="compact" color="transparent" v-if="tilesData.sbd?.running && !loading" style="cursor: pointer;" @click="restartSingbox()">
<v-tooltip activator="parent" location="top">
{{ $t('actions.restartSb') }}
</v-tooltip>
<v-icon icon="mdi-restart" color="warning" />
</v-chip>
</v-col>
<v-col cols="4">{{ $t('main.info.memory') }}</v-col>
<v-col cols="8">
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -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
}
</script>
1 change: 1 addition & 0 deletions frontend/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default {
disable: "Disable",
close: "Close",
restartApp: "Restart App",
restartSb: "Restart Singbox",
},
login: {
title: "Login",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default {
disable: "غیرفعال",
close: "بستن",
restartApp: "ریستارت پنل",
restartSb: "ریستارت سینگ‌باکس",
},
login: {
title: "ورود",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default {
disable: "Отключить",
close: "Закрыть",
restartApp: "Перезапустить приложение",
restartSb: "Перезапустить Singbox",
},
login: {
title: "Вход",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zhcn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default {
disable: "禁用",
close: "关闭",
restartApp: "重启面板",
restartSb: "重启 Singbox",
},
login: {
title: "登录",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zhtw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
disable: "禁用",
close: "關閉",
restartApp: "重啟面板",
restartSb: "重啟 Singbox",
},
login: {
title: "登錄",
Expand Down

0 comments on commit 50d1177

Please sign in to comment.