rtc-voice-chat/src/components/AiChangeCard/index.tsx

57 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Copyright 2025 Beijing Volcano Engine Technology Co., Ltd. All Rights Reserved.
* SPDX-license-identifier: BSD-3-Clause
*/
import { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { RootState } from '@/store';
import CheckScene from './CheckScene';
import { updateScene } from '@/store/slices/room';
import style from './index.module.less';
import { Scenes, SceneMap } from '@/config';
import { useVisionMode } from '@/lib/useCommon';
function AIChangeCard() {
const room = useSelector((state: RootState) => state.room);
const dispatch = useDispatch();
const [scene, setScene] = useState(room.scene);
const { isVisionMode } = useVisionMode();
const avatar = SceneMap[scene]?.icon;
const handleChecked = (checkedScene: string) => {
setScene(checkedScene);
dispatch(updateScene({ scene: checkedScene }));
};
return (
<div className={style.card}>
<div className={style.avatar}>
<img id="avatar-card" src={avatar} alt="Avatar" />
</div>
<div className={style.title}>
<div>Hi AI</div>
<div className={style.desc}>
{isVisionMode ? <> Vision </> : ''}
</div>
</div>
<div className={style.sceneContainer}>
{Scenes.map((key) =>
key ? (
<CheckScene
key={key.name}
icon={key.icon}
title={key.name}
checked={key.name === scene}
onClick={() => handleChecked(key.name)}
/>
) : null
)}
</div>
</div>
);
}
export default AIChangeCard;