Selaa lähdekoodia

修复erp cookie设置后读取不到的问题

yangc 8 vuotta sitten
vanhempi
commit
57dfc77635
3 muutettua tiedostoa jossa 17 lisäystä ja 9 poistoa
  1. 13 8
      layouts/main.vue
  2. 1 1
      server.js
  3. 3 0
      store/option.js

+ 13 - 8
layouts/main.vue

@@ -34,16 +34,21 @@
         return this.$store.state.option.isMobile
       },
       isInFrame () {
-        let cookies = this.$store.state.option.cookies
-        let cookieArr = cookies.split(';')
-        let cookieObj = {}
-        for (let i = 0; i < cookieArr.length; i++) {
-          let tmpArr = cookieArr[i].split('=') || []
-          if (tmpArr.length === 2) {
-            cookieObj[tmpArr[0].trim()] = tmpArr[1].trim()
+        if (this.$route.query.type === 'erp') {
+          this.$store.commit('option/ADD_COOKIES', 'type=erp;')
+          return true
+        } else {
+          let cookies = this.$store.state.option.cookies
+          let cookieArr = cookies.split(';')
+          let cookieObj = {}
+          for (let i = 0; i < cookieArr.length; i++) {
+            let tmpArr = cookieArr[i].split('=') || []
+            if (tmpArr.length === 2) {
+              cookieObj[tmpArr[0].trim()] = tmpArr[1].trim()
+            }
           }
+          return cookieObj.type === 'erp'
         }
-        return cookieObj.type === 'erp' || this.$route.query.type === 'erp'
       },
       title () {
         let path = this.$route.path

+ 1 - 1
server.js

@@ -16,7 +16,7 @@ config.dev = !(process.env.NODE_ENV === 'production')
 const proxyTable = config.proxyTable
 if (proxyTable) {
   // 本地代理支持localhost、127.0.0.1等不同地址跨域
-  app.use((req, res, next) => {
+  app.use((req, res, next, store) => {
     res.header('Access-Control-Allow-Origin', '*')
     res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
     res.header('Access-Control-Allow-Headers', 'Content-Type')

+ 3 - 0
store/option.js

@@ -35,6 +35,9 @@ export const mutations = {
   SET_COOKIES (state, result) {
     state.cookies = result || ''
   },
+  ADD_COOKIES (state, result) {
+    state.cookies += result || ''
+  },
   SET_SESSION_ID (state, result) {
     state.sessionId = result || ''
   },