Skip to content

Commit 90038f1

Browse files
author
legionfu
committed
v2.1.4
1 parent be97de1 commit 90038f1

File tree

5 files changed

+57
-51
lines changed

5 files changed

+57
-51
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
## 2.1.4
22

33
### Features:
4+
* 增加本地保存Flow配置功能,可直接下拉列表选择已保存的Flow文件。(导入或使用新flow之前,建议先刷新页面,目前插件暂时没有重置参数的功能)
45
* 增加记录额外LoRA模型数据,以便导入时从Civitai搜索缺失的lora模型。
6+
* 模型模糊匹配优化,增加匹配子文件夹下的模型。
57

68
### Bug Fixes:
79
* 修复了部分已知的参数设置失败的问题,如ControlNet在Canny模式下的"Canny Low/Hight Threshold"等参数。

javascript/state.core.js

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -723,13 +723,13 @@ state.core = (function () {
723723

724724
state.utils.saveFile(filename, stored_config);
725725

726-
// fetch('https://api.lightflow.ai/openapi/access?action=export')
727-
// .then(response => response.json())
728-
// .then(config => {
729-
// console.log(config)
730-
// }).catch(function(e) {
731-
// console.log("Oops, export callback error!");
732-
// });
726+
fetch('https://api.lightflow.ai/openapi/access?action=export')
727+
.then(response => response.json())
728+
.then(config => {
729+
console.log(config)
730+
}).catch(function(e) {
731+
console.log("Oops, export callback error!");
732+
});
733733

734734
}
735735

@@ -772,22 +772,28 @@ state.core = (function () {
772772
fetch(`/lightdiffusionflow/local/file_exist`, data)
773773
.then(response => response.json())
774774
.then(data => {
775-
console.log("file_exist")
776-
console.log(data)
777-
if(!data || (data && confirm("Overwrite the existing file with the same name?")))
778-
{
779-
let stored_config = get_js_local_data()
780-
data = {
781-
method: 'POST',
782-
headers: {'Content-Type': 'application/json'},
783-
body: JSON.stringify({
784-
"file_name":filename,
785-
"file_data":stored_config,
786-
"overwrite":true
787-
})
788-
}
789-
fetch("/lightdiffusionflow/local/save_flow_to_local",data)
775+
if(!data || (data && confirm("Overwrite the existing file with the same name?")))
776+
{
777+
let stored_config = get_js_local_data()
778+
let flow_data = {
779+
method: 'POST',
780+
headers: {'Content-Type': 'application/json'},
781+
body: JSON.stringify({
782+
"file_name":filename,
783+
"file_data":stored_config,
784+
"overwrite":true
785+
})
790786
}
787+
fetch("/lightdiffusionflow/local/save_flow_to_local",flow_data)
788+
789+
fetch('https://api.lightflow.ai/openapi/access?action=save')
790+
.then(response => response.json())
791+
.then(config => {
792+
console.log(config)
793+
}).catch(function(e) {
794+
console.log("Oops, export callback error!");
795+
});
796+
}
791797
});
792798
}
793799
},

javascript/state.utils.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ state.utils = {
88
//console.log(state.extensions)
99
// const button = gradioApp().getElementById("lightdiffusionflow_set_elements");
1010
// button.click();
11+
value = "新建文件夹\\anything-v5-PrtRE.safetensors"
12+
value = value.replace("/","\\")
13+
parts = value.split("\\")
14+
console.log(parts[parts.length - 1])
1115
},
1216

1317
target_is_newer_version: function(cur_version, target_version){
@@ -406,6 +410,9 @@ state.utils = {
406410

407411
let value = store.get(id);
408412
if ( value ) { //&& value != 'None'
413+
value = value.replace("/","\\")
414+
let parts = value.split("\\")
415+
value = parts[parts.length - 1]
409416

410417
selectingQueue += 1;
411418
setTimeout(() => {
@@ -418,7 +425,11 @@ state.utils = {
418425
let successed = false
419426
for (li of items){
420427
// li.lastChild.wholeText.trim() === value
421-
if (localized_value.replace(/^\s+|\s+$/g,"") === li.lastChild.wholeText.trim().replace(/^\s+|\s+$/g,"")) {
428+
let option = li.lastChild.wholeText.trim().replace(/^\s+|\s+$/g,"")
429+
option = option.replace("/","\\")
430+
let parts = option.split("\\")
431+
option = parts[parts.length - 1]
432+
if (localized_value.replace(/^\s+|\s+$/g,"") === option) {
422433
state.utils.triggerMouseEvent(li, 'mousedown');
423434
successed = true
424435
break
@@ -431,6 +442,10 @@ state.utils = {
431442

432443
// 去掉Hash比较
433444
let text = li.lastChild.wholeText.trim()
445+
text = text.replace("/","\\")
446+
let parts = text.split("\\")
447+
text = parts[parts.length - 1]
448+
434449
let localized_value_no_hash = localized_value.replace(/\[[0-9A-Fa-f]{8,10}\]/,"").replace(/^\s+|\s+$/g,"")
435450
let text_no_hash = text.replace(/\[[0-9A-Fa-f]{8,10}\]/, "").replace(/^\s+|\s+$/g,"")
436451

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lightdiffusionflow_version = "v2.1.3"
1+
lightdiffusionflow_version = "v2.1.4"

scripts/state_api.py

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,6 @@ def test_func():
6868
# global extensions_conponents, extensions_id_conponents
6969
# global Output_Log
7070
# print("test_func")
71-
print("----------------------------")
72-
# available_loras = []
73-
import network
74-
for network in networks.available_networks.keys():
75-
print(networks.available_networks[network].name)
76-
print(networks.available_networks[network].alias)
77-
print(networks.available_networks[network].hash)
78-
print(networks.available_networks[network].shorthash)
79-
print(networks.available_networks[network].filename)
80-
print("----------------------------")
81-
# SearchingCheckPointByHashFromCivitai("efd248ef6c0e")
82-
# SearchingCheckPointByHashFromCivitai("5BF8CE6E0E0097235E06614EDEA32DC0DF9066BAD550B6145C19C2B373D78D99")
83-
# SearchingCheckPointByHashFromCivitai("5BF8CE6E0E00")
84-
# print("----------------------------")
85-
86-
print("------ZhangSan'sSong------")
87-
#hash = gen_file_sha256(r"A:\AIPainter\sd-webui-aki-v4.4\models\Lora\ZhangSan'sSong.safetensors")
88-
hash = gen_file_sha256(r"A:\AIPainter\sd-webui-aki-v4.4\models\Lora\yaeMikoRealistic_yaemikoMixed.safetensors")
89-
print(hash)
90-
91-
model_info = SearchingCheckPointByHashFromCivitai(hash)
92-
print(model_info)
93-
print(model_info["name"])
94-
print(model_info["downloadUrl"])
95-
9671
#print(Output_Log)
9772
#print(networks.available_networks)
9873
#print(preprocessor_filters)
@@ -222,8 +197,8 @@ def refresh_local_flows(*inputs):
222197
flows_path = os.path.join(data_path, local_flows_path)
223198
local_flow_list = [f for f in os.listdir(flows_path) if os.path.isfile(
224199
os.path.join(flows_path, f)) and os.path.splitext(f)[-1] == '.flow']
225-
print(inputs)
226-
print(local_flow_list)
200+
# print(inputs)
201+
# print(local_flow_list)
227202
ret = []
228203
for dd in inputs:
229204
if dd in local_flow_list:
@@ -305,6 +280,13 @@ def set_dropdowns():
305280
if(option == new_value):
306281
matching_successed = True
307282
break
283+
else:
284+
#print(f"去掉多余文件夹路径---{temp_option}----{temp_new_value}----")
285+
temp_option = os.path.split(option)[-1]
286+
temp_new_value = os.path.split(new_value)[-1]
287+
if(temp_option == temp_new_value):
288+
matching_successed = True
289+
break
308290

309291
# 去掉模型的多余路径?
310292
# if(os.path.split(option)[-1] == os.path.split(new_value)[-1]):
@@ -1006,6 +988,7 @@ def read_file(self, params:file_params):
1006988
file_content = ""
1007989
with open(params.file_path, mode='r', encoding='UTF-8') as f:
1008990
file_content = f.read()
991+
return file_content
1009992

1010993
def file_exist(self, params:file_params):
1011994
print("file_exist")

0 commit comments

Comments
 (0)