We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问题:是不是在开发环境和生产环境,二者的覆盖优先级不同?还是我哪里理解错误了?
config/config.ts 中的代码片段
config/config.ts
title: '读取中...', /** * @name layout 插件 * @doc https://umijs.org/docs/max/layout-menu */ layout: { locale: true, ...defaultSettings, title: process.env.SITE_TITLE || 'Default Title', },
config/defaultSetting.ts 中的代码片段
config/defaultSetting.ts
title: 'Default',
config.ts 中可以读取使用 process.env,但 defaultSetting.ts 中不可以,只能写死。所以目前的情况是开发环境下,可以正确使用 config.ts 中定义的,从环境变量SITE_TITLE中读取的 title; 生产环境就只能使用到 defaultSetting.ts 里面写死的 title
在app.tsx中,找到如下代码片段(2处),覆盖掉defaultSetting里面的title
settings: defaultSettings as Partial<LayoutSettings>,
改为
settings:{ ...defaultSettings, title: SITE_TITLE, } as Partial<LayoutSettings>,
在 defaultSetting 中删掉 title 属性,并在登录页面 pages/Users/Login 中删除使用到这个defaultSetting.title 属性的地方
{Settings.title && ` - ${Settings.title}`} // 删除这行
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
🧐 问题描述 | Problem description
问题:是不是在开发环境和生产环境,二者的覆盖优先级不同?还是我哪里理解错误了?
💻 示例代码 | Sample code
config/config.ts
中的代码片段config/defaultSetting.ts
中的代码片段🚑 其他信息 | Other information
config.ts 中可以读取使用 process.env,但 defaultSetting.ts 中不可以,只能写死。所以目前的情况是开发环境下,可以正确使用 config.ts 中定义的,从环境变量SITE_TITLE中读取的 title; 生产环境就只能使用到 defaultSetting.ts 里面写死的 title
临时解决方案 | Workaround
方案1
在app.tsx中,找到如下代码片段(2处),覆盖掉defaultSetting里面的title
改为
方案2
在 defaultSetting 中删掉 title 属性,并在登录页面 pages/Users/Login 中删除使用到这个defaultSetting.title 属性的地方
The text was updated successfully, but these errors were encountered: