@4399ywkf/core 5.0.24 → 5.0.26
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 +59 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +59 -16
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +2 -2
- 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.d.ts +1 -1
- package/dist/rspack/index.js +59 -16
- package/dist/rspack/index.js.map +1 -1
- package/dist/{schema-CGQSqjRr.d.ts → schema-runIYOB7.d.ts} +17 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -566,21 +566,47 @@ var ConventionalRouteGenerator = class {
|
|
|
566
566
|
const errorImports = [];
|
|
567
567
|
const loadingImports = [];
|
|
568
568
|
this.collectImports(routes, lazyImports, errorImports, loadingImports);
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
// \u61D2\u52A0\u8F7D\
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
569
|
+
const { loading } = this.options;
|
|
570
|
+
const hasCustomLoading = loading && typeof loading === "object" && loading.component;
|
|
571
|
+
const loadingDisabled = loading === false;
|
|
572
|
+
let loadingSection;
|
|
573
|
+
if (loadingDisabled) {
|
|
574
|
+
loadingSection = `
|
|
575
|
+
// \u61D2\u52A0\u8F7D\u5305\u88C5\uFF08\u52A0\u8F7D\u72B6\u6001\u5DF2\u7981\u7528\uFF09
|
|
576
|
+
function LazyRoute({
|
|
577
|
+
Component,
|
|
578
|
+
Loading,
|
|
579
|
+
}: {
|
|
580
|
+
Component: React.LazyExoticComponent<React.ComponentType<unknown>>;
|
|
581
|
+
Loading?: React.ComponentType;
|
|
582
|
+
}) {
|
|
583
|
+
const fallback = Loading ? <Loading /> : null;
|
|
584
|
+
return (
|
|
585
|
+
<Suspense fallback={fallback}>
|
|
586
|
+
<Component />
|
|
587
|
+
</Suspense>
|
|
588
|
+
);
|
|
589
|
+
}`;
|
|
590
|
+
} else if (hasCustomLoading) {
|
|
591
|
+
loadingSection = `
|
|
592
|
+
import CustomDefaultLoading from "${loading.component}";
|
|
583
593
|
|
|
594
|
+
// \u61D2\u52A0\u8F7D\u5305\u88C5\uFF08\u4F7F\u7528\u81EA\u5B9A\u4E49\u9ED8\u8BA4\u52A0\u8F7D\u7EC4\u4EF6\uFF09
|
|
595
|
+
function LazyRoute({
|
|
596
|
+
Component,
|
|
597
|
+
Loading = CustomDefaultLoading,
|
|
598
|
+
}: {
|
|
599
|
+
Component: React.LazyExoticComponent<React.ComponentType<unknown>>;
|
|
600
|
+
Loading?: React.ComponentType;
|
|
601
|
+
}) {
|
|
602
|
+
return (
|
|
603
|
+
<Suspense fallback={<Loading />}>
|
|
604
|
+
<Component />
|
|
605
|
+
</Suspense>
|
|
606
|
+
);
|
|
607
|
+
}`;
|
|
608
|
+
} else {
|
|
609
|
+
loadingSection = `
|
|
584
610
|
// \u9ED8\u8BA4\u52A0\u8F7D\u72B6\u6001
|
|
585
611
|
const DefaultLoading = () => <div style={{ padding: 24, textAlign: "center" }}>\u52A0\u8F7D\u4E2D...</div>;
|
|
586
612
|
|
|
@@ -597,7 +623,23 @@ function LazyRoute({
|
|
|
597
623
|
<Component />
|
|
598
624
|
</Suspense>
|
|
599
625
|
);
|
|
600
|
-
}
|
|
626
|
+
}`;
|
|
627
|
+
}
|
|
628
|
+
return `// \u6B64\u6587\u4EF6\u7531 @4399ywkf/core \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u624B\u52A8\u4FEE\u6539
|
|
629
|
+
// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
630
|
+
|
|
631
|
+
import React, { lazy, Suspense } from "react";
|
|
632
|
+
import { createBrowserRouter, type RouteObject } from "react-router";
|
|
633
|
+
|
|
634
|
+
// \u61D2\u52A0\u8F7D\u9875\u9762\u7EC4\u4EF6
|
|
635
|
+
${lazyImports.join("\n")}
|
|
636
|
+
${errorImports.length > 0 ? `
|
|
637
|
+
// \u9519\u8BEF\u8FB9\u754C\u7EC4\u4EF6
|
|
638
|
+
${errorImports.join("\n")}` : ""}
|
|
639
|
+
${loadingImports.length > 0 ? `
|
|
640
|
+
// \u52A0\u8F7D\u72B6\u6001\u7EC4\u4EF6
|
|
641
|
+
${loadingImports.join("\n")}` : ""}
|
|
642
|
+
${loadingSection}
|
|
601
643
|
|
|
602
644
|
// \u8DEF\u7531\u914D\u7F6E
|
|
603
645
|
export const routes: RouteObject[] = ${this.emitRouteArray(routes)};
|
|
@@ -1010,7 +1052,8 @@ var YwkfGenerator = class {
|
|
|
1010
1052
|
const generator = new ConventionalRouteGenerator({
|
|
1011
1053
|
pagesDir,
|
|
1012
1054
|
outputDir,
|
|
1013
|
-
basename: config.router.basename
|
|
1055
|
+
basename: config.router.basename,
|
|
1056
|
+
loading: config.router.loading
|
|
1014
1057
|
});
|
|
1015
1058
|
const content = generator.generateCode();
|
|
1016
1059
|
const routesPath = join3(outputDir, "routes.tsx");
|