@ibiz-template/vue3-util 0.5.3-beta.1 → 0.5.3-beta.11

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.
Files changed (53) hide show
  1. package/dist/index.min.css +1 -1
  2. package/dist/index.system.min.js +1 -1
  3. package/es/common/badge/badge.css +1 -0
  4. package/es/common/badge/badge.d.ts +26 -0
  5. package/es/common/badge/badge.d.ts.map +1 -0
  6. package/es/common/badge/badge.mjs +32 -0
  7. package/es/common/index.d.ts +1 -0
  8. package/es/common/index.d.ts.map +1 -1
  9. package/es/common/index.mjs +1 -0
  10. package/es/common/view-shell/view-shell.d.ts.map +1 -1
  11. package/es/common/view-shell/view-shell.mjs +50 -44
  12. package/es/index.mjs +2 -0
  13. package/es/panel-component/index.d.ts +1 -0
  14. package/es/panel-component/index.d.ts.map +1 -1
  15. package/es/panel-component/index.mjs +1 -0
  16. package/es/panel-component/nav-pos/nav-pos.mjs +1 -1
  17. package/es/panel-component/panel-item-render/index.d.ts +25 -0
  18. package/es/panel-component/panel-item-render/index.d.ts.map +1 -0
  19. package/es/panel-component/panel-item-render/index.mjs +19 -0
  20. package/es/panel-component/panel-item-render/panel-item-render.controller.d.ts +32 -0
  21. package/es/panel-component/panel-item-render/panel-item-render.controller.d.ts.map +1 -0
  22. package/es/panel-component/panel-item-render/panel-item-render.controller.mjs +29 -0
  23. package/es/panel-component/panel-item-render/panel-item-render.d.ts +27 -0
  24. package/es/panel-component/panel-item-render/panel-item-render.d.ts.map +1 -0
  25. package/es/panel-component/panel-item-render/panel-item-render.mjs +47 -0
  26. package/es/panel-component/panel-item-render/panel-item-render.provider.d.ts +17 -0
  27. package/es/panel-component/panel-item-render/panel-item-render.provider.d.ts.map +1 -0
  28. package/es/panel-component/panel-item-render/panel-item-render.provider.mjs +15 -0
  29. package/es/plugin/plugin-factory/plugin-factory.d.ts +15 -4
  30. package/es/plugin/plugin-factory/plugin-factory.d.ts.map +1 -1
  31. package/es/plugin/plugin-factory/plugin-factory.mjs +58 -10
  32. package/es/use/view/use-view-controller/use-view-controller.d.ts.map +1 -1
  33. package/es/use/view/use-view-controller/use-view-controller.mjs +13 -3
  34. package/es/util/route/route.d.ts.map +1 -1
  35. package/es/util/route/route.mjs +8 -3
  36. package/es/util/store/async-action/async-action.d.ts.map +1 -1
  37. package/es/util/store/async-action/async-action.mjs +10 -2
  38. package/lib/index.cjs +19 -15
  39. package/package.json +6 -6
  40. package/src/common/badge/badge.scss +29 -0
  41. package/src/common/badge/badge.tsx +26 -0
  42. package/src/common/index.ts +1 -0
  43. package/src/common/view-shell/view-shell.tsx +74 -55
  44. package/src/panel-component/index.ts +1 -0
  45. package/src/panel-component/nav-pos/nav-pos.tsx +1 -1
  46. package/src/panel-component/panel-item-render/index.ts +18 -0
  47. package/src/panel-component/panel-item-render/panel-item-render.controller.ts +52 -0
  48. package/src/panel-component/panel-item-render/panel-item-render.provider.ts +30 -0
  49. package/src/panel-component/panel-item-render/panel-item-render.tsx +50 -0
  50. package/src/plugin/plugin-factory/plugin-factory.ts +67 -10
  51. package/src/use/view/use-view-controller/use-view-controller.ts +14 -3
  52. package/src/util/route/route.ts +10 -5
  53. package/src/util/store/async-action/async-action.ts +14 -2
@@ -2,6 +2,7 @@ import { RuntimeError, RuntimeModelError } from '@ibiz-template/core';
2
2
  import {
3
3
  IPluginFactory,
4
4
  IPluginItem,
5
+ ISystemImportMap,
5
6
  RemotePluginConfig,
6
7
  RemotePluginItem,
7
8
  } from '@ibiz-template/runtime';
@@ -259,6 +260,14 @@ export class PluginFactory implements IPluginFactory {
259
260
  configData as RemotePluginConfig,
260
261
  );
