feat: 前端登录跳转问题
All checks were successful
Web Console Deploy (Vue 3 + Vite) / deploy (push) Successful in 1m10s
Backend Deploy (Go + Docker) / deploy (push) Successful in 1m44s

This commit is contained in:
zs
2026-03-03 01:33:12 +08:00
parent 235fc9c87f
commit c686d81d30
2 changed files with 7 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package handler
import ( import (
"encoding/json" "encoding/json"
"log"
"net/http" "net/http"
"github.com/zs/InsightReply/internal/service" "github.com/zs/InsightReply/internal/service"
@@ -29,7 +30,8 @@ func (h *UserHandler) Register(w http.ResponseWriter, r *http.Request) {
user, err := h.svc.Register(body.Email, body.Password, body.Identity) user, err := h.svc.Register(body.Email, body.Password, body.Identity)
if err != nil { if err != nil {
SendError(w, http.StatusInternalServerError, 5001, "Failed to register user") log.Printf("[Register] Failed to register user %s: %v", body.Email, err)
SendError(w, http.StatusInternalServerError, 5001, "Failed to register user: "+err.Error())
return return
} }

View File

@@ -25,9 +25,11 @@ const handleLogin = async () => {
if (!res.ok) throw new Error('Invalid credentials') if (!res.ok) throw new Error('Invalid credentials')
const data = await res.json() const data = await res.json()
if (data.token) { if (data.data && data.data.token) {
localStorage.setItem('jwt_token', data.token) localStorage.setItem('jwt_token', data.data.token)
router.push('/dashboard') router.push('/dashboard')
} else {
throw new Error(data.message || 'Login failed')
} }
} catch (err: any) { } catch (err: any) {
errorMsg.value = err.message || 'Login failed' errorMsg.value = err.message || 'Login failed'