|
@@ -628,11 +628,44 @@
|
|
|
self.startServer();
|
|
|
}
|
|
|
},
|
|
|
+ //前置逻辑
|
|
|
+ async prevHandle(parmas){
|
|
|
+ return '';//暂不需要开启
|
|
|
+ //不是首次请求,则无需前置判断 用户上传的也不需要前置处理
|
|
|
+ if(this.subType!=0 || this.userInput){
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
+ let imgRes = await requestConfig("generateTaskImgToImgForAliyun", parmas);
|
|
|
+ if (imgRes.success) {
|
|
|
+ let aiPicId = imgRes.single || '';
|
|
|
+ let res = await requestConfig('generateProcess', {
|
|
|
+ id: aiPicId
|
|
|
+ })
|
|
|
+ if (res.success && res.single) {
|
|
|
+ if(res.single.category == 'scheduler'){//命中了
|
|
|
+ let resultImg = res.single.urls[0];
|
|
|
+ resolve(resultImg);
|
|
|
+ }else{
|
|
|
+ resolve('');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ resolve('');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ resolve('');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
//开始图生图流程
|
|
|
async startServer() {
|
|
|
if(!this.styleList || this.curStyleIndex < 0 || !this.styleList[this.curStyleIndex].imgUrl){
|
|
|
return false
|
|
|
}
|
|
|
+ if(this.$parent.pvCurPageName!="room_show"){//说明用户切换页面了
|
|
|
+ console.warn("***用户已经退出页面***")
|
|
|
+ return false;
|
|
|
+ }
|
|
|
let imgUrl = this.styleList[this.curStyleIndex].imgUrl;
|
|
|
let subType = this.subType;
|
|
|
let session_hash = Date.now();
|
|
@@ -642,6 +675,7 @@
|
|
|
let unit = 768 / this.screenWidth;
|
|
|
this.imageWidth = parseInt((this.screenWidth * unit).toFixed());
|
|
|
this.imageHeight = parseInt((this.$parent.canvasHeight * unit).toFixed());
|
|
|
+ this.timeOut = this.modelType==1? 20000: 50000;
|
|
|
var parmas = {
|
|
|
negativePrompt: noPromot,
|
|
|
prompt: prompt,
|
|
@@ -660,49 +694,85 @@
|
|
|
keyword: "replicate",
|
|
|
model: this.modelType==1? "lucataco/ssd-1b" : 'catio-apps/controlnet-interior-design',
|
|
|
};
|
|
|
- this.timeOut = this.modelType==1? 20000: 50000;
|
|
|
- if(this.modelType==2){//精准设计且当次新开始
|
|
|
+ if(this.modelType==2){//精准设计
|
|
|
if(subType == 0){//首次
|
|
|
parmas.model = this.reqList[0].model;
|
|
|
}else{//重试
|
|
|
parmas.model = this.reqListReset[0].model;
|
|
|
}
|
|
|
- this.otherHandle(parmas);
|
|
|
+ }else{//创意设计
|
|
|
+ if(subType == 0){//首次
|
|
|
+ parmas.model = "lucataco/ssd-1b";
|
|
|
+ }else{//重试
|
|
|
+ parmas.model = "deployments/elabgroup/elab-ssd-1b";
|
|
|
+ }
|
|
|
}
|
|
|
- let res = await requestConfig("generateTaskImgToImgForAliyun", parmas);
|
|
|
-
|
|
|
- console.log("图生图结果:", res);
|
|
|
- if(this.$parent.pvCurPageName!="room_show"){//说明用户切换页面了
|
|
|
- console.warn("***用户已经退出页面***")
|
|
|
+ let result = await this.prevHandle(parmas);
|
|
|
+ console.warn("***prevHandle***",result)
|
|
|
+ if(result && result.length>0){
|
|
|
+ this.randomHandle(result)
|
|
|
return false;
|
|
|
- }
|
|
|
- let that = this;
|
|
|
- if (res.success && res.single) {
|
|
|
- this.taskId = res.single;
|
|
|
+ }else{
|
|
|
if(this.modelType==2){//精准设计
|
|
|
- if(subType == 0){//首次
|
|
|
- this.reqList[0].aiPicId = this.taskId;
|
|
|
- }else{//重试
|
|
|
- this.reqListReset[0].aiPicId = this.taskId;
|
|
|
- }
|
|
|
+ this.otherHandle(parmas);//发送其他AI请求
|
|
|
}
|
|
|
- if (!this.img2imgTimer) {
|
|
|
- this.count = 0;
|
|
|
- this.random = 1;
|
|
|
- this.currentImg = false;//当次生成图还没有结果
|
|
|
- this.img2imgTimer = setInterval(() => {
|
|
|
- this.count ++;
|
|
|
- this.getResultForImgToImg();
|
|
|
- }, 1000);
|
|
|
- this.setOutTimer();
|
|
|
+ let res = await requestConfig("generateTaskImgToImgForAliyun", parmas);
|
|
|
+ console.log("图生图结果:", res);
|
|
|
+ let that = this;
|
|
|
+ if (res.success && res.single) {
|
|
|
+ this.taskId = res.single;
|
|
|
+ if(this.modelType==2){//精准设计
|
|
|
+ if(subType == 0){//首次
|
|
|
+ this.reqList[0].aiPicId = this.taskId;
|
|
|
+ }else{//重试
|
|
|
+ this.reqListReset[0].aiPicId = this.taskId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!this.img2imgTimer) {
|
|
|
+ this.count = 0;
|
|
|
+ this.random = 1;
|
|
|
+ this.currentImg = false;//当次生成图还没有结果
|
|
|
+ this.img2imgTimer = setInterval(() => {
|
|
|
+ this.count ++;
|
|
|
+ this.getResultForImgToImg();
|
|
|
+ }, 1000);
|
|
|
+ this.setOutTimer();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.clearInterval()
|
|
|
+ this.aiFlag = false;
|
|
|
+ this.aiImage = "";
|
|
|
+ this.showToast("渲染失败,请重试")
|
|
|
}
|
|
|
- }else{
|
|
|
- this.clearInterval()
|
|
|
- this.aiFlag = false;
|
|
|
- this.aiImage = "";
|
|
|
- this.showToast("渲染失败,请重试")
|
|
|
}
|
|
|
},
|
|
|
+ //随机处理
|
|
|
+ randomHandle(resultImg){
|
|
|
+ if(this.timer || !resultImg){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let self = this;
|
|
|
+ var count = 1;
|
|
|
+ var process = 0;//进度
|
|
|
+ var randomNum = Math.floor(Math.random() * 4 + 5);//5-8随机数
|
|
|
+ this.img2imgTimer = setInterval(function() {
|
|
|
+ process = parseInt(count * 100/(randomNum));
|
|
|
+ if(process>=100){
|
|
|
+ process = 99;
|
|
|
+ }
|
|
|
+ if (count < randomNum) {//没有到上限
|
|
|
+ if(!self.showAIImage){
|
|
|
+ // this.$store.state.loadingMsg='生成中…' + this.random + '%';
|
|
|
+ self.loadingMsg = '生成中…' + process + '%';
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ self.myloading = false;
|
|
|
+ self.resultHandle(resultImg);
|
|
|
+ }
|
|
|
+ count = count + 1;
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+
|
|
|
otherHandle(parmas){
|
|
|
let reqList = [];
|
|
|
if(this.subType == 0){//首次
|