Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 添加对话模式和视频模式 #170

Merged
merged 9 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/app/chat/Background/index.tsx

This file was deleted.

24 changes: 24 additions & 0 deletions src/app/chat/CameraMode/Background/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useGlobalStore } from '@/store/global';

const Background = () => {
const backgroundUrl = useGlobalStore((s) => s.backgroundUrl);

return backgroundUrl ? (
<div
style={{
position: 'absolute',
left: 0,
top: 0,
backgroundImage: `url(${backgroundUrl})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
width: '100%',
height: '100%',
zIndex: -1,
transition: 'background-image 0.5s ease-in-out',
}}
></div>
) : null;
};

export default Background;
31 changes: 31 additions & 0 deletions src/app/chat/CameraMode/Operation/actions/CallOff.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ActionIcon } from '@lobehub/ui';
import { useTheme } from 'antd-style';
import { Phone } from 'lucide-react';
import { useTranslation } from 'react-i18next';

import { DESKTOP_OPERATION_ICON_SIZE } from '@/constants/token';
import { useSessionStore } from '@/store/session';

const CallOff = () => {
const [setChatMode] = useSessionStore((s) => [s.setChatMode]);
const setVoiceOn = useSessionStore((s) => s.setVoiceOn);
const theme = useTheme();
const { t } = useTranslation('chat');
return (
<ActionIcon
icon={Phone}
onClick={() => {
setVoiceOn(false);
setChatMode('chat');
}}
title={t('callOff')}
size={DESKTOP_OPERATION_ICON_SIZE}
style={{
backgroundColor: theme.colorError,
color: theme.colorWhite,
}}
/>
);
};

export default CallOff;
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { ActionIcon } from '@lobehub/ui';
import { useTheme } from 'antd-style';
import { Mic } from 'lucide-react';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';

import { DESKTOP_OPERATION_ICON_SIZE_LARGE } from '@/constants/token';
import { useSpeechRecognition } from '@/hooks/useSpeechRecognition';
import { useSessionStore } from '@/store/session';

const Record = () => {
const [sendMessage, setMessageInput] = useSessionStore((s) => [s.sendMessage, s.setMessageInput]);
const { t } = useTranslation('chat');
const theme = useTheme();
const handleMessageInput = useCallback(
(result: string, isFinal: boolean) => {
setMessageInput(result);
Expand All @@ -25,7 +28,16 @@ const Record = () => {
});

return (
<ActionIcon icon={Mic} loading={isRecording} onClick={toggleRecord} title={t('tts.record')} />
<ActionIcon
icon={Mic}
loading={isRecording}
onClick={toggleRecord}
title={t('tts.record')}
size={DESKTOP_OPERATION_ICON_SIZE_LARGE}
style={{
backgroundColor: theme.colorBgElevated,
}}
/>
);
};

Expand Down
25 changes: 25 additions & 0 deletions src/app/chat/CameraMode/Operation/actions/Setting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ActionIcon } from '@lobehub/ui';
import { useTheme } from 'antd-style';
import { Box } from 'lucide-react';
import React from 'react';
import { useTranslation } from 'react-i18next';

import { DESKTOP_OPERATION_ICON_SIZE } from '@/constants/token';
import { useGlobalStore } from '@/store/global';

export default () => {
const [toggleChatSideBar] = useGlobalStore((s) => [s.toggleChatSideBar]);
const theme = useTheme();
const { t } = useTranslation('dance');
return (
<ActionIcon
icon={Box}
onClick={() => toggleChatSideBar()}
title={t('menu')}
size={DESKTOP_OPERATION_ICON_SIZE}
style={{
backgroundColor: theme.colorBgElevated,
}}
/>
);
};
20 changes: 20 additions & 0 deletions src/app/chat/CameraMode/Operation/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use client';

import { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import CallOff from './actions/CallOff';
import Record from './actions/Record';
import Setting from './actions/Setting';

const VoiceOperation = memo(() => {
return (
<Flexbox gap={24} horizontal align={'center'}>
<CallOff />
<Record />
<Setting />
</Flexbox>
);
});

export default VoiceOperation;
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { ReactNode, memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import CategoryFilter from '@/app/chat/ChatInfo/PostureList/SideBar/filters/CategoryFilter';
import GenderFilter from '@/app/chat/ChatInfo/PostureList/SideBar/filters/GenderFilter';
import Header from '@/components/Header';
import { GenderEnum } from '@/types/agent';
import { PostureCategoryEnum } from '@/types/touch';

import CategoryFilter from './filters/CategoryFilter';
import GenderFilter from './filters/GenderFilter';

interface IndexProps {
categoryOptions: { icon: ReactNode; label: string; value: PostureCategoryEnum | undefined }[];
currentCategory: PostureCategoryEnum | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use client';

import { DraggablePanel, TabsNav } from '@lobehub/ui';
import { ActionIcon, DraggablePanel, TabsNav } from '@lobehub/ui';
import { createStyles } from 'antd-style';
import { X } from 'lucide-react';
import dynamic from 'next/dynamic';
import { rgba } from 'polished';
import React, { useState } from 'react';
Expand All @@ -20,11 +21,6 @@ const Loading = () => (
</div>
);

const ChatList = dynamic(() => import('./ChatList'), {
ssr: false,
loading: Loading,
});

const BackGround = dynamic(() => import('./BackGroundList'), {
ssr: false,
loading: Loading,
Expand Down Expand Up @@ -56,7 +52,7 @@ const useStyles = createStyles(({ css, token }) => ({
display: flex;
flex-direction: column;

background-color: ${rgba(token.colorBgLayout, 0.2)};
background-color: ${rgba(token.colorBgLayout, 0.8)};
backdrop-filter: saturate(180%) blur(8px);
`,
header: css`
Expand All @@ -66,6 +62,15 @@ const useStyles = createStyles(({ css, token }) => ({
player: css`
min-width: 480px;
`,
closeIcon: css`
cursor: pointer;
margin-right: 12px;
color: ${token.colorTextSecondary};

&:hover {
color: ${token.colorText};
}
`,
}));

export default () => {
Expand All @@ -74,7 +79,7 @@ export default () => {
s.setChatSidebar,
]);

const [tab, setTab] = useState<Tab>(Tab.ChatList);
const [tab, setTab] = useState<Tab>(Tab.DanceList);
const { t } = useTranslation('chat');

const { styles } = useStyles();
Expand All @@ -84,7 +89,7 @@ export default () => {
classNames={{ content: styles.content }}
minWidth={CHAT_INFO_WIDTH}
maxWidth={CHAT_INFO_MAX_WIDTH}
mode={'fixed'}
mode={'float'}
onExpandChange={(expand) => {
setChatSidebar(expand);
}}
Expand All @@ -93,12 +98,20 @@ export default () => {
>
<Flexbox justify={'space-between'} horizontal align={'center'} className={styles.header}>
<TabsNav
variant={'compact'}
activeKey={tab}
tabBarExtraContent={{
left: (
<ActionIcon
icon={X}
onClick={() => {
setChatSidebar(false);
}}
style={{ marginLeft: 12 }}
/>
),
}}
items={[
{
label: t('info.chat'),
key: Tab.ChatList,
},
{
label: t('info.dance'),
key: Tab.DanceList,
Expand All @@ -125,8 +138,7 @@ export default () => {
}}
/>
</Flexbox>
<Flexbox height={'calc(100vh - 128px)'}>
{tab === Tab.ChatList && <ChatList />}
<Flexbox height={`calc(100vh - ${CHAT_HEADER_HEIGHT}px)`}>
{tab === Tab.DanceList && <DanceList />}
{tab === Tab.Motions && <MotionList />}
{tab === Tab.Posture && <PostureList />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export enum Tab {
Background = 'background',
ChatList = 'chats',
DanceList = 'dances',
Motions = 'motions',
Posture = 'posture',
Expand Down
47 changes: 47 additions & 0 deletions src/app/chat/CameraMode/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use client';

import classNames from 'classnames';
import { isEqual } from 'lodash-es';
import React, { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import ChatDialog from '@/app/chat/CameraMode/ChatDialog';
import { HEADER_HEIGHT } from '@/constants/token';
import AgentViewer from '@/features/AgentViewer';
import { sessionSelectors, useSessionStore } from '@/store/session';

import Background from './Background';
import Operation from './Operation';
import Settings from './Settings';
import { useStyles } from './style';

export default memo(() => {
const { styles } = useStyles();
const [currentAgent, interactive] = useSessionStore(
(s) => [sessionSelectors.currentAgent(s), s.interactive],
isEqual,
);

return (
<Flexbox flex={1} horizontal>
<Flexbox flex={1} style={{ position: 'relative' }}>
{currentAgent ? (
<div className={styles.viewer}>
<AgentViewer
height={`calc(100vh - ${HEADER_HEIGHT}px)`}
agentId={currentAgent.agentId}
interactive={interactive}
/>
</div>
) : null}
<ChatDialog className={classNames(styles.dialog, styles.content)} />
<Flexbox flex={1} className={styles.mask} />
<Flexbox align={'center'} className={styles.docker}>
<Operation />
</Flexbox>
</Flexbox>
<Settings />
<Background />
</Flexbox>
);
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { createStyles } from 'antd-style';

import { CHAT_HEADER_HEIGHT, CHAT_INPUT_WIDTH } from '@/constants/token';

export const useStyles = createStyles(({ css, token }) => ({
export const useStyles = createStyles(({ css, token, responsive }) => ({
viewer: css`
position: absolute;
top: 0;
Expand All @@ -16,21 +14,19 @@ export const useStyles = createStyles(({ css, token }) => ({
max-width: 100vw;
padding: 0 12px;

@media (max-width: 768px) {
${responsive.mobile} {
width: 100%;
}
`,
dialog: css`
z-index: 2;
margin: ${CHAT_HEADER_HEIGHT}px auto 0;
margin: ${token.marginLG}px auto 0;
`,
docker: css`
z-index: 2;
width: 100%;
margin-bottom: ${token.marginLG}px;
padding: ${token.paddingSM}px;
`,
input: css`
width: ${CHAT_INPUT_WIDTH};
`,
mask: css``,
}));
Loading
Loading