配置文件
UI 应用
框架默认的 config.ts 文件配置
module.exports = {
/** webpack配置修改 */
webpackConfig: {
// config 是项目的 webpack 配置,可修改
// 如果你对 webpack 不了解,我们不建议修改
chainWebpack: undefined,
/** webpack 别名 */
resolveAlias: {},
/** 打包文件复制 */
copyWebpack: [],
},
/** API配置 */
apiConfig: {
// 启动 mock 调试
isDebug: true,
// 代理服务,即访问接口域名会被替换成 proxyServer,isDebug 为 true 时有效(默认 /)
// http://godzilla-midway.sz.iquantex.com/auth/api/v1/users/login?_t=1596162460875
// 代理后 => /auth/api/v1/users/login?_t=1596162460875
proxyServer: '/',
// 基本路径,接口访问域名
base: '',
// 域,一般用于项目中有多个接口访问域名时
domain: {},
// url路径前缀
urlPrefix: '',
},
/** YAPI配置,只在开发环境时有效 */
yapiConfig: {
// 启动使用
enable: false,
// yapi网站路径,如:https://yapi.iquantex.com
host: '',
// 需要 mock 的项目 token
token: '',
// 启动自动更新接口功能
autoUpdate: false,
// 间隔时间,默认五分钟
interval: 5 * 60 * 1000,
},
/** webpack环境配置 */
definePlugin: {
// 正式环境是否只允许 SSO 登录(默认 true)
ENABLE_SSO: true,
// 是否支持系统自带的websocket(默认false)
ENABLE_WEBSOCKET: false,
// 应用ID
APP_ID: JSON.stringify('portal'),
// 应用名称
PROJECT_NAME: JSON.stringify('Godzilla Portal'),
// 请求响应码
RESPONSE_CODE: {
SUCCESS: 200, // 成功
NOT_MODIFIED: 304, // 未修改
BAD_REQUEST: 400, // 错误的请求
UNAUTHORIZED: 401, // token过期
FORBIDDEN: 403, // 禁止访问
NOT_FOUND: 404, // 请求不存在
METHOD_NOT_ALLOWED: 405, // 不允许访问
REQUEST_TIMEOUT: 408, // 请求超时
ERROR: 500, // 服务器错误
},
// 全局 loading 图片地址
LOADING: 'assets/img/loading.png',
// favicon 图标地址
FAVICON: 'assets/img/icon.ico',
},
/** 系统配置 */
systemConfig: {
// dev server 端口(默认8888)
devServerPort: 8888,
// 主题开发dev server端口(默认9999)
devThemeServerPort: 9999,
// 脚手架开发(默认false,即普通开发)
isScaffoldApp: false,
// 是否是门户入口(默认false)
isPortal: false,
// npm scope
npmScope: '',
// Godzilla框架License
godzillaLicenseKey: '',
// Ag-Grid组件License,详见:https://www.ag-grid.com/license-pricing.php
agGridLicenseKey: '',
},
/** 插件配置 */
pluginConfig: [],
/** 主题配置 */
themeConfig: {
defaultTheme: '',
mainTheme: '',
themes: [],
},
/** electron配置 */
electronConfig: {
// 启用Electron客户端(默认false)
enableElectron: false,
webSecurity: '',
autoUpdate: '',
},
};
自定义的 config/config.ts
const darkChart = require('@gza/quantex-plugin-theme-dark/chart.js');
const whiteChart = require('@gza/quantex-plugin-theme-white/chart.js');
// 注意!!修改该配置文件不会热更新,需要重新执行npm start
const npmScope = '@gza'; // 私有npm依赖的scope
const isDev = process.env.NODE_ENV === 'development';
const config: IConfig = {
webpackConfig: {
resolveAlias: {
'quantex-utils': `${npmScope}/quantex-utils`,
'quantex-design': `${npmScope}/quantex-design`,
'quantex-scripts': `${npmScope}/quantex-scripts`,
},
chainWebpack: webpackConfig => {}, // webpack配置修改
},
systemConfig: {
isPortal: true, // 是否是Portal应用(主应用)
devServerPort: 8888, // dev server 端口
enableElectron: false, // 是否使用Electron客户端
devThemeServerPort: 9999, // 主题开发dev server端口
isScaffoldApp: false, // 是否是脚手架
copyWebpack: [], // 详细使用参考: https://www.npmjs.com/package/copy-webpack-plugin
godzillaLicenseKey:'', // godzilla license
agGridLicenseKey:'', // ag grid license
npmScope: npmScope, // npm scope
},
apiConfig: {
isDebug: isDev,
proxyServer: '/',
base: isDev ? 'http://127.0.0.1:8889' : '', // 基本路径,接口访问域名
domain: {
'/auth': 'http://127.0.0.1:8080/auth' // 例如这里配置/auth接口转发到http://127.0.0.1:8080/auth服务
},
},
definePlugin: {
ENABLE_SSO: false, // 正式环境是否只允许SSO登录
APP_ID: JSON.stringify('pro'), // 应用ID
ENABLE_WEBSOCKET: false, // 是否支持websocket
PROJECT_NAME: JSON.stringify('Godzilla Scaffold') // 应用名称
},
themeConfig: { // 主题配置
defaultTheme: 'themeDark', // 默认主题id
mainTheme: 'themeDark',
themes: [ // 支持的主题列表
{
name: '深色',// 主题显示名称
id: 'themeDark',// 主题id
path: '@gza/quantex-plugin-theme-dark', // 主题依赖
chartConfig: darkChart, // echarts 对应主题文件
},
{
name: '浅色',
id: 'themeWhite',
path: '@gza/quantex-plugin-theme-white',
chartConfig: whiteChart,
},
],
},
pluginConfig: [ // 插件配置
[
'metrics', // 埋点插件
{
enable: true,
domain: 'http://10.16.18.166:32143',
url: '/api/v1/metrics',
method: 'POST',
env: 'DEV', // ST、UAT、PRD等
reportInterval: 10 * 1000, // 一分钟上报一次
package: '@gza/quantex-plugin-metrics',
},
],
],
};