mirror of
https://github.com/JOYCEQL/magic-resume.git
synced 2026-07-03 14:07:11 +02:00
feat: config about AI
This commit is contained in:
@@ -108,6 +108,56 @@ const SettingsPage = () => {
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* <div className="bg-white dark:bg-gray-800 rounded-lg p-6 shadow-sm mt-8">
|
||||
<h2 className="text-xl font-semibold mb-4">OpenAI API Key</h2>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label
|
||||
htmlFor="apiKey"
|
||||
className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"
|
||||
>
|
||||
API Key
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
type="textarea"
|
||||
id="apiKey"
|
||||
className="w-full h-[60px] px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900
|
||||
focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent"
|
||||
placeholder="sk-xxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
/>
|
||||
</div>
|
||||
<p className="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||
您的API Key将被安全加密存储。获取API Key请访问:
|
||||
<a
|
||||
href="https://platform.openai.com/api-keys"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-blue-600 dark:text-blue-400 hover:underline"
|
||||
>
|
||||
OpenAI API Keys
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center space-x-4">
|
||||
<button
|
||||
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700
|
||||
transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
|
||||
>
|
||||
保存
|
||||
</button>
|
||||
<button
|
||||
className="px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300
|
||||
dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700
|
||||
transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2"
|
||||
>
|
||||
验证
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ArrowRight, ChevronRight } from "lucide-react";
|
||||
import ScrollToTop from "../components/shared/ScrollToTop";
|
||||
import EditButton from "@/components/shared/EditButton";
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
import CreateResume from "@/components/home/CreateResume";
|
||||
const AnimatedHero = dynamic(() => import("@/components/home/AnimatedHero"), {
|
||||
ssr: false,
|
||||
loading: () => (
|
||||
@@ -70,8 +70,7 @@ export default function LandingPage() {
|
||||
告别繁琐的简历制作流程,让AI助手帮你完成专业简历
|
||||
</p>
|
||||
|
||||
{/* AI输入区域 */}
|
||||
<div className="max-w-3xl mx-auto relative group">
|
||||
{/* <div className="max-w-3xl mx-auto relative group">
|
||||
<div className="absolute -inset-1 bg-gradient-to-r from-blue-600 to-violet-600 rounded-lg blur opacity-25 group-hover:opacity-40 transition duration-1000 group-hover:duration-200" />
|
||||
<div className="relative flex items-center bg-white dark:bg-gray-900 rounded-lg shadow-xl ring-1 ring-gray-900/5 dark:ring-white/10">
|
||||
<input
|
||||
@@ -79,11 +78,9 @@ export default function LandingPage() {
|
||||
placeholder="例如:'我是一名3年经验的前端开发工程师,擅长React和TypeScript...'"
|
||||
className="flex-1 px-6 py-4 bg-transparent border-none focus:outline-none text-gray-700 dark:text-gray-300 placeholder-gray-400 dark:placeholder-gray-600"
|
||||
/>
|
||||
<button className="px-6 py-4 bg-gradient-to-r from-blue-600 to-violet-600 text-white rounded-r-lg hover:opacity-90 transition-opacity font-medium">
|
||||
生成简历
|
||||
</button>
|
||||
<CreateResume></CreateResume>
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
|
||||
<div className="relative mt-20">
|
||||
@@ -127,7 +124,6 @@ export default function LandingPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="py-12 border-t dark:border-white/5 border-gray-200 relative">
|
||||
<div className="absolute inset-0 bg-gradient-to-b from-transparent to-gray-50/50 dark:to-gray-900/50" />
|
||||
<div className="max-w-7xl mx-auto px-6 relative">
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
"use client";
|
||||
import { openAIRequest } from "@/utils";
|
||||
|
||||
const CreateResume = () => {
|
||||
const createResumeByAI = () => {
|
||||
openAIRequest("你是谁");
|
||||
};
|
||||
return (
|
||||
<button
|
||||
onClick={createResumeByAI}
|
||||
className="px-6 py-4 bg-gradient-to-r from-blue-600 to-violet-600 text-white rounded-r-lg hover:opacity-90 transition-opacity font-medium"
|
||||
>
|
||||
生成简历
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
export default CreateResume;
|
||||
@@ -31,3 +31,27 @@ export async function convertImagesToBase64(
|
||||
|
||||
return clone.innerHTML;
|
||||
}
|
||||
|
||||
const baseUrl = "";
|
||||
const apiKey = "";
|
||||
|
||||
export const openAIRequest = async (prompt: string) => {
|
||||
const response = await fetch(`${baseUrl}/chat/completions`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: "gpt-3.5-turbo",
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`OpenAI API request failed: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.choices[0].message.content.trim();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user