swico 2.9.0-beta.1 → 2.9.0-beta.2

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
1
  {
2
2
  "name": "swico",
3
- "version": "2.9.0-beta.1",
3
+ "version": "2.9.0-beta.2",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -2,7 +2,6 @@ import { SwicoHistoryType, SwicoLocationType } from '../../../typings/global-typ
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 interpolatePathParams: (pathTemplate: string, path: string) => {};
5
- export declare const formatAncPath: (ancPath: string) => string;
6
5
  export declare const pathNameList: {
7
6
  path: string;
8
7
  name: string;
@@ -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.history = exports.getHistory = exports.pathNameList = exports.formatAncPath = exports.interpolatePathParams = exports.interpolatePath = exports.compareURLPatterns = void 0;
6
+ exports.history = exports.getHistory = exports.pathNameList = exports.interpolatePathParams = exports.interpolatePath = exports.compareURLPatterns = void 0;
7
7
  const qs_1 = __importDefault(require("qs"));
8
8
  const router_1 = require("./router");
9
9
  const lastIndexBase = router_1.routerBase[router_1.routerBase.length - 1];
@@ -67,12 +67,11 @@ const formatAncPath = (ancPath) => {
67
67
  newAncPath = newAncPath.endsWith('/') ? newAncPath.slice(0, -1) : newAncPath;
68
68
  return newAncPath;
69
69
  };
70
- exports.formatAncPath = formatAncPath;
71
70
  const getPathNameList = (routes) => {
72
71
  const list = [];
73
72
  const checkRouteItem = (item, ancPath) => {
74
73
  const { path, name, children, custom } = item;
75
- const newAncPath = `${(0, exports.formatAncPath)(ancPath)}${path.startsWith('/') ? path : '/' + path}`;
74
+ const newAncPath = `${formatAncPath(ancPath)}${path.startsWith('/') ? path : '/' + path}`;
76
75
  list.push({ path: newAncPath, name, custom });
77
76
  if (children) {
78
77
  children.some((item) => checkRouteItem(item, newAncPath));
@@ -1,3 +1,9 @@
1
1
  import { SwicoHistoryType } from '../../../typings/global-type';
2
2
  export declare let history: SwicoHistoryType;
3
+ export declare const formatAncPath: (ancPath: string) => string;
4
+ export declare const pathNameList: {
5
+ path: string;
6
+ name: string;
7
+ custom?: any;
8
+ }[];
3
9
  export declare const getRouter: () => import("vue-router").Router;
@@ -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.getRouter = exports.history = void 0;
6
+ exports.getRouter = exports.pathNameList = exports.formatAncPath = exports.history = void 0;
7
7
  const vue_router_1 = require("vue-router");
8
8
  const router_1 = require("./router");
9
9
  const qs_1 = __importDefault(require("qs"));
@@ -14,6 +14,26 @@ const transformRouteItemCustomToMeta = (routeItem) => {
14
14
  return Object.assign(Object.assign({}, newRouteItem), { children: children === null || children === void 0 ? void 0 : children.map((item) => transformRouteItemCustomToMeta(item)) });
15
15
  };
16
16
  const formatRoutes = router_1.routes.map((routeItem) => transformRouteItemCustomToMeta(routeItem));
17
+ const formatAncPath = (ancPath) => {
18
+ let newAncPath = ancPath.startsWith('/') ? ancPath : '/' + ancPath;
19
+ newAncPath = newAncPath.endsWith('/') ? newAncPath.slice(0, -1) : newAncPath;
20
+ return newAncPath;
21
+ };
22
+ exports.formatAncPath = formatAncPath;
23
+ const getPathNameList = (routes) => {
24
+ const list = [];
25
+ const checkRouteItem = (item, ancPath) => {
26
+ const { path, name, children, custom } = item;
27
+ const newAncPath = `${(0, exports.formatAncPath)(ancPath)}${path.startsWith('/') ? path : '/' + path}`;
28
+ list.push({ path: newAncPath, name, custom });
29
+ if (children) {
30
+ children.some((item) => checkRouteItem(item, newAncPath));
31
+ }
32
+ };
33
+ routes.forEach((item) => checkRouteItem(item, ''));
34
+ return list;
35
+ };
36
+ exports.pathNameList = getPathNameList(router_1.routes);
17
37
  const getRouter = () => {
18
38
  const router = (0, vue_router_1.createRouter)({
19
39
  history: (router_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(router_1.routerBase),
@@ -1,9 +1,9 @@
1
1
  import { RouteRecordRaw } from 'vue-router';
2
2
  import { ConfigRouterType } from '../../../main-config';
3
- type RouteItem = RouteRecordRaw & {
3
+ export type RouteItem = RouteRecordRaw & {
4
4
  decorator?: string;
5
+ custom?: any;
5
6
  };
6
7
  export declare const routes: RouteItem[];
7
8
  export declare const routerType: ConfigRouterType['type'];
8
9
  export declare const routerBase: ConfigRouterType['base'];
9
- export {};
@@ -8,7 +8,7 @@ const vue_router_1 = require("vue-router");
8
8
  const qs_1 = __importDefault(require("qs"));
9
9
  const vue_1 = require("vue");
10
10
  const router_1 = require("./$env/router");
11
- const history_1 = require("../.swico-react/$env/history");
11
+ const history_1 = require("./$env/history");
12
12
  const getFormatRouterBase = (routerBase) => {
13
13
  const lastIndexBase = routerBase[routerBase.length - 1];
14
14
  return lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;