diff options
| author | Alireza Ahmadi <alireza7@gmail.com> | 2023-12-10 14:57:39 +0300 |
|---|---|---|
| committer | Alireza Ahmadi <alireza7@gmail.com> | 2023-12-10 14:57:39 +0300 |
| commit | 4cb67fd1c3129b83f3750f863caba081453f42b1 (patch) | |
| tree | 85c7e5c47f4415f775729aff26b60796590ef34a /web | |
| parent | 655e17e162129087263e85dfe9d5ba49c0a7044f (diff) | |
[xray] show xray errors #1300
Diffstat (limited to 'web')
| -rw-r--r-- | web/controller/xray_setting.go (renamed from web/controller/xraySetting.go) | 6 | ||||
| -rw-r--r-- | web/html/xui/xray.html | 21 | ||||
| -rw-r--r-- | web/service/xray_setting.go (renamed from web/service/xraySettings.go) | 0 |
3 files changed, 26 insertions, 1 deletions
diff --git a/web/controller/xraySetting.go b/web/controller/xray_setting.go index a4c8b600..d4deacd9 100644 --- a/web/controller/xraySetting.go +++ b/web/controller/xray_setting.go @@ -10,6 +10,7 @@ type XraySettingController struct { XraySettingService service.XraySettingService SettingService service.SettingService InboundService service.InboundService + XrayService service.XrayService } func NewXraySettingController(g *gin.RouterGroup) *XraySettingController { @@ -23,6 +24,7 @@ func (a *XraySettingController) initRouter(g *gin.RouterGroup) { g.POST("/", a.getXraySetting) g.POST("/update", a.updateSetting) + g.GET("/getXrayResult", a.getXrayResult) g.GET("/getDefaultJsonConfig", a.getDefaultXrayConfig) } @@ -55,3 +57,7 @@ func (a *XraySettingController) getDefaultXrayConfig(c *gin.Context) { } jsonObj(c, defaultJsonConfig, nil) } + +func (a *XraySettingController) getXrayResult(c *gin.Context) { + jsonObj(c, a.XrayService.GetXrayResult(), nil) +} diff --git a/web/html/xui/xray.html b/web/html/xui/xray.html index cdf5fd01..99b1878d 100644 --- a/web/html/xui/xray.html +++ b/web/html/xui/xray.html @@ -65,6 +65,14 @@ <a-space direction="horizontal"> <a-button type="primary" :disabled="saveBtnDisable" @click="updateXraySetting">{{ i18n "pages.xray.save" }}</a-button> <a-button type="danger" :disabled="!saveBtnDisable" @click="restartXray">{{ i18n "pages.xray.restart" }}</a-button> + <a-popover v-if="restartResult" + :overlay-class-name="themeSwitcher.currentTheme"> + <span slot="title" style="font-size: 12pt">Error in running xray-core</span> + <template slot="content"> + <p style="max-width: 400px" v-for="line in restartResult.split('\n')">[[ line ]]</p> + </template> + <a-icon type="question-circle" theme="filled"></a-icon> + </a-popover> </a-space> </a-col> <a-col :xs="24" :sm="16"> @@ -462,6 +470,7 @@ xraySetting: '', inboundTags: [], saveBtnDisable: true, + restartResult: '', isMobile: window.innerWidth <= 768, advSettings: 'xraySetting', cm: null, @@ -586,8 +595,17 @@ const msg = await HttpUtil.post("server/restartXrayService"); this.loading(false); if (msg.success) { - this.loading(true); + await PromiseUtil.sleep(500); + await this.getXrayResult(); } + this.loading(false); + }, + async getXrayResult() { + const msg = await HttpUtil.get("/panel/xray/getXrayResult"); + if(msg.success){ + this.restartResult=msg.obj; + if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj); + } }, async fetchUserSecret() { this.loading(true); @@ -896,6 +914,7 @@ }, async mounted() { await this.getXraySetting(); + await this.getXrayResult(); while (true) { await PromiseUtil.sleep(600); this.saveBtnDisable = this.oldXraySetting === this.xraySetting; diff --git a/web/service/xraySettings.go b/web/service/xray_setting.go index 4550bde2..4550bde2 100644 --- a/web/service/xraySettings.go +++ b/web/service/xray_setting.go |
