【修改】增加登陆持久
This commit is contained in:
@@ -88,6 +88,7 @@ export default {
|
||||
this.$store.commit('setHandleProcess', null)
|
||||
this.$store.commit('savePathUrl', null)
|
||||
this.$store.commit('removeDicts', null)
|
||||
localStorage.removeItem('cookie')
|
||||
// var sevice = "http://"+window.location.host+"/";
|
||||
// var serviceUrl = encodeURIComponent(sevice);
|
||||
// 正式
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import './router-guard'
|
||||
import store from './store'
|
||||
|
||||
// 流程公共样式
|
||||
import './assets/css/process.scss'
|
||||
import './assets/css/common.scss'
|
||||
@@ -43,6 +45,8 @@ VXETable.setup({
|
||||
resizable: true
|
||||
}
|
||||
})
|
||||
import VueCookies from 'vue-cookies';
|
||||
Vue.use(VueCookies)
|
||||
Vue.use(dict);
|
||||
Vue.use(VXETable)
|
||||
Vue.use(VueQuillEditor)
|
||||
|
||||
@@ -19,6 +19,7 @@ export default new Vuex.Store({
|
||||
btnPerssion:[]
|
||||
},
|
||||
getters: {
|
||||
pathUrl:(state)=>state.pathUrl,
|
||||
marketpre: (state) => state.marketpre,
|
||||
menuData: (state) => state.menuData,
|
||||
menuName: (state) => state.menuName,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Message, Loading } from 'element-ui'
|
||||
import store from '../store'
|
||||
import router from '../router'
|
||||
import { BASE_URL } from '../utils/http'
|
||||
axios.defaults.withCredentials = true;// 允许跨域携带cookie
|
||||
|
||||
// 记录请求个数、加载
|
||||
let count = 0; let loading = null
|
||||
@@ -13,7 +14,7 @@ const instance = axios.create({
|
||||
// timeout: 60000,
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache',
|
||||
Pragma: 'no-cache'
|
||||
Pragma: 'no-cache',
|
||||
}
|
||||
})
|
||||
// 添加请求拦截器
|
||||
@@ -82,6 +83,7 @@ instance.interceptors.response.use(function (response) {
|
||||
store.commit('savePathUrl', null)
|
||||
store.commit('setHandleProcess', null)
|
||||
store.commit('removeDicts', null)
|
||||
localStorage.removeItem('cookie')
|
||||
router.push('/login')
|
||||
Message.error('登录超时过期')
|
||||
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
|
||||
@@ -96,6 +98,7 @@ instance.interceptors.response.use(function (response) {
|
||||
store.commit('savePathUrl', null)
|
||||
store.commit('setHandleProcess', null)
|
||||
store.commit('removeDicts', null)
|
||||
localStorage.removeItem('cookie')
|
||||
router.push('/login')
|
||||
Message.error('登录超时过期')
|
||||
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
|
||||
|
||||
@@ -136,6 +136,9 @@ export default {
|
||||
})
|
||||
return
|
||||
}else{
|
||||
localStorage.setItem('cookie',res.data.sessionId)
|
||||
this.$cookies.get('JSESSIONID')
|
||||
console.log( this.$cookies.get('JSESSIONID'),"getCookiegetCookiegetCookiegetCookiegetCookiegetCookie")
|
||||
let routeList=menu.map(item=> item.href)
|
||||
let params
|
||||
if(routeList.indexOf('/report/list')>-1){
|
||||
@@ -182,7 +185,67 @@ export default {
|
||||
reject('')
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取cookie
|
||||
getCookie(key) {
|
||||
if (document.cookie.length > 0) {
|
||||
var start = document.cookie.indexOf(key + "=");
|
||||
if (start !== -1) {
|
||||
start = start + key.length + 1;
|
||||
var end = document.cookie.indexOf(";", start);
|
||||
if (end === -1) {
|
||||
end = document.cookie.length;
|
||||
}
|
||||
return unescape(document.cookie.substring(start, end));
|
||||
}
|
||||
}
|
||||
return "";
|
||||
},
|
||||
/* 这样去cookie
|
||||
函数中的参数为 要获取的cookie键的名称。
|
||||
function getCookie(userName){
|
||||
if (document.cookie.length>0){
|
||||
c_start=document.cookie.indexOf(userName+ "=");
|
||||
if (c_start!=-1){
|
||||
c_start=c_start + userName.length+1;
|
||||
c_end=document.cookie.indexOf(";",c_start);
|
||||
if (c_end==-1){
|
||||
c_end=document.cookie.length;
|
||||
}
|
||||
return unescape(document.cookie.substring(c_start,c_end));
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
var userName = getCookie('userName');
|
||||
*/
|
||||
|
||||
// 保存新增cookie
|
||||
setCookie: function(uname, upass, exdays) {
|
||||
var exdate = new Date();
|
||||
exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays);
|
||||
window.document.cookie =
|
||||
"username" + "=" + uname + ";path=/;expires=" + exdate.toGMTString();
|
||||
window.document.cookie =
|
||||
"password" + "=" + upass + ";path=/;expires=" + exdate.toGMTString();
|
||||
}
|
||||
/* 或者这样设置
|
||||
函数中的参数分别为 cookie 的名称、值以及过期天数
|
||||
function setCookie(c_name,value,expiredays){
|
||||
var exdate = new Date();
|
||||
exdate.setDate(exdate.getDate() + expiredays);
|
||||
document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
|
||||
}
|
||||
setCookie('userName', 'xxx', 1); // cookie过期时间为1天。
|
||||
|
||||
// 设置过期时间以秒为单位
|
||||
function setCookie(c_name,value,expireseconds){
|
||||
var exdate = new Date();
|
||||
exdate.setTime(exdate.getTime() + expireseconds * 1000);
|
||||
document.cookie = c_name + "=" + escape(value) + ((expireseconds == null) ? "" : ";expires=" + exdate.toGMTString())
|
||||
}
|
||||
setCookie('userName', 'xxx', 3600); //cookie过期时间为一个小时
|
||||
*/
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -67,7 +67,6 @@ export default {
|
||||
}
|
||||
this.$message.success('登录成功')
|
||||
this.getMarket().then((resx)=>{
|
||||
debugger
|
||||
this.$store.commit('setMarketpre', resx)
|
||||
this.$router.push(params)
|
||||
}).catch((resx)=>{
|
||||
|
||||
@@ -99,8 +99,9 @@ export default {
|
||||
this.taskId = taskId
|
||||
this.pId = pId
|
||||
this.prcType = prcType
|
||||
this.form.name = {
|
||||
assignee: ''
|
||||
this.form = {
|
||||
assignee: '',
|
||||
assigneeName:''
|
||||
}
|
||||
this.assigneeId = assigneeId
|
||||
this.aid = aid
|
||||
|
||||
Reference in New Issue
Block a user