From ce7cb2f17facfb27f5ebd81591defce1beda0459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=BA=91=E6=B5=B7=20mayunhai=20=28=29?= Date: Mon, 18 Feb 2019 13:06:39 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E7=94=A8Object.assign()=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E6=95=B0=E7=BB=84=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 821392e9b6d..333832580cc 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -276,14 +276,7 @@ export function deepClone(source) { if (!source && typeof source !== 'object') { throw new Error('error arguments', 'shallowClone') } - const targetObj = source.constructor === Array ? [] : {} - Object.keys(source).forEach(keys => { - if (source[keys] && typeof source[keys] === 'object') { - targetObj[keys] = deepClone(source[keys]) - } else { - targetObj[keys] = source[keys] - } - }) + const targetObj = source.constructor === Array ? Object.assign([], source) : Object.assign({}, source) return targetObj } From 344e95c57a74fbcbad5c0219ed890b05bdbeacce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=BA=91=E6=B5=B7=20mayunhai=20=28=29?= Date: Fri, 1 Mar 2019 09:41:48 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=96=87=E5=AD=97?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=EF=BC=8C=E6=88=91=E8=A7=89=E5=BE=97=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E5=A4=A7=E5=86=99=E4=B9=9F=E5=BA=94=E8=AF=A5=E7=AE=97?= =?UTF-8?q?=E4=BD=9C=E4=B8=AD=E6=96=87=EF=BC=8C=E5=B0=A4=E5=85=B6=E6=98=AF?= =?UTF-8?q?W=E8=BF=99=E7=9A=84=E5=AD=97=E5=86=8D=E5=8A=A0=E7=B2=97?= =?UTF-8?q?=E7=9A=84=E8=AF=9D=E5=BE=88=E5=AE=BD=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/index.js b/src/utils/index.js index b8a72e61e85..22456861b00 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -98,7 +98,7 @@ export function getQueryObject(url) { export function getByteLen(val) { let len = 0 for (let i = 0; i < val.length; i++) { - if (val[i].match(/[^\x00-\xff]/gi) != null) { + if (val[i].match(/[^\x00-\xff]/gi) != null || (val[i] >= 'A' && val[i] <= 'Z')) { len += 1 } else { len += 0.5 From 90d9890b069a2d91073543f55797e0d694ea13fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=BA=91=E6=B5=B7=20mayunhai=20=28=29?= Date: Fri, 1 Mar 2019 09:47:28 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/index.js b/src/utils/index.js index 22456861b00..613ae2a3d4c 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -276,7 +276,14 @@ export function deepClone(source) { if (!source && typeof source !== 'object') { throw new Error('error arguments', 'shallowClone') } - const targetObj = source.constructor === Array ? Object.assign([], source) : Object.assign({}, source) + const targetObj = source.constructor === Array ? [] : {} + Object.keys(source).forEach(keys => { + if (source[keys] && typeof source[keys] === 'object') { + targetObj[keys] = deepClone(source[keys]) + } else { + targetObj[keys] = source[keys] + } + }) return targetObj } From b4249cc0842b4926cd13ed8b7b51942b77be6f84 Mon Sep 17 00:00:00 2001 From: Pan Date: Mon, 4 Mar 2019 10:53:17 +0800 Subject: [PATCH 04/10] refactor --- src/utils/index.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 613ae2a3d4c..fbcb4602f83 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -91,20 +91,19 @@ export function getQueryObject(url) { } /** - *get getByteLen - * @param {Sting} val input value + * @param {Sting} input value * @returns {number} output value */ -export function getByteLen(val) { - let len = 0 - for (let i = 0; i < val.length; i++) { - if (val[i].match(/[^\x00-\xff]/gi) != null || (val[i] >= 'A' && val[i] <= 'Z')) { - len += 1 - } else { - len += 0.5 - } +export function byteLength(str) { + // returns the byte length of an utf8 string + let s = str.length + for (var i = str.length - 1; i >= 0; i--) { + const code = str.charCodeAt(i) + if (code > 0x7f && code <= 0x7ff) s++ + else if (code > 0x7ff && code <= 0xffff) s += 2 + if (code >= 0xDC00 && code <= 0xDFFF) i-- } - return Math.floor(len) + return s } export function cleanArray(actual) { From 9ae7cf04ca7d87dfa07bb1168d1ee71db54d9760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=BA=91=E6=B5=B7=20mayunhai=20=28=29?= Date: Wed, 20 Mar 2019 16:51:11 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E4=B8=80=E5=A5=97?= =?UTF-8?q?=E4=B8=8D=E9=94=99=E7=9A=84=E9=A2=9C=E8=89=B2=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ThemePicker/index.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue index be3a573ac9c..f6784710d26 100644 --- a/src/components/ThemePicker/index.vue +++ b/src/components/ThemePicker/index.vue @@ -1,6 +1,7 @@