swico 0.4.0 → 0.5.0-beta2

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": "0.4.0",
3
+ "version": "0.5.0-beta2",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -46,6 +46,18 @@ var getPathNameList = function () {
46
46
  return list;
47
47
  };
48
48
  exports.pathNameList = getPathNameList();
49
+ var getLocation = function (originalHistory) {
50
+ var pathname = originalHistory.pathname, hash = originalHistory.hash, search = originalHistory.search;
51
+ return {
52
+ hash: hash,
53
+ search: search,
54
+ pathname: pathname,
55
+ query: search ? qs_1.default.parse(search.startsWith('?') ? search.slice(1) : search) : {},
56
+ name: '',
57
+ params: {},
58
+ path: ''
59
+ };
60
+ };
49
61
  var getFormatHistoryOption = function (to, formatRouterBase, pathList, type) {
50
62
  var _a;
51
63
  var params = to.params, path = to.path, hash = to.hash, name = to.name, query = to.query;
@@ -76,6 +88,7 @@ var getHistory = function (routerBase, routerType) {
76
88
  var formatRouterBase = lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
77
89
  history = {
78
90
  go: originalHistory.go,
91
+ forward: originalHistory.forward,
79
92
  back: originalHistory.back,
80
93
  push: function (to) {
81
94
  switch (typeof to) {
@@ -102,6 +115,9 @@ var getHistory = function (routerBase, routerType) {
102
115
  default:
103
116
  throw "An error occurred while executing Navigation.replace operation: unexpected type of 'to':".concat(typeof to);
104
117
  }
118
+ },
119
+ get location() {
120
+ return getLocation(originalHistory);
105
121
  }
106
122
  };
107
123
  return { history: history, originalHistory: originalHistory };
@@ -11,6 +11,7 @@ var Container_1 = __importDefault(require("./Container"));
11
11
  var config_1 = require("./config");
12
12
  var Layout_1 = __importDefault(require("../layout/Layout"));
13
13
  var global_1 = __importDefault(require("../global"));
14
+ var qs_1 = __importDefault(require("qs"));
14
15
  var router = (0, vue_router_1.createRouter)({
15
16
  history: (config_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(config_1.routerBase),
16
17
  routes: routes_1.default
@@ -37,7 +38,12 @@ Swico.history = {
37
38
  }
38
39
  },
39
40
  go: router.go,
40
- back: router.back
41
+ back: router.back,
42
+ forward: router.forward,
43
+ get location() {
44
+ var _a = router.currentRoute.value, path = _a.path, params = _a.params, query = _a.query, name = _a.name, hash = _a.hash, fullPath = _a.fullPath;
45
+ return { path: path, pathname: fullPath, params: params, query: query, name: name, hash: hash, search: qs_1.default.stringify(query) };
46
+ }
41
47
  };
42
48
  app.component('Layout', Layout_1.default);
43
49
  app.use(router);