@@ -639,63 +639,82 @@ state.core = (function () {
639639 store . set ( `img2img_seed` , state . utils . getCurSeed ( 'img2img' ) )
640640 }
641641
642- fetch ( '/lightdiffusionflow/local/lightdiffusionflow_config?onlyimg=true' )
642+
643+ fetch ( '/lightdiffusionflow/local/lightdiffusionflow_config?data2export=true' )
644+ . then ( response => response . json ( ) )
645+ . then ( config => {
646+
647+ config = JSON . parse ( config )
648+ stored_config = store . getAll ( )
649+
650+ let data = {
651+ method : 'POST' ,
652+ headers : { 'Content-Type' : 'application/json' } ,
653+ body : JSON . stringify ( {
654+ "config_data" :stored_config
655+ } )
656+ }
657+ fetch ( `/lightdiffusionflow/local/parse_lora_info` , data )
643658 . then ( response => response . json ( ) )
644- . then ( config => {
645- config = JSON . parse ( config )
646- stored_config = store . getAll ( )
659+ . then ( response_lora_info => {
647660
648- for ( let key in config ) {
649- if ( config [ key ] != "" ) {
650- stored_config [ key ] = config [ key ]
651- }
652- }
661+ for ( let key in response_lora_info ) {
662+ stored_config [ key ] = response_lora_info [ key ]
663+ }
653664
654- for ( let key in stored_config ) {
655- if ( key . indexOf ( "allow-preview" ) !== - 1 && key . indexOf ( "ext-control-net" ) !== - 1 )
656- {
657- console . log ( "allow-preview改成false" )
658- stored_config [ key ] = "false"
659- }
665+ for ( let key in config ) {
666+ if ( config [ key ] != "" ) {
667+ stored_config [ key ] = config [ key ]
660668 }
669+ }
661670
662- var checkTime = function ( i ) {
663- if ( i < 10 ) { i = "0" + i ; }
664- return i ;
665- }
666- let nowdate = new Date ( ) ;
667- let year = String ( nowdate . getFullYear ( ) )
668- let month = String ( checkTime ( nowdate . getMonth ( ) + 1 ) )
669- let day = String ( checkTime ( nowdate . getDate ( ) ) )
670- let h = String ( checkTime ( nowdate . getHours ( ) ) )
671- let m = String ( checkTime ( nowdate . getMinutes ( ) ) )
672- let s = String ( checkTime ( nowdate . getSeconds ( ) ) )
673- let time_str = year + month + day + h + m + s
674-
675- filename = 'flow-' + time_str + '.flow'
676- filename = prompt ( "Export workflow as:" , filename ) ;
677- if ( ! filename ) return ;
678- if ( ! filename . toLowerCase ( ) . endsWith ( ".flow" ) ) {
679- filename += ".flow" ;
671+ for ( let key in stored_config ) {
672+ if ( key . indexOf ( "allow-preview" ) !== - 1 && key . indexOf ( "ext-control-net" ) !== - 1 )
673+ {
674+ console . log ( "allow-preview改成false" )
675+ stored_config [ key ] = "false"
680676 }
681- if ( filename != ".flow" ) {
682- // const handle = window.showDirectoryPicker();
683- // console.log(handle)
684-
685- state . utils . saveFile ( filename , stored_config ) ;
686-
687- fetch ( 'https://api.lightflow.ai/openapi/access?action=export' )
688- . then ( response => response . json ( ) )
689- . then ( config => {
690- console . log ( config )
691- } ) . catch ( function ( e ) {
692- console . log ( "Oops, export callback error!" ) ;
693- } ) ;
677+ }
694678
695- }
679+ var checkTime = function ( i ) {
680+ if ( i < 10 ) { i = "0" + i ; }
681+ return i ;
682+ }
683+ let nowdate = new Date ( ) ;
684+ let year = String ( nowdate . getFullYear ( ) )
685+ let month = String ( checkTime ( nowdate . getMonth ( ) + 1 ) )
686+ let day = String ( checkTime ( nowdate . getDate ( ) ) )
687+ let h = String ( checkTime ( nowdate . getHours ( ) ) )
688+ let m = String ( checkTime ( nowdate . getMinutes ( ) ) )
689+ let s = String ( checkTime ( nowdate . getSeconds ( ) ) )
690+ let time_str = year + month + day + h + m + s
691+
692+ filename = 'flow-' + time_str + '.flow'
693+ filename = prompt ( "Export workflow as:" , filename ) ;
694+ if ( ! filename ) return ;
695+ if ( ! filename . toLowerCase ( ) . endsWith ( ".flow" ) ) {
696+ filename += ".flow" ;
697+ }
698+ if ( filename != ".flow" ) {
699+ // const handle = window.showDirectoryPicker();
700+ // console.log(handle)
701+
702+ state . utils . saveFile ( filename , stored_config ) ;
703+
704+ // fetch('https://api.lightflow.ai/openapi/access?action=export')
705+ // .then(response => response.json())
706+ // .then(config => {
707+ // console.log(config)
708+ // }).catch(function(e) {
709+ // console.log("Oops, export callback error!");
710+ // });
711+
712+ }
696713
697714 } ) . catch ( error => console . error ( '[state]: Error getting Flow file:' , error ) ) ;
698715
716+ } ) . catch ( error => console . error ( '[state]: Error getting Flow file:' , error ) ) ;
717+
699718 //config = JSON.stringify(store.getAll(), null, 4);
700719 //fetch(`/lightdiffusionflow/local/ExportLightDiffusionFlow?config=${config}`)
701720 } ,
0 commit comments