This commit is contained in:
2023-03-03 09:58:22 +08:00
parent 03c9432930
commit b55cd47e02

View File

@@ -23,11 +23,13 @@ export default defineEventHandler(async event => {
// 翻译中文到英文
const translate = async (text: string, callback:Function) => {
if (!/^[a-zA-Z]+$/.test(text)) return text
text = encodeURIComponent(text)
const {data} = await axios.get(`http://139.224.128.24:7861//api/text_to_text?zh=${text}`)
if (callback) callback(data.en)
return data.en
if (/^[a-zA-Z]+$/.test(text)) {
text = encodeURIComponent(text)
const {data} = await axios.get(`http://139.224.128.24:7861//api/text_to_text?zh=${text}`)
text = data.en
}
if (callback) callback(text)
return text
}
// 添加任务到队列(生成一个32位随机字符串作为任务ID)