From 88f8ca822f4cd38b1cb6536ce82c8abf5ba05ef8 Mon Sep 17 00:00:00 2001 From: JiangYingjin Date: Sun, 2 Mar 2025 14:04:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20webdav=20=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E5=A1=AB=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/chat.tsx | 59 +++++++++++++++++++++-------------------- nextchat.json | 16 +++++++++++ 2 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 nextchat.json diff --git a/app/components/chat.tsx b/app/components/chat.tsx index ff38b2629..d0dec7be5 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -107,6 +107,7 @@ import { } from "../constant"; import { Avatar } from "./emoji"; import { ContextPrompts, MaskAvatar, MaskConfig } from "./mask"; +import { useSyncStore } from "../store/sync"; import { useMaskStore } from "../store/mask"; import { ChatCommandPrefix, useChatCommand, useCommand } from "../command"; import { prettyObject } from "../utils/format"; @@ -948,6 +949,8 @@ function _Chat() { const fontSize = config.fontSize; const fontFamily = config.fontFamily; + const syncStore = useSyncStore(); + const [showExport, setShowExport] = useState(false); const inputRef = useRef(null); @@ -1395,45 +1398,27 @@ function _Chat() { submit: (text) => { doSubmit(text); }, - code: (text) => { - if (accessStore.disableFastLink) return; - console.log("[Command] got code from url: ", text); - showConfirm(Locale.URLCommand.Code + `code = ${text}`).then((res) => { - if (res) { - accessStore.update((access) => (access.accessCode = text)); - } - }); - }, + // code: (text) => { + // if (accessStore.disableFastLink) return; + // console.log("[Command] got code from url: ", text); + // showConfirm(Locale.URLCommand.Code + `code = ${text}`).then((res) => { + // if (res) { + // accessStore.update((access) => (access.accessCode = text)); + // } + // }); + // }, settings: (text) => { if (accessStore.disableFastLink) return; try { const payload = JSON.parse(text) as { - key?: string; - url?: string; code?: string; + username?: string; + password?: string; }; console.log("[Command] got settings from url: ", payload); - if (payload.key || payload.url) { - showConfirm( - Locale.URLCommand.Settings + - `\n${JSON.stringify(payload, null, 4)}`, - ).then((res) => { - if (!res) return; - if (payload.key) { - accessStore.update( - (access) => (access.openaiApiKey = payload.key!), - ); - } - if (payload.url) { - accessStore.update((access) => (access.openaiUrl = payload.url!)); - } - accessStore.update((access) => (access.useCustomConfig = true)); - }); - } - if (payload.code) { accessStore.update((access) => (access.accessCode = payload.code!)); if (accessStore.isAuthorized()) { @@ -1443,6 +1428,22 @@ function _Chat() { setUserInput(" "); } } + + if (payload.username) { + syncStore.update( + (config) => (config.webdav.username = payload.username!), + ); + } + + if (payload.password) { + syncStore.update( + (config) => (config.webdav.password = payload.password!), + ); + } + + if (payload.username && payload.password) { + syncStore.sync(); + } } catch { console.error("[Command] failed to get settings from url: ", text); } diff --git a/nextchat.json b/nextchat.json new file mode 100644 index 000000000..757755480 --- /dev/null +++ b/nextchat.json @@ -0,0 +1,16 @@ +{ + "name": "nextchat", + "cwd": "/www/nextchat", + "script": "server.js", + "env": { + "PORT": 8032, + "CODE": "scut", + "BASE_URL": "https://oneapi.jyj.cx", + "OPENAI_API_KEY": "sk-jiangyj", + "HIDE_USER_API_KEY": true, + "CUSTOM_MODELS": "-all,gemini-2.0-pro-exp-02-05@openai,gemini-2.0-flash-thinking-exp-01-21@openai,gemini-2.0-flash-exp@openai,gemini-2.0-flash@openai,gemini-2.0-flash-lite@openai,gpt-4o-2024-11-20@openai,o3-mini@openai,deepseek-ai/deepseek-v3@openai,deepseek-ai/deepseek-r1@openai,deepseek-chat@openai,deepseek-reasoner@openai,ep-20250124104315-zsg4p@openai", + "DEFAULT_MODEL": "gemini-2.0-pro-exp-02-05@openai", + "WHITE_WEBDAV_ENDPOINTS": "https://dav.jyj.cx", + "VISION_MODELS": "gemini-2.0-flash-thinking-exp-01-21@openai,gemini-2.0-pro-exp-02-05@openai,gemini-2.0-flash-exp@openai,gemini-2.0-flash@openai,gemini-2.0-flash-lite@openai,gpt-4o-2024-11-20@openai,o3-mini@openai,deepseek-ai/DeepSeek-V3@openai,deepseek-ai/DeepSeek-R1@openai,deepseek-chat@openai,deepseek-reasoner@openai,ep-20250124104315-zsg4p@openai" + } +}