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
ac4af865
Commit
ac4af865
authored
Jun 09, 2026
by
陈冲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复部分功能
parent
1a7d7b79
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
76 additions
and
36 deletions
+76
-36
main.rs
backend/src/main.rs
+10
-11
socket_io.rs
backend/src/protocols/socket_io.rs
+13
-3
useGameSocket.ts
frontend-h5/src/composables/useGameSocket.ts
+1
-1
Loading.vue
frontend-h5/src/pages/Loading.vue
+16
-2
Game.vue
frontend-h5/src/pages/game1/Game.vue
+5
-5
Game4.vue
frontend-h5/src/pages/game4/Game4.vue
+5
-5
Game5.vue
frontend-h5/src/pages/game5/Game5.vue
+5
-5
LoadingView.vue
frontend-h5/src/pages/game5/views/LoadingView.vue
+15
-0
Game.vue
frontend-h5/src/pages/game6/Game.vue
+4
-4
utils.ts
frontend-large/src/commons/utils.ts
+2
-0
No files found.
backend/src/main.rs
View file @
ac4af865
...
...
@@ -6,22 +6,21 @@ mod router;
use
commons
::
utils
::
CONFIG
as
config
;
use
db
::
init_db
;
// 后台测试页,正式线上时不要代理该路径
#[derive(rust_embed
::
RustEmbed)]
#[folder
=
"src/web"
]
struct
AssetsWeb
;
#[tokio
::
main]
async
fn
main
()
{
if
let
Err
(
err
)
=
init_db
()
.await
{
panic!
(
"init db failed: {err}"
);
}
let
router
=
Router
::
new
()
.push
(
router
::
config_router
())
.push
(
Router
::
with_path
(
"/web/{**path}"
)
.get
(
salvo
::
serve_static
::
static_embed
::
<
AssetsWeb
>
()
.fallback
(
"index.html"
)),
)
;
let
mut
router
=
Router
::
new
()
.push
(
router
::
config_router
());
if
cfg!
(
debug_assertions
)
{
#[derive(rust_embed
::
RustEmbed)]
#[folder
=
"src/web"
]
struct
AssetsWeb
;
router
=
router
.push
(
Router
::
with_path
(
"/web/{**path}"
)
.get
(
salvo
::
serve_static
::
static_embed
::
<
AssetsWeb
>
()
.fallback
(
"index.html"
)),
);
}
let
host
=
config
.host
.clone
();
dbg!
(
&
config
);
println!
(
"http://{}"
,
host
);
...
...
backend/src/protocols/socket_io.rs
View file @
ac4af865
...
...
@@ -319,7 +319,7 @@ fn emit_msgpack(socket: &SocketRef, event: &str, payload: &Value) {
}
}
/// 发送给所有
玩家,不包含管理员。
/// 发送给所有
在房间里游玩的玩家
fn
broadcast_msgpack_all_player
(
event
:
&
str
,
payload
:
&
Value
)
{
if
let
Some
(
payload
)
=
encode_msgpack
(
payload
)
{
for
socket
in
CLIENT_PLAYER_MAP
.iter
()
{
...
...
@@ -330,6 +330,16 @@ fn broadcast_msgpack_all_player(event: &str, payload: &Value) {
}
}
}
/// 发送给所有玩家(不管是否在房间里)
fn
broadcast_msgpack_all_player_2
(
event
:
&
str
,
payload
:
&
Value
)
{
if
let
Some
(
payload
)
=
encode_msgpack
(
payload
)
{
for
socket
in
CLIENT_PLAYER_MAP
.iter
()
{
let
(
state
,
socks
)
=
socket
.value
();
_
=
socks
.emit
(
event
,
&
payload
);
}
}
}
/// 发送给所有管理员
fn
broadcast_msgpack_all_admin
(
event
:
&
str
,
payload
:
&
Value
)
{
let
Some
(
payload
)
=
encode_msgpack
(
payload
)
else
{
...
...
@@ -600,9 +610,9 @@ async fn handle_room_command(
state
.status
=
RoomStatus
::
Loading
;
// let snapshot = state.snapshot();
drop
(
state
);
// dbg!(&CLIENT_PLAYER_MAP.len());
emit_msgpack
(
&
socket
,
evt
,
&
ok_resp
(
Some
(
json!
(
index
))));
broadcast_msgpack_all_player
(
evt
,
&
ok_resp
(
Some
(
json!
(
index
))));
broadcast_msgpack_all_player
_2
(
evt
,
&
ok_resp
(
Some
(
json!
(
index
))));
}
}
}
...
...
frontend-h5/src/composables/useGameSocket.ts
View file @
ac4af865
...
...
@@ -159,7 +159,7 @@ export function useGameSocket(options: GameSocketOptions) {
break
;
}
case
'room_close_result'
:
{
$toast
(
'管理员关闭了
该
房间'
)
$toast
(
'管理员关闭了
游戏
房间'
)
break
;
}
default
:
{
...
...
frontend-h5/src/pages/Loading.vue
View file @
ac4af865
<
script
setup
lang=
"ts"
>
import
{
cssAssetUrl
}
from
'@/commons/assets'
import
{
$getWechat
}
from
'@/commons/utils'
;
import
{
useGameSocket
}
from
'@/composables/useGameSocket'
;
import
{
onBeforeUnmount
,
onMounted
,
ref
,
watch
}
from
'vue'
const
imageUrls
=
{
...
...
@@ -22,12 +24,24 @@ const imageUrls = {
// rule: cssAssetUrl('game1/rule.png')
}
const
_offSocketMessage
=
ref
<
(()
=>
void
)
|
undefined
>
()
const
wechat
=
$getWechat
()
if
(
wechat
)
{
const
gameId
=
''
;
const
{
offSocketMessage
}
=
useGameSocket
({
gameId
,
auth
:
{
userid
:
wechat
.
token
,
},
})
_offSocketMessage
.
value
=
offSocketMessage
}
onMounted
(()
=>
{
document
.
title
=
'
小
游戏'
document
.
title
=
'
互动
游戏'
})
onBeforeUnmount
(()
=>
{
_offSocketMessage
.
value
?.()
})
</
script
>
...
...
frontend-h5/src/pages/game1/Game.vue
View file @
ac4af865
...
...
@@ -212,8 +212,8 @@ if (wechat) {
stopGameCountdown
()
currentView
.
value
=
'loading'
setDivDescVisible
(
false
)
// alert('管理员关闭了
该
房间')
$toast
(
'管理员关闭了
该
房间'
)
// alert('管理员关闭了
游戏
房间')
$toast
(
'管理员关闭了
游戏
房间'
)
},
onRoomBack
:
()
=>
{
resetToLoadingView
()
...
...
@@ -226,7 +226,7 @@ if (wechat) {
}
onMounted
(()
=>
{
document
.
title
=
'
小
游戏 - 击鼓齐福'
document
.
title
=
'
互动
游戏 - 击鼓齐福'
if
(
token
.
value
)
{
window
.
addEventListener
(
'beforeunload'
,
confirmRefresh
)
}
...
...
@@ -309,8 +309,8 @@ const showGameRuleHandler = () => {
background
:
v-bind
(
'imageUrls.close'
)
center
/
cover
no-repeat
;
transform
:
translateX
(
-50%
)
scale
(
1.4
);
position
:
absolute
;
bottom
:
-75px
;
left
:
5
0%
;
top
:
0
;
left
:
10
0%
;
}
}
</
style
>
frontend-h5/src/pages/game4/Game4.vue
View file @
ac4af865
...
...
@@ -123,8 +123,8 @@ function showLoadingView() {
stopGameCountdown
()
currentView
.
value
=
'loading'
setDivDescVisible
(
false
)
// alert('管理员关闭了
该
房间')
$toast
(
'管理员关闭了
该
房间'
)
// alert('管理员关闭了
游戏
房间')
$toast
(
'管理员关闭了
游戏
房间'
)
}
function
resetToLoadingView
()
{
...
...
@@ -214,7 +214,7 @@ if (wechat) {
}
onMounted
(()
=>
{
document
.
title
=
'
小
游戏 - 策马迎福'
document
.
title
=
'
互动
游戏 - 策马迎福'
if
(
token
.
value
)
{
window
.
addEventListener
(
'beforeunload'
,
confirmRefresh
)
}
...
...
@@ -293,8 +293,8 @@ onBeforeUnmount(() => {
background
:
v-bind
(
'imageUrls.close'
)
center
/
cover
no-repeat
;
transform
:
translateX
(
-50%
)
scale
(
1.4
);
position
:
absolute
;
bottom
:
-75px
;
left
:
5
0%
;
top
:
0
;
left
:
10
0%
;
}
}
</
style
>
frontend-h5/src/pages/game5/Game5.vue
View file @
ac4af865
...
...
@@ -150,8 +150,8 @@ function showLoadingView() {
stopGameCountdown
()
currentView
.
value
=
'loading'
setDivDescVisible
(
false
)
// alert('管理员关闭了
该
房间')
$toast
(
'管理员关闭了
该
房间'
)
// alert('管理员关闭了
游戏
房间')
$toast
(
'管理员关闭了
游戏
房间'
)
}
function
resetToLoadingView
()
{
...
...
@@ -253,7 +253,7 @@ if (wechat) {
}
onMounted
(()
=>
{
document
.
title
=
'
小
游戏 - 圈彩纳福'
document
.
title
=
'
互动
游戏 - 圈彩纳福'
if
(
token
.
value
)
{
window
.
addEventListener
(
'beforeunload'
,
confirmRefresh
)
}
...
...
@@ -376,8 +376,8 @@ const rankCloseHandler = () => {
background
:
v-bind
(
'imageUrls.close'
)
center
/
cover
no-repeat
;
transform
:
translateX
(
-50%
)
scale
(
1.4
);
position
:
absolute
;
bottom
:
-75px
;
left
:
5
0%
;
top
:
0
;
left
:
10
0%
;
}
}
...
...
frontend-h5/src/pages/game5/views/LoadingView.vue
View file @
ac4af865
...
...
@@ -126,6 +126,20 @@ onMounted(() => {
transform
:
translateX
(
-50%
);
}
@keyframes
loading-text-scale
{
0
%,
100
%
{
transform
:
translateX
(
-50%
)
scale
(
1
);
}
50
%
{
transform
:
translateX
(
-50%
)
scale
(
1.08
);
}
}
.txt-loading
{
position
:
absolute
;
bottom
:
4.74%
;
...
...
@@ -140,6 +154,7 @@ onMounted(() => {
font-size
:
36px
;
color
:
#FFFFFF
;
line-height
:
50px
;
animation
:
loading-text-scale
1.2s
ease-in-out
infinite
;
}
.txt-loading2
{
...
...
frontend-h5/src/pages/game6/Game.vue
View file @
ac4af865
...
...
@@ -244,7 +244,7 @@ if (wechat) {
stopGameCountdown
()
currentView
.
value
=
'loading'
setDivDescVisible
(
false
)
$toast
(
'管理员关闭了
该
房间'
)
$toast
(
'管理员关闭了
游戏
房间'
)
},
onRoomBack
:
()
=>
{
resetToLoadingView
()
...
...
@@ -257,7 +257,7 @@ if (wechat) {
}
onMounted
(()
=>
{
document
.
title
=
'
小
游戏 - 福运当头'
document
.
title
=
'
互动
游戏 - 福运当头'
if
(
token
.
value
)
{
window
.
addEventListener
(
'beforeunload'
,
confirmRefresh
)
}
...
...
@@ -384,8 +384,8 @@ const rankCloseHandler = () => {
background
:
v-bind
(
'imageUrls.close'
)
center
/
cover
no-repeat
;
transform
:
translateX
(
-50%
)
scale
(
1.4
);
position
:
absolute
;
bottom
:
-75px
;
left
:
5
0%
;
top
:
0
;
left
:
10
0%
;
}
}
...
...
frontend-large/src/commons/utils.ts
View file @
ac4af865
...
...
@@ -254,6 +254,7 @@ function ensureConfirmElement() {
'background: #fff'
,
'color: #666'
,
'font-size: 24px'
,
'cursor: pointer'
,
].
join
(
';'
);
confirmCancelElement
.
onclick
=
()
=>
closeConfirm
(
false
);
...
...
@@ -267,6 +268,7 @@ function ensureConfirmElement() {
'background: #AA0000'
,
'color: #fff'
,
'font-size: 24px'
,
'cursor: pointer'
,
].
join
(
';'
);
confirmOkElement
.
onclick
=
()
=>
closeConfirm
(
true
);
...
...
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