diff --git a/dashboard/app/dashboard/layout.tsx b/dashboard/app/dashboard/layout.tsx
index 7b15445..d2ce9a4 100644
--- a/dashboard/app/dashboard/layout.tsx
+++ b/dashboard/app/dashboard/layout.tsx
@@ -1,7 +1,7 @@
"use client"
import { Loader2Icon } from "lucide-react"
-import { useRouter } from "next/navigation"
+import { usePathname, useRouter } from "next/navigation"
import type { CSSProperties, ReactNode } from "react"
import { useEffect } from "react"
@@ -16,13 +16,19 @@ export default function DashboardLayout({
children: ReactNode
}) {
const { ready, session } = useAuth()
+ const pathname = usePathname()
const router = useRouter()
+ const isLoginRoute = pathname?.startsWith("/dashboard/login") ?? false
useEffect(() => {
- if (ready && !session) {
- router.replace("/login")
+ if (ready && !session && !isLoginRoute) {
+ router.replace("/dashboard/login")
}
- }, [ready, router, session])
+ }, [isLoginRoute, ready, router, session])
+
+ if (isLoginRoute) {
+ return <>{children}>
+ }
if (!ready || !session) {
return (
diff --git a/dashboard/app/login/page.tsx b/dashboard/app/dashboard/login/page.tsx
similarity index 94%
rename from dashboard/app/login/page.tsx
rename to dashboard/app/dashboard/login/page.tsx
index bcf63ef..d9e56a7 100644
--- a/dashboard/app/login/page.tsx
+++ b/dashboard/app/dashboard/login/page.tsx
@@ -1,5 +1,5 @@
import { LoginForm } from "@/components/login-form"
-import { BotMessageSquareIcon, ShieldCheckIcon, UsersIcon, KeyRoundIcon } from "lucide-react"
+import { BotMessageSquareIcon, ShieldCheckIcon } from "lucide-react"
import Link from "next/link"
import { Suspense } from "react"
@@ -47,7 +47,7 @@ export default function LoginPage() {
-
+
diff --git a/dashboard/app/login/wxwork/callback/page.tsx b/dashboard/app/dashboard/login/wxwork/callback/page.tsx
similarity index 95%
rename from dashboard/app/login/wxwork/callback/page.tsx
rename to dashboard/app/dashboard/login/wxwork/callback/page.tsx
index 7a74be7..1f6cc61 100644
--- a/dashboard/app/login/wxwork/callback/page.tsx
+++ b/dashboard/app/dashboard/login/wxwork/callback/page.tsx
@@ -31,7 +31,7 @@ function WxWorkLoginCallbackContent() {
if (!ticket) {
toast.error("企业微信登录票据不存在")
- router.replace("/login")
+ router.replace("/dashboard/login")
return
}
@@ -42,7 +42,7 @@ function WxWorkLoginCallbackContent() {
})
.catch((error) => {
toast.error(error instanceof Error ? error.message : "企业微信登录失败")
- router.replace("/login")
+ router.replace("/dashboard/login")
})
}, [router, searchParams])
diff --git a/dashboard/app/favicon.ico b/dashboard/app/favicon.ico
index 718d6fe..432e26d 100644
Binary files a/dashboard/app/favicon.ico and b/dashboard/app/favicon.ico differ
diff --git a/dashboard/app/page.tsx b/dashboard/app/page.tsx
index ab0660d..f45a1dd 100644
--- a/dashboard/app/page.tsx
+++ b/dashboard/app/page.tsx
@@ -15,7 +15,7 @@ export default function HomePage() {
进入控制台
-
+
登录后台
diff --git a/dashboard/components/auth-provider.tsx b/dashboard/components/auth-provider.tsx
index 43591d6..aaa0f43 100644
--- a/dashboard/components/auth-provider.tsx
+++ b/dashboard/components/auth-provider.tsx
@@ -33,7 +33,8 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const router = useRouter()
const [session, setSession] = useState
(null)
const [ready, setReady] = useState(false)
- const requiresAuth = pathname?.startsWith("/dashboard") ?? false
+ const isDashboardLoginRoute = pathname?.startsWith("/dashboard/login") ?? false
+ const requiresAuth = (pathname?.startsWith("/dashboard") ?? false) && !isDashboardLoginRoute
const refreshProfile = useCallback(async () => {
const stored = readSession()
@@ -58,7 +59,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
setSession(null)
if (requiresAuth) {
startTransition(() => {
- router.replace("/login")
+ router.replace("/dashboard/login")
})
}
} finally {
@@ -71,7 +72,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
await logout(current?.refreshToken)
setSession(null)
startTransition(() => {
- router.replace("/login")
+ router.replace("/dashboard/login")
})
}
@@ -86,7 +87,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
setReady(true)
if (requiresAuth) {
startTransition(() => {
- router.replace("/login")
+ router.replace("/dashboard/login")
})
}
}, [requiresAuth, refreshProfile, router])
diff --git a/docs b/docs
index 688d3b0..2c06261 160000
--- a/docs
+++ b/docs
@@ -1 +1 @@
-Subproject commit 688d3b061856055a2e19da8ec6733155eb13fb64
+Subproject commit 2c062610c432b096b2ae984fda45923ca7de04ce
diff --git a/internal/controllers/api/auth_controller.go b/internal/controllers/api/auth_controller.go
index 84af987..5166aac 100644
--- a/internal/controllers/api/auth_controller.go
+++ b/internal/controllers/api/auth_controller.go
@@ -75,7 +75,7 @@ func (c *AuthController) GetWxwork_callback() {
c.redirectWxWorkError(err.Error())
return
}
- c.Ctx.Redirect("/login/wxwork/callback?ticket="+url.QueryEscape(ticket)+"&next="+url.QueryEscape(next), iris.StatusFound)
+ c.Ctx.Redirect("/dashboard/login/wxwork/callback?ticket="+url.QueryEscape(ticket)+"&next="+url.QueryEscape(next), iris.StatusFound)
}
func (c *AuthController) PostWxwork_exchange() *web.JsonResult {