Skip to content

Commit

Permalink
尝试启用公告功能
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Aug 7, 2024
1 parent 26287c8 commit ede5426
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
28 changes: 24 additions & 4 deletions parts/net.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,36 @@ function NET.getAvatar(uid)
end
end)
end
function NET.getNotice(lang,count)

function NET.launchNotice()
local lang=SETTING.locale:find('zh') and 'zh_cn' or 'en_us'
TASK.new(function()
local res=getMsg({
pool='getNotice',
path='/techmino/api/v1/notice?language='..lang..'&lastCount=1',
},6.26)

if res and res.code==200 then
local opt=res.data.contents[1]
if opt then
MES.new('info',opt.content)
else
MES.new('info',text.Techrater.NoticeManager.noticeNotFound)
end
end
end)
end
function NET.getNotice(count)
local lang=SETTING.locale:find('zh') and 'zh_cn' or 'en_us'
WAIT{timeout=6.26}
TASK.new(function()
local res=getMsg({
pool='getNotice',
path='/techmino/api/v1/notice?language='..(lang or 'zh_cn')..'&lastCount='..(count or 5),
path='/techmino/api/v1/notice?language='..lang..'&lastCount='..(count or 5),
},6.26)

if res and res.code==200 and type(res.data)=='string' then
local dataStr=""
if res and res.code==200 then
local dataStr=TABLE.dump(res.data)
SCN.go('notice',nil,dataStr)
end
end)
Expand Down
1 change: 1 addition & 0 deletions parts/scenes/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ function scene.enter()
maxProgress=10
t1,t2=0,0-- Timer
animeType={} for i=1,#SVG_TITLE_FILL do animeType[i]=math.random(#titleTransform) end-- Random animation type
NET.launchNotice()
end
function scene.leave()
SCN.go('quit','none')
Expand Down
5 changes: 2 additions & 3 deletions parts/scenes/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ function scene.keyDown(key,isRep)
end
elseif key=='3' then
if _testButton(10) then
MES.new('warn',text.notFinished)
-- NET.getNotice()
NET.getNotice()
end
elseif key=='4' then
if _testButton(11) then
Expand Down Expand Up @@ -221,7 +220,7 @@ scene.widgetList={
WIDGET.newButton{name='replays',x=2480,y=570,w=800,h=100, color='lC',font=40,align='L',edge=30,code=pressKey','},

WIDGET.newButton{name='music', x=90,y=80,w=100, color='lY',code=pressKey'2',font=70,fText=CHAR.icon.music},
WIDGET.newButton{name='notice', x=210,y=80,w=100, color='D',code=pressKey'3',font=70,fText=CHAR.key.winMenu},
WIDGET.newButton{name='notice', x=210,y=80,w=100, color='lG',code=pressKey'3',font=70,fText=CHAR.key.winMenu},
WIDGET.newButton{name='lang', x=330,y=80,w=100, color='lN',code=pressKey'4',font=70,fText=CHAR.icon.language},
WIDGET.newButton{name='about', x=-110,y=670,w=600,h=70, color='lB',align='R',edge=20,code=pressKey'x',font=50,fText=CHAR.icon.info},
WIDGET.newButton{name='manual', x=1390,y=670,w=600,h=70, color='lR',align='L',edge=20,code=pressKey'm',font=50,fText=CHAR.icon.help},
Expand Down

0 comments on commit ede5426

Please sign in to comment.