更新登录界面

This commit is contained in:
ParticleG
2023-01-12 16:31:17 +08:00
parent c19e656d46
commit d83779662a
14 changed files with 71 additions and 92 deletions

View File

@@ -1,47 +1,41 @@
local scene={}
local function _getCode()
local email=scene.widgetList.email:getText()
if not STRING.simpEmailCheck(email) then
MES.new('error',text.wrongEmail)
else
USER.email=email
NET.getCode(email)
end
local function _authorize()
love.system.openURL("https://dev.studio26f.org/oauth?product=techmino")
end
local function _codeLogin()
local code=scene.widgetList.code:getText():upper()
if #code~=8 then
local function _submit()
local tickets=scene.widgetList.ticket:getText():upper()
if #tickets~=128 then
MES.new('error',text.wrongCode)
else
NET.codeLogin(USER.email,code)
USER.aToken=tickets:sub(1,64)
USER.oToken=tickets:sub(65)
end
end
local function _paste()
local t=love.system.getClipboardText()
if t then
t=STRING.trim(t)
if #t==8 and t:match("[0-9]+") then
scene.widgetList.code:setText(t)
if #t==128 and t:match("[0-9A-Z]+") then
scene.widgetList.ticket:setText(t)
return
end
end
MES.new('warn',text.wrongCode)
MES.new('error',text.wrongCode)
end
function scene.enter()
scene.widgetList.email:setText(USER.email or "")
scene.widgetList.code:clear()
scene.widgetList.ticket:clear()
end
function scene.keyDown(key,rep)
if key=='escape' and not rep then
SCN.back()
elseif key=='return' or key=='kpenter' then
if #scene.widgetList.code:getText():upper()==0 then
_getCode()
if #scene.widgetList.ticket:getText()==0 then
_authorize()
else
_codeLogin()
_submit()
end
elseif key=='v' and love.keyboard.isDown('lctrl','rctrl') then
_paste()
@@ -52,14 +46,12 @@ end
scene.widgetList={
WIDGET.newText{name='title', x=80, y=50,font=70,align='L'},
WIDGET.newButton{name='login_pw', x=1080,y=100,w=260,h=80,color='lY',code=function() SCN.swapTo('login_pw','swipeR') end},
WIDGET.newInputBox{name='email', x=380, y=200,w=626,h=60,limit=128},
WIDGET.newKey{name='send', x=640, y=330,w=300,h=80,font=40,code=_getCode},
WIDGET.newInputBox{name='ticket', x=280, y=200,w=730,h=320,font=30,regex="[0-9A-Z]",limit=128},
WIDGET.newInputBox{name='code', x=380, y=400,w=626,h=60,regex="[0-9a-zA-Z]",limit=8},
WIDGET.newKey{name='verify', x=640, y=530,w=300,h=80,font=40,code=_codeLogin},
WIDGET.newKey{name='paste', x=850, y=530,w=80,font=40,fText=CHAR.icon.import,code=_paste},
WIDGET.newKey{name='authorize', x=430, y=640,w=300,h=80,font=40,code=_authorize},
WIDGET.newKey{name='submit', x=755, y=640,w=300,h=80,font=40,code=_submit},
WIDGET.newKey{name='paste', x=970, y=640,w=80,font=40,fText=CHAR.icon.import,code=_paste},
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=pressKey'escape'},
}

View File

@@ -18,7 +18,6 @@ scene.widgetList={
WIDGET.newButton{name='league',x=640, y=180,w=350,h=120,font=40,color='D',code=goScene'net_league'},
WIDGET.newButton{name='ffa', x=640, y=360,w=350,h=120,font=40,color='D',code=function() MES.new('warn',text.notFinished)--[[NET.enterRoom({name='ffa'})]] end},
WIDGET.newButton{name='rooms', x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'},
WIDGET.newButton{name='resetPW',x=680,y=40,w=180,h=60,color='dG',code=goScene'reset_password'},
WIDGET.newButton{name='logout',x=880, y=40,w=180, h=60,color='dR',
code=function()
if tryBack() then