swico 0.9.0-beta15 → 0.9.0-beta17
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SwicoLocationType } from '../../../typings/global-type';
|
|
1
|
+
import { SwicoHistoryType, SwicoLocationType } from '../../../typings/global-type';
|
|
2
2
|
export declare const compareURLPatterns: (urlPatternWithValues: string, urlPatternWithParams: string) => boolean;
|
|
3
3
|
export declare const interpolatePath: (pathTemplate: string, params: Record<string, any>) => string;
|
|
4
4
|
export declare const formatAncPath: (ancPath: string) => string;
|
|
@@ -14,3 +14,4 @@ export declare const getHistory: (router: any) => {
|
|
|
14
14
|
replace: (to: any) => void;
|
|
15
15
|
readonly location: SwicoLocationType;
|
|
16
16
|
};
|
|
17
|
+
export declare let history: SwicoHistoryType;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getHistory = exports.pathNameList = exports.formatAncPath = exports.interpolatePath = exports.compareURLPatterns = void 0;
|
|
6
|
+
exports.history = exports.getHistory = exports.pathNameList = exports.formatAncPath = exports.interpolatePath = exports.compareURLPatterns = void 0;
|
|
7
7
|
var qs_1 = __importDefault(require("qs"));
|
|
8
8
|
var routes_1 = __importDefault(require("./routes"));
|
|
9
9
|
var config_1 = require("./config");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import '../../global';
|
|
3
|
-
import { SwicoHistoryType } from '../../../typings/global-type';
|
|
4
3
|
export type RoutesItemType = {
|
|
5
4
|
component?: () => Promise<{
|
|
6
5
|
default: FC;
|
|
@@ -11,4 +10,3 @@ export type RoutesItemType = {
|
|
|
11
10
|
name?: string;
|
|
12
11
|
};
|
|
13
12
|
export declare const getChildrenRouteList: (childrenRoutes: RoutesItemType[], ancPathKey: string) => any;
|
|
14
|
-
export declare let history: SwicoHistoryType;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.getChildrenRouteList = void 0;
|
|
30
30
|
var client_1 = require("react-dom/client");
|
|
31
31
|
var react_1 = __importStar(require("react"));
|
|
32
32
|
var react_router_dom_1 = require("react-router-dom");
|
|
@@ -57,16 +57,18 @@ var App = function () {
|
|
|
57
57
|
children: (0, exports.getChildrenRouteList)(routes_1.default, '')
|
|
58
58
|
}
|
|
59
59
|
];
|
|
60
|
-
var router = (config_1.routerType === 'hash' ? react_router_dom_1.createHashRouter : react_router_dom_1.createBrowserRouter)(routeList
|
|
60
|
+
var router = (config_1.routerType === 'hash' ? react_router_dom_1.createHashRouter : react_router_dom_1.createBrowserRouter)(routeList, {
|
|
61
|
+
basename: config_1.routerBase
|
|
62
|
+
});
|
|
61
63
|
if (config_1.routerBase && config_1.routerBase !== '/') {
|
|
62
64
|
if (config_1.routerType === 'browser' && window.location.pathname === '/') {
|
|
63
65
|
window.location.replace("".concat(config_1.routerBase));
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
(0, react_1.useLayoutEffect)(function () {
|
|
67
|
-
|
|
69
|
+
history_1.history = (0, history_1.getHistory)(router);
|
|
68
70
|
});
|
|
69
|
-
return react_1.default.createElement(react_router_dom_1.RouterProvider, { router: router
|
|
71
|
+
return react_1.default.createElement(react_router_dom_1.RouterProvider, { router: router });
|
|
70
72
|
};
|
|
71
73
|
var root = (0, client_1.createRoot)(document.getElementById('root'));
|
|
72
74
|
root.render(react_1.default.createElement(App, null));
|
package/src/utils/config.js
CHANGED
|
@@ -213,7 +213,7 @@ var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, v
|
|
|
213
213
|
.replaceAll('\\', '/');
|
|
214
214
|
replaceFileText = replaceFileText.replaceAll('require("./template/react/react-hooks");', "require(\"".concat(formatHooksPath, "\");"));
|
|
215
215
|
formatHistoryPath = path_1.default
|
|
216
|
-
.resolve(projectPath, "./src/.swico/.".concat(env, "/
|
|
216
|
+
.resolve(projectPath, "./src/.swico/.".concat(env, "/history"))
|
|
217
217
|
.replaceAll('\\', '/');
|
|
218
218
|
replaceFileText = replaceFileText.replaceAll('require("./mock-history");', "require(\"".concat(formatHistoryPath, "\");"));
|
|
219
219
|
return [4, fs_extra_1.default.writeFile(targetPath, replaceFileText)];
|