常见问题
¥Frequently Asked Questions
以下是你在使用 Strapi 时可能遇到的最常见问题的答案和解决方案。
¥Below are answers and solutions to most common issues that you may experience when working with Strapi.
为什么我无法在生产/暂存中创建或更新内容类型?
¥Why can't I create or update content-types in production/staging?
Strapi 将模型配置文件(定义模型架构的内容)存储在诸如 ./src/api/restaurant/content-types/restaurant/schema.json
.txt 之类的文件中。由于 Node.js 的工作原理,为了使更改生效,需要 Node 重新启动服务器。这可能会导致生产服务停机,同样,这些更改应该在某种源代码控制中进行跟踪。
¥Strapi stores model configuration files (what defines the model schema) in files such as ./src/api/restaurant/content-types/restaurant/schema.json
. Due to how Node.js works, in order for changes to take effect, that would require Node to restart the server. This could potentially cause downtime of your production service and likewise these changes should be tracked in some kind of source control.
一般来说,你 的 "flow" 开发会遵循以下路径:
¥Generally your "flow" of development would follow the following path:
-
开发 - 在主机上本地开发 Strapi 应用,然后将更改推送到源代码管理中
¥Development - Develop your Strapi application locally on your host machine, then push changes into source control
-
分期 - 将更改从源代码管理部署到 "production-like" 环境以进行测试
¥Staging - Deploy changes from source control to a "production-like" environment for testing
-
生产 - 如果不需要其他更改,则部署到生产中
¥Production - If no other changes are needed, deploy into production
-
根据需要重复,建议你正确版本化并测试你的应用
¥Repeat as needed, it is recommended that you properly version and test your application as you go
目前和将来没有计划允许在生产环境中创建或更新模型,并且目前没有计划将模型设置移至数据库中。对此没有已知或推荐的解决方法。
¥At this time and in the future there is no plan to allow model creating or updating while in a production environment, and there is currently no plans to move model settings into the database. There are no known nor recommended workarounds for this.
Strapi 是否处理内容的部署或迁移?
¥Does Strapi handle deploying or migrating of content?
Strapi 确实提供了一项称为 数据传输 的功能,允许你将内容从一个 Strapi 实例导出和导入到另一个实例,或者从文件存档导出和导入。这对于将内容从一种环境迁移到另一种环境非常有用。
¥Strapi does offer a feature known as Data Transfer that allows you to export and import content from one Strapi instance to another or exporting and importing from a file archive. This is useful for migrating content from one environment to another.
用户无法登录管理面板
¥User can't login to the admin panel
随着 Strapi 3.0 测试版的发布,发生了根本性变化,终端用户(REST 和 GraphQL 用户)与管理员(管理面板用户)分开,以至于普通用户无法访问管理面板。如果你想了解有关进行此更改的原因的更多信息,你可以阅读有关它的 Strapi 博客文章。
¥With the release of the Strapi 3.0 beta version a fundamental change occurred in that the end users (REST and GraphQL users) were split from the Administrators (admin panel users) in such a way that normal users can not be given access to the admin panel. If you would like to read more on why this change was done, you can read the Strapi blog post about it.
Strapi 发布了管理和权限(RBAC - 基于角色的访问控制),它允许对用户在管理面板中可以访问的内容进行一定程度的控制,并包括一些字段级别的权限。你还可以为角色授予内容类型、单一类型、插件和设置等特定权限。
¥Strapi has released the Admin & Permissions (RBAC - Role-Based Access Control) that does allow for some degree of control over what users can access within the admin panel and includes some field level permissions. You can also give roles specific permissions for things like content-types, single types, plugins, and settings.
为什么我的应用的数据库和上传在 PaaS 类型的服务上重置?
¥Why are my application's database and uploads resetting on PaaS-type services?
如果你使用 --quickstart
创建 Strapi 项目,则默认情况下将使用 SQLite 数据库。PaaS 系统(Heroku、DigitalOcean Apps、Google App Engine 等)文件系统通常是 ephemeral 或只读的,这意味着每次重置 dyno(容器)时,所有文件系统更改都会丢失。由于 SQLite 和本地上传都存储在文件系统上,因此自上次 dyno 重置以来对这些内容所做的任何更改都将被删除。通常,测功机每天至少重置一次,在大多数情况下,每天或在将新代码推送到这些服务时重置多次。