init
This commit is contained in:
parent
e4935e4f22
commit
bba716d6b8
|
@ -1,9 +0,0 @@
|
|||
# Update these with your Supabase details from your project settings > API
|
||||
# https://app.supabase.com/project/_/settings/api
|
||||
NEXT_PUBLIC_SUPABASE_URL=https://yidfukfbrluizjvfrrsj.supabase.co
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InlpZGZ1a2Zicmx1aXpqdmZycnNqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDQ4NjMyNjEsImV4cCI6MjAyMDQzOTI2MX0.EXIXAdNIGLFo5wHmwmY2-9bqLO9vyFYDvMMtCtkxgig
|
||||
NEXT_PUBLIC_TINYMCE_API_KEY=e983nu390inks6be1wwlsrdxjebot3yc4pld7d44zs6vcrxr
|
||||
NEXT_PUBLIC_OPENAI_API_KEY=sess-1CQMw0TDL0VZd9C1W3aGAZ6scffG32JJPcap7Re4
|
||||
NEXT_PUBLIC_SEMANTIC_API_KEY=hEQvK6ARe84dzDPcMnpzX4n9jfoqztkMfaftPWnb
|
||||
NEXT_PUBLIC_AI_URL=https://chatgpt-api-proxy-private.14790897abc.workers.dev/v1/chat/completions
|
||||
#"https://api.openai.com/v1/chat/completions"
|
|
@ -148,7 +148,7 @@ const QEditor = () => {
|
|||
const newReferences = rawData.map((entry) => ({
|
||||
url: entry.url,
|
||||
title: entry.title,
|
||||
year: entry.published,
|
||||
year: entry.year,
|
||||
author: entry.authors?.slice(0, 3).join(", "),
|
||||
venue: entry.venue,
|
||||
journal: entry.journal,
|
||||
|
@ -174,15 +174,15 @@ const QEditor = () => {
|
|||
}
|
||||
|
||||
// 插入论文信息
|
||||
const insertPapers = async (topic: string) => {
|
||||
const rawData = await getArxivPapers(topic);
|
||||
const dataString = rawData
|
||||
.map((entry) => {
|
||||
return `ID: ${entry.id}\nPublished: ${entry.published}\nTitle: ${entry.title}\nSummary: ${entry.summary}\n\n`;
|
||||
})
|
||||
.join("");
|
||||
quill.insertText(quill.getLength(), dataString);
|
||||
};
|
||||
// const insertPapers = async (topic: string) => {
|
||||
// const rawData = await getArxivPapers(topic);
|
||||
// const dataString = rawData
|
||||
// .map((entry) => {
|
||||
// return `ID: ${entry.id}\nPublished: ${entry.published}\nTitle: ${entry.title}\nSummary: ${entry.summary}\n\n`;
|
||||
// })
|
||||
// .join("");
|
||||
// quill.insertText(quill.getLength(), dataString);
|
||||
// };
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -199,12 +199,12 @@ const QEditor = () => {
|
|||
>
|
||||
Insert AI Text
|
||||
</button>*/}
|
||||
<button
|
||||
{/* <button
|
||||
onClick={() => insertPapers(userInput)}
|
||||
className="bg-indigo-500 hover:bg-indigo-700 text-black font-bold py-2 px-4 rounded"
|
||||
>
|
||||
Insert Papers
|
||||
</button>
|
||||
</button> */}
|
||||
<button
|
||||
onClick={() => paper2AI(userInput)}
|
||||
className="bg-red-500 hover:bg-red-700 text-black font-bold py-2 px-4 rounded"
|
||||
|
@ -214,6 +214,7 @@ const QEditor = () => {
|
|||
<select
|
||||
value={selectedSource}
|
||||
onChange={(e) => setSelectedSource(e.target.value)}
|
||||
className=" border border-gray-300 bg-white py-2 px-3 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
|
||||
>
|
||||
<option value="arxiv">arxiv</option>
|
||||
<option value="semanticScholar">semantic scholar</option>
|
||||
|
@ -236,6 +237,7 @@ const QEditor = () => {
|
|||
references={references}
|
||||
addReference={addReference}
|
||||
removeReference={removeReference}
|
||||
setReferences={setReferences}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,17 +4,20 @@ import { Reference } from "@/utils/global";
|
|||
import {
|
||||
copyToClipboard,
|
||||
formatReferenceForCopy,
|
||||
formatAllReferencesForCopy,
|
||||
} from "@/utils/others/quillutils";
|
||||
type ReferenceListProps = {
|
||||
references: Reference[];
|
||||
addReference: (reference: Reference) => void;
|
||||
removeReference: (index: number) => void;
|
||||
setReferences
|
||||
};
|
||||
|
||||
function ReferenceList({
|
||||
references,
|
||||
addReference,
|
||||
removeReference,
|
||||
setReferences
|
||||
}: ReferenceListProps) {
|
||||
const [newTitle, setNewTitle] = useState("");
|
||||
const [newAuthor, setNewAuthor] = useState("");
|
||||
|
@ -80,14 +83,32 @@ function ReferenceList({
|
|||
placeholder="URL"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded mt-4"
|
||||
type="submit"
|
||||
>
|
||||
Add Reference
|
||||
</button>
|
||||
</form>
|
||||
<div className="container mx-auto p-4">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
<button
|
||||
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded mt-4"
|
||||
type="submit"
|
||||
>
|
||||
Add Reference
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded mb-4"
|
||||
onClick={() =>
|
||||
copyToClipboard(formatAllReferencesForCopy(references))
|
||||
}
|
||||
>
|
||||
复制所有引用
|
||||
</button>
|
||||
<button
|
||||
className="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded ml-2"
|
||||
onClick={() => setReferences([])} // 设置引用列表为空数组
|
||||
>
|
||||
删除所有引用
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{/* 引用列表显示区域 */}
|
||||
<ul>
|
||||
{references.map((reference, index) => (
|
||||
|
@ -98,7 +119,7 @@ function ReferenceList({
|
|||
{/* 判断 journal 字段是否存在 */}
|
||||
{reference.journal && reference.journal.name ? (
|
||||
<span>
|
||||
{reference.journal.name},{reference.year},
|
||||
{reference.journal.name}[J],{reference.year},
|
||||
{reference.journal.volume ? ` ${reference.journal.volume}` : ""}
|
||||
{reference.journal.pages ? `: ${reference.journal.pages}` : ""}.
|
||||
</span>
|
||||
|
|
|
@ -57,28 +57,36 @@ function getRandomOffset(max: number) {
|
|||
function removeSpecialCharacters(str: string): string {
|
||||
// 正则表达式匹配除了字母、空格和中文之外的所有字符
|
||||
const regex = /[^\u4e00-\u9fa5a-zA-Z ]/g;
|
||||
return str.replace(regex, '');
|
||||
return str.replace(regex, "");
|
||||
}
|
||||
|
||||
function copyToClipboard(text: string) {
|
||||
navigator.clipboard.writeText(text).then(
|
||||
() => console.log('文献引用复制到剪贴板'),
|
||||
(err) => console.error('复制到剪贴板失败:', err)
|
||||
() => console.log("文献引用复制到剪贴板"),
|
||||
(err) => console.error("复制到剪贴板失败:", err)
|
||||
);
|
||||
}
|
||||
|
||||
function formatReferenceForCopy(reference: Reference): string {
|
||||
let referenceStr = `${reference.author}. ${reference.title}. `;
|
||||
if (reference.journal && reference.journal.name) {
|
||||
referenceStr += `${reference.journal.name}, ${reference.year}, `;
|
||||
referenceStr += `${reference.journal.name}[J], ${reference.year}, `;
|
||||
if (reference.journal.volume) referenceStr += `${reference.journal.volume}`;
|
||||
if (reference.journal.pages) referenceStr += `: ${reference.journal.pages}`;
|
||||
referenceStr += '.';
|
||||
referenceStr += ".";
|
||||
} else {
|
||||
referenceStr += `${reference.venue}, ${reference.year}.`;
|
||||
}
|
||||
return referenceStr;
|
||||
}
|
||||
function formatAllReferencesForCopy(references: Reference[]): string {
|
||||
return references
|
||||
.map(
|
||||
(reference, index) =>
|
||||
`[${index + 1}] ${formatReferenceForCopy(reference)}`
|
||||
)
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
export {
|
||||
getTextBeforeCursor,
|
||||
|
@ -89,4 +97,5 @@ export {
|
|||
removeSpecialCharacters,
|
||||
copyToClipboard,
|
||||
formatReferenceForCopy,
|
||||
formatAllReferencesForCopy,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user