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

Commit 31aa78ae by Wang Yuhang

图层导出功能,请求拦截,未登录导到登录页面

parent 78c64473
......@@ -96,8 +96,10 @@ export default {
var piece = this.piece
if (piece.type === '文本') {
download('/files/downloadZip', relationId)
} else {
} else if (piece.type === '图片') {
download('/image/export/zip', relationId)
} else if (piece.type === '图层') {
download('/layer/export', relationId)
}
}
}
......
......@@ -60,8 +60,10 @@ export default {
var relationId = file.relation_id
if (piece.type === '文本') {
download('/files/downloadZip', relationId)
} else {
} else if (piece.type === '图片') {
download('/image/export/zip', relationId)
} else if (piece.type === '图层') {
download('/layer/export', relationId)
}
}
}
......
......@@ -114,7 +114,6 @@ export default {
password: this.password
}
}).then(res => {
console.log(res)
if (res.code === 1) {
self.$store.commit('setUserInfo', res.data)
self.$router.push({path: '/taskHall'})
......
......@@ -7,7 +7,8 @@
background-color="#409EFF"
text-color="#fff"
active-text-color="#fff"
router>
router
@select="handleSelect">
<el-menu-item index="/taskhall">任务大厅</el-menu-item>
<el-menu-item index="/ongoing">我的任务</el-menu-item>
<el-menu-item v-if="userType" index="/releasetask">发布任务</el-menu-item>
......@@ -30,7 +31,7 @@ export default {
},
computed: {
userType () {
return this.$store.state.userInfo.identity === 1
return this.$store.state.userInfo && this.$store.state.userInfo.identity === 1
}
},
watch: {
......@@ -42,6 +43,11 @@ export default {
}
},
methods: {
handleSelect (index, indexPath) {
if (index === '/') {
this.$store.commit('setUserInfo', null)
}
}
}
}
</script>
......
......@@ -50,7 +50,6 @@ export default {
...self.condition
}
}).then(res => {
console.log(res)
self.tasks = res.data.tasks
self.pageNum = res.data.pageNum
self.pageChange()
......
......@@ -66,8 +66,10 @@ export default {
var relationId = file.relation_id
if (piece.type === '文本') {
download('/files/downloadZip', relationId)
} else {
} else if (piece.type === '图片') {
download('/image/export/zip', relationId)
} else if (piece.type === '图层') {
download('/layer/export', relationId)
}
}
}
......
......@@ -55,9 +55,6 @@ export default {
}
},
methods: {
handleClick (tab, event) {
console.log(tab, event)
},
enterTask (task) {
this.$router.push({
name: 'task',
......
......@@ -37,6 +37,7 @@ export default {
}
},
beforeMount () {
if (!this.userInfo) this.$router.replace('/')
var self = this
// 请求用户信息
this.axios({
......
......@@ -16,39 +16,6 @@ Vue.prototype.$math = math
axios.defaults.baseURL = 'http://localhost:9100/api'
axios.defaults.timeout = 8000
// 添加响应拦截器
axios.interceptors.response.use(function (response) {
let res = response.data
// 未登录
if (res.code === 10) {
window.location.href = '/#/login'
} else {
if (response.config.url === '/file/getFiles') {
res.id = response.config.params.pieceId
}
return res
}
}, function (error) {
// 对响应错误做点什么
return Promise.reject(error)
})
// 添加请求拦截器,每次请求设置都请求cookie信息
// axios.interceptors.request.use(function(config){
// let token = localStorage.getItem("vuex")//获取vuex的全局变量
// // console.log(localStorage)
// // console.log(token)
// //如果vuex的全局变量userInfo为空值
// if(token == "undefined"){
// ElementUI.Message({
// type:"warning",
// message:"您未登录,请前往登录界面进行操作"
// })
// window.location.href = '/#/'
// }
// return config
// },function(error){
// return Promise.reject(error)
// })
Vue.use(VueAxios, axios)
Vue.use(ElementUI)
......@@ -60,10 +27,34 @@ Vue.filter('formatDate', function (value) {
})
/* eslint-disable no-new */
new Vue({
var vm = new Vue({
el: '#app',
router,
store,
components: { App },
template: '<App/>'
})
// 添加响应拦截器
axios.interceptors.response.use(function (response) {
let res = response.data
if (response.config.url === '/file/getFiles') {
res.id = response.config.params.pieceId
}
return res
}, function (error) {
// 对响应错误做点什么
return Promise.reject(error)
})
// 添加请求拦截器,每次请求设置都请求cookie信息
axios.interceptors.request.use(function (config) {
// 除了登录和注册请求,其余请求如果没有用户信息(即没登录),就跳转到登录页面
if (!vm.$store.state.userInfo &&
config.url !== '/user/signin' &&
config.url !== '/user/signup') {
vm.$router.replace('/')
}
return config
}, function (error) {
return Promise.reject(error)
})
......@@ -7,7 +7,7 @@ Vue.use(Vuex)
export default new Vuex.Store({
state: {
userInfo: null,
userInfo: null
// imageData: null,
// layerData: null
},
......@@ -15,7 +15,7 @@ export default new Vuex.Store({
setUserInfo (state, userInfo) {
state.userInfo = userInfo
}
// setImageData (state, imageData) {
// state.imageData = imageData
// },
......@@ -33,5 +33,5 @@ export default new Vuex.Store({
},
modules: {
},
plugins: [createPersistedState()]
plugins: [createPersistedState({ storage: window.sessionStorage })]
})
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