@pisell/core 1.0.24 → 1.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/es/app/app.d.ts +2 -2
- package/es/app/app.js +3 -3
- package/es/menuManager/index.js +23 -0
- package/es/request/index.js +5 -4
- package/lib/app/app.d.ts +2 -2
- package/lib/app/app.js +3 -3
- package/lib/menuManager/index.js +18 -0
- package/lib/request/index.js +4 -3
- package/package.json +1 -1
package/es/app/app.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface AppOptions {
|
|
|
22
22
|
history?: HistoryOptions;
|
|
23
23
|
storage?: StorageOptions;
|
|
24
24
|
locales?: LocalesOptions;
|
|
25
|
-
|
|
25
|
+
getPisellos?: () => any;
|
|
26
26
|
}
|
|
27
27
|
declare class App {
|
|
28
28
|
private static instance;
|
|
@@ -67,7 +67,7 @@ declare class App {
|
|
|
67
67
|
cmd: CMD;
|
|
68
68
|
aws: AWS;
|
|
69
69
|
tasksManager: TasksManager;
|
|
70
|
-
|
|
70
|
+
getPisellos: any;
|
|
71
71
|
dbManager: IndexDBManager | null;
|
|
72
72
|
constants: {
|
|
73
73
|
channel: string;
|
package/es/app/app.js
CHANGED
|
@@ -67,8 +67,8 @@ var App = /*#__PURE__*/function () {
|
|
|
67
67
|
_defineProperty(this, "aws", void 0);
|
|
68
68
|
// 任务管理
|
|
69
69
|
_defineProperty(this, "tasksManager", void 0);
|
|
70
|
-
//
|
|
71
|
-
_defineProperty(this, "
|
|
70
|
+
// getPisellos
|
|
71
|
+
_defineProperty(this, "getPisellos", void 0);
|
|
72
72
|
_defineProperty(this, "dbManager", null);
|
|
73
73
|
_defineProperty(this, "constants", {
|
|
74
74
|
channel: ""
|
|
@@ -89,7 +89,7 @@ var App = /*#__PURE__*/function () {
|
|
|
89
89
|
this.tasksManager = new TasksManager(this);
|
|
90
90
|
this.cmd = new CMD(this, options === null || options === void 0 ? void 0 : options.cmd);
|
|
91
91
|
this.aws = new AWS(this, options === null || options === void 0 ? void 0 : options.aws);
|
|
92
|
-
this.
|
|
92
|
+
this.getPisellos = options === null || options === void 0 ? void 0 : options.getPisellos;
|
|
93
93
|
if (options !== null && options !== void 0 && options.constants) {
|
|
94
94
|
this.constants = options.constants || {};
|
|
95
95
|
}
|
package/es/menuManager/index.js
CHANGED
|
@@ -55,10 +55,27 @@ export var MenuManager = /*#__PURE__*/function () {
|
|
|
55
55
|
}, {
|
|
56
56
|
key: "findMenuItemByPath",
|
|
57
57
|
value: function findMenuItemByPath(items, path) {
|
|
58
|
+
// 首先尝试精确匹配
|
|
58
59
|
var menu = this.menuMaps[path];
|
|
59
60
|
if (menu) {
|
|
60
61
|
return menu;
|
|
61
62
|
}
|
|
63
|
+
|
|
64
|
+
// 提取路径的主要部分(去掉查询参数和hash)
|
|
65
|
+
var getPathname = function getPathname(url) {
|
|
66
|
+
var questionMarkIndex = url.indexOf('?');
|
|
67
|
+
var hashIndex = url.indexOf('#');
|
|
68
|
+
var endIndex = url.length;
|
|
69
|
+
if (questionMarkIndex !== -1 && hashIndex !== -1) {
|
|
70
|
+
endIndex = Math.min(questionMarkIndex, hashIndex);
|
|
71
|
+
} else if (questionMarkIndex !== -1) {
|
|
72
|
+
endIndex = questionMarkIndex;
|
|
73
|
+
} else if (hashIndex !== -1) {
|
|
74
|
+
endIndex = hashIndex;
|
|
75
|
+
}
|
|
76
|
+
return url.substring(0, endIndex);
|
|
77
|
+
};
|
|
78
|
+
var inputPathname = getPathname(path);
|
|
62
79
|
var _iterator = _createForOfIteratorHelper(items),
|
|
63
80
|
_step;
|
|
64
81
|
try {
|
|
@@ -69,6 +86,12 @@ export var MenuManager = /*#__PURE__*/function () {
|
|
|
69
86
|
if (item !== null && item !== void 0 && (_item$path = item.path) !== null && _item$path !== void 0 && _item$path.includes('/:') && path.startsWith(item.path.split('/:')[0])) {
|
|
70
87
|
return item;
|
|
71
88
|
}
|
|
89
|
+
|
|
90
|
+
// 比较路径的主要部分(忽略查询参数)
|
|
91
|
+
var itemPathname = getPathname(item.path);
|
|
92
|
+
if (itemPathname === inputPathname) {
|
|
93
|
+
return item;
|
|
94
|
+
}
|
|
72
95
|
if (item.children) {
|
|
73
96
|
var found = this.findMenuItemByPath(item.children, path);
|
|
74
97
|
if (found) return found;
|
package/es/request/index.js
CHANGED
|
@@ -70,11 +70,12 @@ export var request = function request(props) {
|
|
|
70
70
|
|
|
71
71
|
// 使用os服务层
|
|
72
72
|
if (config !== null && config !== void 0 && config.osServer) {
|
|
73
|
-
var _app$
|
|
73
|
+
var _app$getPisellos, _pisellos$server, _pisellos$server$hasR;
|
|
74
74
|
var app = getApp();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
var pisellos = (_app$getPisellos = app.getPisellos) === null || _app$getPisellos === void 0 ? void 0 : _app$getPisellos.call(app);
|
|
76
|
+
if (pisellos !== null && pisellos !== void 0 && pisellos.server && pisellos !== null && pisellos !== void 0 && (_pisellos$server = pisellos.server) !== null && _pisellos$server !== void 0 && (_pisellos$server$hasR = _pisellos$server.hasRoute) !== null && _pisellos$server$hasR !== void 0 && _pisellos$server$hasR.call(_pisellos$server, method, url)) {
|
|
77
|
+
var _pisellos$server2, _pisellos$server2$han;
|
|
78
|
+
return pisellos === null || pisellos === void 0 || (_pisellos$server2 = pisellos.server) === null || _pisellos$server2 === void 0 || (_pisellos$server2$han = _pisellos$server2.handleRoute) === null || _pisellos$server2$han === void 0 ? void 0 : _pisellos$server2$han.call(_pisellos$server2, method, url, props);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|
package/lib/app/app.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface AppOptions {
|
|
|
22
22
|
history?: HistoryOptions;
|
|
23
23
|
storage?: StorageOptions;
|
|
24
24
|
locales?: LocalesOptions;
|
|
25
|
-
|
|
25
|
+
getPisellos?: () => any;
|
|
26
26
|
}
|
|
27
27
|
declare class App {
|
|
28
28
|
private static instance;
|
|
@@ -67,7 +67,7 @@ declare class App {
|
|
|
67
67
|
cmd: CMD;
|
|
68
68
|
aws: AWS;
|
|
69
69
|
tasksManager: TasksManager;
|
|
70
|
-
|
|
70
|
+
getPisellos: any;
|
|
71
71
|
dbManager: IndexDBManager | null;
|
|
72
72
|
constants: {
|
|
73
73
|
channel: string;
|
package/lib/app/app.js
CHANGED
|
@@ -92,8 +92,8 @@ var App = class _App {
|
|
|
92
92
|
aws;
|
|
93
93
|
// 任务管理
|
|
94
94
|
tasksManager;
|
|
95
|
-
//
|
|
96
|
-
|
|
95
|
+
// getPisellos
|
|
96
|
+
getPisellos;
|
|
97
97
|
dbManager = null;
|
|
98
98
|
constants = {
|
|
99
99
|
channel: ""
|
|
@@ -115,7 +115,7 @@ var App = class _App {
|
|
|
115
115
|
this.tasksManager = new import_tasks.TasksManager(this);
|
|
116
116
|
this.cmd = new import_cmd.default(this, options == null ? void 0 : options.cmd);
|
|
117
117
|
this.aws = new import_aws.default(this, options == null ? void 0 : options.aws);
|
|
118
|
-
this.
|
|
118
|
+
this.getPisellos = options == null ? void 0 : options.getPisellos;
|
|
119
119
|
if (options == null ? void 0 : options.constants) {
|
|
120
120
|
this.constants = options.constants || {};
|
|
121
121
|
}
|
package/lib/menuManager/index.js
CHANGED
|
@@ -62,10 +62,28 @@ var MenuManager = class {
|
|
|
62
62
|
if (menu) {
|
|
63
63
|
return menu;
|
|
64
64
|
}
|
|
65
|
+
const getPathname = (url) => {
|
|
66
|
+
const questionMarkIndex = url.indexOf("?");
|
|
67
|
+
const hashIndex = url.indexOf("#");
|
|
68
|
+
let endIndex = url.length;
|
|
69
|
+
if (questionMarkIndex !== -1 && hashIndex !== -1) {
|
|
70
|
+
endIndex = Math.min(questionMarkIndex, hashIndex);
|
|
71
|
+
} else if (questionMarkIndex !== -1) {
|
|
72
|
+
endIndex = questionMarkIndex;
|
|
73
|
+
} else if (hashIndex !== -1) {
|
|
74
|
+
endIndex = hashIndex;
|
|
75
|
+
}
|
|
76
|
+
return url.substring(0, endIndex);
|
|
77
|
+
};
|
|
78
|
+
const inputPathname = getPathname(path);
|
|
65
79
|
for (const item of items) {
|
|
66
80
|
if (((_a = item == null ? void 0 : item.path) == null ? void 0 : _a.includes("/:")) && path.startsWith(item.path.split("/:")[0])) {
|
|
67
81
|
return item;
|
|
68
82
|
}
|
|
83
|
+
const itemPathname = getPathname(item.path);
|
|
84
|
+
if (itemPathname === inputPathname) {
|
|
85
|
+
return item;
|
|
86
|
+
}
|
|
69
87
|
if (item.children) {
|
|
70
88
|
const found = this.findMenuItemByPath(item.children, path);
|
|
71
89
|
if (found) return found;
|
package/lib/request/index.js
CHANGED
|
@@ -75,7 +75,7 @@ var createRequest = (props) => {
|
|
|
75
75
|
});
|
|
76
76
|
};
|
|
77
77
|
var request = (props) => {
|
|
78
|
-
var _a, _b, _c, _d, _e
|
|
78
|
+
var _a, _b, _c, _d, _e;
|
|
79
79
|
const { config, url, method } = props;
|
|
80
80
|
if (config == null ? void 0 : config.abort) {
|
|
81
81
|
let signal = (0, import_cancelToken.createSignal)(config.abort, url);
|
|
@@ -83,8 +83,9 @@ var request = (props) => {
|
|
|
83
83
|
}
|
|
84
84
|
if (config == null ? void 0 : config.osServer) {
|
|
85
85
|
const app = (0, import_app.getApp)();
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
const pisellos = (_a = app.getPisellos) == null ? void 0 : _a.call(app);
|
|
87
|
+
if ((pisellos == null ? void 0 : pisellos.server) && ((_c = (_b = pisellos == null ? void 0 : pisellos.server) == null ? void 0 : _b.hasRoute) == null ? void 0 : _c.call(_b, method, url))) {
|
|
88
|
+
return (_e = (_d = pisellos == null ? void 0 : pisellos.server) == null ? void 0 : _d.handleRoute) == null ? void 0 : _e.call(_d, method, url, props);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
return (0, import_cache.cacheFn)(props, createRequest);
|