1 | import { install } from './install'
|
2 |
|
3 |
|
4 | import {
|
5 | VuetifyService,
|
6 | VuetifyServiceContract,
|
7 | } from 'vuetify/types/services'
|
8 | import { VuetifyPreset } from 'vuetify/types/presets'
|
9 | import Vue from 'vue'
|
10 |
|
11 |
|
12 | import * as services from './services'
|
13 |
|
14 |
|
15 | import './styles/main.sass'
|
16 |
|
17 | export default class Vuetify {
|
18 | static install = install
|
19 |
|
20 | static installed = false
|
21 |
|
22 | static version = __VUETIFY_VERSION__
|
23 |
|
24 | framework: Record<string, VuetifyServiceContract> = {}
|
25 |
|
26 | installed: string[] = []
|
27 |
|
28 | preset: Partial<VuetifyPreset> = {}
|
29 |
|
30 | constructor (preset: Partial<VuetifyPreset> = {}) {
|
31 | this.preset = preset
|
32 |
|
33 | this.use(services.Application)
|
34 | this.use(services.Breakpoint)
|
35 | this.use(services.Goto)
|
36 | this.use(services.Icons)
|
37 | this.use(services.Lang)
|
38 | this.use(services.Theme)
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | init (root: Vue, ssrContext?: object) {
|
45 | this.installed.forEach(property => {
|
46 | const service = this.framework[property]
|
47 | service.framework = this.framework
|
48 |
|
49 | service.init(root, ssrContext)
|
50 | })
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | this.framework.rtl = Boolean(this.preset.rtl) as any
|
56 | }
|
57 |
|
58 |
|
59 | use (Service: VuetifyService) {
|
60 | const property = Service.property
|
61 |
|
62 | if (this.installed.includes(property)) return
|
63 |
|
64 | this.framework[property] = new Service(this.preset[property])
|
65 | this.installed.push(property)
|
66 | }
|
67 | }
|