diff --git a/web/controller/xraySetting.go b/web/controller/xray_setting.go similarity index 89% rename from web/controller/xraySetting.go rename to 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 31d4feeb..df4c7b20 100644 --- a/web/html/xui/xray.html +++ b/web/html/xui/xray.html @@ -74,6 +74,14 @@ {{ i18n "pages.xray.save" }} {{ i18n "pages.xray.restart" }} + + Error in running xray-core + + + @@ -459,6 +467,7 @@ xraySetting: '', inboundTags: [], saveBtnDisable: true, + restartResult: '', showAlert: false, isMobile: window.innerWidth <= 768, advSettings: 'xraySetting', @@ -567,8 +576,19 @@ async restartXray() { this.loading(true); const msg = await HttpUtil.post("server/restartXrayService"); + if (msg.success) { + await PromiseUtil.sleep(500); + await this.getXrayResult(); + } this.loading(false); }, + async getXrayResult() { + const msg = await HttpUtil.get("/xui/xray/getXrayResult"); + if(msg.success){ + this.restartResult=msg.obj; + if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj); + } + }, async resetXrayConfigToDefault() { this.loading(true); const msg = await HttpUtil.get("/xui/xray/getDefaultJsonConfig"); @@ -838,6 +858,7 @@ this.showAlert = true; } await this.getXraySetting(); + await this.getXrayResult(); while (true) { await PromiseUtil.sleep(1000); this.saveBtnDisable = this.oldXraySetting === this.xraySetting; diff --git a/web/service/xraySettings.go b/web/service/xray_setting.go similarity index 100% rename from web/service/xraySettings.go rename to web/service/xray_setting.go