新增 webdav 一键填入

This commit is contained in:
JiangYingjin 2025-03-02 14:04:57 +08:00
parent 1cccaa2e80
commit 88f8ca822f
2 changed files with 46 additions and 29 deletions

View File

@ -107,6 +107,7 @@ import {
} from "../constant"; } from "../constant";
import { Avatar } from "./emoji"; import { Avatar } from "./emoji";
import { ContextPrompts, MaskAvatar, MaskConfig } from "./mask"; import { ContextPrompts, MaskAvatar, MaskConfig } from "./mask";
import { useSyncStore } from "../store/sync";
import { useMaskStore } from "../store/mask"; import { useMaskStore } from "../store/mask";
import { ChatCommandPrefix, useChatCommand, useCommand } from "../command"; import { ChatCommandPrefix, useChatCommand, useCommand } from "../command";
import { prettyObject } from "../utils/format"; import { prettyObject } from "../utils/format";
@ -948,6 +949,8 @@ function _Chat() {
const fontSize = config.fontSize; const fontSize = config.fontSize;
const fontFamily = config.fontFamily; const fontFamily = config.fontFamily;
const syncStore = useSyncStore();
const [showExport, setShowExport] = useState(false); const [showExport, setShowExport] = useState(false);
const inputRef = useRef<HTMLTextAreaElement>(null); const inputRef = useRef<HTMLTextAreaElement>(null);
@ -1395,45 +1398,27 @@ function _Chat() {
submit: (text) => { submit: (text) => {
doSubmit(text); doSubmit(text);
}, },
code: (text) => { // code: (text) => {
if (accessStore.disableFastLink) return; // if (accessStore.disableFastLink) return;
console.log("[Command] got code from url: ", text); // console.log("[Command] got code from url: ", text);
showConfirm(Locale.URLCommand.Code + `code = ${text}`).then((res) => { // showConfirm(Locale.URLCommand.Code + `code = ${text}`).then((res) => {
if (res) { // if (res) {
accessStore.update((access) => (access.accessCode = text)); // accessStore.update((access) => (access.accessCode = text));
} // }
}); // });
}, // },
settings: (text) => { settings: (text) => {
if (accessStore.disableFastLink) return; if (accessStore.disableFastLink) return;
try { try {
const payload = JSON.parse(text) as { const payload = JSON.parse(text) as {
key?: string;
url?: string;
code?: string; code?: string;
username?: string;
password?: string;
}; };
console.log("[Command] got settings from url: ", payload); 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) { if (payload.code) {
accessStore.update((access) => (access.accessCode = payload.code!)); accessStore.update((access) => (access.accessCode = payload.code!));
if (accessStore.isAuthorized()) { if (accessStore.isAuthorized()) {
@ -1443,6 +1428,22 @@ function _Chat() {
setUserInput(" "); 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 { } catch {
console.error("[Command] failed to get settings from url: ", text); console.error("[Command] failed to get settings from url: ", text);
} }

16
nextchat.json Normal file
View File

@ -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"
}
}