Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
ed2fa105
Commit
ed2fa105
authored
Jan 29, 2024
by
pythongosssss
Browse files
Make auto saved workflow stored per tab
parent
9321198d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
web/scripts/api.js
web/scripts/api.js
+3
-1
web/scripts/app.js
web/scripts/app.js
+18
-7
No files found.
web/scripts/api.js
View file @
ed2fa105
...
@@ -5,6 +5,7 @@ class ComfyApi extends EventTarget {
...
@@ -5,6 +5,7 @@ class ComfyApi extends EventTarget {
super
();
super
();
this
.
api_host
=
location
.
host
;
this
.
api_host
=
location
.
host
;
this
.
api_base
=
location
.
pathname
.
split
(
'
/
'
).
slice
(
0
,
-
1
).
join
(
'
/
'
);
this
.
api_base
=
location
.
pathname
.
split
(
'
/
'
).
slice
(
0
,
-
1
).
join
(
'
/
'
);
this
.
initialClientId
=
sessionStorage
.
getItem
(
"
clientId
"
);
}
}
apiURL
(
route
)
{
apiURL
(
route
)
{
...
@@ -118,7 +119,8 @@ class ComfyApi extends EventTarget {
...
@@ -118,7 +119,8 @@ class ComfyApi extends EventTarget {
case
"
status
"
:
case
"
status
"
:
if
(
msg
.
data
.
sid
)
{
if
(
msg
.
data
.
sid
)
{
this
.
clientId
=
msg
.
data
.
sid
;
this
.
clientId
=
msg
.
data
.
sid
;
window
.
name
=
this
.
clientId
;
window
.
name
=
this
.
clientId
;
// use window name so it isnt reused when duplicating tabs
sessionStorage
.
setItem
(
"
clientId
"
,
this
.
clientId
);
// store in session storage so duplicate tab can load correct workflow
}
}
this
.
dispatchEvent
(
new
CustomEvent
(
"
status
"
,
{
detail
:
msg
.
data
.
status
}));
this
.
dispatchEvent
(
new
CustomEvent
(
"
status
"
,
{
detail
:
msg
.
data
.
status
}));
break
;
break
;
...
...
web/scripts/app.js
View file @
ed2fa105
...
@@ -1499,12 +1499,17 @@ export class ComfyApp {
...
@@ -1499,12 +1499,17 @@ export class ComfyApp {
// Load previous workflow
// Load previous workflow
let
restored
=
false
;
let
restored
=
false
;
try
{
try
{
const
json
=
localStorage
.
getItem
(
"
workflow
"
);
const
loadWorkflow
=
async
(
json
)
=>
{
if
(
json
)
{
if
(
json
)
{
const
workflow
=
JSON
.
parse
(
json
);
const
workflow
=
JSON
.
parse
(
json
);
await
this
.
loadGraphData
(
workflow
);
await
this
.
loadGraphData
(
workflow
);
restored
=
true
;
return
true
;
}
}
};
const
clientId
=
api
.
initialClientId
??
api
.
clientId
;
restored
=
(
clientId
&&
(
await
loadWorkflow
(
sessionStorage
.
getItem
(
`workflow:
${
clientId
}
`
))))
||
(
await
loadWorkflow
(
localStorage
.
getItem
(
"
workflow
"
)));
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
Error loading previous workflow
"
,
err
);
console
.
error
(
"
Error loading previous workflow
"
,
err
);
}
}
...
@@ -1515,7 +1520,13 @@ export class ComfyApp {
...
@@ -1515,7 +1520,13 @@ export class ComfyApp {
}
}
// Save current workflow automatically
// Save current workflow automatically
setInterval
(()
=>
localStorage
.
setItem
(
"
workflow
"
,
JSON
.
stringify
(
this
.
graph
.
serialize
())),
1000
);
setInterval
(()
=>
{
const
workflow
=
JSON
.
stringify
(
this
.
graph
.
serialize
());
localStorage
.
setItem
(
"
workflow
"
,
workflow
);
if
(
api
.
clientId
)
{
sessionStorage
.
setItem
(
`workflow:
${
api
.
clientId
}
`
,
workflow
);
}
},
1000
);
this
.
#
addDrawNodeHandler
();
this
.
#
addDrawNodeHandler
();
this
.
#
addDrawGroupsHandler
();
this
.
#
addDrawGroupsHandler
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment