调整dashboard项目结构
This commit is contained in:
@@ -46,7 +46,7 @@ export function AppSidebar({ ...props }: ComponentProps<typeof Sidebar>) {
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton
|
||||
className="data-[slot=sidebar-menu-button]:p-1.5!"
|
||||
render={<Link href="/" />}
|
||||
render={<Link href="/dashboard" />}
|
||||
>
|
||||
<BotMessageSquareIcon className="size-5!" />
|
||||
<span className="text-base font-semibold">贝壳AGENT</span>
|
||||
|
||||
@@ -33,6 +33,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
const router = useRouter()
|
||||
const [session, setSession] = useState<AuthSession | null>(null)
|
||||
const [ready, setReady] = useState(false)
|
||||
const requiresAuth = pathname?.startsWith("/dashboard") ?? false
|
||||
|
||||
const refreshProfile = useCallback(async () => {
|
||||
const stored = readSession()
|
||||
@@ -55,7 +56,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
} catch {
|
||||
clearSession()
|
||||
setSession(null)
|
||||
if (pathname && !pathname.startsWith("/login")) {
|
||||
if (requiresAuth) {
|
||||
startTransition(() => {
|
||||
router.replace("/login")
|
||||
})
|
||||
@@ -63,7 +64,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
} finally {
|
||||
setReady(true)
|
||||
}
|
||||
}, [pathname, router])
|
||||
}, [requiresAuth, router])
|
||||
|
||||
async function signOut() {
|
||||
const current = readSession()
|
||||
@@ -83,12 +84,12 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
|
||||
setReady(true)
|
||||
if (pathname && !pathname.startsWith("/login")) {
|
||||
if (requiresAuth) {
|
||||
startTransition(() => {
|
||||
router.replace("/login")
|
||||
})
|
||||
}
|
||||
}, [pathname, refreshProfile, router])
|
||||
}, [requiresAuth, refreshProfile, router])
|
||||
|
||||
return (
|
||||
<AuthContext.Provider value={{ session, ready, refreshProfile, signOut }}>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useState } from "react"
|
||||
import { ChevronsUpDownIcon, PlusIcon } from "lucide-react"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { EditDialog as CompanyEditDialog } from "@/app/(dashboard)/companies/_components/edit"
|
||||
import { EditDialog as CompanyEditDialog } from "@/app/dashboard/companies/_components/edit"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Command,
|
||||
|
||||
@@ -36,7 +36,7 @@ export function LoginForm({
|
||||
const nextPath = searchParams.get("next")
|
||||
const wxworkError = searchParams.get("wxworkError")
|
||||
const redirectPath =
|
||||
nextPath && nextPath.startsWith("/") ? nextPath : "/"
|
||||
nextPath && nextPath.startsWith("/") ? nextPath : "/dashboard"
|
||||
|
||||
useEffect(() => {
|
||||
if (session) {
|
||||
|
||||
Reference in New Issue
Block a user