Skip to content

Commit 867b2ca

Browse files
committed
perf: type definitions change
affects: @vue-async/module-loader-typing
1 parent 6b8bcb1 commit 867b2ca

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# @vue-async/module-loader-type
22

3-
### TypeScript definitions for @vue-async/module-loader but using in the child modules
3+
### TypeScript definitions for @vue-async/module-loader but using in the child module
44

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
import { Component as VueComponent, AsyncComponent } from 'vue';
2-
import { Framework, ModuleLoaderOptions } from './module';
1+
import './vue';
32

4-
declare module 'vue/types/vue' {
5-
interface Vue {
6-
$moduleLoadManager: Framework & ModuleLoaderOptions;
7-
$dynamicComponent: {
8-
add: (
9-
component: VueComponent | AsyncComponent | ({ component: VueComponent | AsyncComponent } & Record<string, any>),
10-
position?: string,
11-
) => void;
12-
remove: (name: string, position?: string) => void;
13-
};
14-
$eventBus: {
15-
emit: (eventName: string, playload: any) => void;
16-
on: (eventName: string, handler: (playload: any) => void) => void;
17-
off: (eventName: string, handler: (playload: any) => void) => void;
18-
clear: () => void;
19-
getEvents: () => Record<string, any>;
20-
};
21-
}
22-
}
3+
export { Framework, DynamicComponent } from './module';
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { Component as VueComponent, AsyncComponent } from 'vue';
22
import { RouteConfig } from 'vue-router';
33

4-
export type ModuleLoaderOptions = Omit<Record<string, any>, 'layouts'>;
4+
export type DynamicComponent =
5+
| VueComponent
6+
| AsyncComponent
7+
| ({ component: VueComponent | AsyncComponent; name?: string } & Record<string, any>);
58

69
export interface Framework {
7-
layouts: Record<string, VueComponent | AsyncComponent>;
10+
readonly layouts: Record<string, VueComponent | AsyncComponent>;
811
addRouters: (routes: RouteConfig[]) => void; // 可以被重写
912
addLayouts: (name: string, layout: VueComponent) => void; // 可以被重写
1013
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Framework, DynamicComponent } from './module';
2+
3+
declare module 'vue/types/vue' {
4+
interface Vue {
5+
// @ts-ignore
6+
$moduleLoadManager: Framework & Record<string, any>;
7+
$dynamicComponent: {
8+
add: (component: DynamicComponent, position?: string) => void;
9+
remove: (name: string, position?: string) => void;
10+
};
11+
$eventBus: {
12+
emit: (eventName: string, playload: any) => void;
13+
on: (eventName: string, handler: (playload: any) => void) => void;
14+
off: (eventName: string, handler: (playload: any) => void) => void;
15+
clear: () => void;
16+
getEvents: () => Record<string, any>;
17+
};
18+
}
19+
}

0 commit comments

Comments
 (0)