swico 0.9.0-beta3 → 0.9.0-beta4
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,6 +1,6 @@
|
|
|
1
|
-
import { ConfigRouterType } from '../../../utils/config';
|
|
2
1
|
import { SwicoHistoryType } from '../../../typings/global-type';
|
|
3
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare const Router: (children: any) => React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
4
4
|
export declare const compareURLPatterns: (urlPatternWithValues: string, urlPatternWithParams: string) => boolean;
|
|
5
5
|
export declare const interpolatePath: (pathTemplate: string, params: Record<string, any>) => string;
|
|
6
6
|
export declare const formatAncPath: (ancPath: string) => string;
|
|
@@ -9,4 +9,3 @@ export declare const pathNameList: {
|
|
|
9
9
|
name: string;
|
|
10
10
|
}[];
|
|
11
11
|
export declare let history: SwicoHistoryType;
|
|
12
|
-
export declare const getOriHistory: (routerType: ConfigRouterType['type']) => import("history").HashHistory;
|
|
@@ -3,13 +3,17 @@ 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.
|
|
6
|
+
exports.history = exports.pathNameList = exports.formatAncPath = exports.interpolatePath = exports.compareURLPatterns = exports.Router = void 0;
|
|
7
7
|
var qs_1 = __importDefault(require("qs"));
|
|
8
8
|
var history_1 = require("history");
|
|
9
9
|
var routes_1 = __importDefault(require("./routes"));
|
|
10
10
|
var config_1 = require("./config");
|
|
11
11
|
var react_router_dom_1 = require("react-router-dom");
|
|
12
|
-
|
|
12
|
+
var react_1 = __importDefault(require("react"));
|
|
13
|
+
var Router = function (children) {
|
|
14
|
+
return react_1.default.createElement(react_router_dom_1.unstable_HistoryRouter, { basename: config_1.routerBase, history: getOriHistory(config_1.routerType) }, children);
|
|
15
|
+
};
|
|
16
|
+
exports.Router = Router;
|
|
13
17
|
var lastIndexBase = config_1.routerBase[config_1.routerBase.length - 1];
|
|
14
18
|
var formatRouterBase = lastIndexBase === '/' ? config_1.routerBase.slice(0, config_1.routerBase.length - 1) : config_1.routerBase;
|
|
15
19
|
var compareURLPatterns = function (urlPatternWithValues, urlPatternWithParams) {
|
|
@@ -165,4 +169,3 @@ var getOriHistory = function (routerType) {
|
|
|
165
169
|
};
|
|
166
170
|
return originalHistory;
|
|
167
171
|
};
|
|
168
|
-
exports.getOriHistory = getOriHistory;
|
|
@@ -43,13 +43,12 @@ var renderChildrenRouteList = function (childrenRoutes, ancPathKey) {
|
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
var App = function () {
|
|
46
|
-
var originalHistory = (0, history_1.getOriHistory)(config_1.routerType);
|
|
47
46
|
if (config_1.routerBase && config_1.routerBase !== '/') {
|
|
48
47
|
if (config_1.routerType === 'browser' && window.location.pathname === '/') {
|
|
49
48
|
window.location.replace("".concat(config_1.routerBase));
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
|
-
return (react_1.default.createElement(history_1.
|
|
51
|
+
return (react_1.default.createElement(history_1.Router, null,
|
|
53
52
|
react_1.default.createElement(react_router_dom_1.Routes, null,
|
|
54
53
|
react_1.default.createElement(react_router_dom_1.Route, { element: react_1.default.createElement(layout_1.default, null), path: '' }, renderChildrenRouteList(routes_1.default, '')))));
|
|
55
54
|
};
|