v4 代码迁移:更新主题定制
¥v4 code migration: Updating theme customizations
本指南是 v4 代码迁移指南 的一部分,旨在帮助你将 Strapi 应用的代码从 v3.6.x 迁移到 v4.0.x
¥This guide is part of the v4 code migration guide designed to help you migrate the code of a Strapi application from v3.6.x to v4.0.x
在 Strapi v3 中,不支持主题自定义。
¥In Strapi v3, theme customization was not supported.
Strapi v4 为 Strapi 设计系统 引入了全新的管理面板主题。
¥Strapi v4 introduces the Strapi Design System with a brand new theme for the admin panel.
要在 Strapi v4 中自定义主题:
¥To customize the theme in Strapi v4:
将
./src/admin/app.example.js
文件重命名为./src/admin/app.js
。¥Rename the
./src/admin/app.example.js
file to./src/admin/app.js
.在
./src/admin/app.js
中,在config.theme
对象中声明新的键/值对,更新 默认主题 的设计元素(例如颜色、阴影、大小)。¥In
./src/admin/app.js
, declare new key/value pairs in theconfig.theme
object, updating the design elements (e.g. colors, shadows, sizes) of the default theme.
Example of theme customization in Strapi v4:
export default {
config: {
theme: {
colors, shadows, sizes, …
}
},
bootstrap() {},
};
Strapi 设计系统 是完全可定制的。
¥The Strapi Design System is fully customizable.
Strapi v4 支持浅色和夜间模式。有关更多详细信息,请参阅 管理员定制 文档。
¥Strapi v4 supports light and dark modes. See admin customization documentation for more details.