@kevisual/api 0.0.21 → 0.0.23
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
|
@@ -2,7 +2,7 @@ import { QueryClient as Query, Result } from '@kevisual/query';
|
|
|
2
2
|
import { QueryRouterServer, App, Route } from '@kevisual/router';
|
|
3
3
|
import { filter } from '@kevisual/js-filter'
|
|
4
4
|
import { EventEmitter } from 'eventemitter3';
|
|
5
|
-
import { initApi } from './router-api-proxy';
|
|
5
|
+
import { initApi } from './router-api-proxy.ts';
|
|
6
6
|
|
|
7
7
|
export const RouteTypeList = ['api', 'context', 'worker', 'page'] as const;
|
|
8
8
|
export type RouterViewItemInfo = RouterViewApi | RouterViewContext | RouterViewWorker | RouteViewPage;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Query } from "@kevisual/query";
|
|
2
|
-
import { RouterViewApi, RouterItem } from ".";
|
|
2
|
+
import { RouterViewApi, RouterItem } from "./proxy.ts";
|
|
3
3
|
import { App, type QueryRouterServer } from "@kevisual/router";
|
|
4
4
|
import { filter } from "@kevisual/js-filter";
|
|
5
|
+
import { isBrowser } from "es-toolkit";
|
|
5
6
|
export const initApi = async (opts: {
|
|
6
7
|
item?: RouterViewApi,
|
|
7
8
|
router: QueryRouterServer | App,
|
|
8
9
|
token?: string,
|
|
9
10
|
/**
|
|
10
|
-
* WHERE path = 'auth' OR path = 'router'
|
|
11
|
+
* WHERE path = 'auth' OR path = 'router' OR path = 'call'
|
|
11
12
|
*/
|
|
12
13
|
exclude?: string;
|
|
13
14
|
}) => {
|
|
@@ -22,13 +23,19 @@ export const initApi = async (opts: {
|
|
|
22
23
|
}
|
|
23
24
|
let _list = res.data?.list || []
|
|
24
25
|
if (opts?.exclude) {
|
|
25
|
-
|
|
26
|
+
if (opts?.exclude) {
|
|
27
|
+
let excludeList = filter(_list, opts.exclude);
|
|
28
|
+
const excludeIds = excludeList.map(i => i.id);
|
|
29
|
+
_list = _list.filter(i => !excludeIds.includes(i.id!));
|
|
30
|
+
}
|
|
26
31
|
}
|
|
32
|
+
const _isBrowser = isBrowser();
|
|
27
33
|
for (const r of _list) {
|
|
28
34
|
if (r.path || r.id) {
|
|
29
|
-
console.debug(`注册路由: [${r.path}] ${r?.key}`, 'API');
|
|
35
|
+
_isBrowser && console.debug(`注册路由: [${r.path}] ${r?.key}`, 'API');
|
|
30
36
|
let metadata = r.metadata || {};
|
|
31
37
|
metadata.viewItem = item;
|
|
38
|
+
metadata.url = query.url;
|
|
32
39
|
router.route({
|
|
33
40
|
path: r.path,
|
|
34
41
|
key: r.key || '',
|