You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/shared/model/config.ts

44 lines
761 B
TypeScript

import { request } from '../api/request';
import { t } from '../i18n';
import { showErrorToasts } from '../manager/ui';
/**
*
*/
export interface GlobalConfig {
/**
*
* 1m
*/
uploadFileLimit: number;
}
let globalConfig = {
uploadFileLimit: 1 * 1024 * 1024,
};
export function getGlobalConfig() {
return {
...globalConfig,
};
}
export async function fetchConfig() {
const { data: config } = await request.get('/api/config/global');
globalConfig = {
...globalConfig,
...config,
};
return config;
}
/**
*
*/
fetchConfig().catch((e) => {
showErrorToasts(t('全局配置加载失败'));
console.error('全局配置加载失败', e);
});