41 lines
794 B
TypeScript
41 lines
794 B
TypeScript
import { RecordModel } from "pocketbase"
|
|
|
|
import { managePb404 } from "../../utils/pbTools"
|
|
import pbClient from "../pbClient"
|
|
|
|
interface AppConfigRecordModel extends RecordModel {
|
|
value: string
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
* @param key
|
|
* @returns
|
|
*/
|
|
const get = async (key: string) => {
|
|
const config = await managePb404<AppConfigRecordModel>(() =>
|
|
pbClient.collection("config").getFirstListItem(`key='${key}'`)
|
|
)
|
|
if (!config) return ""
|
|
return config.value
|
|
}
|
|
|
|
/**
|
|
* 获取Deepseek的apiKey
|
|
* @returns {string} ak
|
|
*/
|
|
const getDeepseekApiKey = async () => get("deepseek_api_key")
|
|
|
|
/**
|
|
* 获取OpenAI的key
|
|
* @returns {string} ak
|
|
*/
|
|
const getOpenAIApiKey = async () => get("openai_api_key")
|
|
|
|
const appConfig = {
|
|
getOpenAIApiKey,
|
|
getDeepseekApiKey,
|
|
}
|
|
|
|
export default appConfig
|