Spaces:
Sleeping
Sleeping
Commit
·
3ddd2f7
1
Parent(s):
5bb0441
init state
Browse files- app/(chat)/page.tsx +13 -0
- components/chat.tsx +1 -11
app/(chat)/page.tsx
CHANGED
@@ -1,9 +1,22 @@
|
|
|
|
|
|
1 |
import { nanoid } from '@/lib/utils';
|
2 |
import { Chat } from '@/components/chat';
|
3 |
import { ThemeToggle } from '../../components/theme-toggle';
|
|
|
|
|
|
|
4 |
|
5 |
export default function IndexPage() {
|
6 |
const id = nanoid();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
return (
|
9 |
<>
|
|
|
1 |
+
'use client';
|
2 |
+
|
3 |
import { nanoid } from '@/lib/utils';
|
4 |
import { Chat } from '@/components/chat';
|
5 |
import { ThemeToggle } from '../../components/theme-toggle';
|
6 |
+
import { useAtomValue } from 'jotai';
|
7 |
+
import { targetImageAtom } from '../../state';
|
8 |
+
import { EmptyScreen } from '../../components/empty-screen';
|
9 |
|
10 |
export default function IndexPage() {
|
11 |
const id = nanoid();
|
12 |
+
const targetImage = useAtomValue(targetImageAtom);
|
13 |
+
|
14 |
+
if (!targetImage)
|
15 |
+
return (
|
16 |
+
<div className="pb-[150px] pt-4 md:pt-10 h-full">
|
17 |
+
<EmptyScreen />
|
18 |
+
</div>
|
19 |
+
);
|
20 |
|
21 |
return (
|
22 |
<>
|
components/chat.tsx
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
'use client';
|
2 |
-
|
3 |
import { useChat, type Message } from 'ai/react';
|
4 |
import '@/app/globals.css';
|
5 |
|
@@ -24,8 +22,6 @@ export interface ChatProps extends React.ComponentProps<'div'> {
|
|
24 |
}
|
25 |
|
26 |
export function Chat({ id, initialMessages, className }: ChatProps) {
|
27 |
-
const router = useRouter();
|
28 |
-
const path = usePathname();
|
29 |
const [targetImage, setTargetImage] = useAtom(targetImageAtom);
|
30 |
const { messages, append, reload, stop, isLoading, input, setInput } =
|
31 |
useChat({
|
@@ -42,12 +38,6 @@ export function Chat({ id, initialMessages, className }: ChatProps) {
|
|
42 |
},
|
43 |
});
|
44 |
|
45 |
-
if (!targetImage)
|
46 |
-
return (
|
47 |
-
<div className={cn('pb-[150px] pt-4 md:pt-10 h-full', className)}>
|
48 |
-
<EmptyScreen />
|
49 |
-
</div>
|
50 |
-
);
|
51 |
return (
|
52 |
<>
|
53 |
<div className={cn('pb-[150px] pt-4 md:pt-10 h-full', className)}>
|
@@ -56,7 +46,7 @@ export function Chat({ id, initialMessages, className }: ChatProps) {
|
|
56 |
<div className="relative aspect-[1/1] w-full px-12">
|
57 |
<div className="flex items-center h-[600px] relative">
|
58 |
<Image
|
59 |
-
src={targetImage}
|
60 |
alt="target image"
|
61 |
layout="fill"
|
62 |
objectFit="contain"
|
|
|
|
|
|
|
1 |
import { useChat, type Message } from 'ai/react';
|
2 |
import '@/app/globals.css';
|
3 |
|
|
|
22 |
}
|
23 |
|
24 |
export function Chat({ id, initialMessages, className }: ChatProps) {
|
|
|
|
|
25 |
const [targetImage, setTargetImage] = useAtom(targetImageAtom);
|
26 |
const { messages, append, reload, stop, isLoading, input, setInput } =
|
27 |
useChat({
|
|
|
38 |
},
|
39 |
});
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
return (
|
42 |
<>
|
43 |
<div className={cn('pb-[150px] pt-4 md:pt-10 h-full', className)}>
|
|
|
46 |
<div className="relative aspect-[1/1] w-full px-12">
|
47 |
<div className="flex items-center h-[600px] relative">
|
48 |
<Image
|
49 |
+
src={targetImage!}
|
50 |
alt="target image"
|
51 |
layout="fill"
|
52 |
objectFit="contain"
|