File tree 4 files changed +41
-26
lines changed
packages/@vuepress/core/lib/app
4 files changed +41
-26
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { siteData } from '@internal/siteData'
7
7
import appEnhancers from '@internal/app-enhancers'
8
8
import globalUIComponents from '@internal/global-ui'
9
9
import ClientComputedMixin from '@transform/ClientComputedMixin'
10
- import Store from './Store'
10
+ import Store from './plugins/ Store'
11
11
12
12
// built-in components
13
13
import Content from './components/Content'
@@ -30,9 +30,8 @@ if (module.hot) {
30
30
31
31
Vue . config . productionTip = false
32
32
33
- Vue . $store = new Store ( )
34
-
35
33
Vue . use ( Router )
34
+ Vue . use ( Store , '$vuepress' )
36
35
// mixin for exposing $site and $page
37
36
Vue . mixin ( dataMixin ( ClientComputedMixin , siteData ) )
38
37
// component for rendering markdown content and setting title etc.
@@ -62,7 +61,7 @@ export function createApp (isServer) {
62
61
if ( saved ) {
63
62
return saved
64
63
} else if ( to . hash ) {
65
- if ( Vue . $store . get ( 'disableScrollBehavior' ) ) {
64
+ if ( Vue . $vuepress . $ get( 'disableScrollBehavior' ) ) {
66
65
return false
67
66
}
68
67
return {
Original file line number Diff line number Diff line change @@ -4,16 +4,16 @@ import Vue from 'vue'
4
4
5
5
export default function dataMixin ( I18n , siteData ) {
6
6
prepare ( siteData )
7
- Vue . $store . set ( 'siteData' , siteData )
7
+ Vue . $vuepress . $ set( 'siteData' , siteData )
8
8
9
9
if ( module . hot ) {
10
10
module . hot . accept ( VUEPRESS_TEMP_PATH + '/internal/siteData.js' , ( ) => {
11
11
prepare ( siteData )
12
- Vue . $store . set ( 'siteData' , siteData )
12
+ Vue . $vuepress . $ set( 'siteData' , siteData )
13
13
} )
14
14
}
15
15
16
- const I18nConstructor = I18n ( Vue . $store . get ( 'siteData' ) )
16
+ const I18nConstructor = I18n ( Vue . $vuepress . $ get( 'siteData' ) )
17
17
const i18n = new I18nConstructor ( )
18
18
const descriptors = Object . getOwnPropertyDescriptors ( Object . getPrototypeOf ( i18n ) )
19
19
const computed = { }
Original file line number Diff line number Diff line change
1
+ import Vue from 'vue'
2
+
3
+ class Store {
4
+ constructor ( ) {
5
+ this . store = new Vue ( {
6
+ data : {
7
+ state : { }
8
+ }
9
+ } )
10
+ }
11
+
12
+ $get ( key ) {
13
+ return this . store . state [ key ]
14
+ }
15
+
16
+ $set ( key , value ) {
17
+ Vue . set ( this . store . state , key , value )
18
+ }
19
+
20
+ $emit ( ...args ) {
21
+ this . store . $emit ( ...args )
22
+ }
23
+
24
+ $on ( ...args ) {
25
+ this . store . $on ( ...args )
26
+ }
27
+ }
28
+
29
+ export default {
30
+ install ( Vue , options = '$store' ) {
31
+ const store = new Store ( )
32
+ Vue [ options ] = store
33
+ Vue . prototype [ options ] = store
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments