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

fix: 修复levelKey不存在时显示level1的题目bug #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

htfc786
Copy link
Contributor

@htfc786 htfc786 commented Aug 10, 2023

修复levelKey不存在时显示level1的题目bug

就是添加了一个空的404关卡,不知道这样行不行

我把src\levels\index.tsgetLevelByKey函数里如果在题目列表里找不到就返回404的level数据,原来返回的是第一题数据,不知道我这样改行不行,我测试了一圈,应该没有问题,不知道有没有我没有测试到的有问题的情况,还望大佬指点,谢谢

我实在是不敢动那些level相关的代码,如果没有就把level置空,要改的地方太多了,很多地方都有调用关卡信息,我实在是不敢改啊。。。

又是我,14岁的那个,第三次使用typescript,应该规范一点了吧,希望鱼皮大佬指点,谢谢

最后还是要感谢鱼皮大佬开源此网站!

defaultSQL: "",
answer: "",
hint: "无此关卡",
type: "nolevel",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你的这种解决方案是 ok 的。但我感觉有些复杂了,完全可以定义一个 defaultLevel 的常量(比如我之前是第一关),而不用增加 TS 类型或 level 配置。我理解你这里的考虑,如果找不到关卡返回 404 也是合理的哈,但是用这种方式你还要考虑隐藏掉对应的提交按钮等,反而更麻烦了。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

鱼皮大佬您好,我理解您的思路,不过引发的bug好像就是因为把这个 defaultLevel 设置成第一关了吧,这里我把这个 defaultLevel 设置成了我写的一个 noLevel,直接显示404,至于那些按钮什么的不用担心,因为我这404关不在 allLevels 的全部管卡的数组里所以不用担心,这些按钮都没有显示出来

image
image

不过我这种方法确实有点简单粗暴了,其实我可以写一个404页面,让无法找到管卡的自动跳转到404页面

最后感谢鱼皮大佬的回复与指点!

@htfc786
Copy link
Contributor Author

htfc786 commented Aug 24, 2023

add 404页面

鱼皮大佬您好,我已经把这个改成404页面的那种形式了

@htfc786
Copy link
Contributor Author

htfc786 commented Oct 5, 2023

鱼皮大佬您好,代码之前已经改好,为什么您一个多月都没有回复?是添加404页面的方式有问题吗

@htfc786
Copy link
Contributor Author

htfc786 commented Nov 11, 2023

鱼皮大佬您好,我期中考试都考完了,您为什么还没回我?是404实现这种不行吗?怕您看不见@您一下 @liyupi

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

Successfully merging this pull request may close these issues.

None yet

2 participants