翻译中文到英文

This commit is contained in:
2023-03-03 10:14:11 +08:00
parent b55cd47e02
commit 41d96da246

View File

@@ -23,7 +23,7 @@ export default defineEventHandler(async event => {
// 翻译中文到英文 // 翻译中文到英文
const translate = async (text: string, callback:Function) => { const translate = async (text: string, callback:Function) => {
if (/^[a-zA-Z]+$/.test(text)) { if (/[\u4E00-\u9FA5\uF900-\uFA2D]/.test(text)) {
text = encodeURIComponent(text) text = encodeURIComponent(text)
const {data} = await axios.get(`http://139.224.128.24:7861//api/text_to_text?zh=${text}`) const {data} = await axios.get(`http://139.224.128.24:7861//api/text_to_text?zh=${text}`)
text = data.en text = data.en