@modern-js/main-doc 2.3.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/components/init-app.mdx +1 -1
- 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 +64 -1
- package/en/guides/advanced-features/_category_.json +5 -0
- 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 +5 -5
- package/en/guides/advanced-features/testing.mdx +4 -5
- package/en/guides/advanced-features/web-server.mdx +0 -1
- package/en/guides/basic-features/_category_.json +5 -0
- 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 +33 -7
- package/en/guides/concept/_category_.json +5 -0
- package/en/guides/{basic-features → concept}/builder.mdx +2 -2
- 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/_category_.json +5 -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/config/{mwa.mdx → app.mdx} +1 -1
- package/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/new/createElement.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/new/introduce.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/develop.mdx +3 -3
- 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/custom-router-micro-frontend.mdx +40 -0
- package/zh/components/enable-micro-frontend.mdx +12 -2
- package/zh/components/micro-runtime-config.mdx +9 -10
- package/zh/components/release-note.mdx +1 -1
- package/zh/configure/app/builder-plugins.mdx +3 -3
- package/zh/configure/app/dev/asset-prefix.mdx +1 -1
- package/zh/configure/app/dev/hmr.mdx +1 -1
- package/zh/configure/app/dev/https.mdx +1 -1
- package/zh/configure/app/dev/port.mdx +1 -1
- package/zh/configure/app/dev/progress-bar.mdx +1 -1
- package/zh/configure/app/dev/start-url.mdx +1 -1
- package/zh/configure/app/experiments/lazy-compilation.mdx +1 -1
- package/zh/configure/app/html/app-icon.mdx +1 -1
- package/zh/configure/app/html/crossorigin.mdx +1 -1
- package/zh/configure/app/html/disable-html-folder.mdx +1 -1
- package/zh/configure/app/html/favicon-by-entries.mdx +1 -1
- package/zh/configure/app/html/favicon.mdx +1 -1
- package/zh/configure/app/html/inject-by-entries.mdx +1 -1
- package/zh/configure/app/html/inject.mdx +1 -1
- package/zh/configure/app/html/meta-by-entries.mdx +1 -1
- package/zh/configure/app/html/meta.mdx +1 -1
- package/zh/configure/app/html/mount-id.mdx +1 -1
- package/zh/configure/app/html/tags-by-entries.mdx +1 -1
- package/zh/configure/app/html/tags.mdx +1 -1
- package/zh/configure/app/html/template-by-entries.mdx +1 -1
- package/zh/configure/app/html/template-parameters-by-entries.mdx +1 -1
- package/zh/configure/app/html/template-parameters.mdx +1 -1
- package/zh/configure/app/html/template.mdx +1 -1
- package/zh/configure/app/html/title-by-entries.mdx +1 -1
- package/zh/configure/app/html/title.mdx +1 -1
- package/zh/configure/app/output/asset-prefix.mdx +1 -1
- package/zh/configure/app/output/assets-retry.mdx +1 -1
- package/zh/configure/app/output/charset.mdx +1 -1
- package/zh/configure/app/output/clean-dist-path.mdx +1 -1
- package/zh/configure/app/output/convert-to-rem.mdx +1 -1
- package/zh/configure/app/output/copy.mdx +1 -1
- package/zh/configure/app/output/css-module-local-ident-name.mdx +1 -1
- package/zh/configure/app/output/data-uri-limit.mdx +1 -1
- package/zh/configure/app/output/disable-css-extract.mdx +1 -1
- package/zh/configure/app/output/disable-css-module-extension.mdx +1 -1
- package/zh/configure/app/output/disable-filename-hash.mdx +1 -1
- package/zh/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
- package/zh/configure/app/output/disable-minimize.mdx +1 -1
- package/zh/configure/app/output/disable-source-map.mdx +1 -1
- package/zh/configure/app/output/disable-ts-checker.mdx +1 -1
- package/zh/configure/app/output/dist-path.mdx +1 -1
- package/zh/configure/app/output/enable-asset-fallback.mdx +1 -1
- package/zh/configure/app/output/enable-asset-manifest.mdx +1 -1
- package/zh/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
- package/zh/configure/app/output/enable-inline-scripts.mdx +1 -1
- package/zh/configure/app/output/enable-inline-styles.mdx +1 -1
- package/zh/configure/app/output/enable-latest-decorators.mdx +1 -1
- package/zh/configure/app/output/externals.mdx +1 -1
- package/zh/configure/app/output/filename.mdx +1 -1
- package/zh/configure/app/output/legal-comments.mdx +1 -1
- package/zh/configure/app/output/override-browserslist.mdx +1 -1
- package/zh/configure/app/output/polyfill.mdx +1 -1
- package/zh/configure/app/output/svg-default-export.mdx +1 -1
- package/zh/configure/app/performance/build-cache.mdx +1 -1
- package/zh/configure/app/performance/bundle-analyze.mdx +1 -1
- package/zh/configure/app/performance/chunk-split.mdx +1 -1
- package/zh/configure/app/performance/print-file-size.mdx +1 -1
- package/zh/configure/app/performance/profile.mdx +1 -1
- package/zh/configure/app/performance/remove-console.mdx +1 -1
- package/zh/configure/app/performance/remove-moment-locale.mdx +1 -1
- package/zh/configure/app/plugins.mdx +1 -1
- package/zh/configure/app/security/check-syntax.mdx +1 -1
- package/zh/configure/app/security/sri.mdx +1 -1
- package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
- package/zh/configure/app/source/alias.mdx +1 -1
- package/zh/configure/app/source/compile-js-data-uri.mdx +1 -1
- package/zh/configure/app/source/define.mdx +1 -1
- package/zh/configure/app/source/exclude.mdx +1 -1
- package/zh/configure/app/source/global-vars.mdx +1 -1
- package/zh/configure/app/source/include.mdx +1 -1
- package/zh/configure/app/source/module-scopes.mdx +1 -1
- package/zh/configure/app/source/pre-entry.mdx +1 -1
- package/zh/configure/app/source/resolve-extension-prefix.mdx +1 -1
- package/zh/configure/app/source/resolve-main-fields.mdx +1 -1
- package/zh/configure/app/tools/autoprefixer.mdx +1 -1
- package/zh/configure/app/tools/babel.mdx +1 -1
- package/zh/configure/app/tools/css-extract.mdx +1 -1
- package/zh/configure/app/tools/css-loader.mdx +1 -1
- package/zh/configure/app/tools/dev-server.mdx +1 -1
- package/zh/configure/app/tools/html-plugin.mdx +1 -1
- package/zh/configure/app/tools/inspector.mdx +1 -1
- package/zh/configure/app/tools/less.mdx +1 -1
- package/zh/configure/app/tools/minify-css.mdx +1 -1
- package/zh/configure/app/tools/postcss.mdx +1 -1
- package/zh/configure/app/tools/pug.mdx +1 -1
- package/zh/configure/app/tools/rspack.mdx +13 -0
- package/zh/configure/app/tools/sass.mdx +1 -1
- package/zh/configure/app/tools/style-loader.mdx +1 -1
- package/zh/configure/app/tools/styled-components.mdx +1 -1
- package/zh/configure/app/tools/terser.mdx +1 -1
- package/zh/configure/app/tools/ts-checker.mdx +1 -1
- package/zh/configure/app/tools/ts-loader.mdx +1 -1
- package/zh/configure/app/tools/webpack-chain.mdx +1 -1
- package/zh/configure/app/tools/webpack.mdx +1 -1
- package/zh/configure/app/usage.mdx +64 -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/ssr.mdx +2 -2
- 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 +41 -9
- 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/config/{mwa.mdx → app.mdx} +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/createElement.mdx +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/introduce.mdx +2 -2
- package/zh/guides/topic-detail/generator/plugin/develop.mdx +3 -3
- package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +155 -63
- package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +71 -40
- 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
@@ -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:
|
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,
|
@@ -41,4 +41,4 @@ export type ForgedAPI = {
|
|
41
41
|
|
42
42
|
## params
|
43
43
|
|
44
|
-
启用功能时其他参数,详细参考[应用 New 命令](/guides/topic-detail/generator/config/
|
44
|
+
启用功能时其他参数,详细参考[应用 New 命令](/guides/topic-detail/generator/config/app#new-命令)和[模块 New 命令](/guides/topic-detail/generator/config/module#new-命令)。
|
@@ -6,9 +6,9 @@ sidebar_position: 1
|
|
6
6
|
|
7
7
|
Modern.js 提供的三个工程方案支持在项目中执行 new 命令创建元素和开启功能。在生成器插件中可直接调用相关 API 默认创建一些元素和开启支持的功能。
|
8
8
|
|
9
|
-
不同的工程方案支持的 new
|
9
|
+
不同的工程方案支持的 new 操作:
|
10
10
|
|
11
|
-
- [应用](/guides/topic-detail/generator/config/
|
11
|
+
- [Web 应用](/guides/topic-detail/generator/config/app#new-命令)
|
12
12
|
|
13
13
|
- [模块](/guides/topic-detail/generator/config/module#new-命令)
|
14
14
|
|
@@ -6,7 +6,7 @@ sidebar_position: 3
|
|
6
6
|
|
7
7
|
## 创建项目
|
8
8
|
|
9
|
-
Modern.js
|
9
|
+
Modern.js 提供了生成器插件用于创建开发项目,可直接执行以下命令创建:
|
10
10
|
|
11
11
|
```bash
|
12
12
|
npx @modern-js/create plugin --plugin @modern-js/generator-plugin-plugin
|
@@ -14,7 +14,7 @@ npx @modern-js/create plugin --plugin @modern-js/generator-plugin-plugin
|
|
14
14
|
|
15
15
|
插件类型不同,会提问不同的问题,可根据需求选择插件类型
|
16
16
|
|
17
|
-
###
|
17
|
+
### 扩展工程方案
|
18
18
|
|
19
19
|
```
|
20
20
|
? 请选择你想创建的工程类型 模块
|
@@ -26,7 +26,7 @@ npx @modern-js/create plugin --plugin @modern-js/generator-plugin-plugin
|
|
26
26
|
? 插件基础类型 应用
|
27
27
|
```
|
28
28
|
|
29
|
-
###
|
29
|
+
### 创建工程方案场景
|
30
30
|
|
31
31
|
```
|
32
32
|
? 请选择你想创建的工程类型 模块
|
@@ -10,19 +10,20 @@ title: 体验微前端
|
|
10
10
|
- 微前端项目开发的基本流程。
|
11
11
|
|
12
12
|
## 创建应用
|
13
|
+
目前支持两种路由模式
|
14
|
+
- 自控式路由
|
15
|
+
- 约定式路由
|
13
16
|
|
14
|
-
|
17
|
+
首先明确主应用的路由模式 [创建约定式路由主应用](#创建约定式路由主应用) 或 [创建自控式路由主应用](#创建自控式路由主应用)
|
15
18
|
|
16
|
-
|
17
|
-
- dashboard 子应用
|
18
|
-
- table 子应用
|
19
|
+
在本次体验中我们会为主应用创建两个子应用 Table 和 Dashboard (Table 为约定式路由,Dashboard 为自控式路由)
|
19
20
|
|
20
|
-
###
|
21
|
+
### 创建约定式路由主应用
|
21
22
|
|
22
23
|
通过命令行工具初始化项目:
|
23
24
|
|
24
25
|
```bash
|
25
|
-
mkdir
|
26
|
+
mkdir masterApp && cd masterApp
|
26
27
|
npx @modern-js/create
|
27
28
|
```
|
28
29
|
|
@@ -43,16 +44,96 @@ import EnableMicroFrontend from "@site-docs/components/enable-micro-frontend";
|
|
43
44
|
|
44
45
|
<EnableMicroFrontend />
|
45
46
|
|
46
|
-
|
47
|
+
然后我们在 routes 文件夹下新建两个目录
|
48
|
+
- table (用于加载约定式路由子应用)
|
49
|
+
- dashboard (用于加载自控式路由子应用)
|
47
50
|
|
48
|
-
|
51
|
+
在这两个目录下我们需要新建一个 `$.tsx` 文件作为主应用约定式路由的入口($ 代表模糊匹配,即 `/table` 和 `/table/test` 都会匹配到这个 `$.tsx` 作为该路由的入口文件,这会保证在微前端场景下正确加载子应用路由)
|
49
52
|
|
50
|
-
|
53
|
+
#### 加载约定式路由子应用
|
54
|
+
```js title="src/routes/table/$.tsx"
|
55
|
+
import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
|
56
|
+
|
57
|
+
const Index = () => {
|
58
|
+
const { Table } = useModuleApps();
|
59
|
+
|
60
|
+
return (
|
61
|
+
<div>
|
62
|
+
<Table />
|
63
|
+
</div>
|
64
|
+
)
|
65
|
+
}
|
66
|
+
|
67
|
+
export default Index;
|
68
|
+
```
|
69
|
+
|
70
|
+
#### 加载自控式路由子应用
|
71
|
+
```js title="src/routes/dashboard/$.tsx"
|
72
|
+
import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
|
73
|
+
|
74
|
+
const Index = () => {
|
75
|
+
const { Dashboard } = useModuleApps();
|
76
|
+
|
77
|
+
return (
|
78
|
+
<div>
|
79
|
+
<Dashboard />
|
80
|
+
</div>
|
81
|
+
)
|
82
|
+
}
|
83
|
+
|
84
|
+
export default Index;
|
85
|
+
```
|
86
|
+
#### 路由跳转
|
87
|
+
此时主应用配置已经完成,通过路由即可加载子应用,修改主应用的 `layout.tsx` 来跳转路由
|
88
|
+
```js title="src/route/layout.tsx"
|
89
|
+
import { Outlet, Link } from '@modern-js/runtime/router';
|
90
|
+
|
91
|
+
const Layout = () => (
|
92
|
+
<div>
|
93
|
+
<div><Link to={'/table'}>加载约定式路由子应用</Link></div>
|
94
|
+
<div><Link to={'/dashboard'}>加载自控式路由子应用</Link></div>
|
95
|
+
<div><Link to={'/'}>卸载子应用</Link></div>
|
96
|
+
<Outlet />
|
97
|
+
</div>
|
98
|
+
);
|
99
|
+
|
100
|
+
export default Layout;
|
101
|
+
```
|
102
|
+
|
103
|
+
### 创建自控式路由主应用
|
51
104
|
|
52
105
|
通过命令行工具初始化项目:
|
53
106
|
|
54
107
|
```bash
|
55
|
-
mkdir
|
108
|
+
mkdir masterApp && cd masterApp
|
109
|
+
npx @modern-js/create
|
110
|
+
```
|
111
|
+
|
112
|
+
<DefaultMWAGenerate />
|
113
|
+
|
114
|
+
完成项目创建后我们可以通过 `pnpm run new` 来开启 `微前端` 功能:
|
115
|
+
|
116
|
+
```bash
|
117
|
+
? 请选择你想要的操作 启用可选功能
|
118
|
+
? 启用可选功能 启用「微前端」模式
|
119
|
+
```
|
120
|
+
|
121
|
+
接下来,让我们注册微前端插件并添加开启微前端主应用,并增加子应用列表:
|
122
|
+
|
123
|
+
<EnableMicroFrontend />
|
124
|
+
|
125
|
+
由于是自控式路由,我们删除掉 `routes` 文件夹并在 `src` 目录下增加 `App.tsx` 文件,此处如果使用的 `非 MApp` 组件,需要通过 `React Router v6` 的 `createBrowserRouter` API 来创建路由
|
126
|
+
#### 加载子应用
|
127
|
+
import CustomRouterMicroFrontend from "@site-docs/components/custom-router-micro-frontend";
|
128
|
+
|
129
|
+
<CustomRouterMicroFrontend />
|
130
|
+
|
131
|
+
### 创建约定式路由子应用
|
132
|
+
|
133
|
+
通过命令行工具初始化项目:
|
134
|
+
|
135
|
+
```bash
|
136
|
+
mkdir table && cd table
|
56
137
|
npx @modern-js/create
|
57
138
|
```
|
58
139
|
|
@@ -74,6 +155,9 @@ import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
74
155
|
import garfishPlugin from '@modern-js/plugin-garfish';
|
75
156
|
|
76
157
|
export default defineConfig({
|
158
|
+
dev: {
|
159
|
+
port: 8081
|
160
|
+
},
|
77
161
|
runtime: {
|
78
162
|
router: true,
|
79
163
|
state: true,
|
@@ -85,12 +169,23 @@ export default defineConfig({
|
|
85
169
|
});
|
86
170
|
```
|
87
171
|
|
88
|
-
|
172
|
+
添加 `src/routes/page.tsx` 代码
|
173
|
+
```js title="src/routes/page.tsx"
|
174
|
+
const Index = () => {
|
175
|
+
return (
|
176
|
+
<div className="container-box">subApp: 约定式路由的子应用的根路由</div>
|
177
|
+
)
|
178
|
+
}
|
179
|
+
|
180
|
+
export default Index;
|
181
|
+
```
|
182
|
+
|
183
|
+
### 创建自控式路由子应用
|
89
184
|
|
90
185
|
通过命令行工具初始化项目:
|
91
186
|
|
92
187
|
```bash
|
93
|
-
mkdir
|
188
|
+
mkdir dashboard && cd dashboard
|
94
189
|
npx @modern-js/create
|
95
190
|
```
|
96
191
|
|
@@ -112,6 +207,9 @@ import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
112
207
|
import garfishPlugin from '@modern-js/plugin-garfish';
|
113
208
|
|
114
209
|
export default defineConfig({
|
210
|
+
dev: {
|
211
|
+
port: 8082
|
212
|
+
},
|
115
213
|
runtime: {
|
116
214
|
router: true,
|
117
215
|
state: true,
|
@@ -122,67 +220,61 @@ export default defineConfig({
|
|
122
220
|
plugins: [appTools(), garfishPlugin()],
|
123
221
|
});
|
124
222
|
```
|
223
|
+
自控式路由需要删除掉 `routes` 文件夹并在 `src` 目录下新建 `App.tsx`
|
125
224
|
|
126
|
-
|
127
|
-
|
128
|
-
### main 主应用
|
225
|
+
并在 `src/App.tsx` 添加代码,注意需要从 `props` 中解析并传递 `basename` 给 `BrowserRouter`
|
129
226
|
|
130
|
-
|
227
|
+
```js title="src/App.tsx"
|
228
|
+
import { BrowserRouter, Route, Routes } from '@modern-js/runtime/router';
|
131
229
|
|
132
|
-
|
133
|
-
|
134
|
-
import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
|
230
|
+
export default (props: {basename: string}) => {
|
231
|
+
const { basename } = props;
|
135
232
|
|
136
|
-
const App = () => {
|
137
|
-
const { DashBoard, TableList } = useModuleApps();
|
138
233
|
return (
|
139
|
-
<
|
140
|
-
<
|
141
|
-
<
|
142
|
-
<
|
143
|
-
</
|
144
|
-
|
145
|
-
<DashBoard />
|
146
|
-
</Route>
|
147
|
-
<Route path="/table">
|
148
|
-
<TableList />
|
149
|
-
</Route>
|
150
|
-
</div>
|
234
|
+
<BrowserRouter basename={basename}>
|
235
|
+
<Routes>
|
236
|
+
<Route index element={<div>自控式路由子应用根路由</div>} />
|
237
|
+
<Route path={'path'} element={<div>自控式路由子应用子路由</div>} />
|
238
|
+
</Routes>
|
239
|
+
</BrowserRouter>
|
151
240
|
);
|
152
241
|
};
|
153
|
-
|
154
|
-
export default App;
|
155
|
-
```
|
156
|
-
|
157
|
-
### dashboard 子应用
|
158
|
-
|
159
|
-
删除 `src/routers` 目录, 创建 `src/App.tsx`,并添加如下内容:
|
160
|
-
|
161
|
-
```tsx
|
162
|
-
export default () => <div>Dashboard Page</div>;
|
163
|
-
```
|
164
|
-
|
165
|
-
### table 子应用
|
166
|
-
|
167
|
-
删除 `src/routers` 目录, 创建 `src/App.tsx`,并添加如下内容:
|
168
|
-
|
169
|
-
```tsx
|
170
|
-
export default () => <div>Table Page</div>;
|
171
242
|
```
|
172
243
|
|
173
244
|
## 调试
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
245
|
+
按顺序在目录执行 `pnpm run dev` 命令启动应用:
|
246
|
+
- masterApp 主应用 `http://localhost:8080`
|
247
|
+
- table 子应用(约定式路由) `http://localhost:8081`
|
248
|
+
- dashboard 子应用(自控式路由) `http://localhost:8082`
|
249
|
+
|
250
|
+
访问主应用地址 `http://localhost:8080`
|
251
|
+
|
252
|
+
在完成了微前端整体开发流程的体验后,你可以进一步了解如何 [开发主应用](/guides/topic-detail/micro-frontend/c03-main-app)
|
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 实例`(子应用)
|
186
278
|
|
187
279
|
## 常见问题
|
188
280
|
|
@@ -4,7 +4,7 @@ title: 开发主应用
|
|
4
4
|
---
|
5
5
|
# 开发主应用
|
6
6
|
|
7
|
-
在上一章 [体验微前端](
|
7
|
+
在上一章 [体验微前端](/guides/topic-detail/micro-frontend/c02-development) 通过一个示例演示了如何创建和配置微前端子应用,通过本章你可以进一步了解如何开发主应用,以及它的常见配置。
|
8
8
|
|
9
9
|
在通过 `@modern-js/create` 命令创建应用工程后,可以在项目中执行 `pnpm run new`(实际执行了 `modern new` 命令),在选择了「微前端」模式后,会安装微前端依赖依赖,只需手动注册插件即可。
|
10
10
|
|
@@ -40,16 +40,15 @@ defineConfig(App, {
|
|
40
40
|
manifest: {
|
41
41
|
getAppList: async () => {
|
42
42
|
// 可以从其他远程接口获取
|
43
|
-
return [
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
];
|
43
|
+
return [{
|
44
|
+
name: 'Table',
|
45
|
+
entry: 'http://localhost:8001',
|
46
|
+
// activeWhen: '/table'
|
47
|
+
}, {
|
48
|
+
name: 'Dashboard',
|
49
|
+
entry: 'http://localhost:8002'
|
50
|
+
// activeWhen: '/dashboard'
|
51
|
+
}];
|
53
52
|
},
|
54
53
|
},
|
55
54
|
},
|
@@ -75,39 +74,71 @@ defineConfig(App, {
|
|
75
74
|
|
76
75
|
编辑主应用 `App.tsx` 文件如下:
|
77
76
|
|
78
|
-
```
|
77
|
+
```js title="App.tsx"
|
79
78
|
import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
|
80
|
-
import { Route, Switch } from '@modern-js/runtime/router';
|
81
79
|
|
82
|
-
|
83
|
-
const { DashBoard, TableList } = useModuleApps();
|
80
|
+
import { RouterProvider, Route, createBrowserRouter, createRoutesFromElements, BrowserRouter, Link, Outlet } from '@modern-js/runtime/router';
|
84
81
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
82
|
+
const AppLayout = () => (
|
83
|
+
<>
|
84
|
+
<div><Link to={'/table'}>加载约定式路由子应用</Link></div>
|
85
|
+
<div><Link to={'/dashboard'}>加载自控式路由子应用</Link></div>
|
86
|
+
<div><Link to={'/'}>卸载子应用</Link></div>
|
87
|
+
<Outlet />
|
88
|
+
</>
|
89
|
+
)
|
90
|
+
|
91
|
+
export default () => {
|
92
|
+
const { apps, MApp } = useModuleApps();
|
93
|
+
|
94
|
+
// 使用的不是 MApp 组件,需要使用 createBrowserRouter 来创建路由
|
95
|
+
const router = createBrowserRouter(
|
96
|
+
createRoutesFromElements(
|
97
|
+
<Route path="/" element={<AppLayout />}>
|
98
|
+
{apps.map(app => {
|
99
|
+
const { Component } = app;
|
100
|
+
// 模糊匹配,path 需要写成类似 abc/* 的模式
|
101
|
+
return (
|
102
|
+
<Route
|
103
|
+
key={app.name}
|
104
|
+
path={`${app.name.toLowerCase()}/*`}
|
105
|
+
element={
|
106
|
+
<Component
|
107
|
+
loadable={{
|
108
|
+
loading: ({ pastDelay, error }: any) => {
|
109
|
+
if (error) {
|
110
|
+
return <div>error: {error?.message}</div>;
|
111
|
+
} else if (pastDelay) {
|
112
|
+
return <div>loading</div>;
|
113
|
+
} else {
|
114
|
+
return null;
|
115
|
+
}
|
116
|
+
},
|
117
|
+
}}
|
118
|
+
/>
|
97
119
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
</Route>
|
102
|
-
<Route path="/table">
|
103
|
-
<TableList />
|
120
|
+
/>
|
121
|
+
)
|
122
|
+
})}
|
104
123
|
</Route>
|
105
|
-
|
124
|
+
)
|
106
125
|
);
|
107
|
-
|
126
|
+
|
127
|
+
return (
|
128
|
+
// 方法一:使用 MApp 自动根据配置的 activeWhen 参数加载子应用(本项目配置在 modern.config.ts 中)
|
129
|
+
// <BrowserRouter>
|
130
|
+
// <MApp />
|
131
|
+
// </BrowserRouter>
|
132
|
+
|
133
|
+
// 方法二:手动写 Route 组件方式加载子应用,方便于需要鉴权等需要前置操作的场景
|
134
|
+
<>
|
135
|
+
<RouterProvider router={router} />
|
136
|
+
</>
|
137
|
+
);
|
138
|
+
};
|
108
139
|
```
|
109
140
|
|
110
|
-
这里通过 `Route` 组件自定义了 **
|
141
|
+
这里通过 `Route` 组件自定义了 **Table** 的激活路由为 **/table**, **Dashboard** 的激活路由为 **/dashboard**。
|
111
142
|
|
112
143
|
### 集中式路由
|
113
144
|
|
@@ -131,7 +162,7 @@ function App() {
|
|
131
162
|
}
|
132
163
|
```
|
133
164
|
|
134
|
-
这样启动应用后,访问 `/
|
165
|
+
这样启动应用后,访问 `/table` 路由,会渲染 `Table` 子应用,访问 `/dashboard` 路由,会渲染 `Dashboard` 子应用。
|
135
166
|
|
136
167
|
### 两种模式混用
|
137
168
|
|
@@ -151,7 +182,7 @@ function Loading() {
|
|
151
182
|
|
152
183
|
function App(){
|
153
184
|
return <>
|
154
|
-
<
|
185
|
+
<Table
|
155
186
|
loadable={{
|
156
187
|
loading: Loading,
|
157
188
|
}}
|
@@ -198,7 +229,7 @@ function Loading({ error, pastDelay }) {
|
|
198
229
|
|
199
230
|
function App(){
|
200
231
|
return <>
|
201
|
-
<
|
232
|
+
<Table
|
202
233
|
loadable={{
|
203
234
|
loading: Loading,
|
204
235
|
delay: 300 // 0.3 seconds
|
@@ -234,7 +265,7 @@ function Loading({ error, timeOut, pastDelay }) {
|
|
234
265
|
|
235
266
|
function App(){
|
236
267
|
return <>
|
237
|
-
<
|
268
|
+
<Table
|
238
269
|
loadable={{
|
239
270
|
loading: Loading,
|
240
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
|
|