@4399ywkf/core 5.0.23 → 5.0.25
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/dist/cli/index.js +57 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +65 -19
- package/dist/index.js.map +1 -1
- package/dist/router/index.d.ts +9 -0
- package/dist/router/index.js +57 -15
- package/dist/router/index.js.map +1 -1
- package/dist/rspack/index.js +57 -15
- package/dist/rspack/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -560,21 +560,47 @@ var ConventionalRouteGenerator = class {
|
|
|
560
560
|
const errorImports = [];
|
|
561
561
|
const loadingImports = [];
|
|
562
562
|
this.collectImports(routes, lazyImports, errorImports, loadingImports);
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
// \u61D2\u52A0\u8F7D\
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
563
|
+
const { loading } = this.options;
|
|
564
|
+
const hasCustomLoading = loading && typeof loading === "object" && loading.component;
|
|
565
|
+
const loadingDisabled = loading === false;
|
|
566
|
+
let loadingSection;
|
|
567
|
+
if (loadingDisabled) {
|
|
568
|
+
loadingSection = `
|
|
569
|
+
// \u61D2\u52A0\u8F7D\u5305\u88C5\uFF08\u52A0\u8F7D\u72B6\u6001\u5DF2\u7981\u7528\uFF09
|
|
570
|
+
function LazyRoute({
|
|
571
|
+
Component,
|
|
572
|
+
Loading,
|
|
573
|
+
}: {
|
|
574
|
+
Component: React.LazyExoticComponent<React.ComponentType<unknown>>;
|
|
575
|
+
Loading?: React.ComponentType;
|
|
576
|
+
}) {
|
|
577
|
+
const fallback = Loading ? <Loading /> : null;
|
|
578
|
+
return (
|
|
579
|
+
<Suspense fallback={fallback}>
|
|
580
|
+
<Component />
|
|
581
|
+
</Suspense>
|
|
582
|
+
);
|
|
583
|
+
}`;
|
|
584
|
+
} else if (hasCustomLoading) {
|
|
585
|
+
loadingSection = `
|
|
586
|
+
import CustomDefaultLoading from "${loading.component}";
|
|
577
587
|
|
|
588
|
+
// \u61D2\u52A0\u8F7D\u5305\u88C5\uFF08\u4F7F\u7528\u81EA\u5B9A\u4E49\u9ED8\u8BA4\u52A0\u8F7D\u7EC4\u4EF6\uFF09
|
|
589
|
+
function LazyRoute({
|
|
590
|
+
Component,
|
|
591
|
+
Loading = CustomDefaultLoading,
|
|
592
|
+
}: {
|
|
593
|
+
Component: React.LazyExoticComponent<React.ComponentType<unknown>>;
|
|
594
|
+
Loading?: React.ComponentType;
|
|
595
|
+
}) {
|
|
596
|
+
return (
|
|
597
|
+
<Suspense fallback={<Loading />}>
|
|
598
|
+
<Component />
|
|
599
|
+
</Suspense>
|
|
600
|
+
);
|
|
601
|
+
}`;
|
|
602
|
+
} else {
|
|
603
|
+
loadingSection = `
|
|
578
604
|
// \u9ED8\u8BA4\u52A0\u8F7D\u72B6\u6001
|
|
579
605
|
const DefaultLoading = () => <div style={{ padding: 24, textAlign: "center" }}>\u52A0\u8F7D\u4E2D...</div>;
|
|
580
606
|
|
|
@@ -591,7 +617,23 @@ function LazyRoute({
|
|
|
591
617
|
<Component />
|
|
592
618
|
</Suspense>
|
|
593
619
|
);
|
|
594
|
-
}
|
|
620
|
+
}`;
|
|
621
|
+
}
|
|
622
|
+
return `// \u6B64\u6587\u4EF6\u7531 @4399ywkf/core \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u624B\u52A8\u4FEE\u6539
|
|
623
|
+
// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
624
|
+
|
|
625
|
+
import React, { lazy, Suspense } from "react";
|
|
626
|
+
import { createBrowserRouter, type RouteObject } from "react-router";
|
|
627
|
+
|
|
628
|
+
// \u61D2\u52A0\u8F7D\u9875\u9762\u7EC4\u4EF6
|
|
629
|
+
${lazyImports.join("\n")}
|
|
630
|
+
${errorImports.length > 0 ? `
|
|
631
|
+
// \u9519\u8BEF\u8FB9\u754C\u7EC4\u4EF6
|
|
632
|
+
${errorImports.join("\n")}` : ""}
|
|
633
|
+
${loadingImports.length > 0 ? `
|
|
634
|
+
// \u52A0\u8F7D\u72B6\u6001\u7EC4\u4EF6
|
|
635
|
+
${loadingImports.join("\n")}` : ""}
|
|
636
|
+
${loadingSection}
|
|
595
637
|
|
|
596
638
|
// \u8DEF\u7531\u914D\u7F6E
|
|
597
639
|
export const routes: RouteObject[] = ${this.emitRouteArray(routes)};
|
|
@@ -3677,6 +3719,7 @@ function buildImports(opts) {
|
|
|
3677
3719
|
];
|
|
3678
3720
|
return `
|
|
3679
3721
|
import React, { ${reactImports.join(", ")} } from "react";
|
|
3722
|
+
import { ConfigProvider } from "antd";
|
|
3680
3723
|
import { ${antdStyleImports.join(", ")} } from "antd-style";
|
|
3681
3724
|
import { createWithEqualityFn } from "zustand/traditional";
|
|
3682
3725
|
import { shallow } from "zustand/shallow";
|
|
@@ -3921,15 +3964,18 @@ function buildWrapperCode(opts) {
|
|
|
3921
3964
|
const childrenSlot = cssVar ? `<div ref={containerRef} style={{ display: "contents" }}>
|
|
3922
3965
|
{children}
|
|
3923
3966
|
</div>` : "{children}";
|
|
3924
|
-
const
|
|
3967
|
+
const innerContent = scopePopupContainer ? `<ConfigProvider getPopupContainer={getPopupContainer}>
|
|
3968
|
+
${globalReset ? "<GlobalReset />" : ""}
|
|
3969
|
+
${childrenSlot}
|
|
3970
|
+
</ConfigProvider>` : `${globalReset ? "<GlobalReset />" : ""}
|
|
3971
|
+
${childrenSlot}`;
|
|
3925
3972
|
const antdProvider = `<AntdThemeProvider
|
|
3926
3973
|
prefixCls={RUNTIME_PREFIX_CLS}
|
|
3927
3974
|
appearance={resolvedAppearance}
|
|
3928
3975
|
themeMode={appearance}
|
|
3929
|
-
theme={theme}${cssVar ? "\n customToken={{ cssVar: true }}" : ""}
|
|
3976
|
+
theme={theme}${cssVar ? "\n customToken={{ cssVar: true }}" : ""}
|
|
3930
3977
|
>
|
|
3931
|
-
${
|
|
3932
|
-
${childrenSlot}
|
|
3978
|
+
${innerContent}
|
|
3933
3979
|
</AntdThemeProvider>`;
|
|
3934
3980
|
const wrapperOpen = scopePopupContainer ? `<div
|
|
3935
3981
|
ref={popupContainerRef}
|