@fecommunity/reactpress-toolkit 3.0.4 → 3.1.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/README.md +194 -309
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.js +18 -0
- package/dist/admin/permissions.d.ts +5 -0
- package/dist/admin/permissions.js +33 -0
- package/dist/admin/registry.d.ts +62 -0
- package/dist/admin/registry.js +79 -0
- package/dist/api/HttpClient.d.ts +2 -2
- package/dist/api/HttpClient.js +1 -1
- package/dist/api/Smtp.d.ts +17 -0
- package/dist/api/Smtp.js +15 -0
- package/dist/api/instance.d.ts +1 -1
- package/dist/api/instance.js +3 -3
- package/dist/app/createReactPressApp.d.ts +88 -0
- package/dist/app/createReactPressApp.js +262 -0
- package/dist/app/createThemeApp.d.ts +6 -0
- package/dist/app/createThemeApp.js +47 -0
- package/dist/app/devChunkRecovery.d.ts +2 -0
- package/dist/app/devChunkRecovery.js +68 -0
- package/dist/app/index.d.ts +39 -0
- package/dist/app/index.js +11 -0
- package/dist/config/env.js +29 -15
- package/dist/config/global.d.ts +7 -1
- package/dist/config/global.js +9 -3
- package/dist/config/i18n.js +27 -11
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +6 -5
- package/dist/{locales → config/locales}/en.json +31 -3
- package/dist/{locales → config/locales}/zh.json +31 -3
- package/dist/dev/index.d.ts +3 -0
- package/dist/dev/index.js +12 -0
- package/dist/dev/portRedirect.d.ts +20 -0
- package/dist/dev/portRedirect.js +93 -0
- package/dist/dev/vitePortRedirectPlugin.d.ts +24 -0
- package/dist/dev/vitePortRedirectPlugin.js +40 -0
- package/dist/extension/branding-mods.d.ts +10 -0
- package/dist/extension/branding-mods.js +65 -0
- package/dist/extension/configuration/defaults.d.ts +3 -0
- package/dist/extension/configuration/defaults.js +32 -0
- package/dist/extension/configuration/formily.d.ts +10 -0
- package/dist/extension/configuration/formily.js +170 -0
- package/dist/extension/configuration/index.d.ts +7 -0
- package/dist/extension/configuration/index.js +28 -0
- package/dist/extension/configuration/paths.d.ts +4 -0
- package/dist/extension/configuration/paths.js +50 -0
- package/dist/extension/configuration/presets/twentytwentyfive.d.ts +7 -0
- package/dist/extension/configuration/presets/twentytwentyfive.js +94 -0
- package/dist/extension/configuration/resolve.d.ts +24 -0
- package/dist/extension/configuration/resolve.js +98 -0
- package/dist/extension/configuration/types.d.ts +68 -0
- package/dist/extension/configuration/types.js +3 -0
- package/dist/extension/configuration/validate.d.ts +8 -0
- package/dist/extension/configuration/validate.js +21 -0
- package/dist/extension/index.d.ts +9 -0
- package/dist/extension/index.js +35 -0
- package/dist/extension/manifest-normalize.d.ts +5 -0
- package/dist/extension/manifest-normalize.js +75 -0
- package/dist/extension/node.d.ts +2 -0
- package/dist/extension/node.js +6 -0
- package/dist/extension/presets/twentytwentyfive-appearance.d.ts +10 -0
- package/dist/extension/presets/twentytwentyfive-appearance.js +193 -0
- package/dist/extension/presets/twentytwentyfive-customizer.d.ts +19 -0
- package/dist/extension/presets/twentytwentyfive-customizer.js +199 -0
- package/dist/extension/preview.d.ts +46 -0
- package/dist/extension/preview.js +92 -0
- package/dist/extension/site-notices.d.ts +19 -0
- package/dist/extension/site-notices.js +88 -0
- package/dist/extension/site-settings.d.ts +37 -0
- package/dist/extension/site-settings.js +144 -0
- package/dist/extension/theme-admin-locale.d.ts +11 -0
- package/dist/extension/theme-admin-locale.io.d.ts +2 -0
- package/dist/extension/theme-admin-locale.io.js +54 -0
- package/dist/extension/theme-admin-locale.js +81 -0
- package/dist/extension/theme.d.ts +89 -0
- package/dist/extension/theme.js +93 -0
- package/dist/extension/twentytwentyfive-vars.d.ts +7 -0
- package/dist/extension/twentytwentyfive-vars.js +100 -0
- package/dist/index.d.ts +15 -7
- package/dist/index.js +44 -22
- package/dist/plugin/admin/index.d.ts +2 -0
- package/dist/plugin/admin/index.js +18 -0
- package/dist/plugin/admin/permissions.d.ts +5 -0
- package/dist/plugin/admin/permissions.js +33 -0
- package/dist/plugin/admin/registry.d.ts +62 -0
- package/dist/plugin/admin/registry.js +79 -0
- package/dist/plugin/client/client.d.ts +14 -0
- package/dist/plugin/client/client.js +95 -0
- package/dist/plugin/client/index.d.ts +4 -0
- package/dist/plugin/client/index.js +11 -0
- package/dist/plugin/client/runtime.d.ts +18 -0
- package/dist/plugin/client/runtime.js +30 -0
- package/dist/plugin/dev/index.d.ts +4 -0
- package/dist/plugin/dev/index.js +16 -0
- package/dist/plugin/dev/portRedirect.d.ts +26 -0
- package/dist/plugin/dev/portRedirect.js +111 -0
- package/dist/plugin/dev/vitePortRedirectPlugin.d.ts +24 -0
- package/dist/plugin/dev/vitePortRedirectPlugin.js +40 -0
- package/dist/plugin/index.d.ts +9 -0
- package/dist/plugin/index.js +48 -0
- package/dist/plugin/react/client.d.ts +14 -0
- package/dist/plugin/react/client.js +95 -0
- package/dist/plugin/react/index.d.ts +2 -0
- package/dist/plugin/react/index.js +18 -0
- package/dist/plugin/react/runtime.d.ts +18 -0
- package/dist/plugin/react/runtime.js +30 -0
- package/dist/primitives/AntdStyleTransitionFix.d.ts +2 -0
- package/dist/primitives/AntdStyleTransitionFix.js +16 -0
- package/dist/primitives/Badge.d.ts +7 -0
- package/dist/primitives/Badge.js +9 -0
- package/dist/primitives/Button.d.ts +10 -0
- package/dist/primitives/Button.js +38 -0
- package/dist/primitives/ColorModeToggle.d.ts +8 -0
- package/dist/primitives/ColorModeToggle.js +13 -0
- package/dist/primitives/IconButton.d.ts +7 -0
- package/dist/primitives/IconButton.js +13 -0
- package/dist/primitives/ScrollToTarget.d.ts +9 -0
- package/dist/primitives/ScrollToTarget.js +48 -0
- package/dist/primitives/Separator.d.ts +7 -0
- package/dist/primitives/Separator.js +9 -0
- package/dist/primitives/Skeleton.d.ts +7 -0
- package/dist/primitives/Skeleton.js +9 -0
- package/dist/primitives/Slot.d.ts +10 -0
- package/dist/primitives/Slot.js +25 -0
- package/dist/primitives/Spinner.d.ts +6 -0
- package/dist/primitives/Spinner.js +9 -0
- package/dist/primitives/animation/ConditionTransition.d.ts +8 -0
- package/dist/primitives/animation/ConditionTransition.js +13 -0
- package/dist/primitives/animation/ListTrail.d.ts +10 -0
- package/dist/primitives/animation/ListTrail.js +14 -0
- package/dist/primitives/animation/Opacity.d.ts +3 -0
- package/dist/primitives/animation/Opacity.js +10 -0
- package/dist/primitives/animation/Spring.d.ts +9 -0
- package/dist/primitives/animation/Spring.js +29 -0
- package/dist/primitives/animation/index.d.ts +7 -0
- package/dist/primitives/animation/index.js +11 -0
- package/dist/primitives/cn.d.ts +4 -0
- package/dist/primitives/cn.js +7 -0
- package/dist/primitives/icons.d.ts +4 -0
- package/dist/primitives/icons.js +15 -0
- package/dist/primitives/index.d.ts +22 -0
- package/dist/primitives/index.js +44 -0
- package/dist/react/client.d.ts +14 -0
- package/dist/react/client.js +95 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +11 -0
- package/dist/react/runtime.d.ts +18 -0
- package/dist/react/runtime.js +30 -0
- package/dist/theme/antdDocument.d.ts +18 -0
- package/dist/theme/antdDocument.js +59 -0
- package/dist/theme/api/api-data.d.ts +2 -0
- package/dist/theme/api/api-data.js +8 -0
- package/dist/theme/api/api.d.ts +28 -0
- package/dist/theme/api/api.js +27 -0
- package/dist/theme/api/httpClient.d.ts +24 -0
- package/dist/theme/api/httpClient.js +83 -0
- package/dist/theme/api/json.d.ts +1 -0
- package/dist/theme/api/json.js +5 -0
- package/dist/theme/api/jsonp.d.ts +1 -0
- package/dist/theme/api/jsonp.js +5 -0
- package/dist/theme/api-data.d.ts +12 -0
- package/dist/theme/api-data.js +22 -0
- package/dist/theme/api.d.ts +28 -0
- package/dist/theme/api.js +27 -0
- package/dist/theme/appearance.d.ts +4 -0
- package/dist/theme/appearance.js +16 -0
- package/dist/theme/assets.d.ts +2 -0
- package/dist/theme/assets.js +27 -0
- package/dist/theme/authSession.d.ts +16 -0
- package/dist/theme/authSession.js +92 -0
- package/dist/theme/build/antdDocument.d.ts +145 -0
- package/dist/theme/build/antdDocument.js +70 -0
- package/dist/theme/build/next-config.d.ts +17 -0
- package/dist/theme/build/next-config.js +100 -0
- package/dist/theme/build/node.d.ts +2 -0
- package/dist/theme/build/node.js +6 -0
- package/dist/theme/colorMode.d.ts +12 -0
- package/dist/theme/colorMode.js +45 -0
- package/dist/theme/commentAuthor.d.ts +17 -0
- package/dist/theme/commentAuthor.js +48 -0
- package/dist/theme/content/archiveSlim.d.ts +7 -0
- package/dist/theme/content/archiveSlim.js +38 -0
- package/dist/theme/content/articleSlim.d.ts +10 -0
- package/dist/theme/content/articleSlim.js +35 -0
- package/dist/theme/content/assets.d.ts +8 -0
- package/dist/theme/content/assets.js +74 -0
- package/dist/theme/content/carouselArticles.d.ts +10 -0
- package/dist/theme/content/carouselArticles.js +39 -0
- package/dist/theme/content/excerpt.d.ts +15 -0
- package/dist/theme/content/excerpt.js +42 -0
- package/dist/theme/content/nav.d.ts +10 -0
- package/dist/theme/content/nav.js +30 -0
- package/dist/theme/content/seo.d.ts +6 -0
- package/dist/theme/content/seo.js +12 -0
- package/dist/theme/createAntdApp.d.ts +106 -0
- package/dist/theme/createAntdApp.js +175 -0
- package/dist/theme/createApp.d.ts +10 -0
- package/dist/theme/createApp.js +141 -0
- package/dist/theme/createCatalogApp.d.ts +108 -0
- package/dist/theme/createCatalogApp.js +168 -0
- package/dist/theme/customizer.d.ts +1 -0
- package/dist/theme/customizer.js +5 -0
- package/dist/theme/excerpt.d.ts +16 -0
- package/dist/theme/excerpt.js +31 -0
- package/dist/theme/extension/branding-mods.d.ts +10 -0
- package/dist/theme/extension/branding-mods.js +65 -0
- package/dist/theme/extension/configuration/defaults.d.ts +3 -0
- package/dist/theme/extension/configuration/defaults.js +32 -0
- package/dist/theme/extension/configuration/formily.d.ts +10 -0
- package/dist/theme/extension/configuration/formily.js +170 -0
- package/dist/theme/extension/configuration/index.d.ts +7 -0
- package/dist/theme/extension/configuration/index.js +28 -0
- package/dist/theme/extension/configuration/paths.d.ts +1 -0
- package/dist/theme/extension/configuration/paths.js +7 -0
- package/dist/theme/extension/configuration/presets/twentytwentyfive.d.ts +7 -0
- package/dist/theme/extension/configuration/presets/twentytwentyfive.js +94 -0
- package/dist/theme/extension/configuration/resolve.d.ts +24 -0
- package/dist/theme/extension/configuration/resolve.js +98 -0
- package/dist/theme/extension/configuration/types.d.ts +68 -0
- package/dist/theme/extension/configuration/types.js +3 -0
- package/dist/theme/extension/configuration/validate.d.ts +8 -0
- package/dist/theme/extension/configuration/validate.js +21 -0
- package/dist/theme/extension/index.d.ts +11 -0
- package/dist/theme/extension/index.js +38 -0
- package/dist/theme/extension/manifest-normalize.d.ts +5 -0
- package/dist/theme/extension/manifest-normalize.js +75 -0
- package/dist/theme/extension/presets/twentytwentyfive-appearance.d.ts +10 -0
- package/dist/theme/extension/presets/twentytwentyfive-appearance.js +193 -0
- package/dist/theme/extension/preview.d.ts +46 -0
- package/dist/theme/extension/preview.js +92 -0
- package/dist/theme/extension/site-notices.d.ts +19 -0
- package/dist/theme/extension/site-notices.js +88 -0
- package/dist/theme/extension/site-settings.d.ts +37 -0
- package/dist/theme/extension/site-settings.js +144 -0
- package/dist/theme/extension/siteNav.d.ts +18 -0
- package/dist/theme/extension/siteNav.js +17 -0
- package/dist/theme/extension/theme-admin-locale.d.ts +11 -0
- package/dist/theme/extension/theme-admin-locale.io.d.ts +2 -0
- package/dist/theme/extension/theme-admin-locale.io.js +54 -0
- package/dist/theme/extension/theme-admin-locale.js +68 -0
- package/dist/theme/extension/theme.d.ts +89 -0
- package/dist/theme/extension/theme.js +93 -0
- package/dist/theme/extension/twentytwentyfive-vars.d.ts +9 -0
- package/dist/theme/extension/twentytwentyfive-vars.js +103 -0
- package/dist/theme/fetch.d.ts +134 -0
- package/dist/theme/fetch.js +241 -0
- package/dist/theme/format.d.ts +16 -0
- package/dist/theme/format.js +48 -0
- package/dist/theme/httpClient.d.ts +20 -0
- package/dist/theme/httpClient.js +89 -0
- package/dist/theme/index.d.ts +63 -0
- package/dist/theme/index.js +226 -0
- package/dist/theme/json.d.ts +1 -0
- package/dist/theme/json.js +17 -0
- package/dist/theme/jsonp.d.ts +8 -0
- package/dist/theme/jsonp.js +27 -0
- package/dist/theme/locale.d.ts +23 -0
- package/dist/theme/locale.js +55 -0
- package/dist/theme/nav.d.ts +10 -0
- package/dist/theme/nav.js +30 -0
- package/dist/theme/next-config.d.ts +2 -0
- package/dist/theme/next-config.js +18 -0
- package/dist/theme/node.d.ts +2 -0
- package/dist/theme/node.js +18 -0
- package/dist/theme/preview/preview-config.d.ts +13 -0
- package/dist/theme/preview/preview-config.js +65 -0
- package/dist/theme/preview/preview-draft.d.ts +19 -0
- package/dist/theme/preview/preview-draft.js +51 -0
- package/dist/theme/preview/preview-mods.d.ts +16 -0
- package/dist/theme/preview/preview-mods.js +78 -0
- package/dist/theme/preview-config.d.ts +13 -0
- package/dist/theme/preview-config.js +65 -0
- package/dist/theme/preview-draft.d.ts +19 -0
- package/dist/theme/preview-draft.js +51 -0
- package/dist/theme/preview-mods.d.ts +16 -0
- package/dist/theme/preview-mods.js +78 -0
- package/dist/theme/providers/index.d.ts +118 -0
- package/dist/theme/providers/index.js +251 -0
- package/dist/theme/providers/setup.d.ts +124 -0
- package/dist/theme/providers/setup.js +29 -0
- package/dist/theme/runtime.d.ts +18 -0
- package/dist/theme/runtime.js +19 -0
- package/dist/theme/seo.d.ts +6 -0
- package/dist/theme/seo.js +12 -0
- package/dist/theme/server.d.ts +65 -0
- package/dist/theme/server.js +177 -0
- package/dist/theme/setting.d.ts +12 -0
- package/dist/theme/setting.js +42 -0
- package/dist/theme/ssr/bootstrap.d.ts +48 -0
- package/dist/theme/ssr/bootstrap.js +112 -0
- package/dist/theme/ssr/fetch.d.ts +134 -0
- package/dist/theme/ssr/fetch.js +264 -0
- package/dist/theme/ssr/format.d.ts +3 -0
- package/dist/theme/ssr/format.js +8 -0
- package/dist/theme/ssr/pageProps.d.ts +62 -0
- package/dist/theme/ssr/pageProps.js +138 -0
- package/dist/theme/ssr/setting.d.ts +12 -0
- package/dist/theme/ssr/setting.js +42 -0
- package/dist/theme/ssr/slimBootstrap.d.ts +11 -0
- package/dist/theme/ssr/slimBootstrap.js +75 -0
- package/dist/theme/ssr/static.d.ts +10 -0
- package/dist/theme/ssr/static.js +17 -0
- package/dist/theme/ssr/templates.d.ts +35 -0
- package/dist/theme/ssr/templates.js +50 -0
- package/dist/theme/static.d.ts +10 -0
- package/dist/theme/static.js +17 -0
- package/dist/theme/templates.d.ts +27 -0
- package/dist/theme/templates.js +38 -0
- package/dist/theme/ui-optional.d.ts +1 -0
- package/dist/theme/ui-optional.js +21 -0
- package/dist/theme/visitor/appearance.d.ts +4 -0
- package/dist/theme/visitor/appearance.js +16 -0
- package/dist/theme/visitor/authSession.d.ts +16 -0
- package/dist/theme/visitor/authSession.js +92 -0
- package/dist/theme/visitor/colorMode.d.ts +17 -0
- package/dist/theme/visitor/colorMode.js +59 -0
- package/dist/theme/visitor/commentAuthor.d.ts +16 -0
- package/dist/theme/visitor/commentAuthor.js +45 -0
- package/dist/theme/visitor/i18n.d.ts +4 -0
- package/dist/theme/visitor/i18n.js +28 -0
- package/dist/theme/visitor/locale.d.ts +23 -0
- package/dist/theme/visitor/locale.js +72 -0
- package/dist/theme/visitor/runtime.d.ts +18 -0
- package/dist/theme/visitor/runtime.js +19 -0
- package/dist/theme/visitor/visitorLocale.d.ts +11 -0
- package/dist/theme/visitor/visitorLocale.js +56 -0
- package/dist/theme/visitorLocale.d.ts +6 -0
- package/dist/theme/visitorLocale.js +39 -0
- package/dist/types/index.d.ts +79 -68
- package/dist/ui/AntdStyleTransitionFix.d.ts +5 -0
- package/dist/ui/AntdStyleTransitionFix.js +16 -0
- package/dist/ui/ArchiveEmptyState.d.ts +13 -0
- package/dist/ui/ArchiveEmptyState.js +8 -0
- package/dist/ui/ArchivePageLayout.d.ts +10 -0
- package/dist/ui/ArchivePageLayout.js +8 -0
- package/dist/ui/ArticleCard.d.ts +27 -0
- package/dist/ui/ArticleCard.js +16 -0
- package/dist/ui/ArticleList.d.ts +14 -0
- package/dist/ui/ArticleList.js +16 -0
- package/dist/ui/BaseGlobalStyles.d.ts +5 -0
- package/dist/ui/BaseGlobalStyles.js +18 -0
- package/dist/ui/LocaleSwitcher.d.ts +7 -0
- package/dist/ui/LocaleSwitcher.js +15 -0
- package/dist/ui/NavMenu.d.ts +16 -0
- package/dist/ui/NavMenu.js +8 -0
- package/dist/ui/NotFoundPanel.d.ts +11 -0
- package/dist/ui/NotFoundPanel.js +8 -0
- package/dist/ui/PageHeader.d.ts +10 -0
- package/dist/ui/PageHeader.js +8 -0
- package/dist/ui/SiteBranding.d.ts +10 -0
- package/dist/ui/SiteBranding.js +14 -0
- package/dist/ui/SiteDocument.d.ts +20 -0
- package/dist/ui/SiteDocument.js +13 -0
- package/dist/ui/SiteDocumentFallback.d.ts +8 -0
- package/dist/ui/SiteDocumentFallback.js +9 -0
- package/dist/ui/SiteLogo.d.ts +6 -0
- package/dist/ui/SiteLogo.js +16 -0
- package/dist/ui/SiteTagline.d.ts +7 -0
- package/dist/ui/SiteTagline.js +15 -0
- package/dist/ui/TaxonomyList.d.ts +25 -0
- package/dist/ui/TaxonomyList.js +30 -0
- package/dist/ui/ThemeCssVars.d.ts +2 -0
- package/dist/ui/ThemeCssVars.js +85 -0
- package/dist/ui/ThemeLayout.d.ts +13 -0
- package/dist/ui/ThemeLayout.js +11 -0
- package/dist/ui/components/AntdStyleTransitionFix.d.ts +5 -0
- package/dist/ui/components/AntdStyleTransitionFix.js +16 -0
- package/dist/ui/components/ArchiveEmptyState.d.ts +13 -0
- package/dist/ui/components/ArchiveEmptyState.js +8 -0
- package/dist/ui/components/ArchivePageLayout.d.ts +10 -0
- package/dist/ui/components/ArchivePageLayout.js +8 -0
- package/dist/ui/components/ArticleCard.d.ts +27 -0
- package/dist/ui/components/ArticleCard.js +16 -0
- package/dist/ui/components/ArticleList.d.ts +14 -0
- package/dist/ui/components/ArticleList.js +16 -0
- package/dist/ui/components/BaseGlobalStyles.d.ts +5 -0
- package/dist/ui/components/BaseGlobalStyles.js +18 -0
- package/dist/ui/components/LocaleSwitcher.d.ts +10 -0
- package/dist/ui/components/LocaleSwitcher.js +11 -0
- package/dist/ui/components/NavMenu.d.ts +16 -0
- package/dist/ui/components/NavMenu.js +8 -0
- package/dist/ui/components/NotFoundPanel.d.ts +11 -0
- package/dist/ui/components/NotFoundPanel.js +8 -0
- package/dist/ui/components/PageHeader.d.ts +10 -0
- package/dist/ui/components/PageHeader.js +8 -0
- package/dist/ui/components/RouteProgress.d.ts +9 -0
- package/dist/ui/components/RouteProgress.js +40 -0
- package/dist/ui/components/SiteAnalytics.d.ts +5 -0
- package/dist/ui/components/SiteAnalytics.js +42 -0
- package/dist/ui/components/SiteBranding.d.ts +10 -0
- package/dist/ui/components/SiteBranding.js +14 -0
- package/dist/ui/components/SiteDocument.d.ts +20 -0
- package/dist/ui/components/SiteDocument.js +13 -0
- package/dist/ui/components/SiteDocumentFallback.d.ts +8 -0
- package/dist/ui/components/SiteDocumentFallback.js +9 -0
- package/dist/ui/components/SiteLogo.d.ts +8 -0
- package/dist/ui/components/SiteLogo.js +23 -0
- package/dist/ui/components/SiteSeo.d.ts +13 -0
- package/dist/ui/components/SiteSeo.js +19 -0
- package/dist/ui/components/SiteTagline.d.ts +7 -0
- package/dist/ui/components/SiteTagline.js +15 -0
- package/dist/ui/components/TaxonomyList.d.ts +25 -0
- package/dist/ui/components/TaxonomyList.js +30 -0
- package/dist/ui/components/ThemeCssVars.d.ts +2 -0
- package/dist/ui/components/ThemeCssVars.js +85 -0
- package/dist/ui/components/ThemeLayout.d.ts +13 -0
- package/dist/ui/components/ThemeLayout.js +11 -0
- package/dist/ui/components/content/ArticleReader.d.ts +45 -0
- package/dist/ui/components/content/ArticleReader.js +23 -0
- package/dist/ui/components/content/ArticleToc.d.ts +21 -0
- package/dist/ui/components/content/ArticleToc.js +75 -0
- package/dist/ui/components/content/HtmlContent.d.ts +15 -0
- package/dist/ui/components/content/HtmlContent.js +237 -0
- package/dist/ui/components/content/Image.d.ts +9 -0
- package/dist/ui/components/content/Image.js +13 -0
- package/dist/ui/components/content/ImageViewer.d.ts +8 -0
- package/dist/ui/components/content/ImageViewer.js +33 -0
- package/dist/ui/components/content/LocaleTime.d.ts +9 -0
- package/dist/ui/components/content/LocaleTime.js +63 -0
- package/dist/ui/components/content/index.d.ts +14 -0
- package/dist/ui/components/content/index.js +18 -0
- package/dist/ui/components/toolbar/LocaleToggleButton.d.ts +8 -0
- package/dist/ui/components/toolbar/LocaleToggleButton.js +18 -0
- package/dist/ui/components/toolbar/ThemeToggleButton.d.ts +7 -0
- package/dist/ui/components/toolbar/ThemeToggleButton.js +10 -0
- package/dist/ui/components/toolbar/ToolbarIconButton.d.ts +7 -0
- package/dist/ui/components/toolbar/ToolbarIconButton.js +22 -0
- package/dist/ui/components/toolbar/constants.d.ts +5 -0
- package/dist/ui/components/toolbar/constants.js +8 -0
- package/dist/ui/components/toolbar/icons.d.ts +17 -0
- package/dist/ui/components/toolbar/icons.js +44 -0
- package/dist/ui/components/toolbar/index.d.ts +9 -0
- package/dist/ui/components/toolbar/index.js +25 -0
- package/dist/ui/components/toolbar/locale-label.d.ts +3 -0
- package/dist/ui/components/toolbar/locale-label.js +19 -0
- package/dist/ui/context/LocaleContext.d.ts +15 -0
- package/dist/ui/context/LocaleContext.js +59 -0
- package/dist/ui/context/ReactPressProvider.d.ts +3 -0
- package/dist/ui/context/ReactPressProvider.js +10 -0
- package/dist/ui/context/SiteCatalogContext.d.ts +41 -0
- package/dist/ui/context/SiteCatalogContext.js +60 -0
- package/dist/ui/context/ThemeRuntimeContext.d.ts +21 -0
- package/dist/ui/context/ThemeRuntimeContext.js +59 -0
- package/dist/ui/context/index.d.ts +8 -0
- package/dist/ui/context/index.js +26 -0
- package/dist/ui/context/siteCatalogTypes.d.ts +64 -0
- package/dist/ui/context/siteCatalogTypes.js +20 -0
- package/dist/ui/context/types.d.ts +34 -0
- package/dist/ui/context/types.js +2 -0
- package/dist/ui/hooks/index.d.ts +12 -0
- package/dist/ui/hooks/index.js +29 -0
- package/dist/ui/hooks/useAsyncLoading.d.ts +4 -0
- package/dist/ui/hooks/useAsyncLoading.js +31 -0
- package/dist/ui/hooks/useForceUpdate.d.ts +2 -0
- package/dist/ui/hooks/useForceUpdate.js +11 -0
- package/dist/ui/hooks/useNavActive.d.ts +5 -0
- package/dist/ui/hooks/useNavActive.js +11 -0
- package/dist/ui/hooks/usePagination.d.ts +34 -0
- package/dist/ui/hooks/usePagination.js +55 -0
- package/dist/ui/hooks/useReportArticleView.d.ts +4 -0
- package/dist/ui/hooks/useReportArticleView.js +40 -0
- package/dist/ui/hooks/useReportPageView.d.ts +11 -0
- package/dist/ui/hooks/useReportPageView.js +28 -0
- package/dist/ui/hooks/useRouteParam.d.ts +5 -0
- package/dist/ui/hooks/useRouteParam.js +15 -0
- package/dist/ui/hooks/useToggle.d.ts +2 -0
- package/dist/ui/hooks/useToggle.js +17 -0
- package/dist/ui/hooks/useWarningOnExit.d.ts +5 -0
- package/dist/ui/hooks/useWarningOnExit.js +59 -0
- package/dist/ui/index.d.ts +43 -0
- package/dist/ui/index.js +87 -0
- package/dist/utils/api-envelope.d.ts +14 -0
- package/dist/utils/api-envelope.js +31 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.js +24 -0
- package/dist/utils/cookie.d.ts +2 -0
- package/dist/utils/cookie.js +15 -0
- package/dist/utils/date.d.ts +4 -0
- package/dist/utils/date.js +45 -0
- package/dist/utils/email.d.ts +3 -0
- package/dist/utils/email.js +9 -0
- package/dist/utils/error.d.ts +7 -0
- package/dist/utils/error.js +26 -0
- package/dist/utils/image.d.ts +7 -0
- package/dist/utils/image.js +34 -0
- package/dist/utils/index.d.ts +15 -33
- package/dist/utils/index.js +37 -57
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +18 -0
- package/dist/utils/jsonp.d.ts +8 -0
- package/dist/utils/jsonp.js +27 -0
- package/dist/utils/object.d.ts +7 -0
- package/dist/utils/object.js +63 -0
- package/dist/utils/setting.d.ts +12 -0
- package/dist/utils/setting.js +13 -0
- package/dist/utils/string.d.ts +4 -0
- package/dist/utils/string.js +15 -0
- package/dist/utils/viewport.d.ts +3 -0
- package/dist/utils/viewport.js +14 -0
- package/package.json +129 -16
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,387 +1,272 @@
|
|
|
1
1
|
# @fecommunity/reactpress-toolkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ReactPress 的 TypeScript 工具包:从 OpenAPI/Swagger 生成的 API 客户端、站点配置类型、Next.js 主题 SSR 辅助,以及管理后台插件注册。
|
|
4
|
+
|
|
5
|
+
## 包导出(`package.json` → `exports`)
|
|
6
|
+
|
|
7
|
+
| 子路径 | 用途 |
|
|
8
|
+
|--------|------|
|
|
9
|
+
| `.` | 根入口:`api`、`config`、`theme`、`ui`、`plugin` 命名空间及常用 re-export |
|
|
10
|
+
| `./api` | 各资源 HTTP 客户端类 |
|
|
11
|
+
| `./api/instance` | 默认 `api` 实例与 `createApiInstance` |
|
|
12
|
+
| `./types` | Swagger 生成的请求/响应类型 |
|
|
13
|
+
| `./utils` | 与业务无关的纯工具(见下方模块表) |
|
|
14
|
+
| `./config` | 环境变量、全局默认、`i18n` 文案(`config/locales/*.json`) |
|
|
15
|
+
| `./theme` | 访客主题:SSR 拉数、运行时、扩展配置类型,并 re-export `./ui` |
|
|
16
|
+
| `./theme/next-config` | `createReactPressNextConfig()` |
|
|
17
|
+
| `./theme/node` | Node 专用(如读取主题管理端 locale 文件) |
|
|
18
|
+
| `./ui` | 无样式主题组件与 hooks |
|
|
19
|
+
| `./plugin` | 管理端插件聚合入口 |
|
|
20
|
+
| `./plugin/admin` | 菜单注册、权限常量 |
|
|
21
|
+
| `./plugin/client` | Web/Electron API 客户端工厂(推荐) |
|
|
22
|
+
| `./plugin/react` | 与 `./plugin/client` 相同(兼容旧路径) |
|
|
23
|
+
| `./plugin/dev` | Vite 开发端口重定向等 |
|
|
24
|
+
|
|
25
|
+
**约定:** `src/` 下仅保留与上述导出对应的一级目录;实现细节放在子目录中,根目录用薄 shim 保持对外路径稳定(例如 `theme/node.ts` → `theme/build/node.ts`)。
|
|
26
|
+
|
|
27
|
+
## 源码结构
|
|
4
28
|
|
|
5
|
-
[](https://www.npmjs.com/package/@fecommunity/reactpress-toolkit)
|
|
6
|
-
[](https://github.com/fecommunity/reactpress/blob/master/toolkit/LICENSE)
|
|
7
|
-
[](http://www.typescriptlang.org/)
|
|
8
|
-
|
|
9
|
-
## Overview
|
|
10
|
-
|
|
11
|
-
The ReactPress Toolkit is an API client library that provides strongly-typed interfaces for interacting with the ReactPress backend services. It includes:
|
|
12
|
-
|
|
13
|
-
- **Auto-generated API clients** for all ReactPress modules
|
|
14
|
-
- **TypeScript definitions** for all data contracts
|
|
15
|
-
- **Utility functions** for common operations
|
|
16
|
-
- **HTTP client** with built-in authentication and error handling
|
|
17
|
-
- **Automatic retry mechanisms** for failed requests
|
|
18
|
-
- **Request/response interceptors** for logging
|
|
19
|
-
|
|
20
|
-
The toolkit is automatically generated from the ReactPress backend's OpenAPI specification, ensuring that it's always in sync with the latest API changes. This eliminates manual API client maintenance and reduces the likelihood of API integration errors.
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install @fecommunity/reactpress-toolkit
|
|
26
29
|
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
src/
|
|
31
|
+
├── api/ # OpenAPI 生成(勿手改业务逻辑)
|
|
32
|
+
├── config/ # env、global、i18n + locales/
|
|
33
|
+
├── types/ # Swagger 生成类型
|
|
34
|
+
├── utils/ # 纯函数工具(theme/plugin 共用)
|
|
35
|
+
│ ├── api-envelope.ts # unpackList / unpackOne / unpackPaginated
|
|
36
|
+
│ ├── cookie.ts # readRequestCookie
|
|
37
|
+
│ ├── date.ts # formatDate、formatPublishDate*
|
|
38
|
+
│ ├── email.ts # 评论邮箱校验
|
|
39
|
+
│ ├── error.ts # ApiError、isApiError
|
|
40
|
+
│ ├── json.ts # safeJsonParse
|
|
41
|
+
│ ├── jsonp.ts # 浏览器 JSONP
|
|
42
|
+
│ ├── object.ts # deepMerge、getByPath、deepClone
|
|
43
|
+
│ ├── setting.ts # pickSiteSettings
|
|
44
|
+
│ └── string.ts # stripHtml、truncateWords
|
|
45
|
+
├── plugin/
|
|
46
|
+
│ ├── admin/ # AdminModule、菜单注册、权限
|
|
47
|
+
│ ├── client/ # createClient、resolveApiBaseUrl
|
|
48
|
+
│ ├── dev/ # devPortRedirectPlugin 等
|
|
49
|
+
│ └── react/ # 仅 re-export client(兼容)
|
|
50
|
+
├── theme/
|
|
51
|
+
│ ├── api/ # themeApi、axios 封装(JSON/解包 re-export utils)
|
|
52
|
+
│ ├── ssr/ # fetch、static props、站点 meta
|
|
53
|
+
│ ├── visitor/ # 语言、会话、配色、运行时 mods
|
|
54
|
+
│ ├── content/ # SEO、导航路径、摘要、静态资源 URL
|
|
55
|
+
│ ├── preview/ # 预览 token / mods / config 查询参数
|
|
56
|
+
│ ├── createCatalogApp.js # 完整主题 _app 工厂(无 UI 框架依赖)
|
|
57
|
+
│ ├── createApp.js # Next `_app` 工厂(allowJs,随 tsc 输出到 dist)
|
|
58
|
+
│ ├── extension/ # theme.json schema、站点配置、与服务端共享的类型
|
|
59
|
+
│ ├── node.ts # → build/node
|
|
60
|
+
│ ├── next-config.ts
|
|
61
|
+
│ └── index.ts # 对外 barrel
|
|
62
|
+
└── ui/
|
|
63
|
+
├── components/ # 无样式 React 组件
|
|
64
|
+
├── context/ # ReactPressProvider、locale、runtime
|
|
65
|
+
└── hooks/ # 通用 React hooks(与具体页面无关)
|
|
32
66
|
```
|
|
33
67
|
|
|
34
|
-
|
|
68
|
+
## 安装
|
|
35
69
|
|
|
36
70
|
```bash
|
|
37
71
|
pnpm add @fecommunity/reactpress-toolkit
|
|
38
72
|
```
|
|
39
73
|
|
|
40
|
-
##
|
|
74
|
+
## 快速开始
|
|
41
75
|
|
|
42
|
-
###
|
|
76
|
+
### API 客户端
|
|
43
77
|
|
|
44
78
|
```typescript
|
|
45
79
|
import { api } from '@fecommunity/reactpress-toolkit';
|
|
80
|
+
// 或
|
|
81
|
+
import { api, createApiInstance } from '@fecommunity/reactpress-toolkit/api/instance';
|
|
46
82
|
|
|
47
|
-
// Get all articles
|
|
48
83
|
const articles = await api.article.findAll();
|
|
49
|
-
|
|
50
|
-
// Get a specific article by ID
|
|
51
|
-
const article = await api.article.findById('article-id');
|
|
52
|
-
|
|
53
|
-
// Create a new article
|
|
54
|
-
const newArticle = await api.article.create({
|
|
55
|
-
title: 'My New Article',
|
|
56
|
-
content: 'Article content here...',
|
|
57
|
-
// ... other properties
|
|
58
|
-
});
|
|
59
84
|
```
|
|
60
85
|
|
|
61
|
-
|
|
86
|
+
自定义 baseURL:
|
|
62
87
|
|
|
63
88
|
```typescript
|
|
64
|
-
import {
|
|
65
|
-
|
|
66
|
-
// Working with typed data
|
|
67
|
-
const article: types.IArticle = {
|
|
68
|
-
id: '1',
|
|
69
|
-
title: 'Sample Article',
|
|
70
|
-
// ... other properties
|
|
71
|
-
};
|
|
89
|
+
import { createApiInstance } from '@fecommunity/reactpress-toolkit/api/instance';
|
|
72
90
|
|
|
73
|
-
|
|
74
|
-
const formattedDate = utils.formatDate(new Date());
|
|
91
|
+
const customApi = createApiInstance({ baseURL: 'https://api.example.com/api' });
|
|
75
92
|
```
|
|
76
93
|
|
|
77
|
-
|
|
94
|
+
### 通用工具(`./utils`)
|
|
78
95
|
|
|
79
|
-
|
|
96
|
+
与 Next/主题无关的逻辑应放在 `utils`,`theme` 仅 re-export 以保持 `@fecommunity/reactpress-toolkit/theme` 路径兼容:
|
|
80
97
|
|
|
81
98
|
```typescript
|
|
82
|
-
import {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const articles = await customApi.article.findAll();
|
|
99
|
+
import {
|
|
100
|
+
safeJsonParse,
|
|
101
|
+
unpackList,
|
|
102
|
+
formatPublishDate,
|
|
103
|
+
stripHtml,
|
|
104
|
+
deepMerge,
|
|
105
|
+
getByPath,
|
|
106
|
+
pickSiteSettings,
|
|
107
|
+
} from '@fecommunity/reactpress-toolkit/utils';
|
|
92
108
|
```
|
|
93
109
|
|
|
94
|
-
|
|
110
|
+
| 模块 | 典型用途 |
|
|
111
|
+
|------|----------|
|
|
112
|
+
| `json` | 解析 setting 里的 JSON 字符串 |
|
|
113
|
+
| `api-envelope` | 解包 Nest `TransformInterceptor` 的 `{ data }` |
|
|
114
|
+
| `date` | 文章发布日期展示 |
|
|
115
|
+
| `string` | 归档摘要 HTML 剥离、截断 |
|
|
116
|
+
| `object` | theme.json 配置合并、点路径读写 |
|
|
117
|
+
| `setting` | 把 settings 行映射为 props |
|
|
118
|
+
| `cookie` | SSR 读取 `Cookie` 头 |
|
|
119
|
+
| `email` | 访客评论邮箱格式 |
|
|
95
120
|
|
|
96
|
-
###
|
|
97
|
-
```typescript
|
|
98
|
-
import { http } from '@fecommunity/reactpress-toolkit';
|
|
99
|
-
|
|
100
|
-
// Configure retry settings
|
|
101
|
-
const customApi = http.createApiInstance({
|
|
102
|
-
baseURL: 'https://api.yourdomain.com',
|
|
103
|
-
retry: {
|
|
104
|
-
retries: 3,
|
|
105
|
-
retryDelay: 1000,
|
|
106
|
-
retryCondition: (error) => {
|
|
107
|
-
return error.response?.status === 503 || error.code === 'ECONNABORTED';
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
```
|
|
121
|
+
### 管理后台插件
|
|
112
122
|
|
|
113
|
-
### Request/Response Interceptors
|
|
114
123
|
```typescript
|
|
115
|
-
import {
|
|
116
|
-
|
|
117
|
-
const monitoredApi = http.createApiInstance({
|
|
118
|
-
baseURL: 'https://api.yourdomain.com',
|
|
119
|
-
interceptors: {
|
|
120
|
-
request: (config) => {
|
|
121
|
-
// Add logging, metrics, etc.
|
|
122
|
-
console.log(`Request: ${config.method?.toUpperCase()} ${config.url}`);
|
|
123
|
-
return config;
|
|
124
|
-
},
|
|
125
|
-
response: (response) => {
|
|
126
|
-
// Add logging, metrics, etc.
|
|
127
|
-
console.log(`Response: ${response.status} ${response.config.url}`);
|
|
128
|
-
return response;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
});
|
|
124
|
+
import type { AdminModule } from '@fecommunity/reactpress-toolkit/plugin/admin';
|
|
125
|
+
import { permissionsForRole } from '@fecommunity/reactpress-toolkit/plugin/admin';
|
|
132
126
|
```
|
|
133
127
|
|
|
134
|
-
###
|
|
135
|
-
```typescript
|
|
136
|
-
import { http, api, utils } from '@fecommunity/reactpress-toolkit';
|
|
137
|
-
|
|
138
|
-
// Automatic token refresh
|
|
139
|
-
const secureApi = http.createApiInstance({
|
|
140
|
-
baseURL: 'https://api.yourdomain.com',
|
|
141
|
-
auth: {
|
|
142
|
-
tokenRefresh: async (refreshToken) => {
|
|
143
|
-
const response = await api.auth.refresh({ refreshToken });
|
|
144
|
-
return response.data.accessToken;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Type Definitions
|
|
151
|
-
|
|
152
|
-
All data models are strongly typed and available through the `types` export:
|
|
128
|
+
### Web / Electron 客户端
|
|
153
129
|
|
|
154
130
|
```typescript
|
|
155
|
-
import {
|
|
156
|
-
|
|
157
|
-
const user: types.IUser = {
|
|
158
|
-
name: 'John Doe',
|
|
159
|
-
email: 'john@example.com',
|
|
160
|
-
// ... other properties
|
|
161
|
-
};
|
|
131
|
+
import { createClient, resolveApiBaseUrl } from '@fecommunity/reactpress-toolkit/plugin/client';
|
|
162
132
|
```
|
|
163
133
|
|
|
164
|
-
|
|
165
|
-
- `types.IUser`
|
|
166
|
-
- `types.IArticle`
|
|
167
|
-
- `types.ICategory`
|
|
168
|
-
- `types.ITag`
|
|
169
|
-
- `types.IComment`
|
|
170
|
-
- `types.IFile`
|
|
171
|
-
- `types.ISetting`
|
|
172
|
-
- `types.IPage`
|
|
173
|
-
- `types.IKnowledge`
|
|
174
|
-
- `types.IView`
|
|
175
|
-
- `types.I_SMTP`
|
|
134
|
+
## App 工厂(`./app`)
|
|
176
135
|
|
|
177
|
-
|
|
136
|
+
主题 `_app.tsx` 的入口工厂,与 UI 框架无关:
|
|
178
137
|
|
|
179
|
-
|
|
138
|
+
| 工厂 | 用途 |
|
|
139
|
+
|------|------|
|
|
140
|
+
| `createThemeApp` | 极简主题(hello-world):`ReactPressProvider` + `ThemeCssVars` |
|
|
141
|
+
| `createReactPressApp` | 完整主题:SSR catalog、i18n、统计、PV;通过 `wrapContent` 注入 Ant Design 等 |
|
|
180
142
|
|
|
181
143
|
```typescript
|
|
182
|
-
import {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const formattedDate = utils.formatDate(new Date(), 'YYYY-MM-DD');
|
|
144
|
+
import { createThemeApp } from '@fecommunity/reactpress-toolkit/app';
|
|
145
|
+
import { createReactPressApp } from '@fecommunity/reactpress-toolkit/app';
|
|
146
|
+
```
|
|
186
147
|
|
|
187
|
-
|
|
188
|
-
const clonedObject = utils.deepClone(originalObject);
|
|
148
|
+
也可从 `./theme` re-export 导入(兼容旧路径)。
|
|
189
149
|
|
|
190
|
-
|
|
191
|
-
if (utils.ApiError.isInstance(error)) {
|
|
192
|
-
console.log(`API Error: ${error.code} - ${error.message}`);
|
|
193
|
-
}
|
|
150
|
+
## 主题开发(`./theme`)
|
|
194
151
|
|
|
195
|
-
|
|
196
|
-
const isValidEmail = utils.validateEmail('user@example.com');
|
|
152
|
+
Next.js 访客主题应使用 toolkit 提供的 API 与 SSR 辅助,避免在每个主题里复制 `lib/api.ts`。
|
|
197
153
|
|
|
198
|
-
|
|
199
|
-
|
|
154
|
+
```typescript
|
|
155
|
+
import {
|
|
156
|
+
themeApi,
|
|
157
|
+
fetchVisitorContext,
|
|
158
|
+
fetchThemeCatalog,
|
|
159
|
+
themeStaticProps,
|
|
160
|
+
unpackList,
|
|
161
|
+
} from '@fecommunity/reactpress-toolkit/theme';
|
|
162
|
+
import { createThemeApp } from '@fecommunity/reactpress-toolkit/app';
|
|
200
163
|
```
|
|
201
164
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
165
|
+
```javascript
|
|
166
|
+
// next.config.js
|
|
167
|
+
const { createReactPressNextConfig } = require('@fecommunity/reactpress-toolkit/theme/next-config');
|
|
168
|
+
module.exports = createReactPressNextConfig();
|
|
169
|
+
```
|
|
205
170
|
|
|
206
|
-
|
|
171
|
+
```typescript
|
|
172
|
+
// pages/_app.tsx
|
|
173
|
+
import themeManifest from '../theme.json';
|
|
207
174
|
|
|
208
|
-
|
|
209
|
-
npm run generate
|
|
175
|
+
export default createThemeApp(themeManifest);
|
|
210
176
|
```
|
|
211
177
|
|
|
212
|
-
|
|
213
|
-
1. Generate a new Swagger JSON from the ReactPress server
|
|
214
|
-
2. Create TypeScript definitions from the specification
|
|
215
|
-
3. Organize the generated files into appropriate directories
|
|
216
|
-
4. Create API clients for each module
|
|
178
|
+
**完整功能主题** — 使用 `createReactPressApp`(UI 框架无关),Ant Design 等重型依赖留在主题内:
|
|
217
179
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
180
|
+
```typescript
|
|
181
|
+
import { createReactPressApp } from '@fecommunity/reactpress-toolkit/app';
|
|
182
|
+
import { ConfigProvider } from 'antd';
|
|
183
|
+
import { NextIntlProvider } from 'next-intl';
|
|
184
|
+
|
|
185
|
+
export default createReactPressApp(themeManifest, {
|
|
186
|
+
Layout: AppLayout,
|
|
187
|
+
IntlProvider: NextIntlProvider,
|
|
188
|
+
wrapContent: (content, { locale, isDark, colorPrimary }) => (
|
|
189
|
+
<ConfigProvider locale={{ locale }} theme={{ token: { colorPrimary } }}>
|
|
190
|
+
{content}
|
|
191
|
+
</ConfigProvider>
|
|
192
|
+
),
|
|
193
|
+
});
|
|
222
194
|
```
|
|
223
195
|
|
|
224
|
-
|
|
196
|
+
`createReactPressApp` 内置:SSR 站点数据、预览 mods、SiteCatalogProvider、路由进度条、统计脚本、PV 上报。**不含** Ant Design / cssinjs。
|
|
225
197
|
|
|
226
|
-
|
|
198
|
+
**REST Provider** — 无需在每个主题复制 14 个 Provider 文件:
|
|
227
199
|
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
npm run test
|
|
200
|
+
```typescript
|
|
201
|
+
import { createThemeAxiosClient, createThemeProviders } from '@fecommunity/reactpress-toolkit/theme';
|
|
231
202
|
|
|
232
|
-
|
|
233
|
-
|
|
203
|
+
export const httpProvider = createThemeAxiosClient({ onError, onUnauthorized });
|
|
204
|
+
export const { ArticleProvider, CategoryProvider, TagProvider } = createThemeProviders(httpProvider);
|
|
205
|
+
```
|
|
234
206
|
|
|
235
|
-
|
|
236
|
-
npm run lint
|
|
207
|
+
环境变量:`REACTPRESS_API_URL`(SSR)、`NEXT_PUBLIC_REACTPRESS_API_URL`(浏览器),由 `reactpress theme dev` 注入。
|
|
237
208
|
|
|
238
|
-
|
|
239
|
-
npm run format
|
|
240
|
-
```
|
|
209
|
+
### 无样式 UI(`./ui`)
|
|
241
210
|
|
|
242
|
-
|
|
211
|
+
也可从 `./theme` 一并导入:
|
|
243
212
|
|
|
244
|
-
### React Integration
|
|
245
213
|
```typescript
|
|
246
|
-
import {
|
|
247
|
-
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
248
|
-
|
|
249
|
-
const ArticleList = () => {
|
|
250
|
-
const [articles, setArticles] = useState<types.IArticle[]>([]);
|
|
251
|
-
const [loading, setLoading] = useState(true);
|
|
252
|
-
|
|
253
|
-
useEffect(() => {
|
|
254
|
-
const fetchArticles = async () => {
|
|
255
|
-
try {
|
|
256
|
-
const response = await api.article.findAll();
|
|
257
|
-
setArticles(response.data);
|
|
258
|
-
} catch (error) {
|
|
259
|
-
console.error('Failed to fetch articles:', error);
|
|
260
|
-
} finally {
|
|
261
|
-
setLoading(false);
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
fetchArticles();
|
|
266
|
-
}, []);
|
|
267
|
-
|
|
268
|
-
if (loading) return <div>Loading...</div>;
|
|
269
|
-
|
|
270
|
-
return (
|
|
271
|
-
<div>
|
|
272
|
-
{articles.map(article => (
|
|
273
|
-
<div key={article.id}>
|
|
274
|
-
<h2>{article.title}</h2>
|
|
275
|
-
<p>{article.content}</p>
|
|
276
|
-
</div>
|
|
277
|
-
))}
|
|
278
|
-
</div>
|
|
279
|
-
);
|
|
280
|
-
};
|
|
214
|
+
import { NavMenu, ArticleList, ReactPressProvider, useLocale } from '@fecommunity/reactpress-toolkit/ui';
|
|
281
215
|
```
|
|
282
216
|
|
|
283
|
-
|
|
217
|
+
| 符号 | 说明 |
|
|
218
|
+
|------|------|
|
|
219
|
+
| `ReactPressProvider` | 在 `_app` 注入站点上下文 |
|
|
220
|
+
| `useLocale` / `useThemeRuntime` / `useThemeMod` | 语言与主题 mods |
|
|
221
|
+
| `useToggle` / `useAsyncLoading` | 布尔切换、防抖 loading(评论/搜索等) |
|
|
222
|
+
| `usePagination` | `[items, total]` 分页列表 |
|
|
223
|
+
| `useReportArticleView` / `useReportPageView` | 文章阅读数、全站 PV 上报 |
|
|
224
|
+
| `useRouteParam` / `useNavActive` | 动态路由参数、导航高亮 |
|
|
225
|
+
| `useWarningOnExit` | 离开页面前确认(Next Router) |
|
|
226
|
+
| `NavMenu` | 配置驱动导航,通过 `renderLink` 接 Next `Link` |
|
|
227
|
+
| `ArticleList` | 列表渲染,通过 `renderArticle` 自定义卡片 |
|
|
228
|
+
| `SiteCatalogProvider` / `useSiteSetting` / `useSiteUser` | 全站 catalog + 用户会话 |
|
|
229
|
+
| `SiteSeo` / `RouteProgress` / `SiteAnalytics` | SEO meta、路由进度条、GA/百度统计 |
|
|
230
|
+
| `ArticleReader` / `HtmlContent` / `ArticleToc` | 文章阅读、HTML 渲染、目录 |
|
|
231
|
+
| `ImageViewer` / `LocaleTime` | 图片预览、本地化时间 |
|
|
232
|
+
| `createReactPressApp` | 完整主题 `_app` 工厂(`@fecommunity/reactpress-toolkit/app`) |
|
|
233
|
+
| `fetchAppBootstrap` | `_app.getInitialProps` SSR 数据(setting / taxonomy / preview) |
|
|
234
|
+
|
|
235
|
+
### 扩展配置类型
|
|
236
|
+
|
|
237
|
+
`theme/extension` 中的类型与校验逻辑与 **server**、**web 外观设置** 共用,例如 `ThemeConfigurationSchema`、`resolveSiteConfig`、`PUBLIC_SETTING_KEYS`。服务端可:
|
|
238
|
+
|
|
284
239
|
```typescript
|
|
285
|
-
import {
|
|
286
|
-
|
|
287
|
-
async function syncArticles() {
|
|
288
|
-
try {
|
|
289
|
-
// Fetch articles from ReactPress
|
|
290
|
-
const response = await api.article.findAll({
|
|
291
|
-
limit: 100,
|
|
292
|
-
offset: 0
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
// Process articles
|
|
296
|
-
const articles: types.IArticle[] = response.data;
|
|
297
|
-
|
|
298
|
-
// Sync with another system
|
|
299
|
-
for (const article of articles) {
|
|
300
|
-
// Your sync logic here
|
|
301
|
-
console.log(`Synced article: ${article.title}`);
|
|
302
|
-
}
|
|
303
|
-
} catch (error) {
|
|
304
|
-
console.error('Sync failed:', error);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
syncArticles();
|
|
240
|
+
import { PUBLIC_SETTING_KEYS, systemGlobalSettingDefaults } from '@fecommunity/reactpress-toolkit/theme';
|
|
241
|
+
import { readThemeAdminLocaleFile } from '@fecommunity/reactpress-toolkit/theme/node';
|
|
309
242
|
```
|
|
310
243
|
|
|
311
|
-
##
|
|
244
|
+
## 从 Swagger 重新生成 API
|
|
312
245
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
try {
|
|
318
|
-
const articles = await api.article.findAll();
|
|
319
|
-
// Process articles
|
|
320
|
-
} catch (error) {
|
|
321
|
-
if (utils.ApiError.isInstance(error)) {
|
|
322
|
-
switch (error.code) {
|
|
323
|
-
case 401:
|
|
324
|
-
// Handle unauthorized access
|
|
325
|
-
redirectToLogin();
|
|
326
|
-
break;
|
|
327
|
-
case 403:
|
|
328
|
-
// Handle forbidden access
|
|
329
|
-
showPermissionError();
|
|
330
|
-
break;
|
|
331
|
-
case 500:
|
|
332
|
-
// Handle server errors
|
|
333
|
-
showServerError();
|
|
334
|
-
break;
|
|
335
|
-
default:
|
|
336
|
-
// Handle other API errors
|
|
337
|
-
showGenericError(error.message);
|
|
338
|
-
}
|
|
339
|
-
} else {
|
|
340
|
-
// Handle network errors
|
|
341
|
-
showNetworkError();
|
|
342
|
-
}
|
|
343
|
-
}
|
|
246
|
+
在 monorepo 根目录确保 server 可构建后:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
cd toolkit && pnpm run generate
|
|
344
250
|
```
|
|
345
251
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
let offset = 0;
|
|
353
|
-
const limit = 50;
|
|
354
|
-
|
|
355
|
-
while (true) {
|
|
356
|
-
const response = await api.article.findAll({ limit, offset });
|
|
357
|
-
allArticles.push(...response.data);
|
|
358
|
-
|
|
359
|
-
if (response.data.length < limit) {
|
|
360
|
-
// No more articles to fetch
|
|
361
|
-
break;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
offset += limit;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return allArticles;
|
|
368
|
-
}
|
|
252
|
+
将更新 `src/api/*` 与 `src/types/*`。
|
|
253
|
+
|
|
254
|
+
## 构建
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
cd toolkit && pnpm run build
|
|
369
258
|
```
|
|
370
259
|
|
|
371
|
-
|
|
260
|
+
输出到 `dist/`;`createApp.js` 随 `tsc`(`allowJs`)写入 `dist/theme/createApp.js`。
|
|
372
261
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
262
|
+
## 开发脚本
|
|
263
|
+
|
|
264
|
+
| 命令 | 说明 |
|
|
265
|
+
|------|------|
|
|
266
|
+
| `pnpm run generate` | 从 server Swagger 生成 API |
|
|
267
|
+
| `pnpm run build` | `tsc` + 复制 locales |
|
|
268
|
+
| `pnpm run typecheck` | 仅类型检查 |
|
|
378
269
|
|
|
379
270
|
## License
|
|
380
271
|
|
|
381
272
|
ISC
|
|
382
|
-
|
|
383
|
-
## Related Projects
|
|
384
|
-
|
|
385
|
-
- [ReactPress](https://github.com/fecommunity/reactpress) - The main ReactPress platform
|
|
386
|
-
- [ReactPress Server](https://github.com/fecommunity/reactpress/server) - Backend server
|
|
387
|
-
- [ReactPress Client](https://github.com/fecommunity/reactpress/client) - Frontend client
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./permissions"), exports);
|
|
18
|
+
__exportStar(require("./registry"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Admin capability strings — keep in sync with server guards. */
|
|
2
|
+
export type Permission = 'article:read' | 'article:write' | 'article:publish' | 'media:manage' | 'page:manage' | 'user:manage' | 'setting:manage' | 'extension:manage' | 'comment:manage' | 'view:read';
|
|
3
|
+
export declare const ADMIN_PERMISSIONS: Permission[];
|
|
4
|
+
/** Map legacy server roles to capability strings. */
|
|
5
|
+
export declare function permissionsForRole(role: string | undefined): Permission[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADMIN_PERMISSIONS = void 0;
|
|
4
|
+
exports.permissionsForRole = permissionsForRole;
|
|
5
|
+
exports.ADMIN_PERMISSIONS = [
|
|
6
|
+
'article:read',
|
|
7
|
+
'article:write',
|
|
8
|
+
'article:publish',
|
|
9
|
+
'media:manage',
|
|
10
|
+
'page:manage',
|
|
11
|
+
'user:manage',
|
|
12
|
+
'setting:manage',
|
|
13
|
+
'extension:manage',
|
|
14
|
+
'comment:manage',
|
|
15
|
+
'view:read',
|
|
16
|
+
];
|
|
17
|
+
/** Map legacy server roles to capability strings. */
|
|
18
|
+
function permissionsForRole(role) {
|
|
19
|
+
if (role === 'admin')
|
|
20
|
+
return [...exports.ADMIN_PERMISSIONS];
|
|
21
|
+
if (role === 'editor') {
|
|
22
|
+
return [
|
|
23
|
+
'article:read',
|
|
24
|
+
'article:write',
|
|
25
|
+
'article:publish',
|
|
26
|
+
'media:manage',
|
|
27
|
+
'page:manage',
|
|
28
|
+
'comment:manage',
|
|
29
|
+
'view:read',
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
return ['article:read', 'view:read'];
|
|
33
|
+
}
|