Bladeren bron

修改cookie jssionid获取方式

yangc 7 jaren geleden
bovenliggende
commit
0cfc8b0cf0
1 gewijzigde bestanden met toevoegingen van 7 en 7 verwijderingen
  1. 7 7
      store/index.js

+ 7 - 7
store/index.js

@@ -40,13 +40,13 @@ export const actions = {
     }
     if (cookie && cookie.length) {
       for (let i = 0; i < cookie.length; i++) {
-        if (cookie[i].indexOf('JSESSIONID') > -1) {
-          const sessionId = cookie[i]
-          const first = sessionId.indexOf(';')
-          const second = sessionId.lastIndexOf(';')
-          const newSessionId = sessionId.replace(sessionId.substring(first, second), '')
-          store.commit('option/SET_SESSION_ID', newSessionId)
-          break
+        let cookies = cookie.split(';')
+        for (let i = 0; i < cookies.length; i++) {
+          let cookieArr = cookies[i].split(':')
+          if (cookieArr.length === 2 && cookieArr[0] === 'JSESSIONID') {
+            store.commit('option/SET_SESSION_ID', cookieArr[1])
+            break
+          }
         }
       }
       axios.defaults.headers['cookie'] = store.state.option.cookies + '; ' + store.state.option.sessionId