-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
62 lines (56 loc) · 1.38 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import * as VueRouter from 'vue-router'
import * as Vue from 'vue'
import {store} from './src/store/opt'
import {vuexInit} from './src/store/helper'
import {component} from './src/core'
import {Comp} from './src/core/interface'
import {BaseStore} from './src/store/interface'
import {p} from './src/core'
export {html} from './src/template'
Vue.use(VueRouter)
Vue.mixin({beforeCreate: vuexInit})
export interface InitDef {
component?: Comp<{},{},{},{},{},{},{},{}>
store?: BaseStore
router?: VueRouter
el?: string
}
const defaultComponent = component()
.render(h => h.div`#app`.routerView.routerView().div())
.done()
function start(initDef: InitDef = {}) {
const {
component: comp = defaultComponent,
store, router,
el = '#app'
} = initDef
if (!comp['el']) {
comp['el'] = el
}
if (store) {
comp['store'] = store
}
if (router) {
comp['router'] = router
}
return new Vue(comp)
}
export default {
router(options?: VueRouter.RouterOptions) {
return new VueRouter(options)
},
store,
component,
start,
p
}
// workaround
import * as CoreInterface from './src/core'
import {Extends, HotModule, PropDef} from './src/core/interface'
import {RouterOptions} from 'vue-router/types/router'
import * as StoreInterface from './src/store/interface'
export {
Extends, HotModule,
CoreInterface, StoreInterface, RouterOptions,
p, Vue, PropDef
}