@modern-js/main-doc 2.4.0 → 2.5.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.
- package/.turbo/turbo-build.log +1 -1
- package/LICENSE +0 -123
- package/README.md +26 -0
- package/en/apis/app/commands/_category_.json +1 -4
- package/en/apis/app/commands/new.mdx +11 -10
- package/en/apis/app/commands/test.mdx +1 -1
- package/en/apis/app/hooks/_category_.json +1 -4
- package/en/apis/app/hooks/api/framework/lambda.mdx +1 -1
- package/en/apis/app/hooks/api/functions/api.mdx +1 -1
- package/en/apis/app/hooks/server/index_.mdx +2 -1
- package/en/apis/app/hooks/src/pages.mdx +7 -7
- package/en/apis/app/hooks/src/routes.mdx +1 -1
- package/en/apis/app/runtime/_category_.json +1 -5
- package/en/apis/app/runtime/app/define-config.mdx +2 -2
- package/en/apis/app/runtime/core/bootstrap.mdx +1 -1
- package/en/apis/app/runtime/core/create-app.mdx +2 -2
- package/en/apis/app/runtime/core/use-loader.mdx +4 -4
- package/en/apis/app/runtime/core/use-module-apps.mdx +2 -2
- package/en/apis/app/runtime/model/Provider.mdx +2 -2
- package/en/apis/app/runtime/model/auto-actions.mdx +2 -2
- package/en/apis/app/runtime/model/connect.mdx +5 -5
- package/en/apis/app/runtime/model/create-app.mdx +9 -9
- package/en/apis/app/runtime/model/create-store.mdx +3 -3
- package/en/apis/app/runtime/model/handle-effect.mdx +2 -2
- package/en/apis/app/runtime/model/model_.mdx +1 -1
- package/en/apis/app/runtime/model/use-local-model.mdx +1 -1
- package/en/apis/app/runtime/model/use-model.mdx +1 -1
- package/en/apis/app/runtime/model/use-static-model.mdx +4 -4
- package/en/apis/app/runtime/model/use-store.mdx +1 -1
- package/en/apis/app/runtime/router/router.mdx +1 -1
- package/en/apis/app/runtime/ssr/pre-render.mdx +1 -1
- package/en/apis/app/runtime/testing/render.mdx +1 -1
- package/en/apis/app/runtime/testing/renderApp.mdx +1 -1
- package/en/apis/app/runtime/utility/css-in-js.mdx +1 -1
- package/en/apis/app/runtime/utility/loadable.mdx +1 -1
- package/en/apis/app/runtime/web-server/hook.mdx +5 -5
- package/en/apis/app/runtime/web-server/middleware.mdx +6 -6
- package/en/components/global-proxy-config.mdx +3 -3
- package/en/configure/app/bff/_category_.json +4 -0
- package/en/configure/app/builder-plugins.mdx +3 -3
- package/en/configure/app/deploy/_category_.json +4 -0
- package/en/configure/app/dev/_category_.json +4 -0
- package/en/configure/app/dev/asset-prefix.mdx +1 -1
- package/en/configure/app/dev/hmr.mdx +1 -1
- package/en/configure/app/dev/https.mdx +1 -1
- package/en/configure/app/dev/port.mdx +1 -1
- package/en/configure/app/dev/progress-bar.mdx +1 -1
- package/en/configure/app/dev/start-url.mdx +1 -1
- package/en/configure/app/experiments/_category_.json +4 -0
- package/en/configure/app/experiments/lazy-compilation.mdx +1 -1
- package/en/configure/app/html/_category_.json +4 -0
- package/en/configure/app/html/app-icon.mdx +1 -1
- package/en/configure/app/html/crossorigin.mdx +1 -1
- package/en/configure/app/html/disable-html-folder.mdx +1 -1
- package/en/configure/app/html/favicon-by-entries.mdx +1 -1
- package/en/configure/app/html/favicon.mdx +1 -1
- package/en/configure/app/html/inject-by-entries.mdx +1 -1
- package/en/configure/app/html/inject.mdx +1 -1
- package/en/configure/app/html/meta-by-entries.mdx +1 -1
- package/en/configure/app/html/meta.mdx +1 -1
- package/en/configure/app/html/mount-id.mdx +1 -1
- package/en/configure/app/html/tags-by-entries.mdx +1 -1
- package/en/configure/app/html/tags.mdx +1 -1
- package/en/configure/app/html/template-by-entries.mdx +1 -1
- package/en/configure/app/html/template-parameters-by-entries.mdx +1 -1
- package/en/configure/app/html/template-parameters.mdx +1 -1
- package/en/configure/app/html/template.mdx +1 -1
- package/en/configure/app/html/title-by-entries.mdx +1 -1
- package/en/configure/app/html/title.mdx +1 -1
- package/en/configure/app/output/_category_.json +4 -0
- package/en/configure/app/output/asset-prefix.mdx +1 -1
- package/en/configure/app/output/assets-retry.mdx +1 -1
- package/en/configure/app/output/charset.mdx +1 -1
- package/en/configure/app/output/clean-dist-path.mdx +1 -1
- package/en/configure/app/output/convert-to-rem.mdx +1 -1
- package/en/configure/app/output/copy.mdx +1 -1
- package/en/configure/app/output/css-module-local-ident-name.mdx +1 -1
- package/en/configure/app/output/data-uri-limit.mdx +1 -1
- package/en/configure/app/output/disable-css-extract.mdx +1 -1
- package/en/configure/app/output/disable-css-module-extension.mdx +1 -1
- package/en/configure/app/output/disable-filename-hash.mdx +1 -1
- package/en/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
- package/en/configure/app/output/disable-minimize.mdx +1 -1
- package/en/configure/app/output/disable-source-map.mdx +1 -1
- package/en/configure/app/output/disable-ts-checker.mdx +1 -1
- package/en/configure/app/output/dist-path.mdx +1 -1
- package/en/configure/app/output/enable-asset-fallback.mdx +1 -1
- package/en/configure/app/output/enable-asset-manifest.mdx +1 -1
- package/en/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
- package/en/configure/app/output/enable-inline-scripts.mdx +1 -1
- package/en/configure/app/output/enable-inline-styles.mdx +1 -1
- package/en/configure/app/output/enable-latest-decorators.mdx +1 -1
- package/en/configure/app/output/externals.mdx +1 -1
- package/en/configure/app/output/filename.mdx +1 -1
- package/en/configure/app/output/legal-comments.mdx +1 -1
- package/en/configure/app/output/override-browserslist.mdx +1 -1
- package/en/configure/app/output/polyfill.mdx +1 -1
- package/en/configure/app/output/ssg.mdx +2 -2
- package/en/configure/app/output/svg-default-export.mdx +1 -1
- package/en/configure/app/performance/_category_.json +4 -0
- package/en/configure/app/performance/build-cache.mdx +1 -1
- package/en/configure/app/performance/bundle-analyze.mdx +1 -1
- package/en/configure/app/performance/chunk-split.mdx +1 -1
- package/en/configure/app/performance/print-file-size.mdx +1 -1
- package/en/configure/app/performance/profile.mdx +1 -1
- package/en/configure/app/performance/remove-console.mdx +1 -1
- package/en/configure/app/performance/remove-moment-locale.mdx +1 -1
- package/en/configure/app/plugins.mdx +1 -1
- package/en/configure/app/runtime/_category_.json +4 -0
- package/en/configure/app/runtime/intro.mdx +2 -2
- package/en/configure/app/security/_category_.json +4 -0
- package/en/configure/app/security/check-syntax.mdx +1 -1
- package/en/configure/app/security/sri.mdx +1 -1
- package/en/configure/app/server/_category_.json +4 -0
- package/en/configure/app/server/base-url.mdx +3 -3
- package/en/configure/app/server/enable-framework-ext.mdx +1 -1
- package/en/configure/app/server/ssr-by-entries.mdx +1 -1
- package/en/configure/app/source/_category_.json +4 -0
- package/en/configure/app/source/alias.mdx +1 -1
- package/en/configure/app/source/compile-js-data-uri.mdx +1 -1
- package/en/configure/app/source/define.mdx +1 -1
- package/en/configure/app/source/design-system.mdx +5 -5
- package/en/configure/app/source/entries.mdx +3 -3
- package/en/configure/app/source/exclude.mdx +1 -1
- package/en/configure/app/source/global-vars.mdx +1 -1
- package/en/configure/app/source/include.mdx +1 -1
- package/en/configure/app/source/module-scopes.mdx +1 -1
- package/en/configure/app/source/pre-entry.mdx +1 -1
- package/en/configure/app/source/resolve-extension-prefix.mdx +1 -1
- package/en/configure/app/source/resolve-main-fields.mdx +1 -1
- package/en/configure/app/testing/_category_.json +4 -0
- package/en/configure/app/tools/_category_.json +4 -0
- package/en/configure/app/tools/autoprefixer.mdx +1 -1
- package/en/configure/app/tools/babel.mdx +1 -1
- package/en/configure/app/tools/css-extract.mdx +1 -1
- package/en/configure/app/tools/css-loader.mdx +1 -1
- package/en/configure/app/tools/dev-server.mdx +1 -1
- package/en/configure/app/tools/html-plugin.mdx +1 -1
- package/en/configure/app/tools/inspector.mdx +1 -1
- package/en/configure/app/tools/less.mdx +1 -1
- package/en/configure/app/tools/minify-css.mdx +1 -1
- package/en/configure/app/tools/postcss.mdx +1 -1
- package/en/configure/app/tools/pug.mdx +1 -1
- package/en/configure/app/tools/rspack.mdx +13 -0
- package/en/configure/app/tools/sass.mdx +1 -1
- package/en/configure/app/tools/style-loader.mdx +1 -1
- package/en/configure/app/tools/styled-components.mdx +1 -1
- package/en/configure/app/tools/tailwindcss.mdx +1 -1
- package/en/configure/app/tools/terser.mdx +1 -1
- package/en/configure/app/tools/ts-checker.mdx +1 -1
- package/en/configure/app/tools/ts-loader.mdx +1 -1
- package/en/configure/app/tools/webpack-chain.mdx +1 -1
- package/en/configure/app/tools/webpack.mdx +1 -1
- package/en/configure/app/usage.mdx +1 -1
- package/en/guides/advanced-features/_category_.json +2 -2
- package/en/guides/advanced-features/bff/bff-proxy.mdx +1 -1
- package/en/guides/advanced-features/bff/frameworks.mdx +1 -1
- package/en/guides/advanced-features/bff/function.mdx +3 -3
- package/en/guides/advanced-features/code-split.mdx +2 -2
- package/en/guides/advanced-features/compatibility.mdx +2 -3
- package/en/guides/advanced-features/eslint.mdx +4 -4
- package/en/guides/advanced-features/low-level.mdx +1 -1
- package/en/guides/advanced-features/ssg.mdx +4 -5
- package/en/guides/advanced-features/ssr.mdx +3 -3
- package/en/guides/advanced-features/testing.mdx +4 -5
- package/en/guides/advanced-features/web-server.mdx +0 -1
- package/en/guides/basic-features/alias.mdx +1 -1
- package/en/guides/basic-features/data-fetch.mdx +21 -8
- package/en/guides/basic-features/env-vars.mdx +1 -1
- package/en/guides/basic-features/html.mdx +11 -11
- package/en/guides/basic-features/mock.mdx +21 -1
- package/en/guides/basic-features/proxy.mdx +2 -2
- package/en/guides/basic-features/routes.mdx +6 -8
- package/en/guides/{basic-features → concept}/builder.mdx +1 -1
- package/en/guides/concept/entries.mdx +11 -11
- package/en/guides/css/_category_.json +5 -0
- package/en/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
- package/en/guides/{basic-features/css → css}/css-modules.mdx +0 -0
- package/en/guides/{basic-features/css → css}/less-sass.mdx +1 -1
- package/en/guides/{basic-features/css → css}/postcss.mdx +0 -0
- package/en/guides/{basic-features/css → css}/tailwindcss.mdx +0 -0
- package/en/guides/get-started/introduction.mdx +34 -0
- package/en/guides/get-started/quick-start.mdx +2 -2
- package/en/guides/get-started/upgrade.mdx +2 -1
- package/en/guides/topic-detail/_category_.json +2 -2
- package/en/guides/topic-detail/framework-plugin/hook.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- package/en/guides/topic-detail/micro-frontend/c02-development.mdx +128 -61
- package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +72 -41
- package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
- package/en/guides/topic-detail/model/auto-actions.mdx +1 -1
- package/en/guides/topic-detail/model/define-model.mdx +1 -1
- package/en/guides/topic-detail/model/manage-effects.mdx +1 -1
- package/en/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/en/guides/topic-detail/model/quick-start.mdx +2 -2
- package/en/guides/topic-detail/model/test-model.mdx +1 -1
- package/en/guides/topic-detail/model/use-model.mdx +3 -3
- package/en/guides/troubleshooting/_category_.json +2 -2
- package/en/guides/troubleshooting/cli.mdx +1 -1
- package/en/index.md +1 -1
- package/en/tutorials/first-app/_category_.json +1 -1
- package/en/tutorials/first-app/c01-start.mdx +0 -1
- package/en/tutorials/first-app/c03-css.mdx +1 -2
- package/en/tutorials/first-app/c06-model.mdx +1 -1
- package/en/tutorials/first-app/c07-container.mdx +1 -1
- package/en/tutorials/first-app/c08-entries.mdx +1 -2
- package/en/tutorials/foundations/introduction.mdx +17 -34
- package/package.json +3 -3
- package/scripts/config.ts +3 -1
- package/scripts/summary.en.json +1 -1
- package/scripts/summary.zh.json +1 -1
- package/zh/apis/app/commands/_category_.json +1 -4
- package/zh/apis/app/hooks/_category_.json +1 -4
- package/zh/apis/app/hooks/src/pages.mdx +1 -1
- package/zh/apis/app/hooks/src/routes.mdx +1 -1
- package/zh/apis/app/runtime/_category_.json +1 -5
- package/zh/apis/app/runtime/core/create-app.mdx +1 -1
- package/zh/apis/app/runtime/core/use-module-apps.mdx +81 -40
- package/zh/apis/app/runtime/model/Provider.mdx +2 -2
- package/zh/apis/app/runtime/model/create-app.mdx +7 -7
- package/zh/apis/app/runtime/model/create-store.mdx +2 -2
- package/zh/apis/app/runtime/model/use-local-model.mdx +1 -1
- package/zh/apis/app/runtime/model/use-static-model.mdx +1 -1
- package/zh/apis/app/runtime/model/use-store.mdx +1 -1
- package/zh/apis/app/runtime/testing/renderApp.mdx +1 -1
- package/zh/components/micro-runtime-config.mdx +6 -6
- package/zh/components/release-note.mdx +1 -1
- package/zh/configure/app/builder-plugins.mdx +3 -3
- package/zh/configure/app/plugins.mdx +1 -1
- package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
- package/zh/configure/app/tools/rspack.mdx +13 -0
- package/zh/configure/app/usage.mdx +1 -1
- package/zh/guides/advanced-features/_category_.json +2 -6
- package/zh/guides/advanced-features/compatibility.mdx +0 -1
- package/zh/guides/advanced-features/ssg.mdx +0 -1
- package/zh/guides/advanced-features/testing.mdx +0 -1
- package/zh/guides/advanced-features/web-server.mdx +0 -1
- package/zh/guides/basic-features/_category_.json +1 -5
- package/zh/guides/basic-features/alias.mdx +1 -1
- package/zh/guides/basic-features/data-fetch.mdx +35 -26
- package/zh/guides/basic-features/html.mdx +10 -9
- package/zh/guides/basic-features/mock.mdx +20 -0
- package/zh/guides/basic-features/routes.mdx +15 -10
- package/zh/guides/{basic-features → concept}/builder.mdx +2 -2
- package/zh/guides/concept/entries.mdx +11 -11
- package/zh/guides/css/_category_.json +5 -0
- package/zh/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
- package/zh/guides/{basic-features/css → css}/css-modules.mdx +0 -0
- package/zh/guides/{basic-features/css → css}/less-sass.mdx +1 -1
- package/zh/guides/{basic-features/css → css}/postcss.mdx +5 -4
- package/zh/guides/{basic-features/css → css}/tailwindcss.mdx +0 -1
- package/zh/guides/get-started/introduction.mdx +31 -0
- package/zh/guides/get-started/quick-start.mdx +2 -3
- package/zh/guides/get-started/upgrade.mdx +2 -1
- package/zh/guides/topic-detail/_category_.json +2 -2
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
- package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +25 -0
- package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +15 -15
- package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/zh/guides/troubleshooting/_category_.json +2 -2
- package/zh/index.md +1 -1
- package/zh/tutorials/first-app/_category_.json +1 -1
- package/zh/tutorials/first-app/c01-start.mdx +1 -2
- package/zh/tutorials/first-app/c03-css.mdx +1 -2
- package/zh/tutorials/first-app/c06-model.mdx +2 -2
- package/zh/tutorials/first-app/c07-container.mdx +1 -1
- package/zh/tutorials/first-app/c08-entries.mdx +2 -3
- package/zh/tutorials/foundations/introduction.mdx +14 -29
- package/en/apis/app/commands/index.mdx +0 -7
- package/en/apis/app/hooks/index.mdx +0 -7
- package/en/apis/app/runtime/index.mdx +0 -7
- package/en/guides/advanced-features/index.mdx +0 -7
- package/en/guides/basic-features/css/_category_.json +0 -4
- package/zh/apis/app/commands/index.mdx +0 -7
- package/zh/apis/app/hooks/index.mdx +0 -7
- package/zh/apis/app/runtime/index.mdx +0 -7
- package/zh/guides/advanced-features/index.mdx +0 -7
- package/zh/guides/basic-features/css/_category_.json +0 -4
- package/zh/guides/basic-features/index.mdx +0 -7
|
@@ -4,7 +4,7 @@ title: 开发主应用
|
|
|
4
4
|
---
|
|
5
5
|
# 开发主应用
|
|
6
6
|
|
|
7
|
-
在上一章 [体验微前端](/guides/topic-detail/micro-frontend/c02-development
|
|
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: '
|
|
45
|
-
entry: 'http://localhost:
|
|
46
|
-
// activeWhen: '/
|
|
44
|
+
name: 'Table',
|
|
45
|
+
entry: 'http://localhost:8001',
|
|
46
|
+
// activeWhen: '/table'
|
|
47
47
|
}, {
|
|
48
|
-
name: '
|
|
49
|
-
entry: 'http://localhost:
|
|
50
|
-
// activeWhen: '/
|
|
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={'/
|
|
85
|
-
<div><Link to={'/
|
|
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` 组件自定义了 **
|
|
141
|
+
这里通过 `Route` 组件自定义了 **Table** 的激活路由为 **/table**, **Dashboard** 的激活路由为 **/dashboard**。
|
|
142
142
|
|
|
143
143
|
### 集中式路由
|
|
144
144
|
|
|
@@ -162,7 +162,7 @@ function App() {
|
|
|
162
162
|
}
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
这样启动应用后,访问 `/
|
|
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
|
-
<
|
|
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
|
-
<
|
|
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
|
-
<
|
|
268
|
+
<Table
|
|
269
269
|
loadable={{
|
|
270
270
|
loading: Loading,
|
|
271
271
|
timeOut: 10000 // 10s
|
|
@@ -88,7 +88,7 @@ export default function App() {
|
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
:::info 补充信息
|
|
91
|
-
Modern.js 默认开启 [自动生成 actions](./auto-actions.
|
|
91
|
+
Modern.js 默认开启 [自动生成 actions](./auto-actions.mdx),所以 `stepModel` 中虽然没有手动定义 Actions,但可以使用自动生成的 `setState`。
|
|
92
92
|
|
|
93
93
|
:::
|
|
94
94
|
|
package/zh/index.md
CHANGED
|
@@ -81,10 +81,9 @@ rm src/routes/index.css
|
|
|
81
81
|
|
|
82
82
|
接下来,我们修改项目中的 `modern.config.ts`,开启 SSR 能力:
|
|
83
83
|
|
|
84
|
-
```ts
|
|
84
|
+
```ts title="modern.config.ts"
|
|
85
85
|
import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
86
86
|
|
|
87
|
-
// https://modernjs.dev/docs/apis/app/config
|
|
88
87
|
export default defineConfig({
|
|
89
88
|
runtime: {
|
|
90
89
|
router: true,
|
|
@@ -124,7 +124,6 @@ Modern.js 集成了主流、轻量、通用的 Utility Class 工具库 [Tailwind
|
|
|
124
124
|
import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
125
125
|
import tailwindcssPlugin from '@modern-js/plugin-tailwindcss';
|
|
126
126
|
|
|
127
|
-
// https://modernjs.dev/docs/apis/app/config
|
|
128
127
|
export default defineConfig({
|
|
129
128
|
runtime: {
|
|
130
129
|
router: true,
|
|
@@ -294,7 +293,7 @@ import '../styles/utils.css';
|
|
|
294
293
|
```
|
|
295
294
|
|
|
296
295
|
:::info
|
|
297
|
-
Modern.js 集成了 [PostCSS](/guides/
|
|
296
|
+
Modern.js 集成了 [PostCSS](/guides/css/postcss),支持现代 CSS 语法特性,比如 [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)。
|
|
298
297
|
|
|
299
298
|
:::
|
|
300
299
|
|
|
@@ -10,8 +10,8 @@ title: 添加业务模型(状态管理)
|
|
|
10
10
|
|
|
11
11
|
因此会开始编写一些跟 UI 完全无关的业务逻辑,如果继续写在组件代码中,会产生越来越多的面条式代码。为此,我们引入了一种叫做 **业务模型(Model)** 的代码模块,将这些业务逻辑和 UI 解耦。
|
|
12
12
|
|
|
13
|
-
:::info
|
|
14
|
-
使用状态管理相关 API,需要先启用配置项 [runtime.state](/
|
|
13
|
+
:::info 注意
|
|
14
|
+
使用状态管理相关 API,需要先启用配置项 [runtime.state](/configure/app/runtime/state):
|
|
15
15
|
|
|
16
16
|
```ts title="modern.config.ts"
|
|
17
17
|
import { defineConfig } from '@modern-js/app-tools';
|
|
@@ -277,6 +277,6 @@ export default Index;
|
|
|
277
277
|
|
|
278
278
|
`components/` 里的**视图组件**,都是目录形式,如 `Avatar/index.tsx`。而 `containers/` 里的**容器组件**,都是单文件形式,如 `contacts.tsx`。**这是我们推荐的一种最佳实践**。
|
|
279
279
|
|
|
280
|
-
在 [添加 UI 组件(Component)](./c02-component.
|
|
280
|
+
在 [添加 UI 组件(Component)](./c02-component.mdx) 章节提到过,视图组件用目录形式,是因为视图组件负责实现 UI 展示和交互细节,可以演变的复杂。用目录形式,可以方便增加子文件,包括专用的资源(图片等)、专用子组件、CSS 文件等。在这个目录内部可以随意重构,只考虑最小局部。
|
|
281
281
|
|
|
282
282
|
而容器组件只负责连接,是一个胶水层,复杂的业务逻辑和实现细节都交给 View 层和 Model 层去实现。容器组件自己应该保持简单清晰,不应该包含复杂实现细节,所以不应该有内部结构。采用单文件形式不但更简洁,也能起到约束作用,提醒开发者不要把容器组件写复杂。
|
|
@@ -91,13 +91,12 @@ mv src/myapp src/contacts
|
|
|
91
91
|
|
|
92
92
|
我们可以在 Modern.js 配置文件里,自己写代码来控制项目的配置。
|
|
93
93
|
|
|
94
|
-
现在,修改 `modern.config.ts
|
|
94
|
+
现在,修改 `modern.config.ts`,添加内容:
|
|
95
95
|
|
|
96
|
-
```ts
|
|
96
|
+
```ts title="modern.config.ts"
|
|
97
97
|
import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
98
98
|
import tailwindcssPlugin from '@modern-js/plugin-tailwindcss';
|
|
99
99
|
|
|
100
|
-
// https://modernjs.dev/docs/apis/app/config
|
|
101
100
|
export default defineConfig({
|
|
102
101
|
runtime: {
|
|
103
102
|
router: true,
|
|
@@ -2,44 +2,29 @@
|
|
|
2
2
|
title: 介绍
|
|
3
3
|
sidebar_position: 1
|
|
4
4
|
---
|
|
5
|
+
|
|
5
6
|
# 介绍
|
|
6
7
|
|
|
7
8
|
欢迎来到 Modern.js 教程!
|
|
8
9
|
|
|
9
10
|
阅读本栏目后,你将初步理解 Modern.js,并使用 Modern.js 创建第一个应用。
|
|
10
11
|
|
|
11
|
-
:::note 关注
|
|
12
|
-
加入我们的飞书群,咨询相关问题,了解最新动态。
|
|
13
|
-
|
|
14
|
-
:::
|
|
15
|
-
|
|
16
12
|
## Modern.js 是什么
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
框架内置多种开箱即用的开发工具,拥有极致的构建性能,支持零配置的渲染范式切换,一体化的 API 调用。并从三种工程方案出发(应用工程方案、模块工程方案,Monorepo 工程方案),支持全链路的前端研发。
|
|
21
|
-
|
|
22
|
-
Modern.js 是字节跳动的底层前端研发框架,已经直接或间接的服务上千个应用,包括中后台、PC Web、H5 等多种应用场景。框架覆盖完整的生命周期,拥有完善的插件体系,提供高度定制能力。支持通过生成器插件自定义业务线专属的工程方案,定制各种功能扩展和业务需求,帮助开发者更快速的搭建应用。
|
|
23
|
-
|
|
24
|
-
## 为什么使用 Modern.js
|
|
25
|
-
|
|
26
|
-
Modern.js 能为开发者提供极致的**开发体验(Development Experience)**,让应用拥有更好的**用户体验(User Experience)**。
|
|
27
|
-
|
|
28
|
-
在开发 React 应用过程中,开发者通常需要去为某些功能去设计实现方案,或是使用其他的库、框架来解决这些问题。Modern.js 支持 React 应用所需要的所有配置和工具,并内置**额外的功能和优化**。开发者可以使用 React 构建应用的 UI,然后逐步采用 Modern.js 的功能来解决常见的应用需求,如路由、数据获取、状态管理等。
|
|
29
|
-
|
|
30
|
-
它主要包含以下特点:
|
|
31
|
-
|
|
32
|
-
- 🪜 **渐进式**:使用最精简的模板创建项目,通过生成器逐步开启插件功能,定制解决方案。
|
|
33
|
-
- 🏠 **一体化**:开发与生产环境 Web Server 唯一,CSR 和 SSR 同构开发,函数即接口的 API 服务调用。
|
|
34
|
-
- 📦 **开箱即用**:默认 TS 支持,内置构建、ESLint、调试工具,全功能可测试。
|
|
35
|
-
- 🌏 **周边生态**:自研状态管理、微前端、模块打包、Monorepo 方案等周边需求。
|
|
36
|
-
- 🕸 **多种路由模式**:包含自控路由、基于文件约定的路由(嵌套路由)等。
|
|
37
|
-
- 🚀 **独立构建核心**:支持多种打包工具,深度优化构建产物。
|
|
14
|
+
如果你对 Modern.js 还不了解,可以先阅读 [Modern.js 介绍](/guides/get-started/introduction)。
|
|
38
15
|
|
|
39
|
-
##
|
|
16
|
+
## 实战教程
|
|
40
17
|
|
|
41
|
-
|
|
18
|
+
我们准备了一个创建「联系人列表应用」的实战教程,你可以按照教程一步步创建一个应用,并了解到 Modern.js 中的以下实践:
|
|
42
19
|
|
|
43
|
-
|
|
20
|
+
- 创建项目
|
|
21
|
+
- 使用 antd 组件库
|
|
22
|
+
- 集成 Tailwind CSS
|
|
23
|
+
- 客户端路由
|
|
24
|
+
- 数据获取
|
|
25
|
+
- 状态管理
|
|
26
|
+
- 容器组件
|
|
27
|
+
- 新建入口
|
|
28
|
+
- ...
|
|
44
29
|
|
|
45
|
-
|
|
30
|
+
下面就让我们从 [创建项目](tutorials/first-app/c01-start) 开始吧!
|