feat: context box

This commit is contained in:
archer
2023-07-23 22:58:20 +08:00
parent 6fd83e1e75
commit 6fc6c99477
9 changed files with 88 additions and 67 deletions

View File

@@ -2,8 +2,7 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { jsonRes } from '@/service/response';
import { authUser } from '@/service/utils/auth';
import { connectToDatabase, TrainingData, User, promotionRecord, Chat } from '@/service/mongo';
import { PRICE_SCALE } from '@/constants/common';
import { connectToDatabase, Chat } from '@/service/mongo';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {

View File

@@ -1,18 +1,18 @@
import React, { useRef } from 'react';
import { Box, Flex, useOutsideClick } from '@chakra-ui/react';
import React from 'react';
import { Box, Flex } from '@chakra-ui/react';
import { ModuleTemplates } from '@/constants/flow/ModuleTemplate';
import type { FlowModuleItemType } from '@/types/app';
import { FlowModuleTemplateType } from '@/types/flow';
import type { XYPosition } from 'reactflow';
import { useGlobalStore } from '@/store/global';
import Avatar from '@/components/Avatar';
const ModuleStoreList = ({
const ModuleTemplateList = ({
isOpen,
onAddNode,
onClose
}: {
isOpen: boolean;
onAddNode: (e: { template: FlowModuleItemType; position: XYPosition }) => void;
onAddNode: (e: { template: FlowModuleTemplateType; position: XYPosition }) => void;
onClose: () => void;
}) => {
const { isPc } = useGlobalStore();
@@ -92,4 +92,4 @@ const ModuleStoreList = ({
);
};
export default ModuleStoreList;
export default ModuleTemplateList;

View File

@@ -154,7 +154,7 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
[setEdges, setNodes]
);
const onAddNode = useCallback(
({ template, position }: { template: FlowModuleItemType; position: XYPosition }) => {
({ template, position }: { template: FlowModuleTemplateType; position: XYPosition }) => {
if (!reactFlowWrapper.current) return;
const reactFlowBounds = reactFlowWrapper.current.getBoundingClientRect();
const mouseX = (position.x - reactFlowBounds.left - x) / zoom - 100;

View File

@@ -115,7 +115,6 @@ const Share = ({ appId }: { appId: string }) => {
<Thead>
<Tr>
<Th></Th>
<Th></Th>
<Th></Th>
<Th>使</Th>
<Th></Th>
@@ -125,7 +124,6 @@ const Share = ({ appId }: { appId: string }) => {
{shareChatList.map((item) => (
<Tr key={item._id}>
<Td>{item.name}</Td>
<Td>{item.maxContext}</Td>
<Td>{formatPrice(item.total)}</Td>
<Td>{item.lastTime ? formatTimeToChatTime(item.lastTime) : '未使用'}</Td>
<Td>
@@ -197,42 +195,6 @@ const Share = ({ appId }: { appId: string }) => {
/>
</Flex>
</FormControl>
<FormControl mt={9}>
<Flex alignItems={'center'}>
<Box flex={'0 0 120px'} w={0}>
</Box>
<Slider
aria-label="slider-ex-1"
min={1}
max={20}
step={1}
value={getShareChatValues('maxContext')}
onChange={(e) => {
setShareChatValues('maxContext', e);
setRefresh(!refresh);
}}
>
<SliderMark
value={getShareChatValues('maxContext')}
textAlign="center"
bg="myBlue.600"
color="white"
w={'18px'}
h={'18px'}
borderRadius={'100px'}
fontSize={'xs'}
transform={'translate(-50%, -200%)'}
>
{getShareChatValues('maxContext')}
</SliderMark>
<SliderTrack>
<SliderFilledTrack bg={'myBlue.700'} />
</SliderTrack>
<SliderThumb />
</Slider>
</Flex>
</FormControl>
</ModalBody>
<ModalFooter>

View File

@@ -110,10 +110,10 @@ const ChatHistorySlider = ({
{/* chat history */}
<Box flex={'1 0 0'} h={0} px={[2, 5]} overflow={'overlay'}>
{concatHistory.map((item) => (
{concatHistory.map((item, i) => (
<Flex
position={'relative'}
key={item.id}
key={item.id || `${i}`}
alignItems={'center'}
py={3}
px={4}

View File

@@ -249,7 +249,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
appName={chatData.app.name}
appAvatar={chatData.app.avatar}
activeChatId={chatId}
history={history.map((item) => ({
history={history.map((item, i) => ({
id: item.chatId,
title: item.title,
customTitle: item.customTitle,