Skip to content

Commit ef53a3c

Browse files
committed
feat: typescript definitions from @vue-async/module-loader
affects: @vue-async/module-loader-typing ts 类型定义, 使用在子模块中时
1 parent cdcc66b commit ef53a3c

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# @vue-async/module-loader-type
2+
3+
### TypeScript definitions for @vue-async/module-loader but using in the child modules
4+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component as VueComponent, AsyncComponent } from 'vue';
2+
import { Framework, ModuleLoaderOptions } from './module';
3+
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+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component as VueComponent, AsyncComponent } from 'vue';
2+
import { RouteConfig } from 'vue-router';
3+
4+
export type ModuleLoaderOptions = Omit<Record<string, any>, 'layouts'>;
5+
6+
export interface Framework {
7+
layouts: Record<string, VueComponent | AsyncComponent>;
8+
addRouters: (routes: RouteConfig[]) => void; // 可以被重写
9+
addLayouts: (name: string, layout: VueComponent) => void; // 可以被重写
10+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@vue-async/module-loader-typing",
3+
"version": "0.0.1",
4+
"description": "TypeScript definitions for @vue-async/module-loader but using in the child modules",
5+
"main": "",
6+
"typings": "index.d.ts",
7+
"keywords": [
8+
"vue",
9+
"vue-async",
10+
"module-loader",
11+
"async-module",
12+
"async-loader",
13+
"typescript",
14+
"types"
15+
],
16+
"scripts": {},
17+
"author": "Hubert <yi.xiang@live.cn>",
18+
"license": "MIT",
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/aceHubert/vue-async.git",
22+
"directory": "packages/module-loader-type"
23+
},
24+
"bugs": {
25+
"url": "https://github.com/aceHubert/vus-async/issues"
26+
},
27+
"dependencies": {},
28+
"devDependencies": {
29+
"vue-router": "^3.1.6",
30+
"vue": "^2.6.0"
31+
}
32+
}

0 commit comments

Comments
 (0)