lex-xin 3 سال پیش
والد
کامیت
afb9951f01
4فایلهای تغییر یافته به همراه19 افزوده شده و 3 حذف شده
  1. 19 3
      src/utils/auth.js
  2. 0 0
      web/index.html
  3. 0 0
      web/static/web/js/app.579a31b9.js
  4. 0 0
      web/static/web/js/app.b316ea24.js

+ 19 - 3
src/utils/auth.js

@@ -2,14 +2,30 @@ import Cookies from 'js-cookie'
 
 const TokenKey = 'Admin-Token'
 
+function getCookieDomain() {
+  let 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])$/
+  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)
+  return Cookies.get(TokenKey, { domain: getCookieDomain() })
 }
 
 export function setToken(token) {
-  return Cookies.set(TokenKey, token)
+  return Cookies.set(TokenKey, token, { domain: getCookieDomain() })
 }
 
 export function removeToken() {
-  return Cookies.remove(TokenKey)
+  return Cookies.remove(TokenKey, { domain: getCookieDomain() })
 }

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
web/index.html


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
web/static/web/js/app.579a31b9.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
web/static/web/js/app.b316ea24.js


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است