feat: 更新页面样式
parent
52e849324f
commit
edfc853931
|
|
@ -99,8 +99,8 @@ export default function Antechamber() {
|
|||
};
|
||||
return (
|
||||
<div className="flex flex-col items-center h-full">
|
||||
<AntechamberHeader toRoom={toRoom} />
|
||||
<AntechamberScore toRoom={toRoom} />
|
||||
<AntechamberHeader />
|
||||
<AntechamberScore />
|
||||
<AntechamberWishList />
|
||||
<AntechamberFile />
|
||||
<AntechamberReport />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useState, useEffect } from "react";
|
||||
import { useState, useEffect, useContext } from "react";
|
||||
|
||||
import HelloGIF from "/icons/hello.gif";
|
||||
import WhatsThing from "/icons/whatsThing.png";
|
||||
|
|
@ -7,16 +7,16 @@ import RightIcon from "/icons/right.png";
|
|||
import styles from "./index.module.css";
|
||||
import { fetchQuestions } from "@/apis/questions";
|
||||
import { useAbortController } from "@/hooks/useAbortController";
|
||||
import { RealtimeClientContext } from "../Provider/RealtimeClientProvider";
|
||||
|
||||
type Props = {
|
||||
toRoom: ({initMessage,fileUrl}:{initMessage?:string,fileUrl?:string}) =>void;
|
||||
};
|
||||
|
||||
export default function HeaderGroup({ toRoom }: Props) {
|
||||
export default function HeaderGroup() {
|
||||
const [isRotating, setIsRotating] = useState(false);
|
||||
const [displayQuestions, setDisplayQuestions] = useState<string[]>([]);
|
||||
const [allQuestions, setAllQuestions] = useState<string[]>([]);
|
||||
|
||||
const { handleConnect } = useContext(RealtimeClientContext);
|
||||
|
||||
const { getSignal } = useAbortController();
|
||||
|
||||
// 随机获取4个问题的函数
|
||||
|
|
@ -64,7 +64,7 @@ export default function HeaderGroup({ toRoom }: Props) {
|
|||
};
|
||||
|
||||
const handleQuestion = async (question: string) => {
|
||||
toRoom({initMessage:question});
|
||||
handleConnect({initMessage:question});
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -4,12 +4,11 @@ import { useSearchParams } from 'react-router-dom';
|
|||
import MyInputIcon from '/icons/myInput.png';
|
||||
import RightBlueIcon from '/icons/rightBlue.png';
|
||||
import style from './index.module.css';
|
||||
import { RealtimeClientContext } from '../Provider/RealtimeClientProvider';
|
||||
import { useContext } from 'react';
|
||||
|
||||
type Props = {
|
||||
toRoom: ({initMessage,fileUrl}:{initMessage?:string,fileUrl?:string}) => void;
|
||||
};
|
||||
|
||||
export default function MyInput({ toRoom }: Props) {
|
||||
export default function MyInput() {
|
||||
|
||||
const [searchParams] = useSearchParams()
|
||||
|
||||
|
|
@ -17,9 +16,11 @@ export default function MyInput({ toRoom }: Props) {
|
|||
const subjectGroup = searchParams.get('subjectGroup') || '物/化/史'
|
||||
const expectedScore = searchParams.get('expectedScore') || 500
|
||||
|
||||
const { handleConnect } = useContext(RealtimeClientContext);
|
||||
|
||||
|
||||
const handleQuestion = async () => {
|
||||
toRoom({initMessage:`我的高考地点在${provinceName},我选择的科目是${subjectGroup},我的高考分数为${expectedScore}分。帮我出一个科学的参考志愿表`});
|
||||
handleConnect({initMessage:`我的高考地点在${provinceName},我选择的科目是${subjectGroup},我的高考分数为${expectedScore}分。帮我出一个科学的参考志愿表`});
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -168,16 +168,13 @@ export const RealtimeClientProvider = ({
|
|||
try {
|
||||
if (!clientRef.current) {
|
||||
await initClient({ initMessage, fileInfo });
|
||||
} else {
|
||||
await handleDisconnect();
|
||||
await initClient({ initMessage, fileInfo });
|
||||
}
|
||||
await clientRef.current?.connect();
|
||||
await clientRef.current?.setAudioEnable(false);
|
||||
setAudioEnabled(false);
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
// console.error(error);
|
||||
if (error instanceof RealtimeAPIError) {
|
||||
switch (error.code) {
|
||||
case RealtimeError.CREATE_ROOM_ERROR:
|
||||
|
|
@ -275,7 +272,7 @@ export const RealtimeClientProvider = ({
|
|||
content: JSON.stringify([
|
||||
{
|
||||
type: "text",
|
||||
text: "帮我解读这个文件,结合当下的专业行情以及对该专业未来的发展趋势,简介的给出大学建议",
|
||||
text: "帮我解读这个文件,结合当下的专业行情以及对该专业未来的发展趋势,简介的给出志愿建议",
|
||||
},
|
||||
{ type: "image", file_url: fileInfo.url },
|
||||
]),
|
||||
|
|
@ -294,6 +291,12 @@ export const RealtimeClientProvider = ({
|
|||
client.on(EventNames.ALL, (_eventName, event: any) => {
|
||||
// AI智能体设置
|
||||
|
||||
if(_eventName === 'server.error'){
|
||||
// 长期不活动,服务端终结了
|
||||
handleDisconnect();
|
||||
}
|
||||
|
||||
|
||||
if (
|
||||
event.event_type !== ChatEventType.CONVERSATION_MESSAGE_DELTA &&
|
||||
event.event_type !== ChatEventType.CONVERSATION_MESSAGE_COMPLETED &&
|
||||
|
|
@ -363,8 +366,6 @@ export const RealtimeClientProvider = ({
|
|||
) {
|
||||
// lastEvent = event;
|
||||
if(event.event_type === ChatEventType.CONVERSATION_MESSAGE_DELTA && fileParseStatusRef.current === 2){
|
||||
console.log("重置了");
|
||||
|
||||
fileParseStatusRef.current = -1;
|
||||
}
|
||||
return [
|
||||
|
|
@ -454,9 +455,6 @@ export const RealtimeClientProvider = ({
|
|||
setIsConnected(true);
|
||||
});
|
||||
|
||||
client.on(EventNames.ERROR, (_error: any) => {
|
||||
setIsConnected(false);
|
||||
});
|
||||
},
|
||||
[clientRef.current]
|
||||
);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export default function RoomConversation() {
|
|||
<img
|
||||
src="/icons/conversation-bg.png"
|
||||
alt="background"
|
||||
className="w-[252px] h-[49px] object-contain absolute top-[-50%] z-[-1] left-[50%] translate-x-[-50%]"
|
||||
className="w-[252px] h-[59px] object-contain absolute top-[-50%] z-[-1] left-[50%] translate-x-[-50%] max-w-[unset]"
|
||||
/>
|
||||
Hey,我是您的六纬AI填报师
|
||||
</div>
|
||||
|
|
@ -54,7 +54,7 @@ export default function RoomConversation() {
|
|||
: "bg-blue-500 text-white rounded-tr-none"
|
||||
}`}
|
||||
>
|
||||
{typeof message.fileParseStatus === "undefined" ? (
|
||||
{typeof message.fileParseStatus === "undefined" && typeof message.fileInfo === 'undefined' ? (
|
||||
<ReactMarkdown remarkPlugins={[gfm]}>
|
||||
{message.content}
|
||||
</ReactMarkdown>
|
||||
|
|
@ -93,9 +93,9 @@ export default function RoomConversation() {
|
|||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div ref={messagesEndRef} />
|
||||
</div>
|
||||
<div className="text-[12px] text-[#999] font-[400] text-center mt-auto mb-[7px]">AI也会犯错,请考虑核实重要信息。</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue