File tree Expand file tree Collapse file tree 8 files changed +96
-60
lines changed Expand file tree Collapse file tree 8 files changed +96
-60
lines changed Original file line number Diff line number Diff line change 140
140
"completed" : false ,
141
141
"body" : " asdfasdf" ,
142
142
"id" : 31
143
+ },
144
+ {
145
+ "subject" : " asdf" ,
146
+ "completed" : false ,
147
+ "body" : " asdf" ,
148
+ "id" : 32
149
+ },
150
+ {
151
+ "subject" : " asdf" ,
152
+ "completed" : false ,
153
+ "body" : " asdf" ,
154
+ "id" : 33
155
+ },
156
+ {
157
+ "subject" : " adsf" ,
158
+ "completed" : false ,
159
+ "body" : " asdf" ,
160
+ "id" : 34
161
+ },
162
+ {
163
+ "subject" : " adsf" ,
164
+ "completed" : false ,
165
+ "body" : " asdf" ,
166
+ "id" : 35
143
167
}
144
168
]
145
169
}
Original file line number Diff line number Diff line change 15
15
<div class =" container" >
16
16
<router-view />
17
17
</div >
18
- <Toast
19
- v-if =" showToast"
20
- :message =" toastMessage"
21
- :type =" toastAlertType"
22
- />
18
+ <transition name =" slide" >
19
+ <Toast
20
+ v-if =" showToast"
21
+ :message =" toastMessage"
22
+ :type =" toastAlertType"
23
+ />
24
+ </transition >
23
25
</template >
24
26
25
27
<script >
@@ -50,5 +52,21 @@ export default {
50
52
}
51
53
</script >
52
54
53
- <style >
55
+ <style scoped>
56
+ .slide-enter-active ,
57
+ .slide-leave-active {
58
+ transition : all 0.5s ease ;
59
+ }
60
+
61
+ .slide-enter-from ,
62
+ .slide-leave-to {
63
+ opacity : 0 ;
64
+ transform : translateY (-30px );
65
+ }
66
+
67
+ .slide-enter-to ,
68
+ .slide-leave-from {
69
+ opacity : 1 ;
70
+ transform : translateY (0px );
71
+ }
54
72
</style >
Original file line number Diff line number Diff line change 51
51
Cancel
52
52
</button >
53
53
</form >
54
- <transition name =" fade" >
55
- <Toast
56
- v-if =" showToast"
57
- :message =" toastMessage"
58
- :type =" toastAlertType"
59
- />
60
- </transition >
61
54
</template >
62
55
63
56
<script >
64
57
import { useRoute , useRouter } from ' vue-router' ;
65
58
import axios from ' @/axios' ;
66
59
import { ref , computed } from ' vue' ;
67
60
import _ from ' lodash' ;
68
- import Toast from ' @/components/Toast.vue' ;
69
61
import { useToast } from ' @/composables/toast' ;
70
62
import Input from ' @/components/Input.vue' ;
71
63
72
64
export default {
73
65
components: {
74
- Toast,
75
66
Input
76
67
},
77
68
props: {
Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ import { useStore } from 'vuex';
3
3
4
4
export const useToast = ( ) => {
5
5
const store = useStore ( ) ;
6
- const toastMessage = computed ( ( ) => store . getters . toastMessageWithSmile ) ;
7
- const toastAlertType = computed ( ( ) => store . state . toastAlertType ) ;
8
- const showToast = computed ( ( ) => store . state . showToast ) ;
6
+ const toastMessage = computed ( ( ) => store . getters [ 'toast/ toastMessageWithSmile' ] ) ;
7
+ const toastAlertType = computed ( ( ) => store . state . toast . toastAlertType ) ;
8
+ const showToast = computed ( ( ) => store . state . toast . showToast ) ;
9
9
10
10
const triggerToast = ( message , type = 'success' ) => {
11
- store . dispatch ( 'triggerToast' , message , type ) ;
11
+ store . dispatch ( 'toast/ triggerToast' , message , type ) ;
12
12
}
13
13
14
14
return {
Original file line number Diff line number Diff line change 49
49
</ul >
50
50
</nav >
51
51
</div >
52
- <Toast
53
- v-if =" showToast"
54
- :message =" toastMessage"
55
- :type =" toastAlertType"
56
- />
57
52
</template >
58
53
59
54
<script >
60
55
import { ref , computed , watch } from ' vue' ;
61
56
import TodoList from ' @/components/TodoList.vue' ;
62
57
import axios from ' @/axios' ;
63
- import Toast from ' @/components/Toast.vue' ;
64
58
import { useToast } from ' @/composables/toast' ;
65
59
import {useRouter } from ' vue-router' ;
66
60
67
61
export default {
68
62
components: {
69
63
TodoList,
70
- Toast,
71
64
},
72
65
setup () {
73
66
const router = useRouter ();
Original file line number Diff line number Diff line change 1
1
import { createStore } from 'vuex' ;
2
+ import modules from './modules' ;
2
3
3
4
export default createStore ( {
4
- state : {
5
- toastMessage : '' ,
6
- toastAlertType : '' ,
7
- showToast : false ,
8
- } ,
9
- mutations : {
10
- UPDATE_TOAST_MESSAGE ( state , payload ) {
11
- state . toastMessage = payload ;
12
- } ,
13
- UPDATE_TOAST_ALERT_TYPE ( state , payload ) {
14
- state . toastAlertType = payload ;
15
- } ,
16
- UPDATE_TOAST_STATUS ( state , payload ) {
17
- state . showToast = payload ;
18
- }
19
- } ,
20
- actions : {
21
- triggerToast ( { commit } , message , type = 'success' ) {
22
- commit ( 'UPDATE_TOAST_MESSAGE' , message )
23
- commit ( 'UPDATE_TOAST_ALERT_TYPE' , type )
24
- commit ( 'UPDATE_TOAST_STATUS' , true )
25
-
26
- setTimeout ( ( ) => {
27
- commit ( 'UPDATE_TOAST_MESSAGE' , '' )
28
- commit ( 'UPDATE_TOAST_ALERT_TYPE' , '' )
29
- commit ( 'UPDATE_TOAST_STATUS' , false )
30
- } , 5000 )
31
- }
32
- } ,
33
- getters : {
34
- toastMessageWithSmile ( state ) {
35
- return state . toastMessage + '^_^' ;
36
- }
37
- }
5
+ modules
38
6
} ) ;
Original file line number Diff line number Diff line change
1
+ import toast from './toast' ;
2
+
3
+ export default {
4
+ toast
5
+ }
Original file line number Diff line number Diff line change
1
+ export default {
2
+ namespaced : true ,
3
+ state : {
4
+ toastMessage : '' ,
5
+ toastAlertType : '' ,
6
+ showToast : false ,
7
+ } ,
8
+ mutations : {
9
+ UPDATE_TOAST_MESSAGE ( state , payload ) {
10
+ state . toastMessage = payload ;
11
+ } ,
12
+ UPDATE_TOAST_ALERT_TYPE ( state , payload ) {
13
+ state . toastAlertType = payload ;
14
+ } ,
15
+ UPDATE_TOAST_STATUS ( state , payload ) {
16
+ state . showToast = payload ;
17
+ }
18
+ } ,
19
+ actions : {
20
+ triggerToast ( { commit } , message , type = 'success' ) {
21
+ commit ( 'UPDATE_TOAST_MESSAGE' , message )
22
+ commit ( 'UPDATE_TOAST_ALERT_TYPE' , type )
23
+ commit ( 'UPDATE_TOAST_STATUS' , true )
24
+
25
+ setTimeout ( ( ) => {
26
+ commit ( 'UPDATE_TOAST_MESSAGE' , '' )
27
+ commit ( 'UPDATE_TOAST_ALERT_TYPE' , '' )
28
+ commit ( 'UPDATE_TOAST_STATUS' , false )
29
+ } , 5000 )
30
+ }
31
+ } ,
32
+ getters : {
33
+ toastMessageWithSmile ( state ) {
34
+ return state . toastMessage + '^_^' ;
35
+ }
36
+ } ,
37
+ }
You can’t perform that action at this time.
0 commit comments