|
@@ -2,16 +2,23 @@ import Cookie from 'js-cookie'
|
|
|
|
|
|
export default {
|
|
|
//获取服务端cookie
|
|
|
- getcookiesInServer:function (req) {
|
|
|
- let service_cookie = {};
|
|
|
- req && req.headers.cookie && req.headers.cookie.split(';').forEach(function (val) {
|
|
|
- let parts = val.split('=');
|
|
|
- service_cookie[parts[0].trim()] = (parts[1] || '').trim();
|
|
|
- });
|
|
|
- return service_cookie;
|
|
|
+ getcookiesInServer: function (req) {
|
|
|
+ console.log('get server cookie')
|
|
|
+ let service_cookie = {}
|
|
|
+ req &&
|
|
|
+ req.headers.cookie &&
|
|
|
+ req.headers.cookie.split(';').forEach(function (val) {
|
|
|
+ let parts = val.split('=')
|
|
|
+ service_cookie[parts[0].trim()] = (parts[1] || '').trim()
|
|
|
+ })
|
|
|
+ return service_cookie
|
|
|
},
|
|
|
//获取客户端cookie
|
|
|
- getcookiesInClient:function (key) {
|
|
|
- return Cookie.get(key) ? Cookie.get(key) : ''
|
|
|
- }
|
|
|
-}
|
|
|
+ getcookiesInClient: function (key) {
|
|
|
+ if (Cookies.get('can-use-cookie')) {
|
|
|
+ return Cookie.get(key) || ''
|
|
|
+ } else {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+}
|