Commercial baseurl (#697)

This commit is contained in:
Archer
2024-01-06 10:36:31 +08:00
committed by GitHub
parent dfa4c0831c
commit 84cc4baf21
44 changed files with 124 additions and 119 deletions

View File

@@ -54,7 +54,6 @@ export type FastGPTFeConfigsType = {
};
export type SystemEnvType = {
pluginBaseUrl?: string;
openapiPrefix?: string;
vectorMaxProcess: number;
qaMaxProcess: number;

View File

@@ -1,9 +1,13 @@
export enum InformTypeEnum {
system = 'system'
system = 'system',
admin = 'admin'
}
export const InformTypeMap = {
[InformTypeEnum.system]: {
label: '系统通知'
},
[InformTypeEnum.admin]: {
label: '管理员'
}
};

View File

@@ -1,4 +1,4 @@
import { InformTypeEnum } from './constant';
import { InformTypeEnum } from './constants';
export type SendInformProps = {
tmbId?: string;

View File

@@ -1,4 +1,5 @@
import axios, { Method, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
import { FastGPTProUrl } from '../system/constants';
interface ConfigType {
headers?: { [key: string]: string };
@@ -70,7 +71,7 @@ instance.interceptors.request.use(requestStart, (err) => Promise.reject(err));
instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err));
export function request(url: string, data: any, config: ConfigType, method: Method): any {
if (!global.systemEnv || !global.systemEnv?.pluginBaseUrl) {
if (!FastGPTProUrl) {
console.log('未部署商业版接口', url);
return Promise.reject('The The request was denied...');
}
@@ -84,7 +85,7 @@ export function request(url: string, data: any, config: ConfigType, method: Meth
return instance
.request({
baseURL: global.systemEnv.pluginBaseUrl,
baseURL: FastGPTProUrl,
url,
method,
data: ['POST', 'PUT'].includes(method) ? data : null,

View File

@@ -21,9 +21,6 @@ export const htmlToMarkdown = (html?: string | null) =>
worker.terminate();
reject(err);
});
worker.on('exit', (code) => {
console.log('html 2 md finish', code);
});
worker.postMessage(html);
});

View File

@@ -1,8 +1,11 @@
import { SystemConfigsTypeEnum } from '@fastgpt/global/common/system/config/constants';
import { MongoSystemConfigs } from './schema';
import { FastGPTConfigFileType } from '@fastgpt/global/common/system/types';
import { FastGPTProUrl } from '../constants';
export const getFastGPTConfigFromDB = async () => {
if (!FastGPTProUrl) return {} as FastGPTConfigFileType;
const res = await MongoSystemConfigs.findOne({
type: SystemConfigsTypeEnum.fastgpt
}).sort({
@@ -11,5 +14,5 @@ export const getFastGPTConfigFromDB = async () => {
const config = res?.value || {};
return config as Omit<FastGPTConfigFileType, 'systemEnv'>;
return config as FastGPTConfigFileType;
};

View File

@@ -0,0 +1 @@
export const FastGPTProUrl = process.env.PRO_URL ? `${process.env.PRO_URL}/api` : '';

View File

@@ -1,5 +1,6 @@
import axios from 'axios';
import { MongoOutLink } from './schema';
import { FastGPTProUrl } from '../../common/system/constants';
export const updateOutLinkUsage = async ({
shareId,
@@ -30,7 +31,7 @@ export const pushResult2Remote = async ({
shareId?: string;
responseData?: any[];
}) => {
if (!shareId || !outLinkUid || !global.systemEnv?.pluginBaseUrl) return;
if (!shareId || !outLinkUid || !FastGPTProUrl) return;
try {
const outLink = await MongoOutLink.findOne({
shareId