Skip to content

Commit

Permalink
support enable / disable sd webui extension, comfyui custom node
Browse files Browse the repository at this point in the history
  • Loading branch information
licyk committed Aug 2, 2024
1 parent 90b4921 commit 8446949
Show file tree
Hide file tree
Showing 4 changed files with 352 additions and 14 deletions.
14 changes: 8 additions & 6 deletions help/how_to_use_term_sd.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ Term-SD 支持 Stable Diffusion WebUI,ComfyUI,InvokeAI,Fooocus,lora-scri
- (4) 切换版本:切换插件的版本
- (5) 更新源切换:切换插件的更新源,加速下载;当某个 Github 镜像源无法使用导致无法更新插件时,也可以使用该功能将更新源切换到可用的 Github 镜像源或者切换成 Github 源
- (6) 安装依赖(仅限 ComfyUI):安装插件运行时所需的依赖
- (7) 启用 / 禁用插件:可选择启用或者禁用插件

>[!NOTE]
>1、如果安装了`ComfyUI-Manager`这个扩展,就不需要使用`安装全部插件依赖`这个功能了(`ComfyUI-Manager`把ComfyUI缺失的这个功能给补上了(?),不过`ComfyUI-Manager`有时候不会自动为其它扩展装依赖,这时就使用`安装全部插件依赖`来手动安装依赖)
Expand All @@ -518,12 +519,13 @@ Term-SD 支持 Stable Diffusion WebUI,ComfyUI,InvokeAI,Fooocus,lora-scri
- 4、安装全部自定义节点依赖:一键将所有自定义节点需要的依赖进行安装

选中一个自定义节点后,包含以下功能用于管理自定义节点:
- 1、更新:更新自定义节点
- 2、卸载:卸载自定义节点,且该操作无法恢复,请谨慎选择
- 3、修复更新:修复 Git 分支游离或者还原被修改的自定义节点的源代码
- 4、切换版本:切换自定义节点的版本
- 5、更新源切换:切换自定义节点的更新源,加速下载;当某个 Github 镜像源无法使用导致无法更新插件时,也可以使用该功能将更新源切换到可用的 Github 镜像源或者切换成 Github 源
- 6、安装依赖:安装自定义节点运行时所需的依赖
- (1) 更新:更新自定义节点
- (2) 卸载:卸载自定义节点,且该操作无法恢复,请谨慎选择
- (3) 修复更新:修复 Git 分支游离或者还原被修改的自定义节点的源代码
- (4) 切换版本:切换自定义节点的版本
- (5) 更新源切换:切换自定义节点的更新源,加速下载;当某个 Github 镜像源无法使用导致无法更新插件时,也可以使用该功能将更新源切换到可用的 Github 镜像源或者切换成 Github 源
- (6) 安装依赖:安装自定义节点运行时所需的依赖
- (7) 启用 / 禁用自定义节点:可选择启用或者禁用自定义节点

