2025-12-17 10:13:47 +00:00
|
|
|
'use client';
|
|
|
|
|
import Profile from './Profile';
|
|
|
|
|
import Personal from './Personal';
|
|
|
|
|
import VoiceActor from './VoiceActor';
|
|
|
|
|
import Font from './Font';
|
|
|
|
|
import MaxToken from './MaxToken';
|
|
|
|
|
import Background from './Background';
|
|
|
|
|
import ChatModel from './ChatModel';
|
|
|
|
|
import { IconButton } from '@/components/ui/button';
|
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import {
|
|
|
|
|
AlertDialog,
|
|
|
|
|
AlertDialogAction,
|
|
|
|
|
AlertDialogCancel,
|
|
|
|
|
AlertDialogContent,
|
|
|
|
|
AlertDialogDescription,
|
|
|
|
|
AlertDialogFooter,
|
|
|
|
|
AlertDialogHeader,
|
|
|
|
|
AlertDialogTitle,
|
|
|
|
|
} from '@/components/ui/alert-dialog';
|
2025-12-18 10:14:12 +00:00
|
|
|
import { useStreamChatStore } from '../stream-chat';
|
2025-12-17 10:13:47 +00:00
|
|
|
|
|
|
|
|
type SettingProps = {
|
|
|
|
|
open: boolean;
|
|
|
|
|
onOpenChange: (open: boolean) => void;
|
|
|
|
|
};
|
|
|
|
|
export type ActiveTabType =
|
|
|
|
|
| 'profile'
|
|
|
|
|
| 'personal'
|
|
|
|
|
| 'history'
|
|
|
|
|
| 'voice_actor'
|
|
|
|
|
| 'font'
|
|
|
|
|
| 'max_token'
|
|
|
|
|
| 'background'
|
2025-12-18 10:14:12 +00:00
|
|
|
| 'model';
|
2025-12-17 10:13:47 +00:00
|
|
|
|
|
|
|
|
const titleMap = {
|
|
|
|
|
personal: 'Personal',
|
|
|
|
|
history: 'History',
|
|
|
|
|
voice_actor: 'Voice Actor',
|
|
|
|
|
font: 'Font',
|
|
|
|
|
max_token: 'Max Token',
|
|
|
|
|
background: 'Background',
|
|
|
|
|
model: 'Chat Model',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default function SettingDialog({ open, onOpenChange }: SettingProps) {
|
|
|
|
|
const [activeTab, setActiveTab] = useState<ActiveTabType>('profile');
|
2025-12-18 10:14:12 +00:00
|
|
|
const updateUserChatSetting = useStreamChatStore((store) => store.updateUserChatSetting);
|
|
|
|
|
|
|
|
|
|
const handleChange = (open: boolean) => {
|
|
|
|
|
if (!open) {
|
|
|
|
|
updateUserChatSetting();
|
|
|
|
|
}
|
|
|
|
|
onOpenChange(open);
|
|
|
|
|
};
|
2025-12-17 10:13:47 +00:00
|
|
|
|
|
|
|
|
return (
|
2025-12-18 10:14:12 +00:00
|
|
|
<AlertDialog open={open} onOpenChange={handleChange}>
|
2025-12-17 10:13:47 +00:00
|
|
|
<AlertDialogContent showCloseButton={activeTab === 'profile'}>
|
|
|
|
|
<AlertDialogTitle className="flex justify-between">
|
|
|
|
|
{activeTab === 'profile' ? (
|
|
|
|
|
<IconButton variant="tertiary" size="small" iconfont="icon-Like" />
|
|
|
|
|
) : (
|
|
|
|
|
titleMap[activeTab]
|
|
|
|
|
)}
|
|
|
|
|
{activeTab !== 'profile' && (
|
|
|
|
|
<IconButton variant="tertiary" size="small" onClick={() => setActiveTab('profile')}>
|
|
|
|
|
<i className="iconfont-v2 iconv2-jiantou" />
|
|
|
|
|
</IconButton>
|
|
|
|
|
)}
|
|
|
|
|
</AlertDialogTitle>
|
|
|
|
|
<div className="w-full h-[calc(100vh-160px)] pr-1 mt-4">
|
|
|
|
|
{activeTab === 'profile' && <Profile onActiveTab={setActiveTab} />}
|
|
|
|
|
{activeTab === 'personal' && <Personal />}
|
|
|
|
|
{activeTab === 'voice_actor' && <VoiceActor />}
|
|
|
|
|
{activeTab === 'font' && <Font />}
|
|
|
|
|
{activeTab === 'max_token' && <MaxToken />}
|
|
|
|
|
{activeTab === 'background' && <Background />}
|
|
|
|
|
{activeTab === 'model' && <ChatModel />}
|
|
|
|
|
</div>
|
|
|
|
|
</AlertDialogContent>
|
|
|
|
|
</AlertDialog>
|
|
|
|
|
);
|
|
|
|
|
}
|