Browse Source

更新样式

lex-xin 3 years ago
parent
commit
0b810cb762
3 changed files with 19 additions and 3 deletions
  1. 0 0
      src/theme/index.css
  2. 18 2
      src/utils/auth.js
  3. 1 1
      vue.config.js

File diff suppressed because it is too large
+ 0 - 0
src/theme/index.css


+ 18 - 2
src/utils/auth.js

@@ -7,6 +7,22 @@ const CrossTokenKey = 'Admin-Token'
 // const Token = Cookies.get('cross-Token')
 // console.log(Token, validOaUrl().split('//')[1])
 // Cookies.set('Admin-Token', Token, { domain: `.${validOaUrl().split('//')[1]}`, path: '/' })
+const host = location.hostname
+const ip = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
+function getCookieDomain() {
+  let host = location.hostname
+  if (ip.test(host) === true || host === 'localhost') return host
+  const regex = /([^]*).*/
+  const match = host.match(regex)
+  if (typeof match !== 'undefined' && match !== null) host = match[1]
+  if (typeof host !== 'undefined' && host !== null) {
+    const strAry = host.split('.')
+    if (strAry.length > 1) {
+      host = strAry[strAry.length - 2] + '.' + strAry[strAry.length - 1]
+    }
+  }
+  return '.' + host
+}
 
 export function getToken () {
   return Cookies.get(TokenKey)
@@ -21,9 +37,9 @@ export function removeToken () {
 }
 
 export function setCrossToken (token) {
-  return Cookies.set(CrossTokenKey, token, { domain: `.${validOaUrl().split('//')[1]}`, path: '/' })
+  return Cookies.set(CrossTokenKey, token, { domain: getCookieDomain() })
 }
 
 export function removeCrossToken () {
-  return Cookies.remove(CrossTokenKey, { domain: `.${validOaUrl().split('//')[1]}`, path: '/' })
+  return Cookies.remove(CrossTokenKey, { domain: getCookieDomain() })
 }

+ 1 - 1
vue.config.js

@@ -54,7 +54,7 @@ module.exports = {
     //   warnings: false,
     //   errors: true
     // },
-    https: false,
+    https: true,
     proxy: {
       // change xxx-api/login => mock/login
       // detail: https://cli.vuejs.org/config/#devserver-proxy

Some files were not shown because too many files changed in this diff