feat: add delete cookies functionality for login reset (#275)

This commit is contained in:
Ctrlz
2025-11-02 19:01:48 +08:00
committed by GitHub
parent 7cf35fc4ae
commit 11a937b84f
6 changed files with 88 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"net/http"
"github.com/xpzouying/xiaohongshu-mcp/cookies"
"github.com/xpzouying/xiaohongshu-mcp/xiaohongshu"
"github.com/gin-gonic/gin"
@@ -63,6 +64,22 @@ func (s *AppServer) getLoginQrcodeHandler(c *gin.Context) {
respondSuccess(c, result, "获取登录二维码成功")
}
// deleteCookiesHandler 删除 cookies重置登录状态
func (s *AppServer) deleteCookiesHandler(c *gin.Context) {
err := s.xiaohongshuService.DeleteCookies(c.Request.Context())
if err != nil {
respondError(c, http.StatusInternalServerError, "DELETE_COOKIES_FAILED",
"删除 cookies 失败", err.Error())
return
}
cookiePath := cookies.GetCookiesFilePath()
respondSuccess(c, map[string]interface{}{
"cookie_path": cookiePath,
"message": "Cookies 已成功删除,登录状态已重置。下次操作时需要重新登录。",
}, "删除 cookies 成功")
}
// publishHandler 发布内容
func (s *AppServer) publishHandler(c *gin.Context) {
var req PublishRequest