Skip to content

Commit

Permalink
add 登出
Browse files Browse the repository at this point in the history
  • Loading branch information
wszgxa committed Aug 1, 2016
1 parent 185c9e3 commit 477abc3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/assets/styl/common/sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
color color-font-white
font-size 30px
.logout
padding-top 2px
padding-top 12px
color color-font-white - 60
a
font-size 28px
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
},
methods: {
sure () {
if (this.config.callback) this.config.callbak()
console.log(this.config.callback)
if (this.config.callback) this.config.callback()
this.close()
},
close () {
Expand Down
30 changes: 26 additions & 4 deletions src/components/common/sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@
</div>
</nav>
</div>
<dialog :config.sync="config"></dialog>
</template>

<script>
import { setMenu } from '../../vuex/actions/doc_actions'
import { setDetail } from '../../vuex/actions/user_actions'
import { setMenu, setTip } from '../../vuex/actions/doc_actions'
import { setDetail, deleteUserInfo } from '../../vuex/actions/user_actions'
import dialog from './dialog'
export default {
vuex: {
getters: {
Expand All @@ -77,13 +79,19 @@
},
actions: {
setMenu,
setDetail
setDetail,
deleteUserInfo,
setTip
}
},
components: {
dialog
},
data () {
return {
navState: 'nav-wrap',
userImg: '/static/img/user_avtar_default.png'
userImg: '/static/img/user_avtar_default.png',
config: {}
}
},
ready () {
Expand All @@ -104,6 +112,20 @@
this.navState = 'nav-wrap ' + this.name
},
logout () {
this.config = {
visible: true,
text: '确定要注销吗?',
sureText: '确定',
cancelText: '取消',
callback: () => {
let a = this.deleteUserInfo()
if (a) {
this.setTip({
text: '注销成功'
})
}
}
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/vuex/actions/user_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ export const setDetail = ({dispatch, state}) => {
console.log(err)
})
}
export const deleteUserInfo = ({dispatch}) => {
dispatch(types.DELETE_USER_INFO)
localStorage.removeItem('cnodeBaseInfo')
localStorage.removeItem('cnodeDetailInfo')
return true
}
8 changes: 7 additions & 1 deletion src/vuex/modules/user_info.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// content
import {
SET_BASEINFO,
SET_DETAIL
SET_DETAIL,
DELETE_USER_INFO
} from '../mutation_types'
const state = {
// 保存第一页数据
Expand Down Expand Up @@ -34,6 +35,11 @@ const mutations = {
} catch (err) {
console.log(err)
}
},
[DELETE_USER_INFO] (state) {
for (let key in state) {
state[key] = ''
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/vuex/mutation_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export const SET_TIP = 'SET_TIP'
// user info
export const SET_BASEINFO = 'SET_BASEINFO'
export const SET_DETAIL = 'SET_DETAIL'
export const DELETE_USER_INFO = 'DELETE_USER_INFO'

0 comments on commit 477abc3

Please sign in to comment.