diff --git a/cColorText/cColorText.vue b/cColorText/cColorText.vue index b93eddf..ad4d174 100644 --- a/cColorText/cColorText.vue +++ b/cColorText/cColorText.vue @@ -9,12 +9,16 @@ export default { type: { type: String, default: 'hex' + }, + block: { + type: String, + default: '' } }, data() { return { }}, methods: { - num2hex(value){ // 允许其他进制的num输入? + num2hex(value){ // todo: 允许其他进制的num输入? if (value) { switch (typeof value){ case 'number': value = value.toString(16); break; @@ -26,7 +30,15 @@ export default { }, shrinkHex(hex){ if (/^(0x)?[\dA-F]+$/i.test(hex)){ - return hex.replace(/^0x/, '').replace(/^(\w{18})\w*(\w{18})$/, '$1$2') + hex = hex.replace(/^0x/, '') + let length + switch(this.block){ + case '2': return hex.replace(/^(\w{6})\w*(\w{6})$/, '$1$2') + case '4': return hex.replace(/^(\w{12})\w*(\w{12})$/, '$1$2') + case '6': return hex.replace(/^(\w{18})\w*(\w{18})$/, '$1$2') + case '8': return hex.replace(/^(\w{24})\w*(\w{24})$/, '$1$2') + default: return hex + } } return '' }, @@ -49,6 +61,13 @@ export default { // let fullLength = len + (4-(rest?rest:4)) // address = address.padEnd(fullLength, 'A') // 在 b64 里,'00'字节是A. let colorArray = address.match(/[0-9A-Za-z\-_]{4}/g) + switch(this.block){ + case "2": colorArray.splice(1, colorArray.length-2) + case "4": colorArray.splice(2, colorArray.length-4) + case "6": colorArray.splice(3, colorArray.length-6) + case "8": colorArray.splice(4, colorArray.length-8) + default: + } return colorArray } return [] @@ -67,22 +86,22 @@ export default { diff --git a/cToast/cToast.vue b/cToast/cToast.vue index 24fc722..8e1d5de 100644 --- a/cToast/cToast.vue +++ b/cToast/cToast.vue @@ -3,7 +3,7 @@ based on https://ext.dcloud.net.cn/plugin?id=672 https://github.com/steffenx/uniapp_popup - *数组形式传值 + 传值 *type: success warn info fail loading(string),默认info *content: 内容(string) *duration: 消失时间(Number),默认2000