Hair Keeper v1.0.0:一个高度集成、深度定制、约定优于配置的全栈Web应用模板,旨在保持灵活性的同时提供一套基于成熟架构的开发底座,自带身份认证、权限控制、丰富前端组件、文件上传、后台任务、智能体开发等丰富功能,提供AI开发辅助,免于纠结功能如何实现,可快速上手专注于业务逻辑

This commit is contained in:
2025-11-13 15:24:54 +08:00
commit 42be39b343
249 changed files with 38843 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
'use client'
import { SessionProvider as NextAuthSessionProvider } from "next-auth/react"
export function SessionProvider({ children }: { children: React.ReactNode }) {
return <NextAuthSessionProvider>{children}</NextAuthSessionProvider>
}

View File

@@ -0,0 +1,17 @@
'use client';
import { ThemeProvider } from 'next-themes';
import { ReactNode } from 'react';
export function AppThemeProvider({ children }: { children: ReactNode }) {
return (
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{children}
</ThemeProvider>
);
}

View File

@@ -0,0 +1,45 @@
'use client'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { httpBatchLink, httpSubscriptionLink, splitLink } from '@trpc/client'
import { useState } from 'react'
import superjson from 'superjson'
import { trpc } from '@/lib/trpc'
function getBaseUrl() {
if (typeof window !== 'undefined') return '' // 浏览器环境
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}` // Vercel环境
return `http://localhost:${process.env.PORT ?? 3000}` // 开发环境
}
export function TRPCProvider({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(() => new QueryClient())
const [trpcClient] = useState(() =>
trpc.createClient({
links: [
// 使用splitLink根据操作类型选择不同的link
splitLink({
condition: (op) => op.type === 'subscription',
// subscription使用httpSubscriptionLink (SSE)
true: httpSubscriptionLink({
url: `${getBaseUrl()}/api/trpc`,
transformer: superjson,
}),
// 其他操作使用httpBatchLink
false: httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
transformer: superjson,
}),
}),
],
})
)
return (
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
</trpc.Provider>
)
}