diff --git a/main.go b/main.go index e09b6d7..5f9c376 100644 --- a/main.go +++ b/main.go @@ -190,6 +190,7 @@ func runWebServer() error { http.HandleFunc("/logs", web.Auth(web.Logs)) http.HandleFunc("/clearLog", web.Auth(web.ClearLog)) http.HandleFunc("/webhookTest", web.Auth(web.WebhookTest)) + http.HandleFunc("/logout", web.Auth(web.Logout)) util.Log("监听 %s", *listen) diff --git a/static/common.css b/static/common.css index 8d6e4fe..5d0039f 100644 --- a/static/common.css +++ b/static/common.css @@ -227,4 +227,31 @@ main { line-height: 0; text-align: center; font-size: 16px; -} \ No newline at end of file +} + +.badge { + margin-right: 20px; /* 给版本号添加右侧间距 */ +} + +.action-button { + display: inline-block; + padding: 6px 12px; + font-size: 14px; + color: white; + border: 1px solid white; + border-radius: 8px; + background-color: transparent; + text-align: center; + text-decoration: none; +} + +.action-button:hover, +.action-button:visited, +.action-button:active, +.action-button:focus { + color: white; + border-color: white; + background-color: transparent; + text-decoration: none; + outline: none; +} diff --git a/static/constant.js b/static/constant.js index fab18df..25dc49f 100644 --- a/static/constant.js +++ b/static/constant.js @@ -232,6 +232,7 @@ const I18N_MAP = { "NetInterfaceEmptyHelp": 'No available network card found', "Login": 'Login', "LoginInit": 'Login and configure as an administrator account', + "Logout": 'Logout', }, 'zh-cn': { 'Logs': '日志', @@ -298,5 +299,6 @@ const I18N_MAP = { "NetInterfaceEmptyHelp": '没有找到可用的网卡', "Login": '登录', "LoginInit": '登录并配置为管理员账号', + "Logout": '注销', } }; diff --git a/web/logout.go b/web/logout.go new file mode 100755 index 0000000..778625c --- /dev/null +++ b/web/logout.go @@ -0,0 +1,23 @@ +package web + +import ( + "net/http" + "time" +) + +func Logout(w http.ResponseWriter, r *http.Request) { + // 创建一个过期的 Cookie 来清除客户端的身份认证 Cookie + expiredCookie := http.Cookie{ + Name: cookieName, // 假设你的身份验证使用的是名为 "auth" 的 Cookie + Value: "", + Path: "/", + Expires: time.Unix(0, 0), // 设置为过期时间 + MaxAge: -1, // 立即删除该 Cookie + HttpOnly: true, + } + // 设置过期的 Cookie + http.SetCookie(w, &expiredCookie) + + // 重定向用户到登录页面 + http.Redirect(w, r, "./login", http.StatusFound) +} diff --git a/web/writing.html b/web/writing.html index 18cea23..336a292 100755 --- a/web/writing.html +++ b/web/writing.html @@ -30,11 +30,7 @@ > DDNS-GO - + Logs {{.Version}} + + Logout + @@ -102,7 +101,7 @@ - - - Others @@ -561,7 +560,7 @@ /> @@ -750,7 +749,7 @@ TTL: "", }; - +