-
-
Notifications
You must be signed in to change notification settings - Fork 315
fix: init config data when clear all data #828
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
base: dev
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @ChangeSuger, 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
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
这次的 Pull Request 旨在解决清空所有数据时,config.txt 中的初始配置会丢失的问题。解决方案是在应用初始化时,将 config.txt 的配置缓存到全局的 window 对象上,然后在执行“清空所有数据”操作时,从 window 对象恢复这些配置。这个方法有效地解决了问题。
我的审查意见主要集中在两个方面:
- 在
userDataReducer.ts中,对可能为undefined的window.gameConfigInit进行处理,以避免潜在的运行时错误。 - 关于将状态存储在全局
window对象上的架构选择,我提出了一些长期的改进建议。
整体来看,这是一个有效的修复,合并前请考虑我提出的具体修改建议。
| } | ||
| }); | ||
|
|
||
| window.gameConfigInit = gameConfigInit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
背景
目前如果在剧本中使用了 config.txt 的配置数据,在清空所有数据后,这些配置相关的全局变量将获取不到值,最小复现示例(
start.txt):问题排查 & 解决方案
目前“清空所有数据”的操作会直接将配置数据清空,对于导出的游戏,得重启游戏这些配置才能重新获取到值;本地调试的话,得重新启动项目才行,刷新页面有概率能行。
官方文档里有这么一句话,显然现在的效果是不符合预期的。解决方案是在 config.txt 的配置初始化时,同时存一份临时数据在某个地方(window 等),这里直接选择存在 window 上,然后在执行“清空所有数据”的操作时,将这份初始化配置与默认配置一并写入。
测试用例: