Skip to content

Commit

Permalink
chore: cr
Browse files Browse the repository at this point in the history
  • Loading branch information
zllkjc committed Dec 10, 2024
1 parent 3d7f39f commit de91452
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default defineConfig({
| ---------------- | ------------------------------------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------- |
| mode | `string` | `string` | 默认为使用 `renderToString` 渲染。配置为 `stream` 开启流式渲染 |
| forceCSR | `boolean` | `false` | 默认关闭强制 CSR 渲染。配置为 `true` 后,在页面访问时添加 `?csr=true` 或添加请求头 `x-modern-ssr-fallback` 即可强制 CSR |
| inlineScript | `boolean` | `true` | 默认情况下,SSR 的数据会以内联脚本的方式注入到 HTML 中,并且直接赋值给全局变量。配置为 `false` 后,会下发 JSON,而不是赋值给全局变量,Streaming SSR 下,该配置不会生效 |
| disablePrerender | `boolean` | `fasle` | 为了兼容旧数据请求方式 - `useLoader`, 默认情况下 Modern.js 会对组件进行一次预渲染即有两次渲染 |
| unsafeHeaders | `string[]` | `[]` | 为了安全考虑,Modern.js 不会往 SSR_DATA 添加过多的内容。开发者可以通过该配置,对需要注入的 headers 进行配置 |
| scriptLoading | `defer \| blocking \| module \| async` | `defer` | 配置同 [html.scriptLoading](/configure/app/html/script-loading),支持 ssr 注入的 script 设置为 async 加载方式。优先级为 `ssr.scriptLoading` > `html.scriptLoading` |
| loaderFailureMode| `clientRender \| errorBoundary` | `errorBoundary` |[data loader](/guides/basic-features/data/data-fetch.html#data-loader推荐) 中出错时,默认会渲染路由 [`Error`](/guides/basic-features/routes.html#错误处理) 组件,配置为 `'clientRender'` 时,有一个 data loader 抛错,就降级到客户端渲染,可以与 [Client Loader](/guides/basic-features/data/data-fetch.html#client-loader) 配合使用 |
Expand All @@ -41,7 +41,7 @@ export default defineConfig({
ssr: {
forceCSR: true,
mode: 'stream',
inlineScript: false,
disablePrerender: true,
unsafeHeaders: ['User-Agent'],
scriptLoading: 'async',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/plugin-runtime/src/core/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function createRoot(UserApp?: React.ComponentType | null) {
const App = UserApp || getGlobalApp();

if (isBrowser()) {
// we should get data from HTMLElement when set server.useInline = false
// we should get data from HTMLElement when set server.useJsonScript = true
window._SSR_DATA =
window._SSR_DATA || parsedJSONFromElement(SSR_DATA_JSON_ID);

Expand Down

0 comments on commit de91452

Please sign in to comment.