|
|
|
|
@ -348,12 +348,12 @@ const getCharUnits = (str: string) => {
@@ -348,12 +348,12 @@ const getCharUnits = (str: string) => {
|
|
|
|
|
|
|
|
|
|
// 限制最多 12 个字符单位:中文占2个,英文/数字/空格/符号占1个 |
|
|
|
|
const scenePropInputText = (val: string) => { |
|
|
|
|
if (getCharUnits(val) > 12) { |
|
|
|
|
if (getCharUnits(val) > 18) { |
|
|
|
|
let units = 0 |
|
|
|
|
let i = 0 |
|
|
|
|
for (; i < val.length; i++) { |
|
|
|
|
const add = /[\u4e00-\u9fff\u3400-\u4dbf]/.test(val[i]) ? 2 : 1 |
|
|
|
|
if (units + add > 12) break |
|
|
|
|
if (units + add > 18) break |
|
|
|
|
units += add |
|
|
|
|
} |
|
|
|
|
val = val.slice(0, i) |
|
|
|
|
|