feat: [#5714] 支持GLM

This commit is contained in:
DDMeaqua
2024-10-30 19:24:03 +08:00
parent 4745706c42
commit d357b45e84
11 changed files with 453 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ import {
STABILITY_BASE_URL,
IFLYTEK_BASE_URL,
XAI_BASE_URL,
GLM_BASE_URL,
} from "../constant";
import { getHeaders } from "../client/api";
import { getClientConfig } from "../config/client";
@@ -47,6 +48,8 @@ const DEFAULT_IFLYTEK_URL = isApp ? IFLYTEK_BASE_URL : ApiPath.Iflytek;
const DEFAULT_XAI_URL = isApp ? XAI_BASE_URL : ApiPath.XAI;
const DEFAULT_GLM_URL = isApp ? GLM_BASE_URL : ApiPath.GLM;
const DEFAULT_ACCESS_STATE = {
accessCode: "",
useCustomConfig: false,
@@ -108,6 +111,10 @@ const DEFAULT_ACCESS_STATE = {
xaiUrl: DEFAULT_XAI_URL,
xaiApiKey: "",
// glm
glmUrl: DEFAULT_GLM_URL,
glmApiKey: "",
// server config
needCode: true,
hideUserApiKey: false,
@@ -180,6 +187,10 @@ export const useAccessStore = createPersistStore(
return ensure(get(), ["xaiApiKey"]);
},
isValidGLM() {
return ensure(get(), ["glmApiKey"]);
},
isAuthorized() {
this.fetch();
@@ -196,6 +207,7 @@ export const useAccessStore = createPersistStore(
this.isValidMoonshot() ||
this.isValidIflytek() ||
this.isValidXAI() ||
this.isValidGLM() ||
!this.enabledAccessControl() ||
(this.enabledAccessControl() && ensure(get(), ["accessCode"]))
);