From 76644c66b0835593ff0a14740e676e301fedaaf9 Mon Sep 17 00:00:00 2001 From: Nelson-He Date: Sat, 25 Jun 2022 16:35:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96webclient=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=90=8C=E4=B8=80=E5=A5=97=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=94=AF=E6=8C=81=E6=9C=AC=E5=9C=B0=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E8=B0=83=E6=B5=8B=E5=92=8C=E7=8E=AF=E5=A2=83=E4=B8=8A=E7=BA=BF?= =?UTF-8?q?=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/api/api.go | 6 ++++++ pkg/api/routes.go | 1 + static/js/app.js | 10 +++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 9c75cbc..d3c178d 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -552,3 +552,9 @@ func DataExport(c *gin.Context) { badRequest(c, err) } } + +func GetDebugMode(c *gin.Context) { + successResponse(c, gin.H{ + "debug_mode": command.Opts.Debug, + }) +} diff --git a/pkg/api/routes.go b/pkg/api/routes.go index c69789b..2f0798b 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -55,4 +55,5 @@ func SetupRoutes(router *gin.Engine) { api.GET("/history", GetHistory) api.GET("/bookmarks", GetBookmarks) api.GET("/export", DataExport) + api.GET("/debugmode", GetDebugMode) } diff --git a/static/js/app.js b/static/js/app.js index 31dddd5..cfd6ea8 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1789,7 +1789,6 @@ function goAuthorize(data, cb) { } var isAuthentic = false; - function handleMessage(e) { if (!isAuthentic) { goAuthorize(e.data, function () { @@ -1801,6 +1800,11 @@ function handleMessage(e) { } $(document).ready(function () { - //start(); - window.addEventListener("message", handleMessage); + apiCall("get", "/debugmode", {}, function (resp) { + if (resp.error || !resp.debug_mode) { + window.addEventListener("message", handleMessage); + } else { + start(); + } + }); }); -- Gitee