文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit ac1be441 by Wang Yuhang

区分用户身份

parent 6fb6d90a
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
"element-ui": "^2.13.1", "element-ui": "^2.13.1",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-router": "^3.0.1" "vue-router": "^3.0.1",
"vuex": "^3.4.0"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",
......
...@@ -61,6 +61,11 @@ export default { ...@@ -61,6 +61,11 @@ export default {
}, 550) }, 550)
}, },
login () { login () {
// 将用户信息保存在localStorage里, 为演示效果,暂时不输密码进入视为标注者,输密码视为发布者
var userInfo = {
type: this.password ? 1 : 0
}
this.$store.commit('setUserInfo', userInfo)
this.$router.push('/index').catch(data => {}) this.$router.push('/index').catch(data => {})
}, },
register () { register () {
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
router> router>
<el-menu-item index="/taskhall">任务大厅</el-menu-item> <el-menu-item index="/taskhall">任务大厅</el-menu-item>
<el-menu-item index="/ongoing">我的任务</el-menu-item> <el-menu-item index="/ongoing">我的任务</el-menu-item>
<el-menu-item index="/releasetask">发布任务</el-menu-item> <el-menu-item v-if="userType" index="/releasetask">发布任务</el-menu-item>
<el-menu-item index="/completed">已完成任务</el-menu-item> <el-menu-item v-if="userType" index="/completed">已完成任务</el-menu-item>
<el-menu-item index="/check">待审核任务</el-menu-item> <el-menu-item v-if="userType" index="/check">待审核任务</el-menu-item>
<el-menu-item index="/publishtask">我的发布</el-menu-item> <el-menu-item v-if="userType" index="/publishtask">我的发布</el-menu-item>
<el-menu-item index="/userhome">个人中心</el-menu-item> <el-menu-item index="/userhome">个人中心</el-menu-item>
<el-menu-item class="logout-btn" index="/">退出登录</el-menu-item> <el-menu-item class="logout-btn" index="/">退出登录</el-menu-item>
</el-menu> </el-menu>
...@@ -28,6 +28,11 @@ export default { ...@@ -28,6 +28,11 @@ export default {
activeIndex: '/taskhall' activeIndex: '/taskhall'
} }
}, },
computed: {
userType () {
return this.$store.state.userInfo.type
}
},
watch: { watch: {
// 对路由变化作出响应... // 对路由变化作出响应...
'$route' (to, from) { '$route' (to, from) {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import router from './router' import router from './router'
import store from './store'
import ElementUI from 'element-ui' import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css' import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios' import axios from 'axios'
...@@ -20,6 +21,7 @@ Vue.use(ElementUI) ...@@ -20,6 +21,7 @@ Vue.use(ElementUI)
new Vue({ new Vue({
el: '#app', el: '#app',
router, router,
store,
components: { App }, components: { App },
template: '<App/>' template: '<App/>'
}) })
/* eslint-disable no-undef */
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
userInfo: null
},
mutations: {
setUserInfo (state, userInfo) {
state.userInfo = userInfo
}
},
actions: {
},
modules: {
}
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment