pc端文生图+选项生图;移动端工作室下载结果图错误提示

This commit is contained in:
Double-_-Z 2025-02-10 11:23:43 +08:00
parent 8d1764c264
commit b5296f1512
6 changed files with 390 additions and 68 deletions

View File

@ -4,12 +4,12 @@
let BASE_URL = '/pixelApi';
// #endif
// #ifdef APP-PLUS ||MP
// let BASE_URL = 'http://8.138.171.103/pixelApi';// 测试环境
let BASE_URL = 'https://www.ylemai.cn/pixelApi';// 正式环境
let BASE_URL = 'http://8.138.171.103/pixelApi';// 测试环境
// let BASE_URL = 'https://www.ylemai.cn/pixelApi';// 正式环境
// #endif
// let IP = 'http://8.138.171.103/';// 测试环境
let IP = 'https://www.ylemai.cn/';// 正式环境
let IP = 'http://8.138.171.103/';// 测试环境
// let IP = 'https://www.ylemai.cn/';// 正式环境
let FILE_URL = IP+'static/';
// 阿里OSS地址
let ALIOSS_URL = 'http://guojunjie.oss-cn-hangzhou.aliyuncs.com';

View File

@ -766,6 +766,9 @@ export default {
filePath: res.tempFilePath, //
success: function(resp) {
that.$refs.uToast.show({type:'success',title: "下载成功,请前往手机相册查看!"});
},
fail: function(err) {
that.$refs.uToast.show({type:'error',title: "暂不支持下载,请长按保存!"});
}
});
}else{

View File

@ -24,7 +24,7 @@
<view class="hs-second">
<u-section class="hss-lam" title="AI工具" sub-title="更多"
font-size="50" />
font-size="50" @click="$emit('handleChangeService')"/>
<view class="hss-scroll">
<view class="hss-left" @click="scrollTo(0)" v-show="showScroll[0]">
<u-icon name="arrow-left" size="34"></u-icon>

View File

@ -1,6 +1,6 @@
<template>
<view>
<!-- <el-container class="pc-container">
<el-container class="pc-container">
<view class="pc-header">
<Header ref="header" :currentPage="refs[current]" :isLogin="isLogin" @changePlat="changePlat" />
</view>
@ -12,14 +12,14 @@
<Loading :show="loading" />
<u-back-top class="back-top" :scrollTop="scrollTop" zIndex="100" :iconStyle="{ color: '#fff', fontSize: '50rpx' }"
:customStyle="{background: 'linear-gradient(180deg, #96fe11 0%, #f0fdbf 100%)',
filter: 'opacity(0.96)', width: '120rpx', height: '120rpx'}" /> -->
<view class="all-diabled" :style="{backgroundImage: `url(${fileUrl+pcBackground})`}">
filter: 'opacity(0.96)', width: '120rpx', height: '120rpx'}" />
<!-- <view class="all-diabled" :style="{backgroundImage: `url(${fileUrl+pcBackground})`}">
<image class="all-sleep" :src="fileUrl+sleep"></image>
<view class="all-content">
PC端开发中请移步移动端复制并打开以下网址
</view>
<text @click="copyUrl">{{ ip }}pixel/#/pages/mobile_web/index/index</text>
</view>
</view> -->
<u-toast ref="uToast"></u-toast>
</view>
</template>

View File

@ -15,7 +15,7 @@
<view class="we-content">
<u-input :placeholder="placeholder" v-model="defaultValue" :clearable="false" maxlength="300"
type="textarea" :custom-style="{ height: height+'rpx', fontSize: '25rpx', overflowY: 'scroll',
color: '#fff'}" placeholderStyle="color:#7f7c86" @input="input"/>
color: '#3f3f3f'}" placeholderStyle="color:#7f7c86" @input="input"/>
<view class="strengthen-tips">
<u-icon :name="rightIcon" size="30" :label="rightTip" @click="rightIconClick"
margin-left="10rpx" label-color="#a19daa" color="#a19daa" />
@ -109,9 +109,10 @@ export default {
align-items: center;
.u-icon{
margin-right: 24rpx;
filter: drop-shadow(0 0 2rpx #00a66f);
}
.slot{
color: #fff;
color: #84878c;
font-size: 32rpx;
font-weight: bold;
}
@ -119,18 +120,27 @@ export default {
.wet-right{
color: #d5ff00;
margin-right: 5rpx;
filter: drop-shadow(0 0 4rpx #00a66f);
.u-icon{
font-size: 25rpx;
cursor: pointer;
&:hover{
opacity: 0.8;
}
&:active{
opacity: 0.6;
}
}
}
}
.we-content{
margin: 20rpx 0;
// max-height: 150rpx;
background: #2a233d;
background: #fff;
border-radius: 30rpx;
padding: 30rpx 30rpx 20rpx;
box-shadow: 0 0 8rpx #eee;
border: 2rpx solid #bcc1c8;
box-shadow: 0 0 10rpx #eee;
position: relative;
.u-input{
height: 170rpx;
@ -139,7 +149,16 @@ export default {
display: flex;
align-items: center;
justify-content: flex-end;
text-shadow: 0 0 4rpx #7f7c86;
text-shadow: 0 0 4rpx #abafb6;
.u-icon{
cursor: pointer;
&:hover{
opacity: 0.8;
}
&:active{
opacity: 0.6;
}
}
}
.we-loading{
position: absolute;
@ -153,6 +172,9 @@ export default {
justify-content: center;
background-color: rgba(254,254,254,0.3);
}
&:hover{
border-color: #8c9095;
}
}
}
</style>

View File

@ -23,12 +23,45 @@
<!-- 服务中心 -->
<view class="control-center">
<!-- 文生图 -->
<view v-if="!formData.resultFile && serviceItem.type===1">
<view class="cc-edit" v-if="serviceItem.type===1">
<EditorBox :height="200" :icon="ip+editorIcon" title="提示词"
v-model="formData.text" placeholder="请输入描述的提示词(限制300词)~~" rightIcon="question-circle"
v-model="serviceItem.text" placeholder="请输入描述的提示词(限制300词)~~" rightIcon="question-circle"
rightTip="使用教程" :rightIconClick="showTutorial" @strengthenTip="strengthenTip"/>
</view>
<view class="use-tips">使用提示{{ serviceItem.tips || '智能创作~' }}</view>
<!-- 生成艺术字 -->
<view class="cc-edit" v-if="serviceItem.type===3">
<u-section title="艺术字" color="#84878c" :right="false" lineColor="#c2ea04" fontSize="34" />
<u-input :customStyle="{color:'#333',fontSize:'50rpx',height:'100rpx'}" v-model="serviceItem.text"
placeholder="请输入需要生成的文字" trim inputAlign="center" :clearable="false" :maxlength="6" class="art-input"/>
</view>
<view class="cc-edit" v-if="serviceItem.type===3">
<EditorBox :height="200" :icon="ip+editorIcon" title="提示词"
v-model="serviceItem.promt" placeholder="请输入描述的提示词(限制300词)~~" rightIcon="question-circle"
rightTip="使用教程" :rightIconClick="showTutorial" @strengthenTip="strengthenTip"/>
</view>
<view class="cc-edit" v-if="serviceItem.type===1">
<u-section title="尺寸选择" color="#84878c" :right="false" lineColor="#c2ea04" fontSize="34" />
<view class="dimensional-drawing">
<view class="dimensional-item" v-for="(item,index) in (serviceItem.id === 4 ? aliDimensions : volcengineDimensions)" :key="index"
:class="selectSizeIndex===index?'dimensional-item-select':''" @click="selectSize(index)">
<view :style="{ aspectRatio: item.value }"></view>
<text>{{ item.name }}</text>
</view>
</view>
</view>
<!-- 选项生图 -->
<view class="cc-edit" v-if="serviceItem.type===2||serviceItem.type===3 || serviceItem.type === 1">
<u-section title="类型选择" color="#84878c" :right="serviceItem.options.length>8" lineColor="#c2ea04" fontSize="34" @click="showMoreOptions = true"
subTitle="更多" :subColor="selectElementIndex>=getOptions.length ? '#b3a0da' : '#84878c'"></u-section>
<view class="section-options">
<view class="section-tags" v-for="(item,index) in getOptions" :key="item.id" :title="item.optionName"
:class="selectElementIndex===index?'section-tags-select':''" @click="selectElement(index)">
<image :src="getTypeImage(item.path)"></image>
<text>{{ item.optionName }}</text>
</view>
</view>
</view>
<view class="use-tips">Tips<view class="uset-content">{{ serviceItem.tips || '智能创作~' }}</view></view>
</view>
<!-- 服务底栏 -->
<view class="control-bottom">
@ -61,7 +94,7 @@
<el-upload class="upload-view" drag action="#" :auto-upload="false" ref="uploadCover"
:multiple="false" accept="image/*" list-type="picture-card" :class="{disabled:uploadDisabled}"
:on-change="selectImage" :file-list="formData.fileList" :disabled="formData.resultFile===''&&(serviceItem.type===3||serviceItem.type===1)">
<view class="ulview-block" v-if="formData.fileList&&formData.fileList.length === 0"
<view class="ulview-block" v-show="formData.uploadFile === ''&&formData.resultFile===''"
:style="formData.resultFile===''&&(serviceItem.type===3||serviceItem.type===1)?{opacity:0.6,cursor: 'default'}:{}">
<image class="upload-gif" :src="fileUrl+uploadCenter"></image>
<view class="upload-title">点击 / 拖拽上传图片</view>
@ -85,6 +118,12 @@
</view>
</template>
</el-upload>
<view class="tip-progress" v-if="asyncPollTime !== -1">
<text class="progress-title">进度</text>
<u-line-progress class="uline-progress" :percent="dealPercent" :show-percent="false" inactive-color="#ebecef" round/>
<text class="progress-deal">{{ dealPercent }}%</text>
</view>
<view class="error-tips" v-if="errorTips">失败原因{{ errorTips }}</view>
</view>
<!-- <Loading :show="loading"></Loading> -->
<u-toast ref="uToast"></u-toast>
@ -148,8 +187,11 @@ export default {
fileList: [],
uploadFile: '',//
resultFile: '',//
text: '',//
},
//
selectElementIndex: '',
//
showMoreOptions: false,
//
dealPercent: 0,
//
@ -160,6 +202,25 @@ export default {
asyncResult: false,
//
errorTips: '',
//
selectSizeIndex: '',
//
volcengineDimensions: [
{ name: "512*512", value: "1/1" },
{ name: "512*384", value: "4/3" },
{ name: "384*512", value: "3/4" },
{ name: "512*341", value: "3/2" },
{ name: "341*512", value: "2/3" },
{ name: "512*288", value: "16/9" },
{ name: "288*512", value: "9/16" },
],
//
aliDimensions: [
{ name: "1024*1024", value: "1/1" },
{ name: "720*1280", value: "9/16" },
{ name: "768*1152", value: "2/3" },
{ name: "1280*720", value: "16/9" },
]
}
},
beforeMount() {
@ -172,6 +233,14 @@ export default {
this.getRangeImages();
this.getServices();
},
computed: {
// 8
getOptions(){
let options = this.serviceItem.options;
const length = this.serviceItem.options.length;
return length > 8 ? options.slice(0,8) : options;
},
},
methods: {
//
async getServices(){
@ -214,6 +283,30 @@ export default {
},
//
changeWork(item,index){
let that = this;
//
if(this.asyncPollTime !== -1){
uni.showModal({
title: '提示',
content: `图片生成中,是否确认进行其他服务?`,
confirmColor: '#94d500',
success: (res) => {
if (res.confirm){
that.realRedraw();
that.realChangeWork(item, index);
}
}
});
//
} else if(this.formData.resultFile || Number(item.type) === this.serviceItem.type){
this.realRedraw();
this.realChangeWork(item, index);
} else {
this.realChangeWork(item, index);
}
},
//
realChangeWork(item,index){
if(this.serviceId === item.id) return;
this.serviceId = item.id;
this.$emit('changeService',item.id);
@ -246,6 +339,18 @@ export default {
}
}
},
//
getTypeImage(path){
if(path === null || path === ''){
return '/static/default-select.png';
}else if(path.startsWith("http")){
return path;
}else if(path.startsWith("/")){
return encodeURI(path);
}else{
return encodeURI(this.ip+path);
}
},
//
selectImage(file,uploadFiles){
let that = this;
@ -270,33 +375,28 @@ export default {
const currentType = this.serviceItem.type;
if(currentType !== 3 && currentType !== 1 && this.formData.uploadFile === ''){
this.$refs.uToast.show({type:'error',title: currentType === 4 ? "请选择模特!" : "请上传图片!"});
// this.dotLoading = false;
return false;
}
// if(currentType === 1){
// if(this.selectElementIndex === '' || !this.form.text){
// this.$refs.uToast.show({type:'error',title: "!"});
// // this.dotLoading = false;
// return false;
// }
// }
// if(currentType === 2 && this.selectElementIndex === ''){
// this.$refs.uToast.show({type:'error',title: "!"});
// // this.dotLoading = false;
// return false;
// }
// if(currentType === 3){
// if(this.selectElementIndex === '' || !this.form.text || !this.form.promt){
// this.$refs.uToast.show({type:'error',title: "!"});
// // this.dotLoading = false;
// return false;
// }
// }
if(currentType === 1){
if(this.selectElementIndex === '' || !this.serviceItem.text){
this.$refs.uToast.show({type:'error',title: "请完善信息!"});
return false;
}
}
if(currentType === 2 && this.selectElementIndex === ''){
this.$refs.uToast.show({type:'error',title: "请选择图片元素!"});
return false;
}
if(currentType === 3){
if(this.selectElementIndex === '' || !this.serviceItem.text || !this.serviceItem.promt){
this.$refs.uToast.show({type:'error',title: "请完善信息!"});
return false;
}
}
// if(currentType === 4){
// const { bottomImageUrl, topImageUrl } = this.$refs.dressRef.form;
// if(topImageUrl===''){
// this.$refs.uToast.show({type:'error',title: "!"});
// // this.dotLoading = false;
// return false;
// }
// }
@ -363,7 +463,10 @@ export default {
let image = this.rangeImageList[num]?.path;
this.formData.resultFile = length>0 ?
(image.startsWith("http") ? image : encodeURI(this.ip+image)) : path;
this.formData.fileList[0].url = this.formData.resultFile;
if(this.formData.fileList[0])
this.formData.fileList[0].url = this.formData.resultFile;
else this.formData.fileList = [{url: this.formData.resultFile}];
this.uploadDisabled = true;
},
//
getParams({id, type, options, text, promt}){
@ -375,29 +478,29 @@ export default {
imageUrl: that.formData.uploadFile,
}
break;
// case 1 :
// result = {
// serviceId: id,
// option: options[that.selectElementIndex].optionKey,
// text: text,
// }
// if(this.selectSizeIndex !== '') result.size = that.form.id === 4 ? that.aliDimensions[that.selectSizeIndex].name : that.volcengineDimensions[that.selectSizeIndex].name;
// break;
// case 2 :
// result = {
// serviceId: id,
// imageUrl: that.uploadFile,
// option: options[that.selectElementIndex].optionKey
// }
// break;
// case 3 :
// result = {
// serviceId: id,
// option: options[that.selectElementIndex].optionKey,
// text: text,
// promt: promt
// }
// break;
case 1 :
result = {
serviceId: id,
option: options[that.selectElementIndex].optionKey,
text: text,
}
if(this.selectSizeIndex !== '') result.size = that.serviceId === 4 ? that.aliDimensions[that.selectSizeIndex].name : that.volcengineDimensions[that.selectSizeIndex].name;
break;
case 2 :
result = {
serviceId: id,
imageUrl: that.formData.uploadFile,
option: options[that.selectElementIndex].optionKey
}
break;
case 3 :
result = {
serviceId: id,
option: options[that.selectElementIndex].optionKey,
text: text,
promt: promt
}
break;
// case 4 :
// const { bottomImageUrl, topImageUrl } = this.$refs.dressRef.form;
// result = {
@ -475,12 +578,17 @@ export default {
handleDelete(){
this.$refs.uploadCover.clearFiles();
this.formData.fileList = [];
this.formData.uploadFile = '';
setTimeout(()=>{
this.uploadDisabled = false;
},400);
},
//
download(){
if(!this.asyncResult){
this.$refs.uToast.show({type:'error',title: "图片生成失败,请重试!"});
return;
}
window.open(this.formData.resultFile);
},
//
@ -501,6 +609,10 @@ export default {
this.handleDelete();
this.formData.resultFile = '';
this.formData.uploadFile = '';
delete this.serviceItem.text;
delete this.serviceItem.promt;
this.selectElementIndex = '';
this.selectSizeIndex = '';
// if(this.form.type === 4) this.$refs.dressRef.resetForm();
this.errorTips = '';
this.asyncPollTime = -1;
@ -511,7 +623,15 @@ export default {
if(this.asyncPollTime !== -1){
this.setResultFile();
}
}
},
//
selectElement(index){
this.selectElementIndex = this.selectElementIndex === index ? '' : index;
},
//
selectSize(index){
this.selectSizeIndex = this.selectSizeIndex === index ? '' : index;
},
}
}
</script>
@ -572,7 +692,7 @@ export default {
.controls-right{
flex: 1;
height: 100%;
background-color: rgba(248,248,248,0.7);
// background-color: rgba(248,248,248,0.7);
display: flex;
flex-direction: column;
.control-top{
@ -599,13 +719,159 @@ export default {
.control-center{
flex: 1;
overflow-y: scroll;
// background-color: #99d7ff;
background-color: rgba(248,248,248,0.7);
padding: 40rpx;
display: flex;
flex-direction: column;
position: relative;
.cc-edit{
margin-bottom: 40rpx;
.art-input{
margin: 20rpx 0 10rpx;
border-radius: 20rpx;
box-shadow: 0 0 10rpx #d0d6dd;
border: 2rpx solid #858585;
}
.dimensional-drawing{
width: 710rpx;
height: 180rpx;
margin-top: 20rpx;
margin-bottom: 30rpx;
display: flex;
padding: 0 10rpx 0 0;
overflow-x: scroll;
.dimensional-item{
min-width: 160rpx;
height: 100%;
padding: 0 0 18rpx;
background-color: #eff0f4;
border-radius: 20rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
color: #b3a0da;
margin-right: 30rpx;
cursor: pointer;
&:nth-last-child(1){
margin-right: 0;
}
text{
width: 100%;
text-align: center;
margin-top: 20rpx;
}
view{
opacity: 0.7;
border-radius: 10rpx;
width: 54rpx;
border: 6rpx solid #aea4ee;
aspect-ratio: 1/1;
}
&:hover{
border: 2rpx solid #b3a0da;
view{
opacity: 1;
box-shadow: 0 0 8rpx #aea4ee;
}
text{
text-shadow: 0 0 2rpx #aea4ee;
}
}
}
.dimensional-item-select{
border: 2rpx solid #b3a0da;
view{
opacity: 1;
box-shadow: 0 0 8rpx #aea4ee;
}
text{
text-shadow: 0 0 2rpx #aea4ee;
}
}
}
.section-options{
// margin-top: 40rpx;
display: grid;
grid-gap: 26rpx;
grid-template-columns: repeat(4,1fr);
margin-top: 20rpx;
margin-bottom: 30rpx;
.section-tags{
height: 200rpx;
width: 150rpx;
background-color: #ebecef;
border-radius: 20rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
color: #b3a0da;
cursor: pointer;
text{
width: 90%;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
image{
opacity: 0.7;
border-radius: 20rpx;
width: 130rpx;
height: 130rpx;
}
&:hover{
border: 2rpx solid #b3a0da;
image{
opacity: 1;
}
}
}
.section-tags-select{
border: 2rpx solid #b3a0da;
image{
opacity: 1;
}
}
}
::v-deep .u-section__right-info{
cursor: pointer;
&:hover{
opacity: 0.8;
}
&:active{
opacity: 0.6;
}
}
}
.use-tips{
margin: -10rpx;
border-radius: 20rpx;
font-size: 30rpx;
color: #6b6b6b;
color: #101010;
background-color: #eff0f4;
padding: 30rpx;
font-weight: bold;
transition: 0.3s;
.uset-content{
color: #6b6b6b;
font-weight: normal;
margin-top: 20rpx;
padding-left: 20rpx;
}
&:hover{
box-shadow: 0 0 10rpx #b3b4b6;
}
}
}
.control-bottom{
@ -693,6 +959,7 @@ export default {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
.upload-view{
border: 4rpx dashed #99d7ff;
border-radius: 40rpx;
@ -768,6 +1035,36 @@ export default {
}
}
}
.tip-progress{
margin: 20rpx 0 -50rpx;
display: flex;
align-items: center;
width: 50%;
.progress-title{
margin-right: 20rpx;
white-space: nowrap;
}
.progress-deal{
margin-left: 20rpx;
}
text{
background-image: linear-gradient(to right, #d3e7e7 0%, #a7b6b8 100%);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
::v-deep .u-active{
border-top-right-radius: 100rpx;
border-bottom-right-radius: 100rpx;
box-shadow: 0 0 20rpx #d3e7e7;
background: linear-gradient(to right, #96a3a5 0%, #d3e7e7 100%);
}
}
.error-tips{
font-size: 30rpx;
color: rgba(229, 64, 70, 1);
margin: 20rpx 0 -50rpx;
}
}
}
::v-deep .el-popper[x-placement^=top]{