瀏覽代碼

Merge branch 'beta' of https://git.cocorobo.cn/jack/PPT into beta

lsc 6 天之前
父節點
當前提交
caf895d420
共有 1 個文件被更改,包括 11 次插入6 次删除
  1. 11 6
      src/views/Student/components/choiceQuestionDetailDialog.vue

+ 11 - 6
src/views/Student/components/choiceQuestionDetailDialog.vue

@@ -574,15 +574,20 @@ const setEchartsArea1 = () => {
                 // 非JSON字符串,直接返回
                 // 如果文本文字超过8个字,换行
                 if (typeof value === 'string') {
+                  // 判断value是否全是英文
+                  const isAllEnglish = /^[a-zA-Z0-9\s\p{P}]+$/u.test(value)
                   let displayValue = value
-                  if (value.length > 20) {
-                    displayValue = value.substr(0, 20) + '...'
+                  const maxLength = isAllEnglish ? 30 : 20
+                  const lineLength = isAllEnglish ? 16 : 8
+                  
+                  if (value.length > maxLength) {
+                    displayValue = value.substr(0, maxLength) + '...'
                   }
-                  // 8个字换行
+                  // 换行处理
                   let output = ''
-                  for (let i = 0; i < displayValue.length; i += 8) {
-                    output += displayValue.substr(i, 8)
-                    if (i + 8 < displayValue.length) {
+                  for (let i = 0; i < displayValue.length; i += lineLength) {
+                    output += displayValue.substr(i, lineLength)
+                    if (i + lineLength < displayValue.length) {
                       output += '\n'
                     }
                   }