feat: create/remove iframe command#895
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求的核心目标是增强应用程序的扩展性,通过引入 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
此 PR 增加了 createFrame 和 removeFrame 指令,用于在游戏中创建和移除 iframe 元素,并提供了一套 API 供 iframe 与主应用通信。整体实现思路清晰,功能完整。
我发现了一些可以改进的地方:
createFrame中处理 URL 的逻辑存在一个 bug,可能导致合法的http链接被错误处理。Iframe.tsx组件在向 iframe 注入 API 时存在竞态条件,可能导致 API 未能及时注入。postMessage使用了不安全的targetOrigin,存在安全风险。- 部分 TypeScript 类型可以更精确,以增强类型安全。
具体的修改建议请见代码注释。
相关issue: #520
此PR增加了指令
createIframe、removeIframe指令createIframe
将创建一个iframe元素挂载到界面上,其content内容是iframe路径
我们可以设置sandbox属性:
其余的选项:
PS:参数前面如果使用
@标识开始,则将注入到iframe中,如-@test、-@arg=123,从window.webgal.params中获取webgal变量,包含的方法如下:removeIframe
移除一个指定id的iframe,其content内容是创建时设置的id
示例
实现了一个简单的好感度显示和各个API的示例代码
start.txt:
1.html:
2.html:
有些特性可能未实现,还需参考和讨论。