This commit is contained in:
hailin 2025-06-23 13:32:21 +08:00
parent 2a36e7e08a
commit 54306ea870
2 changed files with 5 additions and 11 deletions

View File

@ -19,11 +19,11 @@ const initialUIState: {
component: React.ReactNode component: React.ReactNode
}[] = [] }[] = []
const AIProvider = createAI({ export const AI = createAI({
actions: { actions: {
submit: async function(formData?: FormData, skip?: boolean) { submit: async function(formData?: FormData, skip?: boolean) {
'use server' 'use server'
const aiState = getMutableAIState<typeof AIProvider>() const aiState = getMutableAIState<typeof AI>()
const uiStream = createStreamableUI() const uiStream = createStreamableUI()
const isGenerating = createStreamableValue(true) const isGenerating = createStreamableValue(true)
const messages: ExperimentalMessage[] = aiState.get() as any const messages: ExperimentalMessage[] = aiState.get() as any
@ -92,5 +92,3 @@ const AIProvider = createAI({
initialUIState, initialUIState,
initialAIState initialAIState
}) })
export default AIProvider

View File

@ -1,6 +1,6 @@
import type { Metadata, Viewport } from 'next' import type { Metadata, Viewport } from 'next'
import { Inter as FontSans } from 'next/font/google' import { Inter as FontSans } from 'next/font/google'
import AIProvider from './action' // ✅ default 导入 import { AI } from './action' // 注意,导入的是 { AI },不是 AIProvider
import '../../globals.css' import '../../globals.css'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { ThemeProvider } from '@/components/mpv2/theme-provider' import { ThemeProvider } from '@/components/mpv2/theme-provider'
@ -52,10 +52,6 @@ export default function RootLayout({
disableTransitionOnChange disableTransitionOnChange
> >
{/* <Header /> */} {/* <Header /> */}
<AIProvider> <AI>
{children} {children}
</AIProvider> </AI>
{/* <Footer /> */}
</ThemeProvider>
)
}