|
@@ -203,6 +203,27 @@
|
|
|
},
|
|
|
],
|
|
|
timeOut:20000, //超时时间
|
|
|
+ subType:0,
|
|
|
+ currentImg:null,
|
|
|
+ reqList:[
|
|
|
+ {
|
|
|
+ model:'batouresearch/sdxl-controlnet-lora',
|
|
|
+ aiPicId:'',
|
|
|
+ },{
|
|
|
+ model:'lucataco/sdxl-controlnet',
|
|
|
+ aiPicId:'',
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ reqListReset:[
|
|
|
+ {
|
|
|
+ model:'deployments/elabgroup/elab-sdxl-controlnet-lora',
|
|
|
+ aiPicId:'',
|
|
|
+ },{
|
|
|
+ model:'batouresearch/sdxl-controlnet-lora',
|
|
|
+ aiPicId:'',
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ dialogVisible: false
|
|
|
}
|
|
|
},
|
|
|
props:{
|
|
@@ -605,7 +626,7 @@
|
|
|
return false
|
|
|
}
|
|
|
let imgUrl = this.styleList[this.curStyleIndex].imgUrl;
|
|
|
-
|
|
|
+ let subType = this.subType;
|
|
|
let session_hash = Date.now();
|
|
|
let theme = this.themeList[this.themeIndex];//主题数据
|
|
|
let prompt = this.styleList[this.curStyleIndex].prompt + theme.prot;
|
|
@@ -631,8 +652,17 @@
|
|
|
keyword: "replicate",
|
|
|
model: this.modelType==1? "lucataco/ssd-1b" : 'catio-apps/controlnet-interior-design',
|
|
|
};
|
|
|
- this.timeOut = this.modelType==1? 20000: 40000;
|
|
|
+ this.timeOut = this.modelType==1? 20000: 50000;
|
|
|
+ if(this.modelType==2){//精准设计且当次新开始
|
|
|
+ if(subType == 0){//首次
|
|
|
+ parmas.model = this.reqList[0].model;
|
|
|
+ }else{//重试
|
|
|
+ parmas.model = this.reqListReset[0].model;
|
|
|
+ }
|
|
|
+ this.otherHandle(parmas);
|
|
|
+ }
|
|
|
let res = await requestConfig("generateTaskImgToImgForAliyun", parmas);
|
|
|
+
|
|
|
console.log("图生图结果:", res);
|
|
|
if(this.$parent.pvCurPageName!="room_show"){//说明用户切换页面了
|
|
|
console.warn("***用户已经退出页面***")
|
|
@@ -640,18 +670,16 @@
|
|
|
}
|
|
|
let that = this;
|
|
|
if (res.success && res.single) {
|
|
|
- if(typeof(res.single)=="object"){
|
|
|
- let cot = res.single.queueCount || 1;
|
|
|
- this.showToast("正有"+cot+"人排队,预计等待"+cot*25+"秒",10000);
|
|
|
- this.aiImage = "";
|
|
|
- this.aiFlag = false;
|
|
|
- this.clearInterval();
|
|
|
- return false;
|
|
|
- }
|
|
|
this.taskId = res.single;
|
|
|
+ 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();
|
|
@@ -665,6 +693,25 @@
|
|
|
this.showToast("渲染失败,请重试")
|
|
|
}
|
|
|
},
|
|
|
+ otherHandle(parmas){
|
|
|
+ let reqList = [];
|
|
|
+ if(this.subType == 0){//首次
|
|
|
+ reqList = this.reqList;
|
|
|
+ }else{//重试
|
|
|
+ reqList = this.reqListReset;
|
|
|
+ }
|
|
|
+ reqList.forEach(async (it,index)=>{
|
|
|
+ let _data = JSON.parse(JSON.stringify(parmas));
|
|
|
+ if(index>0){
|
|
|
+ _data.model = it.model;
|
|
|
+ let res = await requestConfig("generateTaskImgToImgForAliyun", _data);
|
|
|
+ if (res.success) {
|
|
|
+ console.log('生成结果123:', res);
|
|
|
+ it.aiPicId = res.single || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
//设置一个超时逻辑,到底指定时间后停止轮询,当前是90s
|
|
|
setOutTimer() {
|
|
|
if (this.outTimer) {
|
|
@@ -675,24 +722,72 @@
|
|
|
this.outTimer = setTimeout(function() {
|
|
|
if (self.img2imgTimer) {
|
|
|
self.clearInterval();//停止轮询
|
|
|
- self.$message.warning("AI开了个小差,请稍后再试");
|
|
|
+ // self.$message.warning("AI开了个小差,请稍后再试");
|
|
|
+ uni.showModal({
|
|
|
+ title: "提醒",
|
|
|
+ content: "当前AI使用火爆,请继续尝试",
|
|
|
+ confirmText: "继续尝试",
|
|
|
+ cancelText: "取消等待",
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户点击确定')
|
|
|
+ self.subType = 1;
|
|
|
+ self.submitAction();
|
|
|
+ } else if (res.cancel) {
|
|
|
+ console.log('用户点击取消')
|
|
|
+ self.subType = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
clearTimeout(self.outTimer);
|
|
|
self.outTimer = null
|
|
|
}, this.timeOut);
|
|
|
},
|
|
|
+ confirmHandle(){
|
|
|
+ console.log('用户点击确定')
|
|
|
+ this.subType = 1;
|
|
|
+ this.submitAction();
|
|
|
+ },
|
|
|
+ cancelHandle(){
|
|
|
+ console.log('用户点击取消')
|
|
|
+ this.subType = 0;
|
|
|
+ },
|
|
|
// 轮询获取图片结果
|
|
|
async getResultForImgToImg() {
|
|
|
+ if(this.modelType==2){//精准设计且当次新开始
|
|
|
+ let reqList = [];
|
|
|
+ if(this.subType == 0){//首次
|
|
|
+ reqList = this.reqList;
|
|
|
+ }else{//重试
|
|
|
+ reqList = this.reqListReset;
|
|
|
+ }
|
|
|
+ reqList.forEach((item,index) => {
|
|
|
+ this.singleHandle(item)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ this.singleHandle({})
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async singleHandle(model){
|
|
|
+ if(!model || !model.aiPicId){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
var parmas = {
|
|
|
- id: this.taskId,
|
|
|
+ id: model.aiPicId,
|
|
|
};
|
|
|
let res = await requestConfig("generateProcess", parmas);
|
|
|
// let lastPage = getCurrentPages()[getCurrentPages().length - 2] ? getCurrentPages()[getCurrentPages().length - 2].$vm : null;
|
|
|
// console.warn("图生图轮询结果:", res);
|
|
|
if (res.success && res.single) {
|
|
|
+ if(this.currentImg){//当前已经有生成图了
|
|
|
+ console.warn("***当前已经有生成图了***")
|
|
|
+ return false;
|
|
|
+ }
|
|
|
if (res.single.inQueue == false) {
|
|
|
if (res.single.urls) {
|
|
|
- // uni.hideLoading();
|
|
|
+ this.currentImg = true;
|
|
|
this.aiFlag = false;
|
|
|
this.random = 100;
|
|
|
console.warn("图生图轮询结束: ", res);
|
|
@@ -752,7 +847,8 @@
|
|
|
this.aiImage = "";
|
|
|
this.clearInterval();
|
|
|
}else {
|
|
|
- this.random = parseInt(this.count * 2);
|
|
|
+ // this.random = parseInt(this.count * 2);
|
|
|
+ this.random = parseInt(this.count * 100/(this.timeOut/1000));
|
|
|
if(this.random>=100){
|
|
|
this.random = 99;
|
|
|
}
|
|
@@ -763,15 +859,10 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- let cot = res.single.queueCount || 1;
|
|
|
- this.showToast("正有"+cot+"人排队,预计等待"+cot*25+"秒",10000);
|
|
|
- this.aiImage = "";
|
|
|
- this.aiFlag = false;
|
|
|
- this.clearInterval();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
showToast(title,time=3000){
|
|
|
this.$store.state.loading = true;
|
|
|
this.$store.state.loadingMsg = title || "";
|