Skip to content

Commit 8c87409

Browse files
committed
Merge branch 'develop'
2 parents 7b69b35 + 862b18e commit 8c87409

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"author": "mqhe2007 <122274389@qq.com>",
66
"homepage": "https://mengqinghe.com",
77
"main": "dist/index.js",
8+
"typings": "types/index.d.ts",
89
"files": [
9-
"dist"
10+
"dist",
11+
"types"
1012
],
1113
"license": "MIT",
1214
"keywords": [

types/dynamic-component.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Vue from 'vue'
2+
3+
export declare class DynamicComponent {
4+
/**
5+
* 创建动态组件
6+
* @param component 组件
7+
* @param position 插槽,默认GLOBAL
8+
*/
9+
create(component: Vue, position: string): void;
10+
11+
/**
12+
* 删除动态组件方法
13+
* @param name 组件名称
14+
* @param position 插槽,默认GLOBAL
15+
*/
16+
destroy(name: string, position: string): void;
17+
}

types/event-bus.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export declare class EventBus {
2+
/**
3+
* 触发事件
4+
* @param eventName 事件名称
5+
* @param payload 事件载荷
6+
*/
7+
emit(eventName: string, payload: any): void;
8+
9+
/**
10+
* 监听事件
11+
* @param eventName 事件名称
12+
* @param handler 事件处理器
13+
*/
14+
on(eventName: string, handler: Function): void;
15+
16+
17+
/**
18+
* 取消监听事件
19+
* @param eventName 事件名称
20+
* @param handler 事件处理器
21+
*/
22+
off(eventName: string, handler: Function): void;
23+
24+
/**
25+
* 清理事件总线
26+
*/
27+
clear(): void;
28+
29+
/**
30+
* 获取事件总线详情
31+
*/
32+
getEvents(): object;
33+
}

types/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import vueModuleLoader from './vue-module-loader';
2+
3+
export default vueModuleLoader;

types/vue-module-loader.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {PluginFunction} from 'vue';
2+
import {DynamicComponent} from './dynamic-component'
3+
import {EventBus} from './event-bus'
4+
5+
interface VueModuleLoader extends PluginFunction<any> {
6+
}
7+
8+
declare const vueModuleLoader: VueModuleLoader;
9+
export default vueModuleLoader;
10+
11+
declare module 'vue/types/vue' {
12+
interface Vue {
13+
$eventBus: EventBus;
14+
$dynamicComponent: DynamicComponent;
15+
$moduleLoader: (module: Function | object) => Promise<any>;
16+
}
17+
}

0 commit comments

Comments
 (0)