全局变量ACCOUNT改名USER

This commit is contained in:
MrZ626
2020-12-14 15:44:40 +08:00
parent a409557019
commit 4d39924059
7 changed files with 31 additions and 31 deletions

View File

@@ -253,16 +253,16 @@ end
--Collect files
if fs.getInfo("data.dat")then
fs.createDirectory("conf")
for _,v in next,{
"settings",
"unlock",
"data",
"key",
"virtualkey",
"account",
for k,v in next,{
["settings.dat"]="conf/settings",
["unlock.dat"]="conf/unlock",
["data.dat"]="conf/data",
["key.dat"]="conf/key",
["virtualkey.dat"]="conf/virtualkey",
["account.dat"]="conf/user",
}do
fs.write("conf/"..v,fs.read(v..".dat"))
fs.remove(v..".dat")
fs.write(v,fs.read(k))
fs.remove(k)
end
fs.createDirectory("record")
for _,name in next,fs.getDirectoryItems("")do
@@ -295,7 +295,7 @@ if fs.getInfo("conf/unlock")then RANKS=FILE.load("conf/unlock")end
if fs.getInfo("conf/data")then STAT=FILE.load("conf/data")end
if fs.getInfo("conf/key")then keyMap=FILE.load("conf/key")end
if fs.getInfo("conf/virtualkey")then VK_org=FILE.load("conf/virtualkey")end
if fs.getInfo("conf/account")then ACCOUNT=FILE.load("conf/account")end
if fs.getInfo("conf/user")then USER=FILE.load("conf/user")end
for _,v in next,{
"tech_ultimate.dat",

View File

@@ -302,7 +302,7 @@ for i=1,25 do
STAT.spin[i]={0,0,0,0,0,0,0}
end
ACCOUNT={
USER={
email=nil,
auth_token=nil,
access_token=nil,

View File

@@ -44,7 +44,7 @@ function scene.sceneInit()
BG.set("none")
wsConnect(
TICK.wsCONN_connect,
PATH.socket..PATH.chat.."?email="..urlEncode(ACCOUNT.email).."&access_token="..urlEncode(ACCOUNT.access_token)
PATH.socket..PATH.chat.."?email="..urlEncode(USER.email).."&access_token="..urlEncode(USER.access_token)
)
end
function scene.sceneBack()

View File

@@ -180,15 +180,15 @@ function scene.update()
SFX.play("welcome_sfx")
VOC.play("welcome_voc")
httpRequest(tick_httpREQ_launch,PATH.api..PATH.appInfo)
if ACCOUNT.auth_token and ACCOUNT.email then
if USER.auth_token and USER.email then
httpRequest(
tick_httpREQ_autoLogin,
PATH.api..PATH.auth,
"GET",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
auth_token=ACCOUNT.auth_token,
email=USER.email,
auth_token=USER.auth_token,
}
)
end

View File

@@ -9,9 +9,9 @@ local function tick_httpREQ_newLogin(task)
if res then
if LOGIN then
LOG.print(text.loginSuccessed)
ACCOUNT.email=res.email
ACCOUNT.auth_token=res.auth_token
FILE.save(ACCOUNT,"conf/account","q")
USER.email=res.email
USER.auth_token=res.auth_token
FILE.save(USER,"conf/account","q")
httpRequest(
TICK.httpREQ_getAccessToken,
@@ -19,8 +19,8 @@ local function tick_httpREQ_newLogin(task)
"POST",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
auth_token=ACCOUNT.auth_token,
email=USER.email,
auth_token=USER.auth_token,
}
)
else

View File

@@ -16,8 +16,8 @@ local function tick_httpREQ_checkAccessToken(task)
"POST",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
auth_token=ACCOUNT.auth_token,
email=USER.email,
auth_token=USER.auth_token,
}
)
else
@@ -82,15 +82,15 @@ scene.widgetList={
WIDGET.newButton{name="offline",x=150,y=220,w=200,h=140,color="lRed", font=40,code=WIDGET.lnk_goScene("mode")},
WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=function()
if LOGIN then
if ACCOUNT.access_token then
if USER.access_token then
httpRequest(
tick_httpREQ_checkAccessToken,
PATH.api..PATH.access,
"GET",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
access_token=ACCOUNT.access_token,
email=USER.email,
access_token=USER.access_token,
}
)
else
@@ -100,8 +100,8 @@ scene.widgetList={
"POST",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
auth_token=ACCOUNT.auth_token,
email=USER.email,
auth_token=USER.auth_token,
}
)
end

View File

@@ -9,16 +9,16 @@ function Tick.httpREQ_getAccessToken(task)
local res=json.decode(response.body)
if res then
LOG.print(text.accessSuccessed)
ACCOUNT.access_token=res.access_token
FILE.save(ACCOUNT,"conf/account")
USER.access_token=res.access_token
FILE.save(USER,"conf/account")
SCN.swapTo("netgame")
else
LOG.print(text.netErrorCode..response.code..": "..res.message,"warn")
end
else
LOGIN=false
ACCOUNT.access_token=nil
ACCOUNT.auth_token=nil
USER.access_token=nil
USER.auth_token=nil
local err=json.decode(response.body)
if err then
LOG.print(text.loginFailed..": "..text.netErrorCode..response.code.."-"..err.message,"warn")