mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-10 10:12:31 +08:00
feat: add URL content extraction for AI diagram generation
This commit is contained in:
@@ -51,7 +51,8 @@
|
||||
"badResponse": "Bad response",
|
||||
"clickToEdit": "Click to edit",
|
||||
"editMessage": "Edit message",
|
||||
"saveAndSubmit": "Save & Submit"
|
||||
"saveAndSubmit": "Save & Submit",
|
||||
"ExtractURL": "Extract from URL"
|
||||
},
|
||||
"examples": {
|
||||
"title": "Create diagrams with AI",
|
||||
@@ -186,6 +187,13 @@
|
||||
"chars": "chars",
|
||||
"removeFile": "Remove file"
|
||||
},
|
||||
"pdf": {
|
||||
"title": "Extract Content from URL",
|
||||
"description": "Paste a URL to extract and analyze its content",
|
||||
"Extracting": "Extracting...",
|
||||
"extract": "Extract",
|
||||
"Cancel": "Cancel"
|
||||
},
|
||||
"reasoning": {
|
||||
"thinking": "Thinking...",
|
||||
"thoughtFor": "Thought for {duration} seconds",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"badResponse": "悪い応答",
|
||||
"clickToEdit": "クリックして編集",
|
||||
"editMessage": "メッセージを編集",
|
||||
"saveAndSubmit": "保存して送信"
|
||||
"saveAndSubmit": "保存して送信",
|
||||
"ExtractURL": "URLから抽出"
|
||||
},
|
||||
"examples": {
|
||||
"title": "AI でダイアグラムを作成",
|
||||
@@ -186,6 +187,13 @@
|
||||
"chars": "文字",
|
||||
"removeFile": "ファイルを削除"
|
||||
},
|
||||
"pdf": {
|
||||
"title": "URLからコンテンツを抽出",
|
||||
"description": "URLを貼り付けてそのコンテンツを抽出および分析します",
|
||||
"Extracting": "抽出中...",
|
||||
"extract": "抽出",
|
||||
"Cancel": "キャンセル"
|
||||
},
|
||||
"reasoning": {
|
||||
"thinking": "考え中...",
|
||||
"thoughtFor": "{duration} 秒考えました",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"badResponse": "无帮助",
|
||||
"clickToEdit": "点击编辑",
|
||||
"editMessage": "编辑消息",
|
||||
"saveAndSubmit": "保存并提交"
|
||||
"saveAndSubmit": "保存并提交",
|
||||
"ExtractURL": "从 URL 提取"
|
||||
},
|
||||
"examples": {
|
||||
"title": "用 AI 创建图表",
|
||||
@@ -186,6 +187,13 @@
|
||||
"chars": "字符",
|
||||
"removeFile": "移除文件"
|
||||
},
|
||||
"pdf": {
|
||||
"title": "从 URL 提取内容",
|
||||
"description": "粘贴 URL 以提取和分析其内容",
|
||||
"Extracting": "提取中...",
|
||||
"extract": "提取",
|
||||
"Cancel": "取消"
|
||||
},
|
||||
"reasoning": {
|
||||
"thinking": "思考中...",
|
||||
"thoughtFor": "思考了 {duration} 秒",
|
||||
|
||||
29
lib/url-utils.ts
Normal file
29
lib/url-utils.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export interface UrlData {
|
||||
url: string
|
||||
title: string
|
||||
content: string
|
||||
charCount: number
|
||||
isExtracting: boolean
|
||||
}
|
||||
|
||||
export async function extractUrlContent(url: string): Promise<UrlData> {
|
||||
const response = await fetch("/api/parse-url", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ url }),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => null)
|
||||
throw new Error(error?.error || "Failed to extract URL content")
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
return {
|
||||
url,
|
||||
title: data.title,
|
||||
content: data.content,
|
||||
charCount: data.charCount,
|
||||
isExtracting: false,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user