Merge branch 'main' into main

This commit is contained in:
glay
2025-02-06 12:25:47 +08:00
committed by GitHub
17 changed files with 568 additions and 21 deletions

View File

@@ -17,6 +17,7 @@ import {
XAI_BASE_URL,
CHATGLM_BASE_URL,
BEDROCK_BASE_URL,
SILICONFLOW_BASE_URL,
} from "../constant";
import { getHeaders } from "../client/api";
import { getClientConfig } from "../config/client";
@@ -45,6 +46,10 @@ const DEFAULT_XAI_URL = isApp ? XAI_BASE_URL : ApiPath.XAI;
const DEFAULT_CHATGLM_URL = isApp ? CHATGLM_BASE_URL : ApiPath.ChatGLM;
const DEFAULT_BEDROCK_URL = isApp ? BEDROCK_BASE_URL : ApiPath.Bedrock;
const DEFAULT_SILICONFLOW_URL = isApp
? SILICONFLOW_BASE_URL
: ApiPath.SiliconFlow;
const DEFAULT_ACCESS_STATE = {
accessCode: "",
useCustomConfig: false,
@@ -122,6 +127,11 @@ const DEFAULT_ACCESS_STATE = {
encryptionKey: "",
bedrockAnthropicVersion: "bedrock-2023-05-31",
// siliconflow
siliconflowUrl: DEFAULT_SILICONFLOW_URL,
siliconflowApiKey: "",
// server config
needCode: true,
hideUserApiKey: false,
@@ -203,6 +213,7 @@ export const useAccessStore = createPersistStore(
return ensure(get(), ["chatglmApiKey"]);
},
isValidBedrock() {
return ensure(get(), [
"awsRegion",
@@ -212,6 +223,11 @@ export const useAccessStore = createPersistStore(
]);
},
isValidSiliconFlow() {
return ensure(get(), ["siliconflowApiKey"]);
},
isAuthorized() {
this.fetch();
@@ -231,6 +247,7 @@ export const useAccessStore = createPersistStore(
this.isValidXAI() ||
this.isValidChatGLM() ||
this.isValidBedrock() ||
this.isValidSiliconFlow() ||
!this.enabledAccessControl() ||
(this.enabledAccessControl() && ensure(get(), ["accessCode"]))
);