40 lines
758 B
TypeScript
40 lines
758 B
TypeScript
import pbClient from "../pbClient";
|
|
import { managePb404 } from "../../utils/pbTools";
|
|
import { DB } from "../../types";
|
|
|
|
/**
|
|
* 获取配置
|
|
* @param appName
|
|
* @returns
|
|
*/
|
|
const get = async (appName: string) =>
|
|
managePb404<DB.AppInfo>(() =>
|
|
pbClient.collection("app_info").getFirstListItem(`code_name='${appName}'`)
|
|
);
|
|
|
|
/**
|
|
* 获取所有配置
|
|
* @returns
|
|
*/
|
|
const getFullList = () => pbClient.collection("app_info").getFullList();
|
|
|
|
/**
|
|
* 获取配置的某个值
|
|
* @param appName
|
|
* @param key
|
|
* @returns
|
|
*/
|
|
const getVal = async (appName: string, key: string) => {
|
|
const config = await get(appName);
|
|
if (!config) return "";
|
|
return config[key] || "";
|
|
};
|
|
|
|
const appInfo = {
|
|
get,
|
|
getVal,
|
|
getFullList,
|
|
};
|
|
|
|
export default appInfo;
|