Replaces Monaco editor with CodeMirror in the frontend, removing related dependencies and configuration. Refactors font management to support multiple formats (woff, woff2, ttf, otf) and dynamic font switching, including backend API and frontend theme config UI. Adds gzip compression middleware to backend. Updates theme config to allow font selection and custom font upload, and improves theme preview and color customization UI. Cleans up unused code and improves sidebar and terminal font sizing responsiveness.
96 lines
2.5 KiB
TypeScript
96 lines
2.5 KiB
TypeScript
import { Button } from '@heroui/button';
|
|
import {
|
|
Modal,
|
|
ModalBody,
|
|
ModalContent,
|
|
ModalFooter,
|
|
ModalHeader,
|
|
useDisclosure,
|
|
} from '@heroui/modal';
|
|
import { useCallback, useRef } from 'react';
|
|
import toast from 'react-hot-toast';
|
|
|
|
import ChatInputModal from '@/components/chat_input/modal';
|
|
import CodeEditor from '@/components/code_editor';
|
|
import type { CodeEditorRef } from '@/components/code_editor';
|
|
|
|
export interface OneBotSendModalProps {
|
|
sendMessage: (msg: string) => void;
|
|
}
|
|
|
|
const OneBotSendModal: React.FC<OneBotSendModalProps> = (props) => {
|
|
const { sendMessage } = props;
|
|
const { isOpen, onOpen, onOpenChange } = useDisclosure();
|
|
const editorRef = useRef<CodeEditorRef | null>(null);
|
|
|
|
const handleSendMessage = useCallback(
|
|
(onClose: () => void) => {
|
|
const msg = editorRef.current?.getValue();
|
|
if (!msg) {
|
|
toast.error('消息不能为空');
|
|
return;
|
|
}
|
|
try {
|
|
sendMessage(msg);
|
|
toast.success('消息发送成功');
|
|
onClose();
|
|
} catch (_error) {
|
|
toast.error('消息发送失败');
|
|
}
|
|
},
|
|
[sendMessage]
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<Button onPress={onOpen} color='primary' radius='full' variant='flat' size='sm' className="font-medium">
|
|
构造请求
|
|
</Button>
|
|
<Modal
|
|
isOpen={isOpen}
|
|
onOpenChange={onOpenChange}
|
|
placement='top-center'
|
|
size='5xl'
|
|
scrollBehavior='outside'
|
|
isDismissable={false}
|
|
>
|
|
<ModalContent>
|
|
{(onClose) => (
|
|
<>
|
|
<ModalHeader className='flex flex-col gap-1'>
|
|
构造请求
|
|
</ModalHeader>
|
|
<ModalBody>
|
|
<div className='h-96'>
|
|
<CodeEditor
|
|
height='100%'
|
|
defaultLanguage='json'
|
|
defaultValue={`{
|
|
"action": "get_group_list"
|
|
}`}
|
|
ref={editorRef}
|
|
/>
|
|
</div>
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<ChatInputModal />
|
|
|
|
<Button color='primary' variant='flat' onPress={onClose}>
|
|
取消
|
|
</Button>
|
|
<Button
|
|
color='primary'
|
|
onPress={() => handleSendMessage(onClose)}
|
|
>
|
|
发送
|
|
</Button>
|
|
</ModalFooter>
|
|
</>
|
|
)}
|
|
</ModalContent>
|
|
</Modal>
|
|
</>
|
|
);
|
|
};
|
|
export default OneBotSendModal;
|