Skip to content

Commit

Permalink
✨ feat: 添加动作库
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmclin2 committed Jul 16, 2024
1 parent bfe5dbe commit e5854e2
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 2 deletions.
48 changes: 48 additions & 0 deletions src/app/settings/Settings/animations/SideBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { createStyles } from 'antd-style';
import classNames from 'classnames';
import { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import Header from '@/components/Header';
import ListItem from '@/components/ListItem';
import { GenderEnum } from '@/types/agent';

const useStyles = createStyles(({ css, token }) => ({
item: css`
position: relative;
width: 180px;
margin-block: 2px;
border-radius: ${token.borderRadius}px;
`,
}));

interface IndexProps {
currentGender: GenderEnum;
genderOptions: { icon: ReactNode; label: string; value: GenderEnum }[];
setCurrentGender: (area: GenderEnum) => void;
}

const Index = (props: IndexProps) => {
const { styles } = useStyles();
const { currentGender, setCurrentGender, genderOptions = [] } = props;
const { t } = useTranslation(['panel']);

return (
<Flexbox>
<Header title={t('info.genderLabel')} />
{genderOptions.map((item) => (
<ListItem
avatar={item.icon}
className={classNames(styles.item)}
active={item.value === currentGender}
key={item.value}
title={item.label}
onClick={() => setCurrentGender(item.value)}
/>
))}
</Flexbox>
);
};

export default Index;
67 changes: 67 additions & 0 deletions src/app/settings/Settings/animations/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { ManOutlined, QuestionCircleOutlined, WomanOutlined } from '@ant-design/icons';
import { createStyles } from 'antd-style';
import classNames from 'classnames';
import React, { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';

import { GenderEnum } from '@/types/agent';

import SideBar from './SideBar';

const useStyles = createStyles(({ css, token }) => ({
container: css`
position: relative;
display: flex;
width: 100%;
min-height: 480px;
padding: 0 16px;
background-color: rgba(255, 255, 255, 2%);
border-radius: ${token.borderRadius}px;
`,
}));

interface TouchProps {
className?: string;
style?: React.CSSProperties;
}

const Touch = (props: TouchProps) => {
const { style, className } = props;
const { styles } = useStyles();
const [currentGender, setCurrentGender] = useState<GenderEnum>(GenderEnum.FEMALE);

const { t } = useTranslation(['constants']);

const GENDER_OPTIONS = [
{
label: t('agent.gender.female'),
value: GenderEnum.FEMALE,
icon: <WomanOutlined style={{ fontSize: 24 }} />,
},
{
label: t('agent.gender.male'),
value: GenderEnum.MALE,
icon: <ManOutlined style={{ fontSize: 24 }} />,
},
{
label: t('agent.gender.other'),
value: GenderEnum.OTHER,
icon: <QuestionCircleOutlined style={{ fontSize: 24 }} />,
},
];

return (
<div className={classNames(className, styles.container)} style={style}>
<SideBar
currentGender={currentGender}
setCurrentGender={setCurrentGender}
genderOptions={GENDER_OPTIONS}
/>
</div>
);
};

export default memo(Touch);
6 changes: 6 additions & 0 deletions src/app/settings/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import Animations from './animations';
import CommonConfig from './common';
import OpenAIConfig from './model/openai';
import Touch from './touch';
Expand Down Expand Up @@ -35,6 +36,10 @@ const Config = (props: ConfigProps) => {
key: 'touch',
label: t('touchSetting'),
},
{
key: 'animation',
label: t('animationLibrary'),
},
]}
onChange={(key) => {
setTab(key);
Expand All @@ -45,6 +50,7 @@ const Config = (props: ConfigProps) => {
{tab === 'languageModel' ? <OpenAIConfig /> : null}
{tab === 'common' ? <CommonConfig /> : null}
{tab === 'touch' ? <Touch /> : null}
{tab === 'animation' ? <Animations /> : null}
</Flexbox>
</Flexbox>
);
Expand Down
1 change: 1 addition & 0 deletions src/locales/default/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default {
commonSetting: '通用设置',
languageModel: '语言模型',
touchSetting: '触摸设置',
animationLibrary: '动作库',
selectModel: '请选择模型',
selectInDanceList: '请从舞蹈列表中选取',
inputStartChat: '请输入内容开始聊天',
Expand Down
4 changes: 2 additions & 2 deletions src/locales/default/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
description: '这是一个自定义角色',
},
gender: {
male: '',
female: '',
male: '男性',
female: '女性',
other: '其他',
},
},
Expand Down

0 comments on commit e5854e2

Please sign in to comment.