@modern-js/main-doc 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/LICENSE +0 -123
  3. package/README.md +26 -0
  4. package/en/apis/app/commands.mdx +297 -0
  5. package/en/apis/app/hooks/_category_.json +2 -5
  6. package/en/apis/app/hooks/api/framework/lambda.mdx +1 -1
  7. package/en/apis/app/hooks/api/functions/api.mdx +1 -1
  8. package/en/apis/app/hooks/server/index_.mdx +2 -1
  9. package/en/apis/app/hooks/src/pages.mdx +7 -7
  10. package/en/apis/app/hooks/src/routes.mdx +3 -3
  11. package/en/apis/app/runtime/_category_.json +1 -5
  12. package/en/apis/app/runtime/app/define-config.mdx +2 -2
  13. package/en/apis/app/runtime/core/bootstrap.mdx +1 -1
  14. package/en/apis/app/runtime/core/create-app.mdx +2 -2
  15. package/en/apis/app/runtime/core/use-loader.mdx +4 -4
  16. package/en/apis/app/runtime/core/use-module-apps.mdx +2 -2
  17. package/en/apis/app/runtime/model/Provider.mdx +2 -2
  18. package/en/apis/app/runtime/model/auto-actions.mdx +2 -2
  19. package/en/apis/app/runtime/model/connect.mdx +5 -5
  20. package/en/apis/app/runtime/model/create-app.mdx +9 -9
  21. package/en/apis/app/runtime/model/create-store.mdx +3 -3
  22. package/en/apis/app/runtime/model/handle-effect.mdx +2 -2
  23. package/en/apis/app/runtime/model/model_.mdx +1 -1
  24. package/en/apis/app/runtime/model/use-local-model.mdx +1 -1
  25. package/en/apis/app/runtime/model/use-model.mdx +1 -1
  26. package/en/apis/app/runtime/model/use-static-model.mdx +4 -4
  27. package/en/apis/app/runtime/model/use-store.mdx +1 -1
  28. package/en/apis/app/runtime/router/router.mdx +1 -1
  29. package/en/apis/app/runtime/ssr/pre-render.mdx +1 -1
  30. package/en/apis/app/runtime/testing/render.mdx +1 -1
  31. package/en/apis/app/runtime/testing/renderApp.mdx +1 -1
  32. package/en/apis/app/runtime/utility/css-in-js.mdx +1 -1
  33. package/en/apis/app/runtime/utility/loadable.mdx +1 -1
  34. package/en/apis/app/runtime/web-server/hook.mdx +5 -5
  35. package/en/apis/app/runtime/web-server/middleware.mdx +6 -6
  36. package/en/components/global-proxy-config.mdx +3 -3
  37. package/en/components/init-app.mdx +5 -5
  38. package/en/configure/app/bff/_category_.json +4 -0
  39. package/en/configure/app/bff/prefix.mdx +2 -3
  40. package/en/configure/app/bff/proxy.mdx +1 -1
  41. package/en/configure/app/builder-plugins.mdx +3 -3
  42. package/en/configure/app/deploy/_category_.json +4 -0
  43. package/en/configure/app/dev/_category_.json +4 -0
  44. package/en/configure/app/dev/asset-prefix.mdx +1 -1
  45. package/en/configure/app/dev/before-start-url.mdx +13 -0
  46. package/en/configure/app/dev/hmr.mdx +1 -1
  47. package/en/configure/app/dev/host.mdx +13 -0
  48. package/en/configure/app/dev/https.mdx +1 -1
  49. package/en/configure/app/dev/port.mdx +1 -1
  50. package/en/configure/app/dev/progress-bar.mdx +1 -1
  51. package/en/configure/app/dev/start-url.mdx +1 -1
  52. package/en/configure/app/experiments/_category_.json +4 -0
  53. package/en/configure/app/experiments/lazy-compilation.mdx +1 -1
  54. package/en/configure/app/html/_category_.json +4 -0
  55. package/en/configure/app/html/app-icon.mdx +1 -1
  56. package/en/configure/app/html/crossorigin.mdx +1 -1
  57. package/en/configure/app/html/disable-html-folder.mdx +1 -1
  58. package/en/configure/app/html/favicon-by-entries.mdx +1 -1
  59. package/en/configure/app/html/favicon.mdx +1 -1
  60. package/en/configure/app/html/inject-by-entries.mdx +1 -1
  61. package/en/configure/app/html/inject.mdx +1 -1
  62. package/en/configure/app/html/meta-by-entries.mdx +1 -1
  63. package/en/configure/app/html/meta.mdx +1 -1
  64. package/en/configure/app/html/mount-id.mdx +1 -1
  65. package/en/configure/app/html/tags-by-entries.mdx +1 -1
  66. package/en/configure/app/html/tags.mdx +1 -1
  67. package/en/configure/app/html/template-by-entries.mdx +1 -1
  68. package/en/configure/app/html/template-parameters-by-entries.mdx +1 -1
  69. package/en/configure/app/html/template-parameters.mdx +1 -1
  70. package/en/configure/app/html/template.mdx +1 -1
  71. package/en/configure/app/html/title-by-entries.mdx +1 -1
  72. package/en/configure/app/html/title.mdx +1 -1
  73. package/en/configure/app/output/_category_.json +4 -0
  74. package/en/configure/app/output/asset-prefix.mdx +1 -1
  75. package/en/configure/app/output/assets-retry.mdx +1 -1
  76. package/en/configure/app/output/charset.mdx +1 -1
  77. package/en/configure/app/output/clean-dist-path.mdx +1 -1
  78. package/en/configure/app/output/convert-to-rem.mdx +1 -1
  79. package/en/configure/app/output/copy.mdx +1 -1
  80. package/en/configure/app/output/css-module-local-ident-name.mdx +1 -1
  81. package/en/configure/app/output/data-uri-limit.mdx +1 -1
  82. package/en/configure/app/output/disable-css-extract.mdx +1 -1
  83. package/en/configure/app/output/disable-css-module-extension.mdx +1 -1
  84. package/en/configure/app/output/disable-filename-hash.mdx +1 -1
  85. package/en/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
  86. package/en/configure/app/output/disable-minimize.mdx +1 -1
  87. package/en/configure/app/output/disable-source-map.mdx +1 -1
  88. package/en/configure/app/output/disable-ts-checker.mdx +1 -1
  89. package/en/configure/app/output/dist-path.mdx +1 -1
  90. package/en/configure/app/output/enable-asset-fallback.mdx +1 -1
  91. package/en/configure/app/output/enable-asset-manifest.mdx +1 -1
  92. package/en/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
  93. package/en/configure/app/output/enable-inline-scripts.mdx +1 -1
  94. package/en/configure/app/output/enable-inline-styles.mdx +1 -1
  95. package/en/configure/app/output/enable-latest-decorators.mdx +1 -1
  96. package/en/configure/app/output/externals.mdx +1 -1
  97. package/en/configure/app/output/filename.mdx +1 -1
  98. package/en/configure/app/output/legal-comments.mdx +1 -1
  99. package/en/configure/app/output/override-browserslist.mdx +1 -1
  100. package/en/configure/app/output/polyfill.mdx +1 -1
  101. package/en/configure/app/output/ssg.mdx +5 -5
  102. package/en/configure/app/output/svg-default-export.mdx +1 -1
  103. package/en/configure/app/performance/_category_.json +4 -0
  104. package/en/configure/app/performance/build-cache.mdx +1 -1
  105. package/en/configure/app/performance/bundle-analyze.mdx +1 -1
  106. package/en/configure/app/performance/chunk-split.mdx +1 -1
  107. package/en/configure/app/performance/print-file-size.mdx +1 -1
  108. package/en/configure/app/performance/profile.mdx +1 -1
  109. package/en/configure/app/performance/remove-console.mdx +1 -1
  110. package/en/configure/app/performance/remove-moment-locale.mdx +1 -1
  111. package/en/configure/app/plugins.mdx +1 -1
  112. package/en/configure/app/runtime/_category_.json +4 -0
  113. package/en/configure/app/runtime/intro.mdx +2 -2
  114. package/en/configure/app/runtime/master-app.mdx +1 -1
  115. package/en/configure/app/security/_category_.json +4 -0
  116. package/en/configure/app/security/check-syntax.mdx +1 -1
  117. package/en/configure/app/security/sri.mdx +1 -1
  118. package/en/configure/app/server/_category_.json +4 -0
  119. package/en/configure/app/server/base-url.mdx +3 -3
  120. package/en/configure/app/server/enable-framework-ext.mdx +1 -1
  121. package/en/configure/app/server/ssr-by-entries.mdx +1 -1
  122. package/en/configure/app/source/_category_.json +4 -0
  123. package/en/configure/app/source/alias.mdx +1 -1
  124. package/en/configure/app/source/compile-js-data-uri.mdx +1 -1
  125. package/en/configure/app/source/define.mdx +1 -1
  126. package/en/configure/app/source/design-system.mdx +5 -5
  127. package/en/configure/app/source/entries-dir.mdx +1 -1
  128. package/en/configure/app/source/entries.mdx +3 -3
  129. package/en/configure/app/source/exclude.mdx +1 -1
  130. package/en/configure/app/source/global-vars.mdx +1 -1
  131. package/en/configure/app/source/include.mdx +1 -1
  132. package/en/configure/app/source/module-scopes.mdx +1 -1
  133. package/en/configure/app/source/pre-entry.mdx +1 -1
  134. package/en/configure/app/source/resolve-extension-prefix.mdx +1 -1
  135. package/en/configure/app/source/resolve-main-fields.mdx +1 -1
  136. package/en/configure/app/testing/_category_.json +4 -0
  137. package/en/configure/app/testing/transformer.mdx +1 -1
  138. package/en/configure/app/tools/_category_.json +4 -0
  139. package/en/configure/app/tools/autoprefixer.mdx +1 -1
  140. package/en/configure/app/tools/babel.mdx +1 -1
  141. package/en/configure/app/tools/css-extract.mdx +1 -1
  142. package/en/configure/app/tools/css-loader.mdx +1 -1
  143. package/en/configure/app/tools/dev-server.mdx +1 -1
  144. package/en/configure/app/tools/html-plugin.mdx +1 -1
  145. package/en/configure/app/tools/inspector.mdx +1 -1
  146. package/en/configure/app/tools/jest.mdx +1 -1
  147. package/en/configure/app/tools/less.mdx +1 -1
  148. package/en/configure/app/tools/minify-css.mdx +1 -1
  149. package/en/configure/app/tools/postcss.mdx +1 -1
  150. package/en/configure/app/tools/pug.mdx +1 -1
  151. package/en/configure/app/tools/rspack.mdx +13 -0
  152. package/en/configure/app/tools/sass.mdx +1 -1
  153. package/en/configure/app/tools/style-loader.mdx +1 -1
  154. package/en/configure/app/tools/styled-components.mdx +1 -1
  155. package/en/configure/app/tools/tailwindcss.mdx +1 -1
  156. package/en/configure/app/tools/terser.mdx +1 -1
  157. package/en/configure/app/tools/ts-checker.mdx +1 -1
  158. package/en/configure/app/tools/ts-loader.mdx +1 -1
  159. package/en/configure/app/tools/webpack-chain.mdx +1 -1
  160. package/en/configure/app/tools/webpack.mdx +1 -1
  161. package/en/configure/app/usage.mdx +1 -1
  162. package/en/guides/advanced-features/_category_.json +2 -2
  163. package/en/guides/advanced-features/bff/bff-proxy.mdx +1 -1
  164. package/en/guides/advanced-features/bff/frameworks.mdx +1 -1
  165. package/en/guides/advanced-features/bff/function.mdx +3 -3
  166. package/en/guides/advanced-features/code-split.mdx +2 -2
  167. package/en/guides/advanced-features/compatibility.mdx +2 -3
  168. package/en/guides/advanced-features/eslint.mdx +4 -4
  169. package/en/guides/advanced-features/low-level.mdx +1 -1
  170. package/en/guides/advanced-features/rspack-start.mdx +69 -0
  171. package/en/guides/advanced-features/ssg.mdx +12 -13
  172. package/en/guides/advanced-features/ssr.mdx +3 -3
  173. package/en/guides/advanced-features/testing.mdx +4 -5
  174. package/en/guides/advanced-features/web-server.mdx +0 -1
  175. package/en/guides/basic-features/alias.mdx +5 -5
  176. package/en/guides/basic-features/data-fetch.mdx +25 -12
  177. package/en/guides/basic-features/env-vars.mdx +1 -1
  178. package/en/guides/basic-features/html.mdx +11 -11
  179. package/en/guides/basic-features/mock.mdx +21 -1
  180. package/en/guides/basic-features/proxy.mdx +2 -2
  181. package/en/guides/basic-features/routes.mdx +29 -15
  182. package/en/guides/{basic-features → concept}/builder.mdx +2 -2
  183. package/en/guides/concept/entries.mdx +11 -11
  184. package/en/guides/css/_category_.json +5 -0
  185. package/en/guides/{basic-features/css → css}/less-sass.mdx +1 -1
  186. package/en/guides/get-started/introduction.mdx +34 -0
  187. package/en/guides/get-started/quick-start.mdx +4 -4
  188. package/en/guides/get-started/upgrade.mdx +2 -1
  189. package/en/guides/topic-detail/_category_.json +2 -2
  190. package/en/guides/topic-detail/framework-plugin/hook.mdx +1 -1
  191. package/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +1 -1
  192. package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
  193. package/en/guides/topic-detail/micro-frontend/c02-development.mdx +128 -61
  194. package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +73 -42
  195. package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
  196. package/en/guides/topic-detail/model/auto-actions.mdx +1 -1
  197. package/en/guides/topic-detail/model/define-model.mdx +1 -1
  198. package/en/guides/topic-detail/model/manage-effects.mdx +1 -1
  199. package/en/guides/topic-detail/model/model-communicate.mdx +1 -1
  200. package/en/guides/topic-detail/model/quick-start.mdx +2 -2
  201. package/en/guides/topic-detail/model/test-model.mdx +1 -1
  202. package/en/guides/topic-detail/model/use-model.mdx +3 -3
  203. package/en/guides/troubleshooting/_category_.json +2 -2
  204. package/en/guides/troubleshooting/cli.mdx +1 -1
  205. package/en/index.md +1 -1
  206. package/en/tutorials/first-app/_category_.json +1 -1
  207. package/en/tutorials/first-app/c01-start.mdx +0 -1
  208. package/en/tutorials/first-app/c03-css.mdx +1 -2
  209. package/en/tutorials/first-app/c06-model.mdx +1 -1
  210. package/en/tutorials/first-app/c07-container.mdx +18 -18
  211. package/en/tutorials/first-app/c08-entries.mdx +24 -25
  212. package/en/tutorials/foundations/introduction.mdx +17 -34
  213. package/package.json +3 -3
  214. package/scripts/config.ts +3 -1
  215. package/scripts/summary.en.json +1 -1
  216. package/scripts/summary.zh.json +1 -1
  217. package/zh/apis/app/commands.mdx +299 -0
  218. package/zh/apis/app/hooks/_category_.json +2 -5
  219. package/zh/apis/app/hooks/src/pages.mdx +1 -1
  220. package/zh/apis/app/hooks/src/routes.mdx +3 -3
  221. package/zh/apis/app/runtime/_category_.json +1 -5
  222. package/zh/apis/app/runtime/core/create-app.mdx +1 -1
  223. package/zh/apis/app/runtime/core/use-module-apps.mdx +81 -40
  224. package/zh/apis/app/runtime/model/Provider.mdx +2 -2
  225. package/zh/apis/app/runtime/model/create-app.mdx +7 -7
  226. package/zh/apis/app/runtime/model/create-store.mdx +2 -2
  227. package/zh/apis/app/runtime/model/use-local-model.mdx +1 -1
  228. package/zh/apis/app/runtime/model/use-static-model.mdx +1 -1
  229. package/zh/apis/app/runtime/model/use-store.mdx +1 -1
  230. package/zh/apis/app/runtime/testing/renderApp.mdx +1 -1
  231. package/zh/components/init-app.mdx +5 -5
  232. package/zh/components/micro-runtime-config.mdx +6 -6
  233. package/zh/components/release-note.mdx +1 -1
  234. package/zh/configure/app/bff/prefix.mdx +1 -1
  235. package/zh/configure/app/bff/proxy.mdx +1 -1
  236. package/zh/configure/app/builder-plugins.mdx +3 -3
  237. package/zh/configure/app/dev/before-start-url.mdx +13 -0
  238. package/zh/configure/app/dev/host.mdx +13 -0
  239. package/zh/configure/app/output/ssg.mdx +3 -3
  240. package/zh/configure/app/plugins.mdx +1 -1
  241. package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
  242. package/zh/configure/app/source/entries-dir.mdx +1 -1
  243. package/zh/configure/app/tools/rspack.mdx +13 -0
  244. package/zh/configure/app/usage.mdx +1 -1
  245. package/zh/guides/advanced-features/_category_.json +2 -6
  246. package/zh/guides/advanced-features/compatibility.mdx +0 -1
  247. package/zh/guides/advanced-features/rspack-start.mdx +69 -0
  248. package/zh/guides/advanced-features/ssg.mdx +8 -9
  249. package/zh/guides/advanced-features/ssr.mdx +3 -2
  250. package/zh/guides/advanced-features/testing.mdx +0 -1
  251. package/zh/guides/advanced-features/web-server.mdx +0 -1
  252. package/zh/guides/basic-features/_category_.json +1 -5
  253. package/zh/guides/basic-features/alias.mdx +5 -5
  254. package/zh/guides/basic-features/data-fetch.mdx +39 -30
  255. package/zh/guides/basic-features/html.mdx +10 -9
  256. package/zh/guides/basic-features/mock.mdx +20 -0
  257. package/zh/guides/basic-features/routes.mdx +38 -17
  258. package/zh/guides/{basic-features → concept}/builder.mdx +4 -4
  259. package/zh/guides/concept/entries.mdx +11 -11
  260. package/zh/guides/css/_category_.json +5 -0
  261. package/zh/guides/{basic-features/css → css}/less-sass.mdx +1 -1
  262. package/zh/guides/{basic-features/css → css}/postcss.mdx +5 -4
  263. package/zh/guides/{basic-features/css → css}/tailwindcss.mdx +0 -1
  264. package/zh/guides/get-started/introduction.mdx +31 -0
  265. package/zh/guides/get-started/quick-start.mdx +4 -5
  266. package/zh/guides/get-started/upgrade.mdx +2 -1
  267. package/zh/guides/topic-detail/_category_.json +2 -2
  268. package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
  269. package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +25 -0
  270. package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +16 -16
  271. package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
  272. package/zh/guides/troubleshooting/_category_.json +2 -2
  273. package/zh/index.md +1 -1
  274. package/zh/tutorials/first-app/_category_.json +1 -1
  275. package/zh/tutorials/first-app/c01-start.mdx +1 -2
  276. package/zh/tutorials/first-app/c03-css.mdx +1 -2
  277. package/zh/tutorials/first-app/c06-model.mdx +2 -2
  278. package/zh/tutorials/first-app/c07-container.mdx +18 -18
  279. package/zh/tutorials/first-app/c08-entries.mdx +25 -26
  280. package/zh/tutorials/foundations/introduction.mdx +14 -29
  281. package/en/apis/app/commands/_category_.json +0 -8
  282. package/en/apis/app/commands/build.mdx +0 -39
  283. package/en/apis/app/commands/dev.mdx +0 -61
  284. package/en/apis/app/commands/index.mdx +0 -7
  285. package/en/apis/app/commands/inspect.mdx +0 -61
  286. package/en/apis/app/commands/lint.mdx +0 -19
  287. package/en/apis/app/commands/new.mdx +0 -54
  288. package/en/apis/app/commands/serve.mdx +0 -27
  289. package/en/apis/app/commands/test.mdx +0 -35
  290. package/en/apis/app/commands/upgrade.mdx +0 -18
  291. package/en/apis/app/hooks/index.mdx +0 -7
  292. package/en/apis/app/runtime/index.mdx +0 -7
  293. package/en/guides/advanced-features/index.mdx +0 -7
  294. package/en/guides/basic-features/css/_category_.json +0 -4
  295. package/zh/apis/app/commands/_category_.json +0 -8
  296. package/zh/apis/app/commands/build.mdx +0 -39
  297. package/zh/apis/app/commands/dev.mdx +0 -61
  298. package/zh/apis/app/commands/index.mdx +0 -7
  299. package/zh/apis/app/commands/inspect.mdx +0 -61
  300. package/zh/apis/app/commands/lint.mdx +0 -19
  301. package/zh/apis/app/commands/new.mdx +0 -54
  302. package/zh/apis/app/commands/serve.mdx +0 -27
  303. package/zh/apis/app/commands/test.mdx +0 -35
  304. package/zh/apis/app/commands/upgrade.mdx +0 -18
  305. package/zh/apis/app/hooks/index.mdx +0 -7
  306. package/zh/apis/app/runtime/index.mdx +0 -7
  307. package/zh/guides/advanced-features/index.mdx +0 -7
  308. package/zh/guides/basic-features/css/_category_.json +0 -4
  309. package/zh/guides/basic-features/index.mdx +0 -7
  310. /package/en/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
  311. /package/en/guides/{basic-features/css → css}/css-modules.mdx +0 -0
  312. /package/en/guides/{basic-features/css → css}/postcss.mdx +0 -0
  313. /package/en/guides/{basic-features/css → css}/tailwindcss.mdx +0 -0
  314. /package/zh/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
  315. /package/zh/guides/{basic-features/css → css}/css-modules.mdx +0 -0
@@ -23,10 +23,10 @@ Modern.js 允许在 JS 和 CSS 中使用别名导入自定义目录下的模块
23
23
  ```bash
24
24
  .
25
25
  ├── common
26
-    ├── styles
27
-       └── base.css
28
-    └── utils
29
-    └── index.ts
26
+ ├── styles
27
+ └── base.css
28
+ └── utils
29
+ └── index.ts
30
30
  ├── App.tsx
31
31
  ```
32
32
 
@@ -62,4 +62,4 @@ export default defineConfig({
62
62
  });
63
63
  ```
64
64
 
65
- 具体别名配置可以参考 [API 资料 - source.alias](/configure/app/source/alias)】。
65
+ 对于别名配置的具体用法,请参考 [source.alias 文档](/configure/app/source/alias)
@@ -2,6 +2,7 @@
2
2
  title: 数据获取
3
3
  sidebar_position: 3
4
4
  ---
5
+
5
6
  # 数据获取
6
7
 
7
8
  Modern.js 中提供了开箱即用的数据获取能力,开发者可以通过这些 API,在 CSR 和 SSR 环境同构的进行开发。
@@ -81,9 +82,9 @@ export default async (): Promise<ProfileData> => {
81
82
 
82
83
  ```tsx
83
84
  // routes/user/[id]/page.loader.ts
84
- import { LoaderArgs } from '@modern-js/runtime/router';
85
+ import { LoaderFunctionArgs } from '@modern-js/runtime/router';
85
86
 
86
- export default async ({ params }: LoaderArgs) => {
87
+ export default async ({ params }: LoaderFunctionArgs) => {
87
88
  const { id } = params;
88
89
  const res = await fetch(`https://api/user/${id}`);
89
90
  return res.json();
@@ -100,9 +101,9 @@ export default async ({ params }: LoaderArgs) => {
100
101
 
101
102
  ```tsx
102
103
  // routes/user/[id]/page.loader.ts
103
- import { LoaderArgs } from '@modern-js/runtime/router';
104
+ import { LoaderFunctionArgs } from '@modern-js/runtime/router';
104
105
 
105
- export default async ({ request }: LoaderArgs) => {
106
+ export default async ({ request }: LoaderFunctionArgs) => {
106
107
  const url = new URL(request.url);
107
108
  const userId = url.searchParams.get('id');
108
109
  return queryUser(userId);
@@ -220,38 +221,46 @@ export default function UserLayout() {
220
221
 
221
222
  :::
222
223
 
224
+ 创建 `user/layout.loader.ts`,并添加以下代码:
225
+
226
+ ```ts title="routes/user/layout.loader.ts"
227
+ import { defer } from "@edenx/runtime/router"
228
+
229
+ const loader = () =>
230
+ defer({
231
+ userInfo: new Promise((resolve) => {
232
+ setTimeout(() => {
233
+ resolve({
234
+ age: 1,
235
+ name: 'user layout'
236
+ })
237
+ }, 1000)
238
+ })
239
+ })
240
+
241
+ export default loader;
242
+ ```
243
+
223
244
  在 `user/layout.tsx` 中添加以下代码:
224
245
 
225
246
  ```tsx title="routes/user/layout.tsx"
226
- import {
227
- Await,
228
- defer,
229
- useLoaderData,
230
- Outlet
231
- } from '@modern-js/runtime/router';
232
-
233
- export const loader = () => {
234
- return defer({
235
- // fetchUserInfo 是一个异步函数,返回用户信息
236
- userInfo: fetchUserInfo(),
237
- })
238
- }
247
+ import { Await, defer, useLoaderData, Outlet } from '@modern-js/runtime/router';
239
248
 
240
249
  export default function UserLayout() {
241
- const { userInfo } = useLoaderData() as {userInfo: Promise<UserInfo>};
250
+ const { userInfo } = useLoaderData() as { userInfo: Promise<UserInfo> };
242
251
  return (
243
252
  <div>
244
- <React.Suspense
245
- fallback={<p>Loading...</p>}
246
- >
247
- <Await resolve={userInfo} children={userInfo => (
248
- <div>
249
- <span>{userInfo.name}</span>
250
- <span>{userInfo.age}</span>
251
- <Outlet>
252
- </div>
253
- )}>
254
- </Await>
253
+ <React.Suspense fallback={<p>Loading...</p>}>
254
+ <Await
255
+ resolve={userInfo}
256
+ children={userInfo => (
257
+ <div>
258
+ <span>{userInfo.name}</span>
259
+ <span>{userInfo.age}</span>
260
+ <Outlet />
261
+ </div>
262
+ )}
263
+ ></Await>
255
264
  </React.Suspense>
256
265
  </div>
257
266
  );
@@ -265,7 +274,7 @@ defer 的具体用法请查看 [defer](https://reactrouter.com/en/main/guides/de
265
274
 
266
275
  :::
267
276
 
268
- {/* TODO 缓存相关 */}
277
+ {/* TODO 缓存相关 */}
269
278
 
270
279
  ### 错误用法
271
280
 
@@ -2,9 +2,10 @@
2
2
  title: HTML 模板
3
3
  sidebar_position: 9
4
4
  ---
5
+
5
6
  # HTML 模板
6
7
 
7
- Modern.js 提供了 **JSX 语法**和**HTML(Ejs) 语法**两种方式用于自定义 HTML 模板。
8
+ Modern.js 提供了 **JSX 语法**和 **HTML(EJS) 语法**两种方式用于自定义 HTML 模板。
8
9
 
9
10
  ## JSX 语法
10
11
 
@@ -14,14 +15,14 @@ Modern.js 约定,在 `src/` 目录下,或在入口目录下,可以创建 `
14
15
 
15
16
  ```bash
16
17
  .
17
- ├── src
18
- │   ├── Document.tsx
19
- │   ├── entry-a
20
-    │   ├── Document.tsx
21
-    │   └── routes
22
- │   ├── entry-b
23
-    │   └── routes
24
- │   └── modern-app-env.d.ts
18
+ └── src
19
+ ├── Document.tsx
20
+ ├── entry-a
21
+ ├── Document.tsx
22
+ └── routes
23
+ ├── entry-b
24
+ └── routes
25
+ └── modern-app-env.d.ts
25
26
  ```
26
27
 
27
28
  `entry-a` 会优先使用当前入口下的 `Docoument.[jt]sx` 文件。如果当前入口没有 `Document.[jt]sx` 文件,例如 `entry-b`,则会查找根目录下的 `Document.[jt]sx` 文件。
@@ -77,3 +77,23 @@ module.exports = {
77
77
  },
78
78
  };
79
79
  ```
80
+
81
+ ## 按需使用 Mock 服务
82
+
83
+ `config/mock/index.ts` 下还可以到处 `config` 对象,更精细的控制 Mock 服务。
84
+
85
+ ```ts
86
+ type MockConfig = {
87
+ enable: ((req: IncomingMessage, res: ServerResponse) => boolean) | boolean;
88
+ };
89
+
90
+ export const config = {
91
+ enable: false
92
+ }
93
+ ```
94
+
95
+ 目前仅支持 `enable` 配置,开发者可以通过该配置控制是否执行 Mock。
96
+
97
+ :::note
98
+ 修改 `config` 后无需重启服务,即刻生效。
99
+ :::
@@ -4,7 +4,7 @@ sidebar_position: 1
4
4
  ---
5
5
  # 路由
6
6
 
7
- Modern.js 的路由基于 [React Router 6](https://reactrouter.com/en/main),并提供了多种类型的路由模式。根据不同[入口](/docs/guides/concept/entries)类型,将路由分为三种模式,分别是**约定式路由**,**自控式路由**和**其他路由方案**。
7
+ Modern.js 的路由基于 [React Router 6](https://reactrouter.com/en/main),并提供了多种类型的路由模式。根据不同 [入口](/guides/concept/entries) 类型,将路由分为三种模式,分别是**约定式路由**,**自控式路由**和**其他路由方案**。
8
8
 
9
9
  :::note
10
10
  本小节提到的路由,都是客户端路由,即 SPA 路由。
@@ -109,7 +109,7 @@ export default () => {
109
109
  .
110
110
  └── routes
111
111
  ├── blog
112
-    └── page.tsx
112
+ └── page.tsx
113
113
  ├── layout.tsx
114
114
  ├── page.tsx
115
115
  └── user
@@ -156,15 +156,15 @@ export default () => {
156
156
  ```
157
157
  └── routes
158
158
  ├── [id]
159
-    └── page.tsx
159
+ └── page.tsx
160
160
  ├── blog
161
-    └── page.tsx
161
+ └── page.tsx
162
162
  └── page.tsx
163
163
  ```
164
164
 
165
165
  `routes/[id]/page.tsx` 文件会转为 `/:id` 路由。除了可以确切匹配的 `/blog` 路由,其他所有 `/xxx` 都会匹配到该路由。
166
166
 
167
- 在组件中,可以通过 [useParams](/apis/app/runtime/router/#useparams) 获取对应命名的参数。
167
+ 在组件中,可以通过 [useParams](/apis/app/runtime/router/router#useparams) 获取对应命名的参数。
168
168
 
169
169
  在 loader 中,params 会作为 [loader](/guides/basic-features/data-fetch#loader-函数) 的入参,通过 `params.xxx` 可以获取。
170
170
 
@@ -181,11 +181,11 @@ export default () => {
181
181
  └── routes
182
182
  ├── $.tsx
183
183
  ├── blog
184
-    └── page.tsx
184
+ └── page.tsx
185
185
  └── page.tsx
186
186
  ```
187
187
 
188
- 当访问任何匹配不到的路径时,都会渲染 `routes/$.tsx` 组件,同样,`$.tsx` 中可以使用 [useParams](/apis/app/runtime/router/#useparams) 捕获 url 的剩余部分。
188
+ 当访问任何匹配不到的路径时,都会渲染 `routes/$.tsx` 组件,同样,`$.tsx` 中可以使用 [useParams](/apis/app/runtime/router/router#useparams) 捕获 url 的剩余部分。
189
189
  ```ts title="$.tsx"
190
190
  import { useParams } from '@modern-js/runtime/router';
191
191
  // 当 path 是 `/aaa/bbb` 时
@@ -248,9 +248,9 @@ Modern.js 会生成 `/login` 和 `/sign` 两条路由,`__auth/layout.tsx` 组
248
248
  .
249
249
  └── routes
250
250
  ├── blog
251
-    ├── [id]
252
-       └── page.tsx
253
-    └── page.tsx
251
+ ├── [id]
252
+ └── page.tsx
253
+ └── page.tsx
254
254
  ├── layout.tsx
255
255
  ├── loading.tsx
256
256
  └── page.tsx
@@ -292,6 +292,22 @@ Modern.js 建议必须有根 layout 和根 loading。
292
292
 
293
293
  同理,当路由从 `/` 或者 `/blog` 跳转到 `/blog/123` 时,如果 `blog/[id]/page` 组件的 JS Chunk 还未加载,也会先展示 `loading.tsx` 中导出的组件 UI。
294
294
 
295
+ ### 路由重定向
296
+
297
+ 可以通过创建 [`data loader`](/guides/basic-features/data-fetch) 文件做路由的重定向,如有文件 `routes/user/page.tsx`,想对这个文件对应的路由做重定向,可以创建 `routes/user/page.loader.ts` 文件:
298
+
299
+ ```ts title="routes/user/page.loader.ts"
300
+ import { redirect } from "@edenx/runtime/router"
301
+
302
+ export default () => {
303
+ const user = await getUser();
304
+ if(!user){
305
+ return redirect('/login');
306
+ }
307
+ return null;
308
+ }
309
+ ```
310
+
295
311
  ### 错误处理
296
312
 
297
313
  `routes/` 下每一层目录中,开发者同样可以定义一个 `error.tsx` 文件,默认导出一个 `<ErrorBoundary>` 组件。
@@ -302,7 +318,7 @@ Modern.js 建议必须有根 layout 和根 loading。
302
318
 
303
319
  {/* Todo API 路由 */}
304
320
 
305
- 在 `<ErrorBoundary>` 组件内,可以使用 [useRouteError](/apis/app/runtime/router/#useparams) 获取的错误的具体信息:
321
+ 在 `<ErrorBoundary>` 组件内,可以使用 [useRouteError](/apis/app/runtime/router/router#useparams) 获取的错误的具体信息:
306
322
 
307
323
  ```tsx
308
324
  import { useRouteError } from '@modern-js/runtime/router';
@@ -329,8 +345,15 @@ import type { AppConfig } from '@modern-js/runtime';
329
345
  export const config = (): AppConfig => {
330
346
  return {
331
347
  router: {
332
- supportHtml5History: false
333
- }
348
+ createRoutes() {
349
+ return [
350
+ {
351
+ path: 'edenx',
352
+ element: <div>edenx</div>,
353
+ },
354
+ ];
355
+ },
356
+ },
334
357
  }
335
358
  };
336
359
  ```
@@ -380,12 +403,10 @@ export default () => {
380
403
  配合 SSR 功能时,浏览器端可以获取到 SSR 时 `init` 返回的数据,开发者可以自行判断是否要在浏览器端重新获取数据来覆盖 SSR 数据,例如:
381
404
 
382
405
  ```tsx title="src/routes/layout.tsx"
383
- import {
384
- RuntimeContext,
385
- } from '@modern-js/runtime';
406
+ import { RuntimeContext } from '@modern-js/runtime';
386
407
 
387
408
  export const init = (context: RuntimeContext) => {
388
- if (process.env.JUPITER_TARGET === 'node') {
409
+ if (process.env.MODERN_TARGET === 'node') {
389
410
  return {
390
411
  message: 'Hello World By Server',
391
412
  }
@@ -1,12 +1,12 @@
1
1
  ---
2
- title: 构建能力
3
2
  sidebar_position: 2
4
3
  ---
5
- # 构建能力
4
+
5
+ # 构建引擎
6
6
 
7
7
  **Modern.js 的构建能力由 [Modern.js Builder](https://modernjs.dev/builder) 提供。**
8
8
 
9
- Modern.js Builder 是 Modern.js 体系的核心组件之一,它是一个面向 Web 开发场景的构建引擎,可以脱离 Modern.js 被独立使用。Modern.js Builder 同时支持 webpack 和 Rspack 等多种打包工具,默认情况下使用最成熟的 webpack 进行打包。
9
+ Modern.js Builder 是 Modern.js 体系的核心组件之一,它是一个面向 Web 开发场景的构建引擎,可以脱离 Modern.js 被独立使用。Modern.js Builder 同时支持 webpack 和 rspack 等多种打包工具,默认情况下使用最成熟的 webpack 进行打包。
10
10
 
11
11
  ## 构建架构
12
12
 
@@ -14,7 +14,7 @@ Modern.js Builder 是 Modern.js 体系的核心组件之一,它是一个面向
14
14
 
15
15
  - 上层研发框架:Modern.js。
16
16
  - 通用构建引擎:Modern.js Builder。
17
- - 底层打包工具:webpack 和 Rspack
17
+ - 底层打包工具:webpack 和 rspack
18
18
 
19
19
  <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/builder-layers-1117.png" style={{ maxWidth: '540px' }} />
20
20
 
@@ -1,7 +1,7 @@
1
1
  ---
2
- title: 入口
3
- sidebar_position: 2
2
+ sidebar_position: 1
4
3
  ---
4
+
5
5
  # 入口
6
6
 
7
7
  入口是 Modern.js 默认的文件约定,项目的每一个入口是一张独立的页面,对应一条**服务端路由**。
@@ -15,11 +15,11 @@ Modern.js 初始化的项目是单入口的,项目结构如下:
15
15
  ```
16
16
  .
17
17
  ├── src
18
-    ├── modern-app-env.d.ts
19
-    └── routes
20
-    ├── index.css
21
-    ├── layout.tsx
22
-    └── page.tsx
18
+ ├── modern-app-env.d.ts
19
+ └── routes
20
+ ├── index.css
21
+ ├── layout.tsx
22
+ └── page.tsx
23
23
  ├── package.json
24
24
  ├── modern.config.ts
25
25
  ├── pnpm-lock.yaml
@@ -41,10 +41,10 @@ Modern.js 可以很方便的将单入口切换成多入口。可以在项目下
41
41
  .
42
42
  ├── modern-app-env.d.ts
43
43
  ├── myapp
44
-    └── routes
45
-    ├── index.css
46
-    ├── layout.tsx
47
-    └── page.tsx
44
+ └── routes
45
+ ├── index.css
46
+ ├── layout.tsx
47
+ └── page.tsx
48
48
  └── new-entry
49
49
  └── routes
50
50
  ├── index.css
@@ -0,0 +1,5 @@
1
+ {
2
+ "label": "CSS 开发方案",
3
+ "position": 5,
4
+ "collapsed": false
5
+ }
@@ -12,6 +12,6 @@ sidebar_position: 4
12
12
  - 如果需要自定义 [sass-loader](https://github.com/webpack-contrib/sass-loader) 的配置,请参考 [tools.less](/configure/app/tools/sass) 配置项。
13
13
 
14
14
  :::tip 提示
15
- 经过 Less 和 Sass 预编译后的 CSS 文件,仍然会经过 Modern.js 内置的 [PostCSS](https://postcss.org/) 的转换,具备良好的浏览器兼容性。相关内容请参考【[PostCSS](/guides/basic-features/css/postcss)】。
15
+ 经过 Less 和 Sass 预编译后的 CSS 文件,仍然会经过 Modern.js 内置的 [PostCSS](https://postcss.org/) 的转换,具备良好的浏览器兼容性。相关内容请参考【[PostCSS](/guides/css/postcss)】。
16
16
 
17
17
  :::
@@ -10,10 +10,11 @@ sidebar_position: 3
10
10
 
11
11
  1. [Autoprefixer](https://github.com/postcss/autoprefixer) 根据需要支持的浏览器范围,会自动为 CSS 规则添加需要的浏览器厂商前缀。Modern.js 默认支持的浏览器范围为:`['> 0.01%', 'not dead', 'not op_mini all']`。
12
12
 
13
- :::info
14
- - 【支持的浏览器范围为:`> 0.01%`】是指浏览器市场份额大于 0.01%。
15
- - `not dead` 是指不包含官方不再支持的浏览器和过去24个月没有更新的浏览器。
16
- - `not op_mini all` 是指不包含 Opera Mini。
13
+ :::info 注意
14
+
15
+ - 【支持的浏览器范围为:`> 0.01%`】是指浏览器市场份额大于 0.01%。
16
+ - `not dead` 是指不包含官方不再支持的浏览器和过去 24 个月没有更新的浏览器。
17
+ - `not op_mini all` 是指不包含 Opera Mini。
17
18
 
18
19
  :::
19
20
 
@@ -18,7 +18,6 @@ sidebar_position: 2
18
18
  ```ts title="modern.config.ts"
19
19
  import tailwindcssPlugin from '@modern-js/plugin-tailwindcss';
20
20
 
21
- // https://modernjs.dev/docs/apis/app/config
22
21
  export default defineConfig({
23
22
  plugins: [..., tailwindcssPlugin()],
24
23
  });
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: 介绍
3
+ sidebar_position: 1
4
+ ---
5
+
6
+ # Modern.js 介绍
7
+
8
+ **Modern.js** 是基于 React 的渐进式现代 Web 开发框架。
9
+
10
+ 框架内置多种开箱即用的开发工具,拥有极致的构建性能,支持零配置的渲染范式切换,一体化的 API 调用。并从三种工程方案出发(应用工程方案、模块工程方案,Monorepo 工程方案),支持全链路的前端研发。
11
+
12
+ Modern.js 是字节跳动的底层前端研发框架,已经直接或间接的服务上千个应用,包括中后台、PC Web、H5 等多种应用场景。框架覆盖完整的生命周期,拥有完善的插件体系,提供高度定制能力。支持通过生成器插件自定义业务线专属的工程方案,定制各种功能扩展和业务需求,帮助开发者更快速的搭建应用。
13
+
14
+ ## 为什么使用 Modern.js
15
+
16
+ Modern.js 能为开发者提供极致的**开发体验(Development Experience)**,让应用拥有更好的**用户体验(User Experience)**。
17
+
18
+ 在开发 React 应用过程中,开发者通常需要去为某些功能去设计实现方案,或是使用其他的库、框架来解决这些问题。Modern.js 支持 React 应用所需要的所有配置和工具,并内置**额外的功能和优化**。开发者可以使用 React 构建应用的 UI,然后逐步采用 Modern.js 的功能来解决常见的应用需求,如路由、数据获取、状态管理等。
19
+
20
+ 它主要包含以下特点:
21
+
22
+ - 🪜 **渐进式**:使用最精简的模板创建项目,通过生成器逐步开启插件功能,定制解决方案。
23
+ - 🏠 **一体化**:开发与生产环境 Web Server 唯一,CSR 和 SSR 同构开发,函数即接口的 API 服务调用。
24
+ - 📦 **开箱即用**:默认 TS 支持,内置构建、ESLint、调试工具,全功能可测试。
25
+ - 🌏 **周边生态**:自研状态管理、微前端、模块打包、Monorepo 方案等周边需求。
26
+ - 🕸 **多种路由模式**:包含自控路由、基于文件约定的路由(嵌套路由)等。
27
+ - 🚀 **独立构建核心**:支持多种打包工具,深度优化构建产物。
28
+
29
+ ## 下一步
30
+
31
+ 如果你希望了解如何使用 Modern.js,可以尝试 [创建第一个应用](/tutorials/first-app/c01-start),或是阅读 [快速上手](/guides/get-started/quick-start)。
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: 快速上手
3
- sidebar_position: 1
3
+ sidebar_position: 2
4
4
  ---
5
5
  # 快速上手
6
6
 
@@ -45,10 +45,9 @@ import DebugApp from "@site-docs/components/debug-app"
45
45
 
46
46
  可以通过配置文件来开启功能,或覆盖 Modern.js 的默认行为。例如添加如下配置,开启 SSR:
47
47
 
48
- ```ts
48
+ ```ts title="modern.config.ts"
49
49
  import appTools, { defineConfig } from '@modern-js/app-tools';
50
50
 
51
- // https://modernjs.dev/docs/apis/app/config
52
51
  export default defineConfig({
53
52
  runtime: {
54
53
  router: true,
@@ -97,9 +96,9 @@ info File sizes after production build:
97
96
  .
98
97
  ├── asset-manifest.json
99
98
  ├── html
100
-    └── main
99
+ └── main
101
100
  ├── loader-routes
102
-    └── main
101
+ └── main
103
102
  ├── modern.config.json
104
103
  ├── route.json
105
104
  └── static
@@ -1,7 +1,8 @@
1
1
  ---
2
2
  title: 升级
3
- sidebar_position: 2
3
+ sidebar_position: 3
4
4
  ---
5
+
5
6
  # 升级
6
7
 
7
8
  ## 通过命令行升级
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "label": "专题详解",
3
- "position": 5,
4
- "collapsed": true
3
+ "position": 6,
4
+ "collapsed": false
5
5
  }
@@ -45,7 +45,7 @@ context.addInputBefore('packageManager', {
45
45
  });
46
46
  ```
47
47
 
48
- :::info意事项
48
+ :::info 注意事项
49
49
 
50
50
  1. 添加问题的 key 不能和 Modern.js 提供的项目类型自身的问题的 key 重复
51
51
 
@@ -251,6 +251,31 @@ export default (props: {basename: string}) => {
251
251
 
252
252
  在完成了微前端整体开发流程的体验后,你可以进一步了解如何 [开发主应用](/guides/topic-detail/micro-frontend/c03-main-app)
253
253
 
254
+ ## Modern.js 微前端和直接使用 Garfish 的区别
255
+
256
+ 使用纯 `Garfish` API 开发微前端应用时
257
+ - 主应用:
258
+ - 安装 Garfish 依赖并使用 `Garfish.run` 注册子应用 [参考](https://www.garfishjs.org/api/run)
259
+ - 提供一个常驻的 `DOM` 节点供子应用挂载 [参考](https://www.garfishjs.org/api/registerApp#domgetter)
260
+ - 子应用:
261
+ - 导出 `provider` [参考](https://www.garfishjs.org/guide/start#2%E5%AF%BC%E5%87%BA-provider-%E5%87%BD%E6%95%B0)
262
+ - 设置应用的 `basename` [参考](https://www.garfishjs.org/guide/start#3-%E8%AE%BE%E7%BD%AE%E5%BA%94%E7%94%A8%E8%B7%AF%E7%94%B1-basename)
263
+
264
+ 区别于直接使用 `Garfish` 运行时 API 开发微前端项目,`Modern.js` 的微前端方案更加开箱即用。
265
+ 使用 `pnpm new` 启用微前端模式后会自动在 `Modern.js` 应用中集成 `Garfish` 插件,在 `Garfish`
266
+ 插件的加持下,你只需要
267
+ - 主应用:
268
+ - 配置 `runtime.masterApp.apps` 参数注册子应用
269
+ - 使用 `useModuleApps` API 获取子应用实例并在组件中完成渲染
270
+ - 子应用:
271
+ - 配置 `deploy.microFrontend`
272
+
273
+ 所以插件中为你做了如下事情
274
+ - 帮助你通过 `Garfish` 运行时 API 自动注册子应用(主应用)
275
+ - `useModulesApps` 函数的返回值提供了一个常驻的 `DOM` 节点供子应用挂载(主应用)
276
+ - 帮助你正确导出了 `provider`(子应用)
277
+ - 帮助你正确设置了 `basename` 给 `Modern.js` 运行时提供 `Router` 实例,如果是`自控式路由`或`手动引入的 react-router-dom` 那么需要从 `App.tsx` 的 `props` 中获取 `basename` 手动传递给引入的 `Router 实例`(子应用)
278
+
254
279
  ## 常见问题
255
280
 
256
281
  自查手册: https://www.garfishjs.org/issues/
@@ -4,7 +4,7 @@ title: 开发主应用
4
4
  ---
5
5
  # 开发主应用
6
6
 
7
- 在上一章 [体验微前端](/guides/topic-detail/micro-frontend/c02-development.md) 通过一个示例演示了如何创建和配置微前端子应用,通过本章你可以进一步了解如何开发主应用,以及它的常见配置。
7
+ 在上一章 [体验微前端](/guides/topic-detail/micro-frontend/c02-development) 通过一个示例演示了如何创建和配置微前端子应用,通过本章你可以进一步了解如何开发主应用,以及它的常见配置。
8
8
 
9
9
  在通过 `@modern-js/create` 命令创建应用工程后,可以在项目中执行 `pnpm run new`(实际执行了 `modern new` 命令),在选择了「微前端」模式后,会安装微前端依赖依赖,只需手动注册插件即可。
10
10
 
@@ -41,13 +41,13 @@ defineConfig(App, {
41
41
  getAppList: async () => {
42
42
  // 可以从其他远程接口获取
43
43
  return [{
44
- name: 'SubConvention',
45
- entry: 'http://localhost:3002',
46
- // activeWhen: '/SubConvention'
44
+ name: 'Table',
45
+ entry: 'http://localhost:8001',
46
+ // activeWhen: '/table'
47
47
  }, {
48
- name: 'SubCustom',
49
- entry: 'http://localhost:3003'
50
- // activeWhen: '/SubConvention'
48
+ name: 'Dashboard',
49
+ entry: 'http://localhost:8002'
50
+ // activeWhen: '/dashboard'
51
51
  }];
52
52
  },
53
53
  },
@@ -81,8 +81,8 @@ import { RouterProvider, Route, createBrowserRouter, createRoutesFromElements, B
81
81
 
82
82
  const AppLayout = () => (
83
83
  <>
84
- <div><Link to={'/SubConvention'}>加载约定式路由子应用</Link></div>
85
- <div><Link to={'/SubCustom'}>加载自控式路由子应用</Link></div>
84
+ <div><Link to={'/table'}>加载约定式路由子应用</Link></div>
85
+ <div><Link to={'/dashboard'}>加载自控式路由子应用</Link></div>
86
86
  <div><Link to={'/'}>卸载子应用</Link></div>
87
87
  <Outlet />
88
88
  </>
@@ -101,7 +101,7 @@ export default () => {
101
101
  return (
102
102
  <Route
103
103
  key={app.name}
104
- path={`${app.name}/*`}
104
+ path={`${app.name.toLowerCase()}/*`}
105
105
  element={
106
106
  <Component
107
107
  loadable={{
@@ -138,7 +138,7 @@ export default () => {
138
138
  };
139
139
  ```
140
140
 
141
- 这里通过 `Route` 组件自定义了 **SubConvention** 的激活路由为 **/SubConvention**, **SubCustom** 的激活路由为 **/SubCustom**。
141
+ 这里通过 `Route` 组件自定义了 **Table** 的激活路由为 **/table**, **Dashboard** 的激活路由为 **/dashboard**。
142
142
 
143
143
  ### 集中式路由
144
144
 
@@ -149,7 +149,7 @@ export default () => {
149
149
  然后在主应用中使用 `useModuleApp` 方法获取 `MApp` 组件, 并在主应用渲染 `MApp`。
150
150
 
151
151
  ```tsx title=主应用:App.tsx
152
- import { useModuleApp } from '@modern-js/plugin-runtime';
152
+ import { useModuleApp } from '@modern-js/plugin-garfish/runtime';
153
153
 
154
154
  function App() {
155
155
  const { MApp } = useModuleApps();
@@ -162,7 +162,7 @@ function App() {
162
162
  }
163
163
  ```
164
164
 
165
- 这样启动应用后,访问 `/SubCustom` 路由,会渲染 `SubCustom` 子应用,访问 `/SubConvention` 路由,会渲染 `SubConvention` 子应用。
165
+ 这样启动应用后,访问 `/table` 路由,会渲染 `Table` 子应用,访问 `/dashboard` 路由,会渲染 `Dashboard` 子应用。
166
166
 
167
167
  ### 两种模式混用
168
168
 
@@ -182,7 +182,7 @@ function Loading() {
182
182
 
183
183
  function App(){
184
184
  return <>
185
- <SubCustom
185
+ <Table
186
186
  loadable={{
187
187
  loading: Loading,
188
188
  }}
@@ -229,7 +229,7 @@ function Loading({ error, pastDelay }) {
229
229
 
230
230
  function App(){
231
231
  return <>
232
- <SubCustom
232
+ <Table
233
233
  loadable={{
234
234
  loading: Loading,
235
235
  delay: 300 // 0.3 seconds
@@ -265,7 +265,7 @@ function Loading({ error, timeOut, pastDelay }) {
265
265
 
266
266
  function App(){
267
267
  return <>
268
- <SubCustom
268
+ <Table
269
269
  loadable={{
270
270
  loading: Loading,
271
271
  timeOut: 10000 // 10s