Browse Source
* Password verification and v-for add key * DAG automatic layout * combo.js replacement * combo.js replacement * webpack upgrade to 4 * packjson has a file name that has not changed * Solve jertty packing garbled * Modify dashboard color * Remove iconfont, awesome, replace with ans-ui icon * Menu arrow style fix * Script input box style fix * console.log('Front-end third-party js, css introduced using npm * Front-end supplemental license * Modify naming * Repair license * replace cookie.js with js-cookie, add js-cookie licensepull/2/head
break60
5 years ago
committed by
lgcareer
9 changed files with 36 additions and 101 deletions
@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (c) 2018 Copyright 2018 Klaus Hartl, Fagner Brack, GitHub Contributors |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
@ -1,88 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
let document = window.document |
||||
let trim = function (s) { |
||||
if (typeof s !== 'string') { |
||||
throw new Error('trim need a string as parameter') |
||||
} |
||||
let len = s.length, i = 0, j = len - 1, re = /(\u3000|\s|\t|\u00A0)/ |
||||
while (i < len && re.test(s.charAt(i))) ++i |
||||
while (j >= 0 && re.test(s.charAt(j))) --j |
||||
return s.substring(i, j + 1) |
||||
} |
||||
let copy = function (o) { |
||||
let d = {} |
||||
for (let k in o) { if (o.hasOwnProperty(k)) d[k] = o[k] } |
||||
return d |
||||
} |
||||
/** |
||||
* Cookie setter & setter |
||||
* |
||||
* @param {String} name The identify name of cookie. |
||||
* @param {String} value (Optional) String to set cookie value. (`null` to remove cookie) |
||||
* @param {Object} options (Optional) Set the cooke native options, (path domain, secure, expires) |
||||
*/ |
||||
let cookie = function (name, value, options) { |
||||
options = options || {} |
||||
if (value !== undefined) { // set cookie
|
||||
options = copy(options) |
||||
if (value === null) { |
||||
value = '' |
||||
options.expires = -1 |
||||
} |
||||
if (typeof options.expires === 'number') { |
||||
let days = options.expires, t = options.expires = new Date() |
||||
t.setTime(t.getTime() + days * 864e+5) // 24 * 60 * 60 * 1000
|
||||
} |
||||
let encode = function (s) { |
||||
try { |
||||
return options.raw ? s : encodeURIComponent(s) |
||||
} catch (e) { |
||||
} |
||||
return s |
||||
} |
||||
return (document.cookie = [ |
||||
encode(name), '=', encode(value), |
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '', |
||||
options.domain ? '; domain=' + options.domain : '', |
||||
options.secure ? '; secure' : '' |
||||
].join('')) |
||||
} else { |
||||
let value = null, |
||||
cookie = document.cookie, |
||||
decode = function (s) { |
||||
return options.raw ? s : decodeURIComponent(s) |
||||
}, |
||||
cookies = cookie ? cookie.split('; ') : [] |
||||
for (let i = -1, l = cookies.length, c = name.length + 1; ++i < l;) { |
||||
cookie = trim(cookies[i]) |
||||
if (cookie.substring(0, c) === (name + '=')) { |
||||
value = decode(cookie.substring(c)) |
||||
break |
||||
} |
||||
} |
||||
return value |
||||
} |
||||
} |
||||
cookie.set = function (k, v, opts) { |
||||
return cookie(k, v, opts) |
||||
} |
||||
cookie.get = function (k) { |
||||
return cookie(k) |
||||
} |
||||
export default cookie |
Loading…
Reference in new issue