-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
增加随机主页预设 #5432
base: main
Are you sure you want to change the base?
增加随机主页预设 #5432
Conversation
龙猫添加的是
有些主页没有版本号文件,总有人会重复刷新,从而带来额外开销 |
ElseIf RandomFlag = False Then '确保每次启动只生成一次随机数 | ||
Log("[Page] 主页预设:随机预设") | ||
PresetIndex = New Random().Next(0, 12) '生成0-11的随机数 | ||
RandomFlag = True |
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.
随机数注释部分,中文和数字之间需要加个空格
补充一下代码运行逻辑(已经过本地测试) ...
Case 3 '选择使用预设主页
'静态变量 在类的生存期内继续存在 不会重复初始化
Static RandomFlag As Boolean
Static PresetIndex As Integer
'局部变量
Dim Preset = Setup.Get("UiCustomPreset") '获取选择的预设索引
If Preset <> 12 Then '非随机预设
PresetIndex = Preset '直接将选择的索引赋值到下面去处理
ElseIf RandomFlag = False Then '确保只生成一次随机数 选择随机预设且flag未赋值的情况下这个if是成立的
Log("[Page] 主页预设:随机预设")
PresetIndex = New Random().Next(0, 12) '生成 0-11 的随机数
RandomFlag = True '生成随机数后设置flag,不然缓存未命中导致下载完主页后再次调用刷新 又会生成新的随机数 然后再下载 再刷新..
End If
'到这里 要么是自己选的主页预设 要么是随机出来的 直接按原逻辑去处理
Select Case PresetIndex
... |
请求了龙猫对此代码进行审查,但根据 的结论,大概率是不会制作 Tip 在你的 PR 正文(最顶上一楼中)加入以下内容能够更方便让开发者的管理 PR 与其对应 Issue
|
@JingHai-Lingyun 是不是给错 issue 了?#5425 |
诶,糟糕 |
抽象的 VB.NET( |
明确 RandomFlag 的默认值
昨天提了个issue #5425 希望增加随机主页预设,今天被关闭了,不知道是因为作者没有精力还是其他原因拒绝了。
如果是作者精力不足,我想着提个PR把功能实现了,如果是因为其他原因不想添加,那就忽略这个吧。