mirror of
https://gitee.com/onvia/ccc-tnt-psd2ui
synced 2024-12-25 11:18:26 +00:00
增加移除规则标记末尾的中文
This commit is contained in:
parent
34615d4b6e
commit
12975ba1a8
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ccc-tnt-psd2ui",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
15
psd2ui-tools/dist/index.js
vendored
15
psd2ui-tools/dist/index.js
vendored
@ -1166,7 +1166,7 @@
|
||||
this.scale = new Vec3(1, 1, 1);
|
||||
}
|
||||
parseNameRule(name) {
|
||||
var _a, _b;
|
||||
var _a, _b, _c;
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
@ -1177,11 +1177,11 @@
|
||||
return;
|
||||
}
|
||||
let obj = {
|
||||
name: (_b = (_a = fragments[0]) === null || _a === void 0 ? void 0 : _a.replace(/\.|>|\/|\ /g, "_")) !== null && _b !== void 0 ? _b : "unknow",
|
||||
name: (_c = (_b = (_a = fragments[0]) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.replace(/\.|>|\/|\ /g, "_")) !== null && _c !== void 0 ? _c : "unknow",
|
||||
comps: {},
|
||||
};
|
||||
for (let i = 1; i < fragments.length; i++) {
|
||||
const fragment = fragments[i].trim();
|
||||
const fragment = this.removeChineseFromEnd(fragments[i].trim()).trim(); // 删除规则尾部的中文
|
||||
let attr = {};
|
||||
let startIdx = fragment.indexOf("{");
|
||||
let comp = fragment;
|
||||
@ -1255,6 +1255,15 @@
|
||||
// }
|
||||
return obj;
|
||||
}
|
||||
removeChineseFromEnd(inputString) {
|
||||
const chineseRegex = /[\u4e00-\u9fa5]+$/;
|
||||
const match = inputString.match(chineseRegex);
|
||||
if (match && match[0]) {
|
||||
const chineseLength = match[0].length;
|
||||
return inputString.slice(0, -chineseLength);
|
||||
}
|
||||
return inputString;
|
||||
}
|
||||
/** 解析数据 */
|
||||
parseSource() {
|
||||
var _a, _b;
|
||||
|
@ -112,11 +112,13 @@ export abstract class PsdLayer {
|
||||
return;
|
||||
}
|
||||
let obj: PsdAttr = {
|
||||
name: fragments[0]?.replace(/\.|>|\/|\ /g, "_") ?? "unknow",
|
||||
name: fragments[0]?.trim()?.replace(/\.|>|\/|\ /g, "_") ?? "unknow",
|
||||
comps: {},
|
||||
}
|
||||
for (let i = 1; i < fragments.length; i++) {
|
||||
const fragment = fragments[i].trim();
|
||||
const fragment = this.removeChineseFromEnd(fragments[i].trim()).trim(); // 删除规则尾部的中文
|
||||
|
||||
|
||||
let attr = {};
|
||||
let startIdx = fragment.indexOf("{");
|
||||
let comp = fragment;
|
||||
@ -203,7 +205,17 @@ export abstract class PsdLayer {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
removeChineseFromEnd(inputString: string): string {
|
||||
const chineseRegex = /[\u4e00-\u9fa5]+$/;
|
||||
const match = inputString.match(chineseRegex);
|
||||
|
||||
if (match && match[0]) {
|
||||
const chineseLength = match[0].length;
|
||||
return inputString.slice(0, -chineseLength);
|
||||
}
|
||||
|
||||
return inputString;
|
||||
}
|
||||
/** 解析数据 */
|
||||
parseSource() {
|
||||
let _source = this.source;
|
||||
|
Loading…
Reference in New Issue
Block a user