feat: add prompt translate handler

This commit is contained in:
RockYang
2023-12-11 06:56:00 +08:00
parent f19c15491e
commit 411335ebcb
5 changed files with 124 additions and 21 deletions

View File

@@ -105,12 +105,12 @@
:value="item.id"
/>
</el-select>
<!-- <el-button type="primary" @click="newChat">-->
<!-- <el-icon>-->
<!-- <Plus/>-->
<!-- </el-icon>-->
<!-- 新建-->
<!-- </el-button>-->
<el-button type="primary" @click="newChat">
<el-icon>
<Plus/>
</el-icon>
新建
</el-button>
<el-button type="success" @click="exportChat" plain>
<i class="iconfont icon-export"></i>
@@ -237,7 +237,7 @@ import {
Check,
Close,
Delete,
Edit,
Edit, Plus,
Promotion,
RefreshRight,
Search,

View File

@@ -243,7 +243,7 @@
</el-icon>
</el-tooltip>
</div>
<el-button type="success">
<el-button type="success" @click="translatePrompt">
<el-icon style="margin-right: 6px;font-size: 18px;">
<Refresh/>
</el-icon>
@@ -268,12 +268,12 @@
</el-icon>
</el-tooltip>
</div>
<el-button type="success">
<el-icon style="margin-right: 6px;font-size: 18px;">
<Refresh/>
</el-icon>
翻译
</el-button>
<!-- <el-button type="success">-->
<!-- <el-icon style="margin-right: 6px;font-size: 18px;">-->
<!-- <Refresh/>-->
<!-- </el-icon>-->
<!-- 翻译-->
<!-- </el-button>-->
</div>
</div>
@@ -286,7 +286,7 @@
<div class="submit-btn">
<el-button color="#47fff1" :dark="false" @click="generate" round>立即生成</el-button>
<div class="text-info">
<el-tag type="success">可用额度{{ imgCalls }}</el-tag>
<el-tag type="success">绘图可用额度{{ imgCalls }}</el-tag>
</div>
</div>
</el-form>
@@ -336,7 +336,7 @@
<h2>创作记录</h2>
<div class="finish-job-list">
<ItemList :items="finishedJobs" v-if="finishedJobs.length > 0" width="240" :gap="16">
<ItemList :items="finishedJobs" v-if="finishedJobs.length > 0" :width="240" :gap="16">
<template #default="scope">
<div class="job-item">
<el-image
@@ -487,7 +487,7 @@ const params = ref({
img: "",
weight: 0.25,
prompt: "",
neg_prompt: "",
neg_prompt: "nsfw, paintings, cartoon, anime, sketches, low quality,easynegative,ng_deepnegative _v1 75t,(worst quality:2),(low quality:2),(normalquality:2),lowres,bad anatomy,bad hands,normal quality,((monochrome)),((grayscale)),((watermark))",
tile: false,
quality: 0.5
})
@@ -568,6 +568,14 @@ const connect = () => {
});
}
const translatePrompt = () => {
httpPost("/api/prompt/translate",{"prompt":params.value.prompt}).then(res => {
params.value.prompt = res.data
}).then(e => {
ElMessage.error("翻译失败:"+e.message)
})
}
onMounted(() => {
checkSession().then(user => {
imgCalls.value = user['img_calls']

View File

@@ -502,14 +502,14 @@ const samplers = ["Euler a", "Euler", "DPM2 a Karras", "DPM++ 2S a Karras", "DPM
"LMS Karras", "DPM2 Karras", "DDIM", "PLMS", "UniPC", "LMS", "Heun",]
const scaleAlg = ["Latent", "ESRGAN_4x", "R-ESRGAN 4x+", "SwinIR_4x", "LDSR"]
const params = ref({
width: 512,
height: 512,
width: 1024,
height: 1024,
sampler: samplers[0],
seed: -1,
steps: 30,
cfg_scale: 7,
face_fix: false,
hd_fix: true,
hd_fix: false,
hd_redraw_rate: 0.7,
hd_scale: 2,
hd_scale_alg: scaleAlg[0],