Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit 93ae02b

Browse files
committed
feat(PageFooter): 抽离 PageFooter 组件
1 parent da97f31 commit 93ae02b

4 files changed

Lines changed: 45 additions & 23 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template functional>
2+
<p class="author__info">Copyright &copy; {{new Date().getFullYear()}} 版权所有 All rights reserved.</p>
3+
</template>
4+
5+
<script>
6+
export default {
7+
}
8+
</script>
9+
10+
<style lang='scss' scoped>
11+
12+
$gap: 60px;
13+
14+
.author__info {
15+
margin: 0;
16+
text-align: center;
17+
line-height: $gap;
18+
font-size: 14px;
19+
color: #999999;
20+
}
21+
</style>

src/layout/Material/index.vue

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</el-main>
1414

1515
<el-footer class="layout__material__footer">
16-
Copyright &copy; {{currentYear}}
16+
<page-footer/>
1717
</el-footer>
1818
</el-container>
1919
</el-container>
@@ -22,17 +22,13 @@
2222
<script>
2323
import MaterialHeader from './Header'
2424
import MaterialAside from './Aside'
25+
import PageFooter from 'COMPONENTS/PageFooter'
2526
2627
export default {
27-
computed: {
28-
currentYear () {
29-
return new Date().getFullYear()
30-
}
31-
},
32-
3328
components: {
3429
MaterialHeader,
35-
MaterialAside
30+
MaterialAside,
31+
PageFooter
3632
}
3733
}
3834
</script>

src/pages/Login/index.vue

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@
4040
</el-form-item>
4141
</el-form>
4242
<el-footer class="login__footer">
43-
<p class="author__info">Copyright &copy; {{currentYear}}</p>
43+
<page-footer/>
4444
</el-footer>
4545
</section>
4646
</template>
4747

4848
<script>
49+
import PageFooter from 'COMPONENTS/PageFooter'
4950
import rules from './rules'
5051
5152
export default {
@@ -60,24 +61,28 @@ export default {
6061
}
6162
},
6263
63-
computed: {
64-
currentYear () {
65-
return new Date().getFullYear()
66-
}
67-
},
68-
6964
methods: {
7065
onSubmit () {
71-
this.toggleLoading(true)
72-
this.$refs.login.validate(isValid => {
73-
if (!isValid) return
66+
this.switchLoading(true)
67+
this.$refs.login.validate()
68+
.then(valid => ({
69+
...this.userInfo,
70+
vm: this
71+
}))
7472
// This action has included routes replacement
75-
this.$store.dispatch('login/userLogin', { ...this.userInfo, vm: this })
76-
})
73+
// dispatch() will return a Promise instance
74+
.then(payload => this.$store.dispatch('login/userLogin', payload))
75+
.then(() => this.$router.replace('/'))
76+
.catch(e => console.error('[Login form]: validate failed !'))
77+
.finally(() => this.switchLoading(false))
7778
},
78-
toggleLoading (state) {
79+
switchLoading (state) {
7980
this.isLoading = state
8081
}
82+
},
83+
84+
components: {
85+
PageFooter
8186
}
8287
}
8388
</script>
@@ -88,9 +93,9 @@ export default {
8893
}
8994
9095
.login {
91-
background-image: url('~ASSETS/animation.gif');
96+
background-image: url('~./img/animation.gif');
9297
background-repeat: no-repeat;
93-
background-position: center bottom;
98+
background-position: center center;
9499
95100
&__form {
96101
display: flex;

0 commit comments

Comments
 (0)