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调用本脚本时,会自动赋值给插件版本号`);