>[!NOTE]
>1、如果安装了`ComfyUI-Manager`这个扩展,就不需要使用`安装全部自定义节点依赖`这个功能了(`ComfyUI-Manager`把ComfyUI缺失的这个功能给补上了,不过`ComfyUI-Manager`有时候不会自动为其它扩展装依赖,这时就使用`安装全部自定义节点依赖`来手动安装依赖)
Expand Down
71 changes: 66 additions & 5 deletions modules/comfyui_custom_node_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,40 @@ comfyui_custom_node_list() {
# comfyui_custom_node_interface <自定义节点的文件夹名>
comfyui_custom_node_interface() {
local dialog_arg
local custom_node_name=$@
local custom_node_name=
local custom_node_folder=$@
local dialog_buttom
local status_display
local custom_node_status
local tmp_folder_name

while true; do
if [[ "$(awk -F '.' '{print $NF}' <<< ${custom_node_folder})" == "disabled" ]]; then
custom_node_status=0
status_display="已禁用"
dialog_buttom="启用"
else
custom_node_status=1
status_display="已启用"
dialog_buttom="禁用"
fi

custom_node_name=$(awk -F '.disabled' '{print $1}' <<< ${custom_node_folder})

dialog_arg=$(dialog --erase-on-exit --notags \
--title "ComfyUI 选项" \
--backtitle "ComfyUI 自定义节点管理选项" \
--ok-label "确认" --cancel-label "取消" \
--menu "请选择对 ${custom_node_name} 自定义节点的管理功能\n当前更新源: $(git_remote_display)\n当前分支: $(git_branch_display)" \
--menu "请选择对 ${custom_node_name} 自定义节点的管理功能\n当前更新源: $(git_remote_display)\n当前分支: $(git_branch_display)\n当前状态: ${status_display}" \
$(get_dialog_size_menu) \
"0" "> 返回" \
"1" "> 更新" \
"2" "> 修复更新" \
"3" "> 安装依赖" \
"4" "> 版本切换" \
"5" "> 更新源切换" \
"6" "> 卸载" \
"6" "> ${dialog_buttom}自定义节点" \
"7" "> 卸载" \
3>&1 1>&2 2>&3)

case "${dialog_arg}" in
Expand Down Expand Up @@ -261,7 +279,7 @@ comfyui_custom_node_interface() {
--yesno "是否安装 ${custom_node_name} 自定义节点依赖 ?" \
$(get_dialog_size)); then

comfyui_extension_depend_install_single "自定义节点" "${custom_node_name}"
comfyui_extension_depend_install_single "自定义节点" "${custom_node_folder}"
else
term_sd_echo "取消安装 ${custom_node_name} 自定义节点依赖"
fi
Expand Down Expand Up @@ -313,6 +331,49 @@ comfyui_custom_node_interface() {
fi
;;
6)
if [[ "${custom_node_status}" == 0 ]]; then
if (dialog --erase-on-exit \
--title "ComfyUI 管理" \
--backtitle "ComfyUI 自定义节点更新源切换" \
--yes-label "" --no-label "" \
--yesno "是否启用 ${custom_node_name} 自定义节点 ?" \
$(get_dialog_size)); then

tmp_folder_name=$custom_node_folder
custom_node_folder=$(awk -F '.disabled' '{print $1}' <<< ${custom_node_folder})
cd ..
mv "${tmp_folder_name}" "${custom_node_folder}"
cd "${custom_node_folder}"
else
continue
fi
else
if (dialog --erase-on-exit \
--title "ComfyUI 管理" \
--backtitle "ComfyUI 自定义节点更新源切换" \
--yes-label "" --no-label "" \
--yesno "是否启用 ${custom_node_name} 自定义节点 ?" \
$(get_dialog_size)); then

tmp_folder_name=$custom_node_folder
custom_node_folder="${custom_node_folder}.disabled"
cd ..
mv -f "${tmp_folder_name}" "${custom_node_folder}"
cd "${custom_node_folder}"
else
continue
fi
fi

dialog --erase-on-exit \
--title "ComfyUI 管理" \
--backtitle "ComfyUI 自定义节点删除选项" \
--ok-label "确认" \
--msgbox "${dialog_buttom} ${custom_node_name} 自定义节点成功" \
$(get_dialog_size)

;;
7)
if (dialog --erase-on-exit \
--title "ComfyUI 选项" \
--backtitle "ComfyUI 自定义节点删除选项" \
Expand All @@ -327,7 +388,7 @@ comfyui_custom_node_interface() {
yes|y|YES|Y)
term_sd_echo "删除 ${custom_node_name} 自定义节点中"
cd ..
rm -rf "${custom_node_name}"
rm -rf "${custom_node_folder}"

dialog --erase-on-exit \
--title "ComfyUI 管理" \
Expand Down
Loading

0 comments on commit 8446949

Please sign in to comment.