对比新文件 |
| | |
| | | /** |
| | | * Created by 工业互联网平台 |
| | | * |
| | | * AI 枚举类 |
| | | * |
| | | * 问题:为什么不放在 src/utils/common-utils.ts 呢? |
| | | * 回答:主要 AI 是可选模块,考虑到独立、解耦,所以放在了 /views/ai/utils/common-utils.ts |
| | | */ |
| | | |
| | | /** 判断字符串是否包含中文 */ |
| | | export const hasChinese = (str: string) => { |
| | | return /[\u4e00-\u9fa5]/.test(str) |
| | | } |
| | | |
| | | export const formatReasoningContent = (content: string) => { |
| | | // 匹配 "数字" + "." + ("中文"或"空格") + "其他内容" + ":" |
| | | const stepRegex = /(\d+\.(?:[\u4e00-\u9fa5]|\s)[^:]*:)(\s*)/g; |
| | | |
| | | // 替换逻辑: |
| | | // - 如果标题后没有换行(即 `$2` 是空或只有空格),则添加 `<br>` |
| | | // - 如果标题后已有换行(如 `\n` 或 `<br>`),则不额外添加 |
| | | return content.replace( |
| | | stepRegex, |
| | | (match, title, whitespace) => { |
| | | const hasNewline = whitespace.includes('\\n') || whitespace.includes('<br>'); |
| | | const lineBreak = hasNewline ? '' : '<br>'; |
| | | return `<strong style="font-size: 16px; line-height: 32px; color: #FFFFFF;">${title}</strong>${lineBreak}`; |
| | | } |
| | | ); |
| | | } |