mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2026-01-30 16:00:15 +08:00
share to esheep
This commit is contained in:
parent
fc4c017f07
commit
182a2cf197
15
__init__.py
15
__init__.py
@ -831,7 +831,6 @@ def nickname_filter(json_obj):
|
||||
|
||||
return json_obj
|
||||
|
||||
|
||||
@server.PromptServer.instance.routes.get("/customnode/getmappings")
|
||||
async def fetch_customnode_mappings(request):
|
||||
mode = request.rel_url.query["mode"]
|
||||
@ -2127,6 +2126,20 @@ async def api_get_comfyworkflows_auth(request):
|
||||
return web.Response(status=404)
|
||||
return web.json_response({"comfyworkflows_sharekey" : comfyworkflows_auth})
|
||||
|
||||
@server.PromptServer.instance.routes.post("/manager/set_esheep_workflow_and_images")
|
||||
async def set_esheep_workflow_and_images(request):
|
||||
json_data = await request.json()
|
||||
current_workflow = json_data['workflow']
|
||||
images = json_data['images']
|
||||
with open(os.path.join(comfyui_manager_path, "esheep_share_message.json"), "w", encoding='utf-8') as file:
|
||||
json.dump(json_data, file, indent=4)
|
||||
return web.Response(status=200)
|
||||
|
||||
@server.PromptServer.instance.routes.get("/manager/get_esheep_workflow_and_images")
|
||||
async def get_esheep_workflow_and_images(request):
|
||||
with open(os.path.join(comfyui_manager_path, "esheep_share_message.json"), 'r', encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
return web.Response(status=200, text=json.dumps(data))
|
||||
|
||||
def set_matrix_auth(json_data):
|
||||
homeserver = json_data['homeserver']
|
||||
|
||||
@ -1174,6 +1174,15 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
ShareDialogChooser.instance.show();
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Open 'esheep 电子羊'",
|
||||
callback: () => {
|
||||
const url = "https://www.esheep.com";
|
||||
localStorage.setItem("wg_last_visited", url);
|
||||
window.open(url, url);
|
||||
modifyButtonStyle(url);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Open 'openart.ai'",
|
||||
callback: () => {
|
||||
|
||||
@ -164,6 +164,35 @@ export function parseURLPath(urlPath) {
|
||||
}
|
||||
|
||||
|
||||
export const shareToEsheep= () => {
|
||||
// 1、获得workflow和图片信息
|
||||
app.graphToPrompt()
|
||||
.then(prompt => {
|
||||
const nodes = app.graph._nodes
|
||||
const { potential_outputs, potential_output_nodes } = getPotentialOutputsAndOutputNodes(nodes);
|
||||
const workflow = prompt['workflow']
|
||||
// 2、把workflow和图片保存到本地
|
||||
api.fetchApi(`/manager/set_esheep_workflow_and_images`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
workflow: workflow,
|
||||
images: potential_outputs
|
||||
})
|
||||
}).then(response => {
|
||||
// 获取域名(不包含子域)
|
||||
var domain = window.location.hostname;
|
||||
// 获取端口号
|
||||
var port = window.location.port;
|
||||
// 如果端口为空字符串,则可能是使用了标准端口(80 for http and 443 for https)
|
||||
port = port || (window.location.protocol === 'http:' ? '80' : window.location.protocol === 'https:' ? '443' : '');
|
||||
var full_domin = domain + ':' + port
|
||||
// 打开新tab
|
||||
window.open('https://www.esheep.com/app/workflow_upload?from_local='+ full_domin, '_blank');
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export const showOpenArtShareDialog = () => {
|
||||
if (!OpenArtShareDialog.instance) {
|
||||
OpenArtShareDialog.instance = new OpenArtShareDialog();
|
||||
@ -241,6 +270,17 @@ export class ShareDialogChooser extends ComfyDialog {
|
||||
}
|
||||
createButtons() {
|
||||
const buttons = [
|
||||
{
|
||||
key: "esheep",
|
||||
textContent: "eSheep 电子羊",
|
||||
website: "https://www.esheep.com",
|
||||
description: "在电子羊社区体验工作流免费分享与下载 \n\
|
||||
Share & download thousands of ComfyUI workflows on <a style='color:white;' href='https://www.esheep.com' target='_blank'>esheep.com</a>",
|
||||
onclick: () => {
|
||||
shareToEsheep();
|
||||
this.close();
|
||||
}
|
||||
},
|
||||
{
|
||||
key: "openart",
|
||||
textContent: "OpenArt AI",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user