lastopenworkflow
This commit is contained in:
@@ -508,12 +508,11 @@ def define_comfyui_nodes(sdpppServer):
|
||||
def action(self, layer_or_group, unique_id, prompt, document = None, **kwargs):
|
||||
sdpppServer.has_ps_instance(throw_error=True)
|
||||
|
||||
document = json.loads(document)
|
||||
document = layer_or_group[0]['document']
|
||||
|
||||
res_text = []
|
||||
for i, item_layer in enumerate(layer_or_group):
|
||||
if linked_style:
|
||||
item_layer = item_layer['layer_identify']
|
||||
item_layer = item_layer['layer_identify']
|
||||
|
||||
text = call_async_func_in_server_thread(
|
||||
ProtocolPhotoshop.get_text(
|
||||
|
||||
@@ -170,6 +170,8 @@ def define_comfyui_nodes_legacy(sdppp):
|
||||
sdppp.has_ps_instance(throw_error=True)
|
||||
|
||||
linked_style, document = parse_params(unique_id, prompt, layer_or_group, document)
|
||||
sdppp_arg = kwargs['sdppp']
|
||||
sdppp_arg_item = json.loads(sdppp_get_prompt_item_from_list(sdppp_arg, 0))
|
||||
|
||||
# dont check here, some python cannot read the data in this thread.
|
||||
# if document['instance_id'] not in sdppp.ppp_instances:
|
||||
@@ -211,7 +213,8 @@ def define_comfyui_nodes_legacy(sdppp):
|
||||
document_identify=document['identify'],
|
||||
image_blobs=[p['image_blob'] for p in params],
|
||||
layer_identifies=[p['layer_identify'] for p in params],
|
||||
boundaries=[p['boundary'] for p in params]
|
||||
boundaries=[p['boundary'] for p in params],
|
||||
new_layer_name=sdppp_arg_item['lastOpenedWorkflow']
|
||||
), True)
|
||||
|
||||
return (document,)
|
||||
|
||||
@@ -31,7 +31,7 @@ class ProtocolPhotoshop:
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
async def send_images(cls, instance_id, document_identify, layer_identifies, boundaries, image_urls=[], image_blobs=[]):
|
||||
async def send_images(cls, instance_id, document_identify, layer_identifies, boundaries, image_urls=[], image_blobs=[], new_layer_name=""):
|
||||
ppp_instance = cls.sdpppServer.ppp_instances[instance_id]
|
||||
result = await protocol_call(ppp_instance, 'B_photoshop', data={
|
||||
'action': 'sendImages',
|
||||
@@ -40,7 +40,8 @@ class ProtocolPhotoshop:
|
||||
'layer_identifies': layer_identifies,
|
||||
'boundaries': boundaries,
|
||||
'image_urls': image_urls,
|
||||
'image_blobs': image_blobs
|
||||
'image_blobs': image_blobs,
|
||||
'new_layer_name': new_layer_name
|
||||
}
|
||||
})
|
||||
return result
|
||||
|
||||
@@ -77,6 +77,7 @@ async function _init(app: any, api: any, $el: any) {
|
||||
image_urls: ev.detail.output.images.map((image: any) => {
|
||||
return location.origin + '/api/view?type=' + image.type + '&filename=' + image.filename
|
||||
}),
|
||||
new_layer_name: pageStore.data.lastOpenedWorkflow
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,10 @@ export class DocumentWidget extends SDPPPComboWidget {
|
||||
const documentWidget = node.addWidget('combo', name, options[0] || '', () => { }, { forceInput: true, values: makeDocumentDataOptions })
|
||||
documentWidget.serializeValue = async () => {
|
||||
const data = parseDocumentOption(documentWidget.value);
|
||||
if (!data) return '';
|
||||
if (!data) return JSON.stringify({
|
||||
instance_id: i18n('document {0} not found', documentWidget.value),
|
||||
identify: ''
|
||||
});
|
||||
return JSON.stringify({
|
||||
instance_id: data.instance_id,
|
||||
identify: data.identify
|
||||
@@ -226,7 +229,8 @@ export class DownloadWidget extends SDPPPWidget {
|
||||
];
|
||||
widget.serializeValue = async () => {
|
||||
const ret: any = {
|
||||
ps_maxGetImageWH: pageStore.data.maxImageWH
|
||||
ps_maxGetImageWH: pageStore.data.maxImageWH,
|
||||
lastOpenedWorkflow: pageStore.data.lastOpenedWorkflow
|
||||
}
|
||||
const documentNode = findDocumentNodeRecursive(node);
|
||||
if (documentNode?.widgets[0]) {
|
||||
|
||||
@@ -216,10 +216,16 @@ export function WorkflowCalleeSocket(SocketClass: SocketConstructor<Socket>) {
|
||||
}
|
||||
private async open(params: WorkflowCalleeActions['open']['params']) {
|
||||
const { workflow_path } = params;
|
||||
if (workflow_path.startsWith('sdppp://')) {
|
||||
this.openSDPPPWorkflow(params)
|
||||
} else {
|
||||
this.openComfyWorkflow(params)
|
||||
try {
|
||||
if (workflow_path.startsWith('sdppp://')) {
|
||||
this.openSDPPPWorkflow(params)
|
||||
} else {
|
||||
this.openComfyWorkflow(params)
|
||||
}
|
||||
pageStore.setLastOpenedWorkflow(workflow_path)
|
||||
} catch (error) {
|
||||
pageStore.setLastOpenedWorkflow('')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
private async openSDPPPWorkflow(params: WorkflowCalleeActions['open']['params']) {
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface PageStoreData {
|
||||
executingNodeTitle: string
|
||||
|
||||
currentForm: SDPPPGraphForm[]
|
||||
lastOpenedWorkflow: string
|
||||
|
||||
hasPSDNodes: boolean
|
||||
maxImageWH: number
|
||||
@@ -23,6 +24,7 @@ export class PageStore extends MainStore<PageStoreData> {
|
||||
constructor(data?: PageStoreData, version?: number) {
|
||||
super(data || {
|
||||
title: '',
|
||||
webviewFromSid: location.search.match(/webview_fromsid=([^&]+)/)?.[1] || '',
|
||||
|
||||
progress: 0,
|
||||
lastError: '',
|
||||
@@ -30,9 +32,9 @@ export class PageStore extends MainStore<PageStoreData> {
|
||||
queueSize: 0,
|
||||
executingNodeTitle: "",
|
||||
|
||||
webviewFromSid: location.search.match(/webview_fromsid=([^&]+)/)?.[1] || '',
|
||||
|
||||
currentForm: [],
|
||||
lastOpenedWorkflow: '',
|
||||
|
||||
hasPSDNodes: false,
|
||||
maxImageWH: 60606,
|
||||
comfyUserToken: ''
|
||||
@@ -83,4 +85,9 @@ export class PageStore extends MainStore<PageStoreData> {
|
||||
setComfyUserToken(comfyUserToken: string) {
|
||||
this._data.comfyUserToken = comfyUserToken;
|
||||
}
|
||||
|
||||
@StoreMutation
|
||||
setLastOpenedWorkflow(lastOpenedWorkflow: string) {
|
||||
this._data.lastOpenedWorkflow = lastOpenedWorkflow;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user