From be3e27461e3a0426eed285ce2f529ba18d1161c3 Mon Sep 17 00:00:00 2001 From: liuxianghui <519646741@qq.com> Date: Mon, 9 Jan 2023 10:40:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AF=AD=E8=A8=80=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../babylon/model/data/mark/mark-plan-data.ts | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/app/babylon/model/data/mark/mark-plan-data.ts b/src/app/babylon/model/data/mark/mark-plan-data.ts index a5a37ac..fd6af43 100644 --- a/src/app/babylon/model/data/mark/mark-plan-data.ts +++ b/src/app/babylon/model/data/mark/mark-plan-data.ts @@ -378,20 +378,45 @@ export class MarkNodeData { * 最短3秒 */ getShowTime() { - let textNum = 0; + let textNum = 0; // 总长度 + let num_ch = 0;//中文的个数 + let num_dan = 0; //单字符 + let num_point = 0;//标点 if (this.describe != null) { + // let str_noBlank = this.describe.replace(/\s*/g, ""); textNum = this.describe.length; + let re = /[\u4E00-\u9FA5]/; //测试中文字符的正则 + + if (re.test(this.describe)) //使用正则判断是否存在中文 + { + num_ch = this.describe.match(re).length; + } + + let re2 = /\w/; //所有单字符 + if (re2.test(this.describe)) //使用正则判断是否存在中文 + { + num_dan = this.describe.match(re2).length; + } + } + num_point = textNum - num_ch - num_dan; + let timeScale = 0.3; let minTime = 4; //最短停留时间 - let result = textNum * timeScale + 1; + let result = textNum * timeScale + 0.6 - textNum * num_dan * 0.06; + + + // let result = textNum * 0.15 + num_ch * 0.15 + num_point * 0.15 + num_dan * 0.07 + if (result < minTime) { result = minTime; } + result -= 0.06 * textNum; + return result; }