"use client"; // Settings.tsx import { useAppDispatch, useAppSelector } from "@/app/store"; import { setApiKey, setUpsreamUrl, setSystemPrompt, } from "@/app/store/slices/authSlice"; import { setIsJumpToReference } from "@/app/store/slices/stateSlice"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faArrowLeft } from "@fortawesome/free-solid-svg-icons"; import Link from "next/link"; import { useLocalStorage } from "react-use"; import { useTranslation } from "@/app/i18n/client"; const Settings = ({ lng }: { lng: string }) => { //i18n const { t } = useTranslation(lng); const CONFIG_OPTIONS = [ { name: t("configurations.cocopilot-gpt4"), apiKey: "_pXVxLPBzcvCjSvG0Mv4K7G9ffw3xsM2ZKolZ", upstreamUrl: "https://proxy.cocopilot.org", }, { name: t("configurations.deepseek-chat"), apiKey: "sk-ffe19ebe9fa44d00884330ff1c18cf82", upstreamUrl: "https://api.deepseek.com", }, { name: t("configurations.caifree"), apiKey: "sk-aiHrrRLYUUelHstX69E9484509254dBf92061d6744FfFaD1", upstreamUrl: "https://one.caifree.com", }, { name: t("configurations.custom"), apiKey: "", upstreamUrl: "", }, ]; //https://freeapi.iil.im sk-GdUOBeCCCpeB16G877C8C62b849c4653A561550bEb79Fe7e //redux const dispatch = useAppDispatch(); const apiKey = useAppSelector((state) => state.auth.apiKey); const upstreamUrl = useAppSelector((state) => state.auth.upsreamUrl); const systemPrompt = useAppSelector((state) => state.auth.systemPrompt); const isJumpToReference = useAppSelector( (state) => state.state.isJumpToReference ); //state const [userConfigNumber, setUserConfigNumber] = useLocalStorage( "userConfigNumber", "2" ); const toggleSwitch = () => { dispatch(setIsJumpToReference(!isJumpToReference)); }; return (

settings


{/* 配置选择器 */} {/* api key */}
dispatch(setApiKey(event.target.value))} className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" /> {/* upstream-url */}
dispatch(setUpsreamUrl(event.target.value))} className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" />
{/* systemPrompt */}