fix: 移除繁体转简体和资讯
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* 滚动情报文本处理:转为简体中文,过滤非中文内容
|
||||
* 滚动情报文本处理:过滤非中文为主的内容
|
||||
*/
|
||||
import { Converter } from 'opencc-js/t2cn'
|
||||
|
||||
const t2s = Converter({ from: 'twp', to: 'cn' })
|
||||
|
||||
/** 简体中文字符范围 */
|
||||
const ZH_REGEX = /[\u4e00-\u9fff]/g
|
||||
|
||||
@@ -16,20 +12,10 @@ export function isMostlyChinese(text: string): boolean {
|
||||
return zhCount / text.length >= 0.3
|
||||
}
|
||||
|
||||
/** 繁体转简体 */
|
||||
export function toSimplifiedChinese(text: string): string {
|
||||
if (!text?.trim()) return text
|
||||
try {
|
||||
return t2s(text)
|
||||
} catch {
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
/** 处理滚动情报项:转为简体,非中文为主则过滤 */
|
||||
/** 处理滚动情报项:非中文为主则过滤 */
|
||||
export function processTickerText(text: string): string | null {
|
||||
const t = (text || '').trim()
|
||||
if (!t) return null
|
||||
if (!isMostlyChinese(t)) return null
|
||||
return toSimplifiedChinese(t)
|
||||
return t
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user