perf: 文件拆分

This commit is contained in:
archer
2023-04-03 21:04:38 +08:00
parent becee69d6a
commit 85e11abc0a
3 changed files with 14 additions and 13 deletions

View File

@@ -85,7 +85,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
4. 添加数据库数据,表为"users" ,内容为{phone, code, createTime} 4. 添加数据库数据,表为"users" ,内容为{phone, code, createTime}
5. 删除数据库数据,删除 code 记录 5. 删除数据库数据,删除 code 记录
--------------- ---------------
更新客记录。传入blogIdblogTexttags还需要记录更新的时间 更新客记录。传入blogIdblogTexttags还需要记录更新的时间
1. 从 body 中获取 blogIdblogText 和 tags 1. 从 body 中获取 blogIdblogText 和 tags
2. 校验 blogId 是否为空,为空则返回 {error: "博客ID不能为空"} 2. 校验 blogId 是否为空,为空则返回 {error: "博客ID不能为空"}
3. 校验 blogText 是否为空,为空则返回 {error: "博客内容不能为空"} 3. 校验 blogText 是否为空,为空则返回 {error: "博客内容不能为空"}

View File

@@ -9,7 +9,8 @@ import {
ModalHeader, ModalHeader,
ModalCloseButton, ModalCloseButton,
ModalBody, ModalBody,
Input Input,
Textarea
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import { useToast } from '@/hooks/useToast'; import { useToast } from '@/hooks/useToast';
import { useSelectFile } from '@/hooks/useSelectFile'; import { useSelectFile } from '@/hooks/useSelectFile';
@@ -66,8 +67,8 @@ const SelectFileModal = ({
}) })
) )
) )
.join('\n') .join(' ')
.replace(/\n+/g, '\n'); .replace(/(\\n|\n)+/g, '\n');
setFileText(fileTexts); setFileText(fileTexts);
console.log(encode(fileTexts)); console.log(encode(fileTexts));
} catch (error: any) { } catch (error: any) {
@@ -142,18 +143,18 @@ const SelectFileModal = ({
size={'sm'} size={'sm'}
/> />
</Flex> </Flex>
<Box <Textarea
flex={'1 0 0'} flex={'1 0 0'}
h={0} h={0}
w={'100%'} w={'100%'}
overflowY={'auto'} placeholder="文件内容"
p={2} maxLength={-1}
backgroundColor={'blackAlpha.50'} resize={'none'}
whiteSpace={'pre-wrap'}
fontSize={'xs'} fontSize={'xs'}
> whiteSpace={'pre-wrap'}
{fileText} value={fileText}
</Box> onChange={(e) => setFileText(e.target.value)}
/>
</ModalBody> </ModalBody>
<Flex px={6} pt={2} pb={4}> <Flex px={6} pt={2} pb={4}>

View File

@@ -76,7 +76,7 @@ export const readPdfContent = (file: File) =>
const page = await doc.getPage(pageNo); const page = await doc.getPage(pageNo);
const tokenizedText = await page.getTextContent(); const tokenizedText = await page.getTextContent();
const pageText = tokenizedText.items.map((token: any) => token.str).join(''); const pageText = tokenizedText.items.map((token: any) => token.str).join('');
return pageText.replaceAll(/\s+/g, '\n'); return pageText;
}; };
let reader = new FileReader(); let reader = new FileReader();