refactor: move ROUTES from @/lib/routes to @/router/routes
This commit is contained in:
@@ -17,7 +17,7 @@ import { useAuthState, useAuthDispatch } from "@/stores/auth/auth-context";
|
|||||||
import { useChatDispatch } from "@/stores/chat/chat-context";
|
import { useChatDispatch } from "@/stores/chat/chat-context";
|
||||||
import { useUserDispatch } from "@/stores/user/user-context";
|
import { useUserDispatch } from "@/stores/user/user-context";
|
||||||
import { useAuthGate } from "@/lib/auth/nextauth";
|
import { useAuthGate } from "@/lib/auth/nextauth";
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
import { MobileShell } from "@/app/_components/core/mobile-shell";
|
import { MobileShell } from "@/app/_components/core/mobile-shell";
|
||||||
import { AuthPanel } from "@/app/auth/components/auth-panel";
|
import { AuthPanel } from "@/app/auth/components/auth-panel";
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
|
|
||||||
import { ChatMenuBar } from "./chat-menu-bar";
|
import { ChatMenuBar } from "./chat-menu-bar";
|
||||||
import styles from "./chat-header.module.css";
|
import styles from "./chat-header.module.css";
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
|
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
import { SpAsyncUtil } from "@/utils/storage";
|
import { SpAsyncUtil } from "@/utils/storage";
|
||||||
import { useAuthDispatch } from "@/stores/auth/auth-context";
|
import { useAuthDispatch } from "@/stores/auth/auth-context";
|
||||||
import { useUserDispatch } from "@/stores/user/user-context";
|
import { useUserDispatch } from "@/stores/user/user-context";
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
|
|
||||||
import styles from "./quota-dialog.module.css";
|
import styles from "./quota-dialog.module.css";
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { useRouter } from "next/navigation";
|
|||||||
|
|
||||||
import { AuthStorage } from "@/data/storage/auth/auth_storage";
|
import { AuthStorage } from "@/data/storage/auth/auth_storage";
|
||||||
import { StorageKeys } from "@/data/storage/storage_keys";
|
import { StorageKeys } from "@/data/storage/storage_keys";
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
|
|
||||||
interface DeepLinkPersistProps {
|
interface DeepLinkPersistProps {
|
||||||
deviceId: string;
|
deviceId: string;
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
|
|
||||||
interface ErrorProps {
|
interface ErrorProps {
|
||||||
error: Error & { digest?: string };
|
error: Error & { digest?: string };
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { Geist, Geist_Mono } from "next/font/google";
|
import { Geist, Geist_Mono } from "next/font/google";
|
||||||
import localFont from "next/font/local";
|
import localFont from "next/font/local";
|
||||||
import { SessionProvider } from "next-auth/react";
|
import { SessionProvider } from "@/providers/session-provider";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
import { RootProviders } from "@/providers/root-providers";
|
import { RootProviders } from "@/providers/root-providers";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
|
|
||||||
export default function NotFound() {
|
export default function NotFound() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
redirect(ROUTES.splash);
|
redirect(ROUTES.splash);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { useAuthState, useAuthDispatch } from "@/stores/auth/auth-context";
|
|||||||
import { useChatDispatch } from "@/stores/chat/chat-context";
|
import { useChatDispatch } from "@/stores/chat/chat-context";
|
||||||
import { useUserDispatch } from "@/stores/user/user-context";
|
import { useUserDispatch } from "@/stores/user/user-context";
|
||||||
import { facebookLogin, useAuthGate } from "@/lib/auth/nextauth";
|
import { facebookLogin, useAuthGate } from "@/lib/auth/nextauth";
|
||||||
import { ROUTES } from "@/lib/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
import { LoadingIndicator } from "@/app/_components/core/loading-indicator";
|
import { LoadingIndicator } from "@/app/_components/core/loading-indicator";
|
||||||
import styles from "./splash-button.module.css";
|
import styles from "./splash-button.module.css";
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -4,7 +4,10 @@
|
|||||||
* 注意:故意**不**把 `src/lib/auth/nextauth.ts`(Client-only)放进来,
|
* 注意:故意**不**把 `src/lib/auth/nextauth.ts`(Client-only)放进来,
|
||||||
* 避免 Server bundle 误把 React 客户端代码拉进去。
|
* 避免 Server bundle 误把 React 客户端代码拉进去。
|
||||||
* 如需导入,请直接 `import { ... } from "@/lib/auth/nextauth";`。
|
* 如需导入,请直接 `import { ... } from "@/lib/auth/nextauth";`。
|
||||||
|
*
|
||||||
|
* 注:路由相关常量已迁移至 `@/router`(`src/router/routes.ts`)。
|
||||||
|
* 路由守卫已迁移至 `@/router/proxy`(`src/router/proxy.ts`)。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from "./routes";
|
export * from "./breakpoints";
|
||||||
export * from "./auth/nextauth-helpers";
|
export * from "./auth/nextauth-helpers";
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
"use client";
|
||||||
|
/**
|
||||||
|
* SessionProvider 客户端包装
|
||||||
|
*
|
||||||
|
* 背景:next-auth v4 的 `SessionProvider`(从 `next-auth/react` 导出)
|
||||||
|
* **没有** `"use client"` 指令。这是 v4 的历史遗留(v5 / Auth.js 已修正)。
|
||||||
|
*
|
||||||
|
* 当 Server Component(如 `src/app/layout.tsx`)直接 import 时,Next.js
|
||||||
|
* 不会自动把它当 client component 渲染,会继续在服务端 tree 里执行,导致
|
||||||
|
* `useContext` / `useState` 报错:
|
||||||
|
* "Error: React Context is unavailable in Server Components"
|
||||||
|
*
|
||||||
|
* 修复:新建一个显式 `"use client"` 的 wrapper,re-export `SessionProvider`。
|
||||||
|
* 这样 Server Component 看到的入口是 `"use client"`,会触发 RSC 边界。
|
||||||
|
*/
|
||||||
|
export { SessionProvider } from "next-auth/react";
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Router 公共导出
|
||||||
|
*
|
||||||
|
* 集中管理:
|
||||||
|
* - 路由常量(ROUTES、ROUTE_BUILDERS、AUTH_ONLY_ROUTES、PUBLIC_ROUTES、ALL_STATIC_ROUTES)
|
||||||
|
* - Next.js 16 Proxy(CDN 端鉴权重定向)
|
||||||
|
*
|
||||||
|
* 业务层导入示例:
|
||||||
|
* ```ts
|
||||||
|
* import { ROUTES, AUTH_ONLY_ROUTES, type Route } from "@/router";
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export * from "./routes";
|
||||||
|
export { proxy, config as proxyConfig } from "./proxy";
|
||||||
@@ -27,7 +27,7 @@ import {
|
|||||||
AUTH_ONLY_ROUTES,
|
AUTH_ONLY_ROUTES,
|
||||||
ROUTES,
|
ROUTES,
|
||||||
type StaticRoute,
|
type StaticRoute,
|
||||||
} from "@/lib/routes";
|
} from "@/router/routes";
|
||||||
|
|
||||||
const SESSION_COOKIE_NAMES = [
|
const SESSION_COOKIE_NAMES = [
|
||||||
"next-auth.session-token",
|
"next-auth.session-token",
|
||||||
Reference in New Issue
Block a user