重构配置管理,更新域名处理逻辑,简化配置结构
This commit is contained in:
@@ -1,19 +1,12 @@
|
|||||||
import { useConfig } from '@kevisual/use-config';
|
import { useConfig } from '@kevisual/use-config';
|
||||||
import { useFileStore } from '@kevisual/use-config';
|
import { useFileStore } from '@kevisual/use-config';
|
||||||
import { minioResources } from './s3.ts';
|
import { minioResources } from './s3.ts';
|
||||||
|
import { proxyDomain } from './domain.ts';
|
||||||
|
|
||||||
export const config = useConfig() as any;
|
export const config = useConfig() as any;
|
||||||
export const port = config.PORT ? Number(config.PORT) : 4005;
|
export const port = config.PORT ? Number(config.PORT) : 4005;
|
||||||
export const fileStore = useFileStore('pages');
|
export const fileStore = useFileStore('pages');
|
||||||
type ConfigType = {
|
type ConfigType = {
|
||||||
api: {
|
|
||||||
/**
|
|
||||||
* API host address
|
|
||||||
*/
|
|
||||||
host: string;
|
|
||||||
path?: string;
|
|
||||||
port?: number;
|
|
||||||
};
|
|
||||||
apiList: {
|
apiList: {
|
||||||
path: string;
|
path: string;
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +22,11 @@ type ConfigType = {
|
|||||||
/**
|
/**
|
||||||
* self domain kevisual.xiongxiao.me
|
* self domain kevisual.xiongxiao.me
|
||||||
*/
|
*/
|
||||||
domain: string;
|
domain?: string;
|
||||||
|
/**
|
||||||
|
* self ip
|
||||||
|
*/
|
||||||
|
ip?: string;
|
||||||
/**
|
/**
|
||||||
* resources path
|
* resources path
|
||||||
* https://minio.xiongxiao.me/resources
|
* https://minio.xiongxiao.me/resources
|
||||||
@@ -41,24 +38,8 @@ type ConfigType = {
|
|||||||
*/
|
*/
|
||||||
allowedOrigin: string[];
|
allowedOrigin: string[];
|
||||||
};
|
};
|
||||||
stat: {
|
|
||||||
/**
|
|
||||||
* 统计网站ID
|
|
||||||
*/
|
|
||||||
websiteId: string;
|
|
||||||
};
|
|
||||||
redis?: {
|
|
||||||
host: string;
|
|
||||||
port: number;
|
|
||||||
password?: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
export const myConfig: ConfigType = {
|
export const myConfig: ConfigType = {
|
||||||
api: {
|
|
||||||
host: config.API_HOST,
|
|
||||||
path: config.API_PATH,
|
|
||||||
port: config.PROXY_PORT,
|
|
||||||
},
|
|
||||||
apiList: [
|
apiList: [
|
||||||
// {
|
// {
|
||||||
// path: '/api',
|
// path: '/api',
|
||||||
@@ -66,20 +47,12 @@ export const myConfig: ConfigType = {
|
|||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
path: '/client',
|
path: '/client',
|
||||||
target: config.API_CLIENT_HOST || 'http://localhost:51015',
|
target: config.API_CLIENT_HOST || 'http://localhost:51515',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
proxy: {
|
proxy: {
|
||||||
domain: config.PROXY_DOMAIN,
|
domain: proxyDomain as string,
|
||||||
resources: minioResources,
|
resources: minioResources,
|
||||||
allowedOrigin: (config.PROXY_ALLOWED_ORIGINS as string)?.split(',') || [],
|
allowedOrigin: (config.PROXY_ALLOWED_ORIGINS as string)?.split(',') || [],
|
||||||
},
|
}
|
||||||
redis: {
|
|
||||||
host: config.REDIS_HOST,
|
|
||||||
port: config.REDIS_PORT,
|
|
||||||
password: config.REDIS_PASSWORD,
|
|
||||||
},
|
|
||||||
stat: {
|
|
||||||
websiteId: config.DATA_WEBSITE_ID,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
|
import { useKey } from "@kevisual/use-config";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用来放cookie的域名
|
* 用来放cookie的域名
|
||||||
*/
|
*/
|
||||||
export const domain = process.env.DOMAIN || ''; // 请在这里填写你的域名
|
export const proxyDomain = useKey('PROXY_DOMAIN') || ''; // 请在这里填写你的域名
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { app } from '@/app.ts';
|
import { app } from '@/app.ts';
|
||||||
import { Org } from '@/models/org.ts';
|
import { Org } from '@/models/org.ts';
|
||||||
import { User } from '@/models/user.ts';
|
import { User } from '@/models/user.ts';
|
||||||
import { domain } from '@/modules/domain.ts';
|
import { proxyDomain as domain } from '@/modules/domain.ts';
|
||||||
/**
|
/**
|
||||||
* 当配置了domain后,创建cookie,当get请求地址的时候,会自动带上cookie
|
* 当配置了domain后,创建cookie,当get请求地址的时候,会自动带上cookie
|
||||||
* @param token
|
* @param token
|
||||||
|
|||||||
Reference in New Issue
Block a user