翻译中文到英文
This commit is contained in:
@@ -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
|
||||||
|
Reference in New Issue
Block a user