从服务端异步翻译
This commit is contained in:
@@ -216,7 +216,7 @@ const imageCreate = ref({
|
||||
const new_task = ref({
|
||||
model: 'SD2', // 模型
|
||||
ckpt: '768-v-ema', // 风格参数
|
||||
prompt: 'A tabby cat, with a fluffy tail, basking in the sun, bright, warm, very cute!', // 渲染提示词
|
||||
prompt: '一只猫, 汤姆', // 渲染提示词
|
||||
exclude: 'puppets, death, decay, mess', // 排除词汇
|
||||
number: 1, // 生成图片数量
|
||||
width: 512, // 图片宽度
|
||||
@@ -282,10 +282,32 @@ const ModelsSelect = (index, model) => {
|
||||
imageCreate.value.models_show = false
|
||||
}
|
||||
|
||||
//// 判断是否为中文
|
||||
//const isChinese = (str) => {
|
||||
// var reg = /[\u4E00-\u9FA5\uF900-\uFA2D]/;
|
||||
// return reg.test(str);
|
||||
//}
|
||||
//
|
||||
//// 判断是否为英文
|
||||
//const isEnglish = (str) => {
|
||||
// var reg = /^[a-zA-Z]+$/;
|
||||
// return reg.test(str);
|
||||
//}
|
||||
//
|
||||
//// 翻译中文为英文
|
||||
//const translate = async (str) => {
|
||||
// let res = await fetch('/api/text?zh='+encodeURIComponent(str))
|
||||
// let data = await res.json()
|
||||
// return data.en
|
||||
//}
|
||||
|
||||
// 提交新任务
|
||||
const TaskSubmit = () => {
|
||||
let data = new_task.value
|
||||
data.exclude = imageCreate.value.exclude_on ? '' : data.exclude // 是否启用排除词汇
|
||||
const TaskSubmit = async () => {
|
||||
const data = Object.assign({}, new_task.value) // 复制一份来修改
|
||||
//data.prompt = isChinese(data.prompt) ? await translate(data.prompt) : data.prompt // 翻译中文为英文
|
||||
data.exclude = imageCreate.value.exclude_on ? data.exclude : '' // 是否启用排除词汇
|
||||
console.log(data)
|
||||
|
||||
fetch('/api/drawing', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
@@ -299,7 +321,6 @@ const TaskSubmit = () => {
|
||||
console.log(data.id, data.status, data.progress)
|
||||
tasks.value = tasks.value.map(x => x.id == data.id ? data : x)
|
||||
if (data.status == 'done') {
|
||||
//data.data = ['https://storage.googleapis.com/pai-marketing/filters/elizaport_style.png']
|
||||
window.clearInterval(t2)
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user