261
262
  if (remotePlugin) {
263
+ if (remotePlugin.config['systemjs-importmap']) {
264
+ const importMap = this.handleSystemImportMap(
265
+ remotePlugin.config['systemjs-importmap'],
266
+ );
267
+ if (importMap) {
268
+ System.addImportMap(importMap);
269
+ }
270
+ }
262
271
  try {
263
272
  await this.loadScript(remotePlugin);
264
273
  this.pluginCache.set(rtObjectName, remotePlugin);
@@ -324,24 +333,28 @@ export class PluginFactory implements IPluginFactory {
324
333
  * 编译请求文件地址
325
334
  *
326
335
  * @author chitanda
327
- * @date 2022-10-31 14:10:19
336
+ * @date 2024-01-11 16:01:19
328
337
  * @protected
329
- * @param {string} script
338
+ * @param {string} pathUrl
339
+ * @param {string} [baseUrl=ibiz.env.pluginBaseUrl]
330
340
  * @return {*} {string}
331
341
  */
332
- protected parseUrl(script: string): string {
333
- if (this.urlReg.test(script)) {
334
- return script;
342
+ protected parseUrl(
343
+ pathUrl: string,
344
+ baseUrl: string = ibiz.env.pluginBaseUrl,
345
+ ): string {
346
+ if (this.urlReg.test(pathUrl)) {
347
+ return pathUrl;
335
348
  }
336
349
  let url: string = '';
337
- if (this.urlReg.test(ibiz.env.pluginBaseUrl)) {
338
- if (script.startsWith('/')) {
339
- url = ibiz.env.pluginBaseUrl + script;
350
+ if (this.urlReg.test(baseUrl)) {
351
+ if (pathUrl.startsWith('/')) {
352
+ url = baseUrl + pathUrl;
340
353
  } else {
341
- url = `${ibiz.env.pluginBaseUrl}/${script}`;
354
+ url = `${baseUrl}/${pathUrl}`;
342
355
  }
343
356
  } else {
344
- url = `${join(ibiz.env.pluginBaseUrl, script)}`;
357
+ url = `${join(baseUrl, pathUrl)}`;
345
358
  }
346
359
  const { origin, pathname } = window.location;
347
360
  if (pathname.endsWith('/') && url.startsWith('/')) {
@@ -352,4 +365,48 @@ export class PluginFactory implements IPluginFactory {
352
365
  }
353
366
  return url;
354
367
  }
368
+
369
+ /**
370
+ * 处理 systemjs importmap 配置
371
+ *
372
+ * @author chitanda
373
+ * @date 2024-01-11 20:01:07
374
+ * @protected
375
+ * @param {ISystemImportMap} importMap
376
+ * @return {*} {IParams}
377
+ */
378
+ protected handleSystemImportMap(
379
+ importMap: ISystemImportMap,
380
+ ): ISystemImportMap | null {
381
+ if (importMap) {
382
+ if (importMap.imports) {
383
+ const imps = importMap.imports;
384
+ // eslint-disable-next-line no-restricted-syntax
385
+ for (const key in imps) {
386
+ if (Object.prototype.hasOwnProperty.call(imps, key)) {
387
+ const url = imps[key];
388
+ imps[key] = this.parseUrl(url, importMap.baseUrl);
389
+ }
390
+ }
391
+ }
392
+ if (importMap.styles) {
393
+ const styles = importMap.styles;
394
+ // eslint-disable-next-line no-restricted-syntax
395
+ for (const key in styles) {
396
+ if (Object.prototype.hasOwnProperty.call(styles, key)) {
397
+ const urls = styles[key];
398
+ if (typeof urls === 'string') {
399
+ styles[key] = this.parseUrl(urls, importMap.baseUrl);
400
+ } else {
401
+ styles[key] = urls.map(url =>
402
+ this.parseUrl(url, importMap.baseUrl),
403
+ );
404
+ }
405
+ }
406
+ }
407
+ }
408
+ return importMap;
409
+ }
410
+ return null;
411
+ }
355
412
  }
@@ -107,6 +107,8 @@ export function useViewController<T extends IViewController>(
107
107
  c = fn(props.modelData, props.context, props.params, ctx) as T;
108
108
  }
109
109
 
110
+ ibiz.util.viewStack.add(c.id, c);
111
+
110
112
  watchAndUpdateContextParams(props, c);
111
113
  watchAndUpdateState(props, c);
112
114
 
@@ -123,9 +125,15 @@ export function useViewController<T extends IViewController>(
123
125
  c.modal = props.modal;
124
126
  }
125
127
 
126
- onActivated(() => c.onActivated());
128
+ onActivated(() => {
129
+ c.onActivated();
130
+ ibiz.util.viewStack.active(c.id);
131
+ });
127
132
 
128
- onDeactivated(() => c.onDeactivated());
133
+ onDeactivated(() => {
134
+ c.onDeactivated();
135
+ ibiz.util.viewStack.deactivate(c.id);
136
+ });
129
137
 
130
138
  c.force = useForce();
131
139
 
@@ -137,6 +145,9 @@ export function useViewController<T extends IViewController>(
137
145
  c.created();
138
146
 
139
147
  // 卸载时销毁
140
- onBeforeUnmount(() => c.destroyed());
148
+ onBeforeUnmount(() => {
149
+ c.destroyed();
150
+ ibiz.util.viewStack.remove(c.id);
151
+ });
141
152
  return c as T;
142
153
  }
@@ -162,7 +162,12 @@ export function routePath2string(routePath: IRoutePath): string {
162
162
  */
163
163
  export function getOwnRouteContext(context: IContext): IParams {
164
164
  const ownContext = context.getOwnContext();
165
- const excludeKeys = ['srfsessionid', 'srfappid'];
165
+ const excludeKeys = [
166
+ 'srfsessionid',
167
+ 'srfappid',
168
+ 'currentSrfNav',
169
+ 'toRouteDepth',
170
+ ];
166
171
  Object.keys(ownContext).forEach(key => {
167
172
  if (excludeKeys.includes(key)) {
168
173
  delete ownContext[key];
@@ -258,8 +263,8 @@ export async function generateRoutePath(
258
263
  let depth = context.srfdefaulttoroutedepth || 2; // 默认层级看上下文的srfdefaulttoroutedepth,如果没有就是2
259
264
  if (context.toRouteDepth) {
260
265
  depth = context.toRouteDepth;
261
- // 使用完后删除,避免添加到上下文里
262
- delete context.toRouteDepth;
266
+ // 使用完后转为undefined,避免添加到上下文里
267
+ context.toRouteDepth = undefined;
263
268
  } else if (ibiz.env.isMob) {
264
269
  // 移动端默认补充home层级
265
270
  routePath.pathNodes[0] = {
@@ -275,8 +280,8 @@ export async function generateRoutePath(
275
280
  const currentNode = routePath.pathNodes[routePath.pathNodes.length - 1];
276
281
  currentNode.params = currentNode.params || {};
277
282
  currentNode.srfnav = context.currentSrfNav;
278
- // 使用完后删除,避免添加到上下文里
279
- delete context.currentSrfNav;
283
+ // 使用完后转为undefined,避免添加到上下文里
284
+ context.currentSrfNav = undefined;
280
285
  }
281
286
 
282
287
  // 重定向视图跳转的一级首页路由
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { IPortalAsyncAction, IPortalMessage } from '@ibiz-template/core';
4
4
  import dayjs from 'dayjs';
5
- import { isNumber } from 'lodash-es';
5
+ import { isNil, isNumber } from 'lodash-es';
6
6
  import { computed, onUnmounted, ref } from 'vue';
7
7
 
8
8
  /**
@@ -25,6 +25,16 @@ function formatAsyncAction(data: IPortalAsyncAction): IPortalAsyncAction {
25
25
  data[key] = dayjs(data[key]).format('YYYY-MM-DD HH:mm:ss');
26
26
  }
27
27
  });
28
+
29
+ if (!isNil(data.actionresult)) {
30
+ try {
31
+ const json = JSON.parse(data.actionresult as string);
32
+ data.actionresult = json;
33
+ } catch (error) {
34
+ // 不是对象类型就是字符串。
35
+ }
36
+ }
37
+
28
38
  return data;
29
39
  }
30
40
 
@@ -50,6 +60,7 @@ export function useAsyncAction() {
50
60
 
51
61
  const load = async () => {
52
62
  const res = await ibiz.asyncAction.fetch();
63
+ res.data.forEach(formatAsyncAction);
53
64
  allAsyncActions.value = res.data;
54
65
  };
55
66
 
@@ -63,10 +74,11 @@ export function useAsyncAction() {
63
74
  return;
64
75
  }
65
76
  const asyncAction = formatAsyncAction(msg.data as IPortalAsyncAction);
77
+
66
78
  const findIndex = allAsyncActions.value.findIndex(
67
79
  item => item.asyncacitonid === asyncAction.asyncacitonid,
68
80
  );
69
- if (findIndex !== -1) {
81
+ if (findIndex === -1) {
70
82
  // 不存在的数据补充到最开始,并显示长度加一
71
83
  allAsyncActions.value.unshift(asyncAction);
72
84
  showLength.value += 1;