@vc-shell/framework 1.0.96 → 1.0.97
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/CHANGELOG.md +9 -1
- package/dist/framework.mjs +2392 -2375
- package/dist/shared/components/blade-navigation/components/vc-blade-navigation/index.d.ts +0 -1
- package/dist/shared/components/blade-navigation/components/vc-blade-navigation/index.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue.d.ts +0 -1
- package/dist/shared/components/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/composables/useBladeNavigation/index.d.ts +2 -1
- package/dist/shared/components/blade-navigation/composables/useBladeNavigation/index.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/types/index.d.ts +0 -5
- package/dist/shared/components/blade-navigation/types/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/shared/components/blade-navigation/composables/useBladeNavigation/index.ts +38 -2
- package/shared/components/blade-navigation/types/index.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/framework",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.97",
|
|
4
4
|
"main": "./dist/framework.mjs",
|
|
5
5
|
"module": "./dist/framework.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"whatwg-fetch": "^3.6.2"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@vc-shell/api-client-generator": "^1.0.
|
|
59
|
-
"@vc-shell/config-generator": "^1.0.
|
|
58
|
+
"@vc-shell/api-client-generator": "^1.0.97",
|
|
59
|
+
"@vc-shell/config-generator": "^1.0.97",
|
|
60
60
|
"@vitejs/plugin-vue": "^4.2.3",
|
|
61
61
|
"sass": "^1.62.1",
|
|
62
62
|
"typescript": "~5.0.4",
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
markRaw,
|
|
10
10
|
inject,
|
|
11
11
|
nextTick,
|
|
12
|
+
warn,
|
|
12
13
|
} from "vue";
|
|
13
14
|
import * as _ from "lodash-es";
|
|
14
15
|
import { useRouter, RouteLocationNormalized } from "vue-router";
|
|
@@ -55,6 +56,7 @@ interface IUseBladeNavigation {
|
|
|
55
56
|
resolveBlades: (to: RouteLocationNormalized) => string;
|
|
56
57
|
resolveLastBlade: (pages: BladePageComponent[]) => void;
|
|
57
58
|
resolveUnknownRoutes: (to: RouteLocationNormalized) => string;
|
|
59
|
+
resolveBladeByName: (name: string) => BladeConstructor;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -118,6 +120,9 @@ export function useBladeNavigation(): IUseBladeNavigation {
|
|
|
118
120
|
{ blade, param, options, onOpen, onClose }: IBladeEvent<Blade>,
|
|
119
121
|
isWorkspace = false
|
|
120
122
|
) {
|
|
123
|
+
if (!blade) {
|
|
124
|
+
throw new Error("You should pass blade component as openBlade argument");
|
|
125
|
+
}
|
|
121
126
|
if (isWorkspace) {
|
|
122
127
|
openWorkspace({ blade, param, options });
|
|
123
128
|
return;
|
|
@@ -205,6 +210,7 @@ export function useBladeNavigation(): IUseBladeNavigation {
|
|
|
205
210
|
if (blade && checkPermission(blade.permissions)) {
|
|
206
211
|
navigationInstance.blades.value.push({
|
|
207
212
|
blade: markRaw(blade),
|
|
213
|
+
...resolveDynamicProps(blade),
|
|
208
214
|
options,
|
|
209
215
|
param,
|
|
210
216
|
onOpen,
|
|
@@ -222,6 +228,21 @@ export function useBladeNavigation(): IUseBladeNavigation {
|
|
|
222
228
|
}
|
|
223
229
|
}
|
|
224
230
|
|
|
231
|
+
function resolveDynamicProps(blade: BladeConstructor) {
|
|
232
|
+
const routerRoutes = router.getRoutes();
|
|
233
|
+
|
|
234
|
+
const selectedRoute = routerRoutes.find((r) => r.path === blade.url);
|
|
235
|
+
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
237
|
+
const selectedRouteProps = selectedRoute?.props as Record<string, () => any>;
|
|
238
|
+
|
|
239
|
+
if (selectedRouteProps && "default" in selectedRouteProps && typeof selectedRouteProps.default === "function") {
|
|
240
|
+
return selectedRouteProps.default();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return {};
|
|
244
|
+
}
|
|
245
|
+
|
|
225
246
|
async function onParentCall(index: number, args: IParentCallArgs) {
|
|
226
247
|
console.debug(`vc-app#onParentCall(${index}, { method: ${args.method} }) called.`);
|
|
227
248
|
|
|
@@ -296,18 +317,33 @@ export function useBladeNavigation(): IUseBladeNavigation {
|
|
|
296
317
|
}
|
|
297
318
|
}
|
|
298
319
|
|
|
320
|
+
function resolveBladeByName(name: string) {
|
|
321
|
+
if (!instance) {
|
|
322
|
+
warn("resolveComponentByName can only be used in setup().");
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (!name) {
|
|
326
|
+
throw new Error("blade name is required");
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
console.log(instance.appContext.components);
|
|
330
|
+
const components = instance && instance.appContext.components;
|
|
331
|
+
return components[name] as BladeConstructor;
|
|
332
|
+
}
|
|
333
|
+
|
|
299
334
|
return {
|
|
300
|
-
blades: computed(() => navigationInstance
|
|
335
|
+
blades: computed(() => navigationInstance?.blades.value),
|
|
301
336
|
workspaceOptions: computed(() => workspaceOptions.value),
|
|
302
337
|
workspaceParam: computed(() => workspaceParam.value),
|
|
303
338
|
lastBladeData: computed(() => lastBladeData.value),
|
|
304
339
|
activeBlade,
|
|
305
|
-
bladesRefs: navigationInstance
|
|
340
|
+
bladesRefs: navigationInstance?.bladesRefs,
|
|
306
341
|
openBlade,
|
|
307
342
|
closeBlade,
|
|
308
343
|
onParentCall,
|
|
309
344
|
resolveBlades,
|
|
310
345
|
resolveUnknownRoutes,
|
|
311
346
|
resolveLastBlade,
|
|
347
|
+
resolveBladeByName,
|
|
312
348
|
};
|
|
313
349
|
}
|
|
@@ -25,9 +25,6 @@ export type BladePageComponent = BladeConstructor;
|
|
|
25
25
|
export type CoreBladeAdditionalSettings = {
|
|
26
26
|
url?: `/${string}`;
|
|
27
27
|
permissions?: string | string[];
|
|
28
|
-
scope?: {
|
|
29
|
-
notificationClick?: (notification: PushNotification | Record<string, any>) => IBladeEvent;
|
|
30
|
-
};
|
|
31
28
|
};
|
|
32
29
|
|
|
33
30
|
export type CoreBladeNavigationData = {
|
|
@@ -36,7 +33,6 @@ export type CoreBladeNavigationData = {
|
|
|
36
33
|
|
|
37
34
|
export interface CoreBladeExposed {
|
|
38
35
|
title?: string;
|
|
39
|
-
notificationClick?: (notification: PushNotification) => IBladeEvent;
|
|
40
36
|
onBeforeClose?: () => Promise<boolean>;
|
|
41
37
|
reloadParent?: () => void;
|
|
42
38
|
reload?: () => void;
|