Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fc-minigame
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈冲
fc-minigame
Commits
254f0527
Commit
254f0527
authored
Jun 30, 2026
by
陈冲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修复排名提交
parent
c6bf1726
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
11 deletions
+37
-11
useGameSocket.ts
frontend-h5/src/composables/useGameSocket.ts
+37
-11
No files found.
frontend-h5/src/composables/useGameSocket.ts
View file @
254f0527
...
...
@@ -49,6 +49,14 @@ function getGameHomePath(data: any) {
return
`/game
${
gameIndex
}
`
}
function
getServerRank
(
data
:
any
)
{
const
value
=
typeof
data
===
'object'
&&
data
?
data
.
rank
??
data
.
rank_no
??
data
.
rankNo
??
data
.
game_rank
??
data
.
gameRank
:
data
const
rank
=
Number
(
value
)
return
Number
.
isFinite
(
rank
)
&&
rank
>
0
?
rank
:
0
}
export
function
joinSharedRoom
(
nickname
:
string
,
token
:
string
,
avatar
:
string
,
gameId
:
string
)
{
return
sendSocketMessage
(
'room_join'
,
{
nickname
:
nickname
,
token
,
avatar
,
gameId
:
gameId
})
}
...
...
@@ -77,6 +85,31 @@ export function useGameSocket(options: GameSocketOptions) {
let
statusTimer
:
ReturnType
<
typeof
window
.
setInterval
>
|
undefined
const
domain
=
$read
(
'domain'
,
''
);
let
resubmitcount
=
0
;
let
pendingSubmittedScore
:
SubmittedGameScore
|
undefined
let
finalScorePosted
=
false
const
postFinalScoreIfReady
=
(
data
:
any
)
=>
{
if
(
finalScorePosted
||
!
pendingSubmittedScore
||
Number
(
data
?.
status
)
!==
4
)
{
return
}
const
token_origin
=
$getWechat
()?.
token_origin
if
(
!
token_origin
||
!
Number
.
isFinite
(
pendingSubmittedScore
.
score
))
{
return
}
const
finalRank
=
getServerRank
(
data
)
const
finalScore
=
Number
(
data
?.
score
)
const
batch_no
=
$read
(
'batch_no'
)
finalScorePosted
=
true
void
postScreenGameScore
({
code
:
pendingSubmittedScore
.
code
,
score
:
Number
.
isFinite
(
finalScore
)
?
finalScore
:
pendingSubmittedScore
.
score
,
batch_no
,
rank_no
:
finalRank
,
})
}
const
stopStatusPolling
=
()
=>
{
if
(
statusTimer
)
{
...
...
@@ -186,6 +219,8 @@ export function useGameSocket(options: GameSocketOptions) {
case
'game_start_result'
:
{
if
(
data
.
index
===
options
.
gameId
)
{
$save
(
'batch_no'
,
data
.
batch_no
);
pendingSubmittedScore
=
undefined
finalScorePosted
=
false
options
.
onGameStart
?.(
data
)
}
break
...
...
@@ -195,17 +230,7 @@ export function useGameSocket(options: GameSocketOptions) {
break
}
case
'submit_score_save_result'
:
{
const
submittedScore
=
options
.
onScoreSubmitted
?.(
true
,
data
)
const
token_origin
=
$getWechat
()?.
token_origin
if
(
token_origin
&&
submittedScore
&&
Number
.
isFinite
(
submittedScore
.
score
))
{
let
batch_no
=
$read
(
'batch_no'
)
void
postScreenGameScore
({
code
:
submittedScore
.
code
,
score
:
submittedScore
.
score
,
batch_no
:
batch_no
,
rank_no
:
submittedScore
.
rank_no
,
})
}
pendingSubmittedScore
=
options
.
onScoreSubmitted
?.(
true
,
data
)
||
pendingSubmittedScore
break
}
case
'status_result'
:
{
...
...
@@ -213,6 +238,7 @@ export function useGameSocket(options: GameSocketOptions) {
return
}
options
.
onStatus
?.(
data
)
postFinalScoreIfReady
(
data
)
break
}
case
'room_back_result'
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment