@modern-js/main-doc 2.0.0-canary.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/_category_.json +1 -1
  3. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-module-apps.md +62 -31
  4. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/router/router.md +174 -375
  5. package/en/docusaurus-plugin-content-docs/current/components/enable-micro-frontend.md +13 -0
  6. package/en/docusaurus-plugin-content-docs/current/components/micro-master-manifest-config.md +15 -0
  7. package/en/docusaurus-plugin-content-docs/current/components/micro-runtime-config.md +18 -0
  8. package/en/docusaurus-plugin-content-docs/current/components/router-legacy-tip.md +1 -0
  9. package/en/docusaurus-plugin-content-docs/current/configure/app/auto-load-plugin.md +62 -0
  10. package/en/docusaurus-plugin-content-docs/current/configure/app/deploy/microFrontend.md +54 -0
  11. package/en/docusaurus-plugin-content-docs/current/configure/app/output/ssg.md +226 -0
  12. package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/master-app.md +20 -39
  13. package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/router.md +17 -4
  14. package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/state.md +17 -4
  15. package/en/docusaurus-plugin-content-docs/current/configure/app/server/enable-framework-ext.md +47 -0
  16. package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/function.md +2 -2
  17. package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/ssg.md +6 -2
  18. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/_category_.json +4 -0
  19. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/data-fetch.md +1 -1
  20. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/routes.md +0 -2
  21. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/_category_.json +5 -0
  22. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/extend.md +162 -0
  23. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook-list.md +803 -0
  24. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook.md +169 -0
  25. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/implement.md +247 -0
  26. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/introduction.md +49 -0
  27. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/plugin-api.md +116 -0
  28. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/relationship.md +118 -0
  29. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/common.md +1 -1
  30. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/module.md +3 -1
  31. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/mwa.md +1 -9
  32. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/project.md +2 -2
  33. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/_category_.json +4 -0
  34. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c01-introduction.md +29 -0
  35. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c02-development.md +191 -0
  36. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c03-main-app.md +246 -0
  37. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c04-communicate.md +54 -0
  38. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c05-mixed-stack.md +24 -0
  39. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/_category_.json +4 -0
  40. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/auto-actions.md +90 -0
  41. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/computed-state.md +151 -0
  42. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/define-model.md +66 -0
  43. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/faq.md +43 -0
  44. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/manage-effects.md +259 -0
  45. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/model-communicate.md +219 -0
  46. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/performance.md +173 -0
  47. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/quick-start.md +116 -0
  48. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/redux-integration.md +21 -0
  49. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/test-model.md +43 -0
  50. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/typescript-best-practice.md +71 -0
  51. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/use-model.md +244 -0
  52. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/use-out-of-modernjs.md +51 -0
  53. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/_category_.json +5 -0
  54. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c01-start.md +99 -0
  55. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c02-component.md +56 -0
  56. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c03-css.md +324 -0
  57. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c04-routes.md +169 -0
  58. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c05-loader.md +82 -0
  59. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c06-model.md +260 -0
  60. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c07-container.md +283 -0
  61. package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c08-entries.md +137 -0
  62. package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/_category_.json +1 -1
  63. package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/introduction.md +5 -3
  64. package/package.json +4 -4
  65. package/zh/apis/app/runtime/core/use-module-apps.md +2 -0
  66. package/zh/apis/app/runtime/router/router.md +169 -371
  67. package/zh/components/micro-master-manifest-config.md +15 -0
  68. package/zh/components/router-legacy-tip.md +1 -0
  69. package/zh/configure/app/auto-load-plugin.md +62 -0
  70. package/zh/configure/app/deploy/microFrontend.md +0 -10
  71. package/zh/configure/app/output/ssg.md +1 -5
  72. package/zh/configure/app/runtime/master-app.md +4 -18
  73. package/zh/configure/app/runtime/router.md +19 -4
  74. package/zh/configure/app/runtime/state.md +7 -7
  75. package/zh/configure/app/server/enable-framework-ext.md +47 -0
  76. package/zh/configure/app/server/port.md +1 -1
  77. package/zh/configure/app/tools/_category_.json +1 -1
  78. package/zh/guides/advanced-features/eslint.md +2 -1
  79. package/zh/guides/advanced-features/ssg.md +4 -0
  80. package/zh/guides/basic-features/data-fetch.md +1 -1
  81. package/zh/guides/basic-features/env-vars.md +1 -1
  82. package/zh/guides/basic-features/routes.md +0 -3
  83. package/zh/guides/topic-detail/generator/config/module.md +3 -1
  84. package/zh/guides/topic-detail/generator/config/mwa.md +1 -9
  85. package/zh/guides/topic-detail/model/quick-start.md +1 -1
  86. package/zh/tutorials/first-app/c06-model.md +5 -1
  87. package/zh/tutorials/first-app/c08-entries.md +1 -1
  88. package/zh/tutorials/foundations/introduction.md +5 -3
  89. package/en/docusaurus-plugin-content-docs/current/apis/app/overview.md +0 -12
  90. package/en/docusaurus-plugin-content-docs/current/configure/app/bff/fetcher.md +0 -28
  91. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/with-master-app.md +0 -31
  92. package/en/docusaurus-plugin-content-docs/current/guides/overview.md +0 -11
  93. package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/basic.md +0 -8
  94. package/zh/apis/app/overview.md +0 -11
  95. package/zh/apis/monorepo/overview.md +0 -11
  96. package/zh/configure/app/bff/fetcher.md +0 -31
  97. package/zh/configure/app/dev/with-master-app.md +0 -32
  98. package/zh/guides/overview.md +0 -11
  99. package/zh/tutorials/foundations/basic.md +0 -8
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: autoLoadPlugins (自动注册插件)
3
+ sidebar_position: 11
4
+ ---
5
+
6
+ - 类型:`boolean`
7
+ - 默认值:`false`
8
+
9
+ 用于配置 Modern.js 是否开启自动注册插件。
10
+
11
+ ### 手动注册插件
12
+
13
+ 默认情况下,安装插件后需要你在 `modern.config.ts` 文件中手动注册插件。
14
+
15
+ ```ts title="modern.config.ts"
16
+ import AppToolsPlugin, { defineConfig } from '@modern-js/app-tools';
17
+ import I18nPlugin from '@modern-js/plugin-i18n';
18
+
19
+ default export defineConfig({
20
+ plugins: [AppToolsPlugin(), I18nPlugin()]
21
+ })
22
+
23
+ ```
24
+
25
+ ### 自动注册插件
26
+
27
+ 除了手段注册,Modern.js 还提供自动注册插件的方式: 将 `autoLoadPlugin` 配置项置为 `true`。
28
+
29
+ ```ts title="modern.config.ts"
30
+ import { defineConfig } from '@modern-js/app-tools';
31
+
32
+ default export defineConfig({
33
+ autoLoadPlugins: true
34
+ })
35
+ ```
36
+
37
+ Modern.js 将通过以下几个步骤帮你自动注册插件
38
+
39
+ 1. Modern.js 在内部维护一份官方插件列表。
40
+
41
+ ```js
42
+ const InternalPlugins = ['@modern-js/app-tools', '@modern-js/plugin-i18n', ...];
43
+ ```
44
+
45
+ 2. Modern.js 将读取你的 `package.json` 文件,收集依赖信息。
46
+
47
+ ```json title="package.json"
48
+ "dependencies": {
49
+ "@modern-js/plugin-i18n": "x.x.x"
50
+ ...
51
+ },
52
+ "devDependencies": {
53
+ "@modern-js/app-tools": "x.x.x"
54
+ ...
55
+ }
56
+ ```
57
+
58
+ 3. Modern.js 观察到你安装了 `@modern-js/plugin-i18n` 和 `@modern-js/app-tools` 等依赖后,将会引入插件自动注册。
59
+
60
+ 可以注意到这种方式相对黑盒,你甚至对加载插件的过程是无感知的。我们希望更多的细节暴露给开发者,能让开发者去控制这一过程。
61
+
62
+ **因此我们更加推荐你手动注册插件。**
@@ -52,13 +52,3 @@ export default defineConfig({
52
52
  * 默认值:`false`
53
53
 
54
54
  是否 `external` 基础库,当设置为 `true` 时,当前子应用将会 `external`:`react`、`react-dom`,`EdenX` 主应用会自动 `setExternal` 这两个基础库,如果其他类型的框架请通过 `Garfish.setExternal` 增加 `react`、`react-dom` 依赖
55
-
56
-
57
- ### moduleApp
58
-
59
- * 类型:`string`
60
-
61
- * 默认值:`undefined`
62
-
63
- 该值可以配置子应用的名称,目前主要结合 [`dev.withMasterApp`](/docs/configure/app/dev/with-master-app) 进行测试。
64
-
@@ -35,7 +35,7 @@ sidebar_label: ssg
35
35
  │ └── page.tsx
36
36
  ```
37
37
 
38
- 在 `modern.js.config` 中做以下设置:
38
+ 在 `modern.config.js` 中做以下设置:
39
39
 
40
40
  ```js
41
41
  export default defineConfig({
@@ -73,10 +73,6 @@ export default () => {
73
73
 
74
74
  ### 多入口
75
75
 
76
- :::note
77
- 多入口 SSG 暂未支持,敬请期待。
78
- :::
79
-
80
76
  `output.ssg` 也可以按照入口配置,配置生效的规则同样由入口路由方式决定。
81
77
 
82
78
  例如以下目录结构:
@@ -6,31 +6,17 @@ sidebar_label: masterApp
6
6
 
7
7
  * 类型: `Object`
8
8
 
9
- :::caution 注意
9
+ :::info
10
10
  需要先通过 `pnpm run new` 启用「微前端」 功能。
11
11
  :::
12
12
 
13
13
  ## 示例
14
14
 
15
15
  import EnableMicroFrontend from '@site-docs/components/enable-micro-frontend.md';
16
+ import MasterManifestAppConfig from '@site-docs/components/micro-master-manifest-config.md';
16
17
 
17
18
  <EnableMicroFrontend />
18
-
19
- ## `manifest`
20
-
21
- ```ts
22
- interface Manifest {
23
- getAppList?: ()=> Array<AppInfo>
24
- }
25
- ```
26
-
27
- #### `getAppList?`
28
-
29
- 通过 `getAppList` 配置,可以自定义如何获取远程列表数据
30
-
31
- ```ts
32
- type GetAppList = ()=> Promise<Array<AppInfo>>;
33
- ```
19
+ <MasterManifestAppConfig />
34
20
 
35
21
 
36
22
  ### apps
@@ -53,4 +39,4 @@ interface AppInfo {
53
39
 
54
40
  在 `masterApp` 配置下,开发者可以透传 Garfish 的配置项。
55
41
 
56
- 所有支持的配置项[点此查看](https://garfishjs.org/api/run/#%E5%8F%82%E6%95%B0)
42
+ 所有支持的配置项[点此查看](https://garfishjs.org/api/run/#%E5%8F%82%E6%95%B0)
@@ -2,19 +2,34 @@
2
2
  sidebar_label: router
3
3
  ---
4
4
 
5
+ import RouterLegacyTip from '@site-docs/components/router-legacy-tip.md'
6
+
7
+ <RouterLegacyTip />
8
+
5
9
  # runtime.router
6
10
 
7
11
  * 类型: `boolean | Object`
8
12
  * 默认值: `false`。
9
13
 
10
- 开启 `router` 之后,支持使用 Modern.js 默认提供的约定式路由进行路由管理。
14
+ 开启 `router` 之后,支持使用 Modern.js 默认提供的约定式路由进行路由管理。Modern.js 的路由模块基于 [React Router 6](https://reactrouter.com/) 实现。
11
15
 
12
16
  具体配置如下:
13
17
 
14
- ### supportHtml5History
15
18
 
16
- * 类型: `Boolean`
19
+ ## basename
20
+
21
+ * 类型: `string`
22
+ * 默认值: ``
23
+
24
+ 设置客户端路由的 `basename`,通常用于应用需要部署在域名非根路径下的场景。
25
+
26
+ ## supportHtml5History
27
+
28
+ * 类型: `boolean`
17
29
  * 默认值: `true`
18
30
 
19
- 值为 `true` 则使用 `BrowserRouter` 否则使用 `HashRouter`。
31
+ 值为 `true`,使用 `BrowserRouter`;否则使用 `HashRouter`。推荐使用 `BrowserRouter`。
20
32
 
33
+ :::warning
34
+ 当开启 SSR 时,不支持设置 `supportHtml5History`。
35
+ :::
@@ -12,34 +12,34 @@ sidebar_label: state
12
12
 
13
13
  具体配置项如下:
14
14
 
15
- ## `models`
15
+ ## models
16
16
 
17
17
  * 类型:`Array<Model>`
18
18
  * 默认值:`[]`
19
19
 
20
20
  注册提前挂载的 model 对象,这些 model 会在 Reduck store 创建完成后立即执行挂载。一般使用无需提前挂载。
21
21
 
22
- ## `initialState`
22
+ ## initialState
23
23
  * 类型: `Object`
24
- * * 默认值:`{}`
24
+ * 默认值:`{}`
25
25
 
26
26
  用于设置全局 store 的初始状态。一般用于 SSR 在 hydration 阶段初始化数据。
27
27
 
28
- ## `immer`
28
+ ## immer
29
29
 
30
30
  * 类型:`boolean`
31
31
  * 默认值:`true`
32
32
 
33
33
  是否启用以 mutable 更新 state 的方式,默认启用,若想禁用则设置为 `false`。
34
34
 
35
- ## `effects`
35
+ ## effects
36
36
 
37
37
  * 类型:`boolean`
38
38
  * 默认值:`true`
39
39
 
40
40
  是否启用副作用管理特性,默认启用,若想禁用则设置为 `false`。
41
41
 
42
- ## `autoActions`
42
+ ## autoActions
43
43
 
44
44
  * 类型:`boolean`
45
45
  * 默认值:`true`
@@ -47,7 +47,7 @@ sidebar_label: state
47
47
  是否启用自动生成 actions 特性,默认启用,若想禁用则设置为 `false`。
48
48
 
49
49
 
50
- ## `devtools`
50
+ ## devtools
51
51
 
52
52
  * 类型:`boolean | EnhancerOptions`
53
53
  * 默认值:`true`
@@ -0,0 +1,47 @@
1
+ ---
2
+ sidebar_label: enableFrameworkExt
3
+ ---
4
+ # server.enableFrameworkExt
5
+
6
+ * 类型: `Boolean`
7
+ * 默认值: `false`
8
+
9
+ 默认情况下,开启[自定义 Web Server 功能](/docs/guides/advanced-features/web-server)后,Middleware 会使用 Modern.js 本身的语法。
10
+
11
+ 开启 `server.enableFrameworkExt` 可以使用其他框架扩展的语法。
12
+
13
+ ```typescript title="modern.config.ts"
14
+ export default defineConfig({
15
+ server: {
16
+ enableFrameworkExt: true,
17
+ }
18
+ });
19
+ ```
20
+
21
+ ## 示例
22
+
23
+ 默认的使用方式:
24
+
25
+ ```ts title="server/index.ts"
26
+ import { Middleware } from '@modern-js/runtime/server';
27
+
28
+ export const middleware: Middleware = (ctx, next) => {
29
+ console.log(ctx.request.url);
30
+ next();
31
+ };
32
+ ```
33
+
34
+ 开启后,Middleware 类型将从其他命名空间下导出,并且可以使用框架拓展的语法:
35
+
36
+ ```ts title="server/index.ts"
37
+ import { SomeType } from '@modern-js/runtime/{frameworknName}';
38
+
39
+ export const middleware: SomeType = (...args) => {
40
+ console.log(args[0].url);
41
+ next();
42
+ };
43
+ ```
44
+
45
+ :::note
46
+ 上述代码为伪代码,具体使用方式需要参考对应的框架拓展。
47
+ :::
@@ -9,7 +9,7 @@ sidebar_label: port
9
9
  * 类型: `Number`
10
10
  * 默认值: `8080`
11
11
 
12
- Modern.js 在 `dev` 和 `start` 时会以 `8080` 为默认端口启动,通过该配置可以修改 Server 启动的端口号:
12
+ Modern.js 在 `dev` 和 `start` 时会以 `8080` 为默认端口启动,通过该配置可以修改 Server 启动的端口号:
13
13
 
14
14
  ```typescript title="modern.config.ts"
15
15
  export default defineConfig({
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "label": "tools (底层配置)",
3
- "position": 10
3
+ "position": 12
4
4
  }
@@ -17,7 +17,8 @@ sidebar_position: 8
17
17
 
18
18
  :::info 注
19
19
  主要在 IDE 保存文件的环节执行这种自动修复,少数漏网之鱼会在提交代码环节被自动修复。
20
- :::info 注
20
+ :::
21
+
21
22
  ### 批量自动修复
22
23
 
23
24
  在少数情况下,比如旧项目迁移的时候,可以执行以下命令,批量修复和检查所有文件:
@@ -19,6 +19,10 @@ import SSGPlugin from '@modern-js/plugin-ssg';
19
19
  // https://modernjs.dev/docs/apis/app/config
20
20
  export default defineConfig({
21
21
  ...,
22
+ output: {
23
+ ...,
24
+ ssg: true,
25
+ },
22
26
  plugins: [..., SSGPlugin()],
23
27
  });
24
28
  ```
@@ -425,7 +425,7 @@ export default () => {
425
425
  // 这里没有发送真实的请求,只是返回了一个写死的数据。
426
426
  // 真实项目中,应该返回从远端获取的数据。
427
427
  return {
428
- name: 'modern.js',
428
+ name: 'Modern.js',
429
429
  };
430
430
  });
431
431
 
@@ -11,7 +11,7 @@ Modern.js 提供了对环境变量的支持,包含内置的环境变量和自
11
11
 
12
12
  表示当前的执行环境,是**只读的**的环境变量,其值在不同的执行命令下具有不同的值:
13
13
 
14
- - `production`:执行 `modern build`、`modern preview` 命令时的默认值。
14
+ - `production`:执行 `modern build`、`modern serve` 命令时的默认值。
15
15
  - `test`:执行 `modern test` 命令时的默认值。
16
16
  - `development`:执行 `modern dev` 命令时的默认值,同时也是其他所有情况下的默认值。
17
17
 
@@ -306,9 +306,6 @@ export default () => {
306
306
 
307
307
  :::note
308
308
  在自控式路由下,开发者如果希望在 SSR 中使用 React Router 6 中 [Loader API](https://reactrouter.com/en/main/hooks/use-loader-data#useloaderdata) 的能力会相对复杂,推荐直接使用约定式路由。Modern.js 已经为你封装好了一切。
309
-
310
- <!-- Todo 嵌套路由带来的优化可以补充下文档-->
311
- 如果项目只想升级到 React Router 6,而不希望使用嵌套路由带来的优化,那 [useLoader](/docs/apis/app/runtime/core/use-loader) 在 SSR 下仍然可以工作。
312
309
  :::
313
310
 
314
311
  ## 其他路由方案
@@ -34,6 +34,8 @@ New 命令的操作类型(actionType),类型支持一种:
34
34
 
35
35
  - Tailwind CSS(tailwindcss)
36
36
 
37
- - Storybook(mwa_storybook)
37
+ - Storybook(storybook)
38
38
 
39
39
  - Runtime API(runtimeApi)
40
+
41
+ - 测试(test)
@@ -34,20 +34,12 @@ New 命令的操作类型(actionType),类型支持两种:
34
34
 
35
35
  - 新建自定义 Web Serve 源码目录(server)
36
36
 
37
- 这两个选项还需要配置具体的配合使用,介绍如下:
37
+ 入口还需要配置具体的配合使用,介绍如下:
38
38
 
39
39
  #### name
40
40
 
41
41
  入口名称(name), 字符串类型。
42
42
 
43
- #### framework
44
-
45
- 自定义 Web Serve 运行时框架(framework),支持两个选项:
46
-
47
- - Express(express)
48
-
49
- - Koa(koa)
50
-
51
43
  ### function
52
44
 
53
45
  可选功能名称(function),支持如下选项:
@@ -16,7 +16,7 @@ Reduck 在 MVC 模式中,扮演 M(Model) 的角色,React UI Component 对应
16
16
  Modern.js 的状态管理解决方案,是通过内置 Reduck 实现的。在 Modern.js 中使用 Reduck,不仅免去了手动集成的环节,而且所有 Reduck API 都可以从 Modern.js 的 Runtime 包中直接导入使用,具有更好的一致性体验。
17
17
 
18
18
  :::info 注
19
- 1. Modern.js 中使用 Reduck API,需要设置 [runtime.state](/docs/configure/app/runtime/state) 以开启状态管理功能(默认创建的项目已开启)。
19
+ 1. Modern.js 中使用 Reduck API,需要先设置 [runtime.state](/docs/configure/app/runtime/state) 以启用状态管理插件。
20
20
  2. Reduck 也可以脱离 Modern.js 作为状态管理库[单独使用](/docs/guides/topic-detail/model/use-out-of-modernjs)。
21
21
  :::
22
22
 
@@ -6,7 +6,11 @@ title: 添加业务模型(状态管理)
6
6
 
7
7
  这一章节中,我们会进一步实现项目的功能,例如实现 **Archive** 按钮的功能,把联系人归档。
8
8
 
9
- 因此会开始编写一些跟 UI 完全无关的业务逻辑,如果继续写在组件代码中,会产生越来越多的面条式代码。为此,我们引入了一种叫做**业务模型(Model)**的代码模块,将这些业务逻辑和 UI 解耦。
9
+ 因此会开始编写一些跟 UI 完全无关的业务逻辑,如果继续写在组件代码中,会产生越来越多的面条式代码。为此,我们引入了一种叫做 **业务模型(Model)** 的代码模块,将这些业务逻辑和 UI 解耦。
10
+
11
+ :::info 注
12
+ 使用 Model API,需要先设置 [runtime.state](/docs/configure/app/runtime/state) 以启用状态管理插件。
13
+ :::
10
14
 
11
15
  ## 实现 Model
12
16
 
@@ -134,4 +134,4 @@ export default defineConfig({
134
134
 
135
135
  ## 下一步
136
136
 
137
- 接下来你可以通过了解[指南](/docs/guides/overview)、[配置](/docs/configure/app/usage) 等更多教程,进一步完善你的应用。
137
+ 接下来你可以通过了解[指南](/docs/guides/get-started/quick-start)、[配置](/docs/configure/app/usage) 等更多教程,进一步完善你的应用。
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Modern.js 介绍
2
+ title: 介绍
3
3
  sidebar_position: 1
4
4
  ---
5
5
 
@@ -36,6 +36,8 @@ Modern.js 能为开发者提供极致的**开发体验(Development Experience
36
36
 
37
37
  ## 下一步
38
38
 
39
- 如果你是前端初学者,可能会觉得这些概念有些复杂。我们提供了一些 [JavaScript 和 React](/docs/tutorials/foundations/basic) 的学习资料,你可以先对它们做些了解。
39
+ <!-- 如果你是前端初学者,可能会觉得这些概念有些复杂。我们提供了一些 [JavaScript 和 React](/docs/tutorials/foundations/basic) 的学习资料,你可以先对它们做些了解。
40
40
 
41
- 如果你是有经验的开发者,希望了解如何使用 Modern.js,你可以尝试[创建第一个应用](/docs/tutorials/first-app/c01-start),或是阅读[指南](/docs/guides/overview)。
41
+ 如果你是有经验的开发者,希望了解如何使用 Modern.js,你可以尝试[创建第一个应用](/docs/tutorials/first-app/c01-start),或是阅读[指南](/docs/guides/get-started/quick-start)。 -->
42
+
43
+ 如果你希望了解如何使用 Modern.js,可以尝试[创建第一个应用](/docs/tutorials/first-app/c01-start),或是阅读[指南](/docs/guides/get-started/quick-start)。
@@ -1,12 +0,0 @@
1
- ---
2
- sidebar_position: 0
3
- ---
4
-
5
- # overview
6
-
7
- This section covers all APIs in `@modern-js/app-tools`.
8
-
9
- import OverviewNav from '@site/src/components/OverviewNav';
10
- import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json';
11
-
12
- <OverviewNav cards={sidebarData.docsSidebars.apisAppSidebar} />
@@ -1,28 +0,0 @@
1
- ---
2
- sidebar_label: fetcher
3
- ---
4
-
5
- # bff.fetcher
6
-
7
- * Type: `string`
8
- * Default:
9
- * Brower:[global.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
10
- * Node.js:[node-fetch](https://github.com/node-fetch/node-fetch)
11
-
12
- :::caution Caution
13
- First you need to enable the "BFF" function using [new](/docs/apis/app/commands/new) command.
14
- :::
15
-
16
- Custom `fetch` function, which can be used for `fetch` function customization in Native and Mini Program scenarios.
17
-
18
- ```ts title="modern.config.ts"
19
- export default defineConfig({
20
- bff: {
21
- fetcher: 'custom-fetch'
22
- }
23
- });
24
- ```
25
-
26
- :::info
27
- You need to judge the running environment when you implement the isomorphic fetch function.
28
- :::
@@ -1,31 +0,0 @@
1
- ---
2
- sidebar_label: withMasterApp
3
- ---
4
-
5
- # dev.withMasterApp
6
-
7
- * Type: `Object`
8
- * Default: `null`
9
-
10
- When the project is a micro-front-end sub-application, you can use the `withMasterApp` configuration to enable the sub-application debugging mode.
11
-
12
- :::caution Caution
13
- When using child app debugging mode, you should first ensure that the main app has online debugging mode turned on.
14
- :::
15
-
16
- ```js title=modern.config.js
17
- export default defineConfig({
18
- dev: {
19
- withMasterApp: {
20
- //the path of the main application
21
- moduleApp: 'https://www.masterApp.com',
22
- //name of the subapplication
23
- moduleName: 'Contact'
24
- }
25
- }
26
- })
27
- ```
28
-
29
- - moduleApp: `string` Online address of the main application.
30
- - moduleName: `Contact` The name of the child app (needs to match the module name registered in the main app)。
31
-
@@ -1,11 +0,0 @@
1
- ---
2
- sidebar_position: 0
3
- ---
4
-
5
- # Overview
6
-
7
- import OverviewNav from '@site/src/components/OverviewNav';
8
-
9
- import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json';
10
-
11
- <OverviewNav cards={sidebarData.docsSidebars.guidesSidebar} />
@@ -1,8 +0,0 @@
1
- ---
2
- title: JavaScript & React
3
- sidebar_position: 2
4
- ---
5
-
6
- :::note Todo
7
- Coming Soon...
8
- :::
@@ -1,11 +0,0 @@
1
- ---
2
- sidebar_position: 0
3
- ---
4
-
5
- # 概览
6
- 本节涵盖了使用 `@modern-js/app-tools` 的所有 API。
7
-
8
- import OverviewNav from '@site/src/components/OverviewNav';
9
- import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json';
10
-
11
- <OverviewNav cards={sidebarData.docsSidebars.apisAppSidebar} />
@@ -1,11 +0,0 @@
1
- ---
2
- sidebar_position: 0
3
- ---
4
-
5
- # 概览
6
- 本节涵盖了使用@modern-js/monorepo-tools的所有API。
7
-
8
- import OverviewNav from '@site/src/components/OverviewNav';
9
- import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json';
10
-
11
- <OverviewNav cards={sidebarData.docsSidebars.apisMonorepoSidebar} />
@@ -1,31 +0,0 @@
1
- ---
2
- sidebar_label: fetcher
3
- ---
4
-
5
- # bff.fetcher
6
-
7
-
8
-
9
- * 类型:`string`
10
- * 默认值:
11
- * 浏览器端:[global.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
12
- * Node.js 端:[node-fetch](https://github.com/node-fetch/node-fetch)
13
-
14
- :::caution 注意
15
- 请先在当前应用项目根目录使用【[new](/docs/apis/app/commands/new)】 启用 BFF 功能。
16
- :::
17
-
18
-
19
- 自定义 `fetch` 函数,可以用于 Native、小程序场景下的 `fetch` 函数定制。
20
-
21
- ```ts title="modern.config.ts"
22
- export default defineConfig({
23
- bff: {
24
- fetcher: 'custom-fetch'
25
- }
26
- });
27
- ```
28
-
29
- :::info 注
30
- 这里定制就需要定制两种场景下的 `fetch` 函数,即自行判断运行环境,实现同构的 fetch 函数。
31
- :::
@@ -1,32 +0,0 @@
1
- ---
2
- sidebar_label: withMasterApp
3
- ---
4
-
5
- # dev.withMasterApp
6
-
7
-
8
-
9
- * 类型: `Object`
10
- * 默认值: `null`
11
-
12
- 当项目为微前端子应用的时候,可以使用 `withMasterApp` 配置启用子应用调试模式。
13
-
14
- :::caution 注意
15
- 使用子应用调试的模式时,应该先确保主应用开启了线上 debug 模式。
16
- :::
17
-
18
- ```js title=modern.config.js
19
- export default defineConfig({
20
- dev: {
21
- withMasterApp: {
22
- // 主应用的路径
23
- moduleApp: 'https://www.masterApp.com',
24
- // 子应用的名称
25
- moduleName: 'Contact'
26
- }
27
- }
28
- })
29
- ```
30
-
31
- - moduleApp: `string` 主应用的线上地址。
32
- - moduleName: `Contact` 子应用的名称(需要和在主应用中注册的模块名匹配)。
@@ -1,11 +0,0 @@
1
- ---
2
- sidebar_position: 0
3
- ---
4
-
5
- # 概览
6
-
7
- import OverviewNav from '@site/src/components/OverviewNav';
8
-
9
- import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json';
10
-
11
- <OverviewNav cards={sidebarData.docsSidebars.guidesSidebar} />
@@ -1,8 +0,0 @@
1
- ---
2
- title: JavaScript & React
3
- sidebar_position: 2
4
- ---
5
-
6
- :::note Todo
7
- 敬请期待
8
- :::