Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph.registerNodeTool 不应报错,而是仅仅给出警告 #4245

Open
xiyuvi opened this issue Mar 29, 2024 · 6 comments
Open

Graph.registerNodeTool 不应报错,而是仅仅给出警告 #4245

xiyuvi opened this issue Mar 29, 2024 · 6 comments

Comments

@xiyuvi
Copy link

xiyuvi commented Mar 29, 2024

功能描述

···
Graph.registerNodeTool("btn1)
···
重复进一次页面,以上初始化代码会执行,导致x6抛出错误,之后的代码无法执行
”Node tool with name 'btn1' already registered.“

期望解决方案

个人觉得没必要抛出错误,给一个警告信息就可以了。
目前我的解决方法是包一层捕捉错误

try{Graph.registerNodeTool("btn1)} catch (error) {
                console.error(error);
            }

我在文档中没有搜到怎么判断某个Tool是否已经存在的函数,如果有这种函数的话麻烦分享一下,谢谢

@x6-bot
Copy link
Contributor

x6-bot bot commented Mar 29, 2024

👋 @xiyuvi

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@xiyuvi
Copy link
Author

xiyuvi commented Mar 29, 2024

有删除自定义Tool的方法吗

@xiyuvi
Copy link
Author

xiyuvi commented Mar 29, 2024

我上面说的解决方法无效,重新跳转页面是一个新的vue实例,这导致在已经销毁的页面创建的btn1按钮,无法正常调用新页面的函数。我需要查询tool是否存在以及删除tool的方法,有人可以告诉我吗,十分感谢

@xiyuvi
Copy link
Author

xiyuvi commented Mar 29, 2024

我解决了这个问题,使用的是unregisterNodeTool方法
image
虽然没有查找自定义tool是否存在的方法,但是删除不存在的tool并不会报错。
希望对和我遇到相同问题的人有帮助。
吐槽一下,官方文档没有写这个函数,问ai问题真的像炼丹,你永远不知道你会得到什么仙丹(ai告诉我的判断tool是否存在的方法hasNodeTool是错的,没有那个方法)
image
image

@GuangZ96
Copy link

的确没有 hasNodeTool 这个方法
只有 hasTool 跟 removeTool 🤔

@cuidong626
Copy link
Contributor

register 的有个force属性,会强制覆盖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants