@ibiz-template/vue3-util 0.0.3-beta.4 → 0.0.3-beta.6
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/dist/system/index.system.js +1 -1
- package/out/interface/util/route/route.d.ts +28 -14
- package/out/interface/util/route/route.d.ts.map +1 -1
- package/out/props/editor/date-range.d.ts +51 -0
- package/out/props/editor/date-range.d.ts.map +1 -0
- package/out/props/editor/date-range.js +21 -0
- package/out/props/editor/index.d.ts +2 -0
- package/out/props/editor/index.d.ts.map +1 -1
- package/out/props/editor/index.js +2 -0
- package/out/props/editor/number-range.d.ts +51 -0
- package/out/props/editor/number-range.d.ts.map +1 -0
- package/out/props/editor/number-range.js +21 -0
- package/out/props/editor/text-box.d.ts +53 -0
- package/out/props/editor/text-box.d.ts.map +1 -1
- package/out/props/editor/text-box.js +24 -0
- package/out/use/route/route.d.ts +0 -9
- package/out/use/route/route.d.ts.map +1 -1
- package/out/use/route/route.js +0 -25
- package/out/use/widget/index.d.ts +1 -1
- package/out/use/widget/index.d.ts.map +1 -1
- package/out/use/widget/index.js +1 -1
- package/out/use/widget/use-panel-controller/use-panel-controller.d.ts +14 -0
- package/out/use/widget/use-panel-controller/use-panel-controller.d.ts.map +1 -0
- package/out/use/widget/{use-layout-panel-controller/use-layout-panel-controller.js → use-panel-controller/use-panel-controller.js} +6 -6
- package/out/util/index.d.ts +1 -0
- package/out/util/index.d.ts.map +1 -1
- package/out/util/index.js +1 -0
- package/out/util/render-provider/render-ctrl-provider.d.ts +14 -0
- package/out/util/render-provider/render-ctrl-provider.d.ts.map +1 -0
- package/out/util/render-provider/render-ctrl-provider.js +24 -0
- package/out/util/route/route.d.ts +11 -2
- package/out/util/route/route.d.ts.map +1 -1
- package/out/util/route/route.js +117 -54
- package/package.json +6 -6
- package/src/interface/util/route/route.ts +31 -15
- package/src/props/editor/date-range.ts +24 -0
- package/src/props/editor/index.ts +2 -0
- package/src/props/editor/number-range.ts +24 -0
- package/src/props/editor/text-box.ts +26 -0
- package/src/use/route/route.ts +0 -28
- package/src/use/widget/index.ts +1 -1
- package/src/use/widget/{use-layout-panel-controller/use-layout-panel-controller.ts → use-panel-controller/use-panel-controller.ts} +10 -10
- package/src/util/index.ts +1 -0
- package/src/util/render-provider/render-ctrl-provider.ts +31 -0
- package/src/util/route/route.ts +126 -60
- package/out/use/widget/use-layout-panel-controller/use-layout-panel-controller.d.ts +0 -14
- package/out/use/widget/use-layout-panel-controller/use-layout-panel-controller.d.ts.map +0 -1
package/src/util/route/route.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notNilEmpty } from 'qx-util';
|
|
1
|
+
import { isNilOrEmpty, notNilEmpty } from 'qx-util';
|
|
2
2
|
import { IBizContext, RuntimeError } from '@ibiz-template/core';
|
|
3
3
|
import { IPSApplication, IPSAppView, IPSSubAppRef } from '@ibiz-template/model';
|
|
4
4
|
import qs from 'qs';
|
|
@@ -6,6 +6,26 @@ import { RouteLocationNormalizedLoaded as Route } from 'vue-router';
|
|
|
6
6
|
import { calcRouteContext } from '@ibiz-template/runtime';
|
|
7
7
|
import { IRoutePath, IRoutePathNode, IRouteViewData } from '../../interface';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* 获取自身的路由上下文,排除了部分不需要路由携带的参数
|
|
11
|
+
*
|
|
12
|
+
* @author lxm
|
|
13
|
+
* @date 2023-03-14 02:07:41
|
|
14
|
+
* @export
|
|
15
|
+
* @param {IContext} context
|
|
16
|
+
* @returns {*} {IParams}
|
|
17
|
+
*/
|
|
18
|
+
export function getOwnRouteContext(context: IContext): IParams {
|
|
19
|
+
const ownContext = context.getOwnContext();
|
|
20
|
+
const excludeKeys = ['srfsessionid'];
|
|
21
|
+
Object.keys(ownContext).forEach(key => {
|
|
22
|
+
if (excludeKeys.includes(key)) {
|
|
23
|
+
delete ownContext[key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return ownContext;
|
|
27
|
+
}
|
|
28
|
+
|
|
9
29
|
/**
|
|
10
30
|
* 生成route路径
|
|
11
31
|
*
|
|
@@ -21,27 +41,32 @@ import { IRoutePath, IRoutePathNode, IRouteViewData } from '../../interface';
|
|
|
21
41
|
export function generateRoutePath(
|
|
22
42
|
appView: IPSAppView,
|
|
23
43
|
route: Route,
|
|
24
|
-
context
|
|
44
|
+
context: IBizContext,
|
|
25
45
|
params?: IParams | undefined,
|
|
26
|
-
): { path: string
|
|
46
|
+
): { path: string } {
|
|
27
47
|
const routePath = route2routePath(route);
|
|
28
48
|
// 如果上下文存在toRouteLevel时,使用上下文的层级,否则是第二级路由
|
|
29
49
|
let level = 2;
|
|
30
|
-
if (context
|
|
50
|
+
if (context.toRouteLevel) {
|
|
31
51
|
level = context.toRouteLevel;
|
|
32
52
|
// 使用完后删除,避免添加到首页上下文里
|
|
33
53
|
delete context.toRouteLevel;
|
|
34
54
|
}
|
|
55
|
+
|
|
35
56
|
// 删除目标层级和之后的路由,保留之前层级的路由
|
|
36
57
|
routePath.pathNodes.splice(level - 1, routePath.pathNodes.length - level + 1);
|
|
37
58
|
|
|
38
|
-
//
|
|
39
|
-
if (context
|
|
40
|
-
routePath.pathNodes[
|
|
59
|
+
// 导航视图的导航参数,加在目标层级之前的一个层级的视图参数里
|
|
60
|
+
if (context.currentSrfNav) {
|
|
61
|
+
const currentNode = routePath.pathNodes[routePath.pathNodes.length - 1];
|
|
62
|
+
currentNode.params = currentNode.params || {};
|
|
63
|
+
currentNode.params.srfnav = context.currentSrfNav;
|
|
64
|
+
// 使用完后删除,避免添加到首页上下文里
|
|
65
|
+
delete context.currentSrfNav;
|
|
41
66
|
}
|
|
42
67
|
|
|
43
68
|
// 重定向视图跳转的一级首页路由
|
|
44
|
-
if (routePath.pathNodes[0]
|
|
69
|
+
if (routePath.pathNodes[0]?.viewName === 'appredirectview') {
|
|
45
70
|
if (params?.srfindexname) {
|
|
46
71
|
routePath.pathNodes[0].viewName = params.srfindexname;
|
|
47
72
|
delete params.srfindexname;
|
|
@@ -51,22 +76,38 @@ export function generateRoutePath(
|
|
|
51
76
|
}
|
|
52
77
|
|
|
53
78
|
// 计算目标视图path路径
|
|
54
|
-
routePath.pathNodes.push({
|
|
55
|
-
|
|
79
|
+
routePath.pathNodes.push({
|
|
80
|
+
viewName: appView.codeName.toLowerCase(),
|
|
81
|
+
context: getOwnRouteContext(context),
|
|
82
|
+
params,
|
|
83
|
+
});
|
|
56
84
|
|
|
57
|
-
//
|
|
58
|
-
|
|
85
|
+
// 计算二级视图的资源路径加到index后面
|
|
86
|
+
const codeName = appView.getPSAppDataEntity()?.codeName;
|
|
87
|
+
if (level === 2 && codeName) {
|
|
59
88
|
const app = ibiz.hub.getApp(appView.getPSModelService().app);
|
|
60
89
|
const paths = app.resourcePathUtil.calcPaths(codeName);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
90
|
+
const resContext = calcRouteContext(context, paths);
|
|
91
|
+
if (!isNilOrEmpty(resContext)) {
|
|
92
|
+
// 资源路径不为空,二级视图的上下文删掉多余的资源上下文
|
|
93
|
+
routePath.pathNodes[0].context = resContext;
|
|
94
|
+
Object.keys(resContext).forEach(key => {
|
|
95
|
+
const currentNode = routePath.pathNodes[level - 1];
|
|
96
|
+
if (
|
|
97
|
+
currentNode.context &&
|
|
98
|
+
Object.prototype.hasOwnProperty.call(currentNode.context, key)
|
|
99
|
+
) {
|
|
100
|
+
delete currentNode.context[key];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
routePath.pathNodes[0].context = undefined;
|
|
105
|
+
}
|
|
65
106
|
}
|
|
66
107
|
|
|
67
108
|
// 视图参数通过query传递
|
|
68
109
|
|
|
69
|
-
return { path: routePath2string(routePath)
|
|
110
|
+
return { path: routePath2string(routePath) };
|
|
70
111
|
}
|
|
71
112
|
|
|
72
113
|
/**
|
|
@@ -169,8 +210,8 @@ export function parseRouteViewData(
|
|
|
169
210
|
const modelPath = viewModel.modelPath!;
|
|
170
211
|
const { viewType } = viewModel.refM;
|
|
171
212
|
|
|
172
|
-
//
|
|
173
|
-
const context:
|
|
213
|
+
// !解析上下文参数,整合当前层级之前所有的上下文参数
|
|
214
|
+
const context: IParams = {};
|
|
174
215
|
// 合并appData里的应用上下文
|
|
175
216
|
if (ibiz.appData?.context) {
|
|
176
217
|
Object.assign(context, ibiz.appData.context);
|
|
@@ -181,28 +222,23 @@ export function parseRouteViewData(
|
|
|
181
222
|
if (routePath.appContext) {
|
|
182
223
|
Object.assign(context, routePath.appContext);
|
|
183
224
|
}
|
|
184
|
-
//
|
|
225
|
+
// 逐层合并视图上下文
|
|
185
226
|
for (let index = 0; index < level; index++) {
|
|
186
227
|
const pathNode = routePath.pathNodes[index];
|
|
187
228
|
if (notNilEmpty(pathNode.context)) {
|
|
188
|
-
|
|
189
|
-
// 首页的context是对象直接合并
|
|
190
|
-
Object.assign(context, pathNode.context);
|
|
191
|
-
}
|
|
229
|
+
Object.assign(context, pathNode.context);
|
|
192
230
|
}
|
|
193
231
|
}
|
|
194
232
|
|
|
195
233
|
// 最后一级路由对应的视图才会解析视图参数
|
|
196
|
-
|
|
197
|
-
if (route.matched.length === level) {
|
|
198
|
-
params = route.query as IParams;
|
|
199
|
-
}
|
|
234
|
+
const { params, srfnav } = routePath.pathNodes[level - 1];
|
|
200
235
|
|
|
201
236
|
return {
|
|
202
237
|
viewPath: modelPath,
|
|
203
238
|
viewType,
|
|
204
239
|
context,
|
|
205
240
|
params,
|
|
241
|
+
srfnav,
|
|
206
242
|
};
|
|
207
243
|
}
|
|
208
244
|
|
|
@@ -223,17 +259,46 @@ export function route2routePath(route: Route): IRoutePath {
|
|
|
223
259
|
const pathNodes: IRoutePathNode[] = [];
|
|
224
260
|
for (let index = 1; index <= level; index++) {
|
|
225
261
|
const viewName = route.params[`view${index}`] as string;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
262
|
+
const paramsStr = route.params[`params${index}`] as string;
|
|
263
|
+
|
|
264
|
+
/** 路由参数,默认是视图参数 */
|
|
265
|
+
let params: IParams | undefined;
|
|
266
|
+
|
|
267
|
+
/** 上下文参数 */
|
|
268
|
+
let context: IParams | undefined;
|
|
269
|
+
let srfnav: string | undefined;
|
|
270
|
+
// params为占位符时置空
|
|
271
|
+
if (!paramsStr || paramsStr === ibiz.env.routePlaceholder) {
|
|
272
|
+
params = undefined;
|
|
273
|
+
} else {
|
|
233
274
|
// 首页上下文要解析
|
|
234
|
-
|
|
275
|
+
params = qs.parse(paramsStr, {
|
|
276
|
+
strictNullHandling: true,
|
|
277
|
+
delimiter: ';',
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// 路由参数存在的时候,解析里面的上下文。
|
|
282
|
+
if (params) {
|
|
283
|
+
if (index === 1) {
|
|
284
|
+
// 首页的时候,路由上的参数是资源路径,属于上下文
|
|
285
|
+
context = params;
|
|
286
|
+
params = undefined;
|
|
287
|
+
} else {
|
|
288
|
+
if (params.srfnavctx) {
|
|
289
|
+
// 解析额外上下文
|
|
290
|
+
context = JSON.parse(decodeURIComponent(params.srfnavctx));
|
|
291
|
+
delete params.srfnavctx;
|
|
292
|
+
}
|
|
293
|
+
if (params.srfnav) {
|
|
294
|
+
// 解析额外自身视图导航参数
|
|
295
|
+
srfnav = params.srfnav;
|
|
296
|
+
delete params.srfnav;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
235
299
|
}
|
|
236
|
-
|
|
300
|
+
|
|
301
|
+
pathNodes.push({ viewName, context, params, srfnav });
|
|
237
302
|
}
|
|
238
303
|
|
|
239
304
|
// 解析应用上下文
|
|
@@ -243,17 +308,12 @@ export function route2routePath(route: Route): IRoutePath {
|
|
|
243
308
|
route.params.appContext !== ibiz.env.routePlaceholder
|
|
244
309
|
) {
|
|
245
310
|
appContext = qs.parse(route.params.appContext as string, {
|
|
311
|
+
strictNullHandling: true,
|
|
246
312
|
delimiter: ';',
|
|
247
313
|
});
|
|
248
314
|
}
|
|
249
315
|
|
|
250
|
-
|
|
251
|
-
let params;
|
|
252
|
-
if (route.query) {
|
|
253
|
-
params = { ...route.query };
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return { appContext, pathNodes, params };
|
|
316
|
+
return { appContext, pathNodes };
|
|
257
317
|
}
|
|
258
318
|
|
|
259
319
|
/**
|
|
@@ -269,35 +329,41 @@ export function routePath2string(routePath: IRoutePath): string {
|
|
|
269
329
|
let pathStr = '';
|
|
270
330
|
// 应用上下文
|
|
271
331
|
if (routePath.appContext) {
|
|
272
|
-
pathStr += `/${qs.stringify(routePath.appContext, {
|
|
332
|
+
pathStr += `/${qs.stringify(routePath.appContext, {
|
|
333
|
+
delimiter: ';',
|
|
334
|
+
strictNullHandling: true,
|
|
335
|
+
})}`;
|
|
273
336
|
} else {
|
|
274
337
|
pathStr += `/${ibiz.env.routePlaceholder}`;
|
|
275
338
|
}
|
|
276
339
|
|
|
277
340
|
// 每一层级的视图
|
|
278
341
|
routePath.pathNodes.forEach((pathNode: IRoutePathNode, index: number) => {
|
|
279
|
-
pathStr += `/${pathNode.viewName}
|
|
342
|
+
pathStr += `/${pathNode.viewName}/`;
|
|
343
|
+
let routeParams: IParams | undefined;
|
|
280
344
|
// 首页路由
|
|
281
345
|
if (index === 0) {
|
|
282
|
-
if (
|
|
283
|
-
notNilEmpty(pathNode.context) &&
|
|
284
|
-
Object.values(pathNode.context!).length
|
|
285
|
-
) {
|
|
346
|
+
if (notNilEmpty(pathNode.context)) {
|
|
286
347
|
// 对象转成a=11;b=222的格式,字符串直接附加在后面
|
|
287
|
-
|
|
288
|
-
} else {
|
|
289
|
-
pathStr += `/${ibiz.env.routePlaceholder}`;
|
|
348
|
+
routeParams = pathNode.context;
|
|
290
349
|
}
|
|
291
350
|
} else {
|
|
292
|
-
//
|
|
293
|
-
|
|
351
|
+
// 非首页路由,视图参数直接放到路由参数上,上下文转换后放到路由参数的srfnavctx上
|
|
352
|
+
routeParams = notNilEmpty(pathNode.params) ? pathNode.params : {};
|
|
353
|
+
if (notNilEmpty(pathNode.context)) {
|
|
354
|
+
const objStr = JSON.stringify(pathNode.context);
|
|
355
|
+
// undefined 的vlaue会被JSON.stringify删除,可能会转成{}
|
|
356
|
+
if (objStr !== '{}') {
|
|
357
|
+
routeParams!.srfnavctx = encodeURIComponent(objStr);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
294
360
|
}
|
|
295
|
-
});
|
|
296
361
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
362
|
+
// 把路由参数转换到路由路径上去
|
|
363
|
+
pathStr +=
|
|
364
|
+
qs.stringify(routeParams, { delimiter: ';', strictNullHandling: true }) ||
|
|
365
|
+
ibiz.env.routePlaceholder;
|
|
366
|
+
});
|
|
301
367
|
|
|
302
368
|
return pathStr;
|
|
303
369
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { LayoutPanelController } from '@ibiz-template/runtime';
|
|
2
|
-
import { IBizContext } from '@ibiz-template/core';
|
|
3
|
-
import { LayoutPanelModel } from '@ibiz-template/model';
|
|
4
|
-
/**
|
|
5
|
-
* 获取布局面板控制器
|
|
6
|
-
*
|
|
7
|
-
* @export
|
|
8
|
-
* @param {LayoutPanelModel} model
|
|
9
|
-
* @param {IBizContext} context
|
|
10
|
-
* @param {IParams} [params={}]
|
|
11
|
-
* @returns {*} {LayoutPanelController}
|
|
12
|
-
*/
|
|
13
|
-
export declare function useLayoutPanelController(model: LayoutPanelModel, context: IBizContext, params?: IParams): LayoutPanelController;
|
|
14
|
-
//# sourceMappingURL=use-layout-panel-controller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-layout-panel-controller.d.ts","sourceRoot":"","sources":["../../../../src/use/widget/use-layout-panel-controller/use-layout-panel-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,WAAW,EACpB,MAAM,GAAE,OAAY,GACnB,qBAAqB,CAOvB"}
|