1

We are looking to use KeystoneJS in a large project and we want to be able to customise the Admin panel. There's a nice example of how to do it here, and I've been reviewing this PR to the project. Although the example looks as if it would work for us, I don't understand the logic behind it, that is, what we would need to implement to make it work, what the possibilities and constraints are.

Is it the case that when you use the Keystone NextJS app (which is good for us), if you add a folder /admin/pages the Keystone app will look there and use those custom admin pages instead of the regular ones? I'm assuming we have full access to the rest of the app, the controllers, the DB from these pages as well....

I also noticed that JedWatson notes in https://github.com/keystonejs/keystone/pull/1019 that

Note this lacks SSR support, and I didn't put as much effort into the examples, but it's otherwise (I think) identical in functionality.

Does it lack SSR support just for the admin part, or does adding custom admin pages somehow affect SSR support in the rest of the app? (SSR is the reason we're using next)

Thanks for any info.

4

1 回答 1

1

自定义页面有两个api,一个是app构造函数pages中的选项,第二个是keystone构造函数中api的一部分。admin-uihooks

  1. pages:这个是遗留的,只添加自定义页面,它不会覆盖 admin-ui 中现有的列表页面,如果配置不正确,它只会隐藏它们。通常Dashboard是可见的,并且所有列表都列在那里。
  2. hooks:这是新的,预计会添加更多自定义选项,不幸的是我的 PR 已经过时,它们不是规范 keystone 核心团队想要添加的。这也不会删除任何页面。

admin ui 作为使用 webpack 配置构建或加载的 react 应用程序运行。这就是为什么没有ssr支持的原因。即使该示例使用自定义管理目录但未由nextjs组件加载,它也是使用安装 admin-ui react 应用程序的 webpack 服务器动态加载的

如果你真的想拥有 ssr,你可以从很久以前用作 POC 的封闭 PR 中学习一些东西。但这将是矫枉过正,因为 admin-ui 之后有更多更新。

钩子/页面可以访问核心有限的一组访问,有一些基于 React 上下文、提供者和消费者钩子的访问。您可以使用 react-apollo 钩子,因为在 react 上下文的根目录中已经包含了提供程序。您还可以使用 react 路由器挂钩,它们已升级到最新版本。它无法访问服务器端上下文或控制器。(不知道你说的控制器是什么意思)

于 2020-02-19T18:03:33.033 回答