Skip to content

Commit ceee81d

Browse files
author
legionfu
committed
v2.1.0
1 parent c6b2e7c commit ceee81d

File tree

6 files changed

+132
-88
lines changed

6 files changed

+132
-88
lines changed

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.1.0
2+
3+
### Bug Fixes:
4+
* py实现与js一样的创建组件编号,优化导入逻辑,部分dropdown组件改由py处理,降低UI面板无限转圈概率。
5+
* 修复了一些已知的问题。
6+
17
## 2.0.4
28

39
### Bug Fixes:

javascript/state.core.js

Lines changed: 69 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ state.core = (function () {
8686
fetch('/lightdiffusionflow/local/need_preload')
8787
.then(response => response.json())
8888
.then(data => {
89-
//console.log(`fn_timer ${data}`)
89+
//console.log(`fn_timer`)
9090
if (data != ""){
9191
//state.core.actions.handleLightDiffusionFlow([{"name":data}]);
9292
const btn1 = gradioApp().querySelector(`button#set_lightdiffusionflow_file`);
@@ -168,7 +168,6 @@ state.core = (function () {
168168
}
169169

170170
function load(config) {
171-
172171
config.hasSetting = hasSetting
173172

174173
//loadUI(); // 往页面上添加按钮
@@ -481,8 +480,9 @@ state.core = (function () {
481480
// alert('All state values deleted!');
482481
// }
483482
// },
484-
applyState: function () {
485-
fetch('/lightdiffusionflow/local/config.json?_=' + (+new Date()))
483+
applyState: async function () {
484+
console.log("applyState")
485+
await fetch('/lightdiffusionflow/local/config.json?_=' + (+new Date()))
486486
.then(response => response.json())
487487
.then(config => {
488488
try {
@@ -644,7 +644,6 @@ state.core = (function () {
644644
actions.output_log("Please select a valid lightdiffusionflow or image file!")
645645
return;
646646
}
647-
console.log(json_obj)
648647

649648
forEachElement_WithoutTabs(IMAGES_WITHOUT_PREFIX, (image_id) => {
650649
json_obj[image_id] = ""
@@ -653,58 +652,84 @@ state.core = (function () {
653652
store.clear();
654653
store.load(json_obj);
655654
actions.applyState();
656-
657655
return;
658656
},
659657
startImportImage: function (index){
658+
index = Number(index)
659+
660+
if(index+1 < img_elem_keys.length){
661+
//console.log(`---------${img_elem_keys}---------------`)
662+
//console.log(`---------${index}-----${img_elem_keys.length}-----------`)
663+
switch_tab_dict = {
664+
"txt2img_invisible_img2img_image": "switch_to_img2img()",
665+
"txt2img_invisible_img2img_sketch": "switch_to_sketch()",
666+
"txt2img_invisible_img2maskimg": "switch_to_inpaint()",
667+
"txt2img_invisible_inpaint_sketch": "switch_to_inpaint_sketch()",
668+
"txt2img_invisible_img_inpaint_base": "state.utils.switch_to_img_inpaint()",
669+
"txt2img_invisible_img_inpaint_mask": "state.utils.switch_to_img_inpaint()",
670+
"txt2img_invisible_txt2img_controlnet_ControlNet_input_image": "state.utils.switch_to_txt2img_ControlNet(0)",
671+
"txt2img_invisible_img2img_controlnet_ControlNet_input_image": "state.utils.switch_to_img2img_ControlNet(0)"
672+
}
673+
674+
for (let i = 0; i < 10; i++) {
675+
switch_tab_dict[`txt2img_invisible_txt2img_controlnet_ControlNet-${i}_input_image`] = `state.utils.switch_to_txt2img_ControlNet(${i})`
676+
switch_tab_dict[`txt2img_invisible_img2img_controlnet_ControlNet-${i}_input_image`] = `state.utils.switch_to_img2img_ControlNet(${i})`
677+
}
660678

661-
console.log(`---------${img_elem_keys}---------------`)
662-
console.log(`---------${index}-----${img_elem_keys.length}-----------`)
663-
switch_tab_dict = {
664-
"txt2img_invisible_img2img_image": "switch_to_img2img()",
665-
"txt2img_invisible_img2img_sketch": "switch_to_sketch()",
666-
"txt2img_invisible_img2maskimg": "switch_to_inpaint()",
667-
"txt2img_invisible_inpaint_sketch": "switch_to_inpaint_sketch()",
668-
"txt2img_invisible_img_inpaint_base": "state.utils.switch_to_img_inpaint()",
669-
"txt2img_invisible_img_inpaint_mask": "state.utils.switch_to_img_inpaint()",
670-
"txt2img_invisible_txt2img_controlnet_ControlNet_input_image": "state.utils.switch_to_txt2img_ControlNet(0)",
671-
"txt2img_invisible_img2img_controlnet_ControlNet_input_image": "state.utils.switch_to_img2img_ControlNet(0)"
672-
}
673-
674-
for (let i = 0; i < 10; i++) {
675-
switch_tab_dict[`txt2img_invisible_txt2img_controlnet_ControlNet-${i}_input_image`] = `state.utils.switch_to_txt2img_ControlNet(${i})`
676-
switch_tab_dict[`txt2img_invisible_img2img_controlnet_ControlNet-${i}_input_image`] = `state.utils.switch_to_img2img_ControlNet(${i})`
679+
state.utils.sleep(300).then(() => {
680+
try{
681+
key = "txt2img_invisible_"+img_elem_keys[index+1]
682+
eval( switch_tab_dict[key] ) // 跳转界面
683+
const button = gradioApp().getElementById(key);
684+
button.click();
685+
} catch (error) {
686+
console.warn('[startImportImage]: Error:', error);
687+
if(index+1 < img_elem_keys.length){
688+
// 图片组件设置出错了,但是需要继续后续的流程
689+
690+
index = img_elem_keys.length-1
691+
}
692+
}
693+
});
677694
}
678695

679-
state.utils.sleep(300).then(() => {
680-
try{
681-
key = "txt2img_invisible_"+img_elem_keys[Number(index)+1]
682-
//console.log(key)
683-
eval( switch_tab_dict[key] ) // 跳转界面
684-
const button = gradioApp().getElementById(key);
685-
button.click();
686-
} catch (error) {
687-
console.warn('[startImportImage]: Error:', error);
688-
}
689-
});
690-
691-
if(Number(index)+1 >= img_elem_keys.length){ // 图片导入完成
692-
console.log(lightdiffusionflow_set_dropdowns)
693-
const button = gradioApp().getElementById("lightdiffusionflow_set_dropdowns");
694-
button.click();
696+
switch(index+1 - img_elem_keys.length){
697+
case 0:// 图片导入完成,开始导入Dropdown
698+
state.utils.sleep(500).then(() => {
699+
try{
700+
const button = gradioApp().getElementById("lightdiffusionflow_set_dropdowns");
701+
button.click();
702+
} catch (error) {
703+
console.warn('[set_dropdowns]: Error:', error);
704+
}
705+
});
706+
break
707+
// case 1:// 触发了导入Dropdown,现在导入其他参数会卡死,触发导入按钮,等下一轮正式开始导入
708+
// state.utils.sleep(500).then(() => {
709+
// const button = gradioApp().getElementById("lightdiffusionflow_set_js_params");
710+
// console.log("lightdiffusionflow_set_js_params")
711+
// button.click();
712+
// });
713+
// break
714+
// case 2:// 导入其他参数
715+
// state.utils.sleep(500).then(() => {
716+
// console.log("导入其他参数")
717+
// actions.applyState();
718+
// });
719+
// break
695720
}
696721

697722
},
698-
output_log: function (msg, style=""){
699-
fetch(`/lightdiffusionflow/local/output_log?msg=${msg}&style=${style}`).then(() => {
723+
output_log: function (msg, msg_style=""){
724+
fetch(`/lightdiffusionflow/local/output_log?msg=${msg}&style=${msg_style}`).then(() => {
700725
gradioApp().getElementById("txt2img_invisible_refresh_log").click();
701726
});
702727
},
703-
output_warning: function (msg, style="color:Orange;"){
704-
actions.output_log(msg,style)
728+
output_warning: function (msg, msg_style="color:Orange;"){
729+
actions.output_log(msg,msg_style)
705730
},
706-
output_error: function (msg, style="color:Tomato;"){
707-
actions.output_log(msg,style)
731+
output_error: function (msg, msg_style="color:Tomato;"){
732+
actions.output_log(msg,msg_style)
708733
}
709734
};
710735

javascript/state.ext.general.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function general_ext(tab_name, extension_name, root_container) {
116116
textarea.addEventListener('change', function () {
117117
let text = this.value;
118118
store.set(id, text);
119-
console.log(`id = ${id} value = ${text}`)
119+
//console.log(`id = ${id} value = ${text}`)
120120
});
121121
}
122122
function handleTextAreas() {
@@ -418,7 +418,7 @@ function general_ext_main(tab){
418418
reg = /(.+) v[0-9\.]+/
419419
if(reg.test(title)){title = RegExp.$1} // 匹配 xxx v0.0.0 格式的标题,把后半部分的版本号去掉
420420

421-
//if(title == "ControlNet"){title = "Control Net"} // 兼容旧命名
421+
if(title == "ControlNet"){title = "Control Net"} // 兼容旧命名
422422

423423
let ext_name = title.replace(" ","-").toLowerCase()
424424
console.log(ext_name)

javascript/state.utils.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,20 @@ state.utils = {
306306
let child = accordion.querySelector('div.cursor-pointer, .label-wrap');
307307
if (value) {
308308
//for(child of children){
309-
if(child.className.split(' ').pop() != "open"){
309+
let span = child.querySelector('.transition, .icon');
310+
if(span.style.transform !== 'rotate(90deg)'){
311+
//if(child.className.split(' ').pop() != "open"){
310312
state.utils.triggerMouseEvent(child, 'click')
311313
}
312314
//}
313315
}
314316

315317
setTimeout(() => {
316318
state.utils.onContentChange(child, function (el) {
317-
store.set(id, el.className.split(' ').pop() == "open");
319+
//store.set(id, el.className.split(' ').pop() == "open");
320+
//console.log(`accordion on change ${id}`)
321+
let span = el.querySelector('.transition, .icon');
322+
store.set(id, span.style.transform !== 'rotate(90deg)');
318323
});
319324
}, 150);
320325

@@ -405,7 +410,7 @@ state.utils = {
405410

406411
state.utils.triggerMouseEvent(input, 'blur');
407412
selectingQueue -= 1;
408-
console.log(`selectingQueue = ${selectingQueue}`)
413+
//console.log(`selectingQueue = ${selectingQueue}`)
409414
}, 100);
410415

411416
}, selectingQueue * 200)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lightdiffusionflow_version = "v2.0.4"
1+
lightdiffusionflow_version = "v2.1.0"

0 commit comments

Comments
 (0)