From 963a48256a39bb0f885cf9328ba2899ccc05e6d6 Mon Sep 17 00:00:00 2001 From: onvia <272493431@qq.com> Date: Fri, 15 Sep 2023 10:39:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A7=BB=E9=99=A4=E8=A7=84?= =?UTF-8?q?=E5=88=99=E6=A0=87=E8=AE=B0=E6=9C=AB=E5=B0=BE=E7=9A=84=E4=B8=AD?= =?UTF-8?q?=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- psd2ui-tools/dist/index.js | 7 +++++-- psd2ui-tools/src/psd/PsdLayer.ts | 11 +++++++---- src/index.js | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 29601a6..5c2becc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ccc-tnt-psd2ui", - "version": "1.0.2", + "version": "1.0.3", "description": "", "main": "index.js", "scripts": { diff --git a/psd2ui-tools/dist/index.js b/psd2ui-tools/dist/index.js index 5e47352..fc0a7c0 100644 --- a/psd2ui-tools/dist/index.js +++ b/psd2ui-tools/dist/index.js @@ -1256,11 +1256,14 @@ return obj; } removeChineseFromEnd(inputString) { + if (!inputString) { + return inputString; + } const chineseRegex = /[\u4e00-\u9fa5]+$/; - const match = inputString.match(chineseRegex); + const match = inputString.trim().match(chineseRegex); if (match && match[0]) { const chineseLength = match[0].length; - return inputString.slice(0, -chineseLength); + return this.removeChineseFromEnd(inputString.slice(0, -chineseLength)); } return inputString; } diff --git a/psd2ui-tools/src/psd/PsdLayer.ts b/psd2ui-tools/src/psd/PsdLayer.ts index 8b2560e..d2462fa 100644 --- a/psd2ui-tools/src/psd/PsdLayer.ts +++ b/psd2ui-tools/src/psd/PsdLayer.ts @@ -206,14 +206,17 @@ export abstract class PsdLayer { return obj; } removeChineseFromEnd(inputString: string): string { + if (!inputString) { + return inputString; + } const chineseRegex = /[\u4e00-\u9fa5]+$/; - const match = inputString.match(chineseRegex); - + const match = inputString.trim().match(chineseRegex); + if (match && match[0]) { const chineseLength = match[0].length; - return inputString.slice(0, -chineseLength); + return this.removeChineseFromEnd(inputString.slice(0, -chineseLength)); } - + return inputString; } /** 解析数据 */ diff --git a/src/index.js b/src/index.js index 404b6e5..ac23380 100644 --- a/src/index.js +++ b/src/index.js @@ -190,7 +190,7 @@ function reWriteVersion() { cocosVersion = "v3.4.+" //cocosVersion = "v2.4.x" -const pluginVersion = "1.0.1"; // 打包之前记得修改这里的版本号,第三位为只更新lib文件,前两位为更新整个插件。 +const pluginVersion = "1.0.3"; // 打包之前记得修改这里的版本号,第三位为只更新lib文件,前两位为更新整个插件。 console.log(`打包版本号为${pluginVersion}\n记得升级版本号~\n版本规则:第三位为只更新lib文件,前两位为更新整个插件。\n调用本脚本时,会自动赋值给插件版本号`);