Commit 03def38d authored by 陈冲's avatar 陈冲

commit

parent 2912c668
...@@ -215,6 +215,7 @@ if (wechat) { ...@@ -215,6 +215,7 @@ if (wechat) {
} }
onMounted(() => { onMounted(() => {
document.title = '小游戏 - 击鼓齐福'
if (token.value) { if (token.value) {
window.addEventListener('beforeunload', confirmRefresh) window.addEventListener('beforeunload', confirmRefresh)
} }
......
...@@ -74,7 +74,7 @@ onMounted(() => { ...@@ -74,7 +74,7 @@ onMounted(() => {
.img-score { .img-score {
position: absolute; position: absolute;
top: 500px; top: 450px;
left: 50%; left: 50%;
width: 465px; width: 465px;
height: 731px; height: 731px;
...@@ -144,7 +144,7 @@ onMounted(() => { ...@@ -144,7 +144,7 @@ onMounted(() => {
.btn-group { .btn-group {
position: absolute; position: absolute;
top: 1354px; top: 1320px;
left: 50%; left: 50%;
display: flex; display: flex;
gap: 40px; gap: 40px;
......
...@@ -17,7 +17,7 @@ type AdminGameSocketOptions = { ...@@ -17,7 +17,7 @@ type AdminGameSocketOptions = {
onGameStart?: (data: any) => void | Promise<void> onGameStart?: (data: any) => void | Promise<void>
onGameStartRejected?: (data: any) => void onGameStartRejected?: (data: any) => void
onRoomRank?: (data: any) => void onRoomRank?: (data: any) => void
onEvent?: (evt: string, payload: SocketPayload) => void onRelogin?: () => void
} }
export function useAdminGameSocket(options: AdminGameSocketOptions) { export function useAdminGameSocket(options: AdminGameSocketOptions) {
...@@ -64,6 +64,10 @@ export function useAdminGameSocket(options: AdminGameSocketOptions) { ...@@ -64,6 +64,10 @@ export function useAdminGameSocket(options: AdminGameSocketOptions) {
options.onGameStartRejected?.(data) options.onGameStartRejected?.(data)
return return
} }
if (evt == 'login_result') {
options.onRelogin?.()
return;
}
alert(msg) alert(msg)
return return
} }
...@@ -88,8 +92,6 @@ export function useAdminGameSocket(options: AdminGameSocketOptions) { ...@@ -88,8 +92,6 @@ export function useAdminGameSocket(options: AdminGameSocketOptions) {
break break
} }
} }
options.onEvent?.(evt, payload)
}) })
}) })
......
...@@ -48,23 +48,25 @@ onMounted(() => { ...@@ -48,23 +48,25 @@ onMounted(() => {
<template> <template>
<DesignStage> <DesignStage>
<table> <form>
<tbody> <table>
<tr> <tbody>
<td>用户名</td> <tr>
<td><input v-model="username" type="text" /></td> <td>用户名</td>
</tr> <td><input v-model="username" type="text" /></td>
<tr> </tr>
<td>密码</td> <tr>
<td><input v-model="password" type="password" /></td> <td>密码</td>
</tr> <td><input v-model="password" type="password" /></td>
<tr> </tr>
<td colspan="2" align="center"> <tr>
<input type="button" value="Login" @click="loginHandler" /> <td colspan="2" align="center">
</td> <input type="button" value="登录" @click="loginHandler" />
</tr> </td>
</tbody> </tr>
</table> </tbody>
</table>
</form>
</DesignStage> </DesignStage>
</template> </template>
......
<script setup lang="ts"> <script setup lang="ts">
import { nextTick, onMounted, onUnmounted, ref } from 'vue' import { nextTick, onMounted, onUnmounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import Loading from './views/LoadingView.vue' import Loading from './views/LoadingView.vue'
import Rank1 from './views/Rank1View.vue' import Rank1 from './views/Rank1View.vue'
import Rank2 from './views/Rank2View.vue' import Rank2 from './views/Rank2View.vue'
import { useAdminGameSocket } from '@/composables/useAdminGameSocket' import { useAdminGameSocket } from '@/composables/useAdminGameSocket'
import type Player from '@/commons/player.ts' import type Player from '@/commons/player.ts'
import { playGame1Music } from '@/commons/music' import { playGame1Music } from '@/commons/music'
import { $remove_socket_storage } from '@/commons/utils.ts'
const router = useRouter()
type GameScreen = 'loading' | 'rank1' | 'rank2' type GameScreen = 'loading' | 'rank1' | 'rank2'
...@@ -145,6 +149,10 @@ const { startGame, createRoom, backRoom } = useAdminGameSocket({ ...@@ -145,6 +149,10 @@ const { startGame, createRoom, backRoom } = useAdminGameSocket({
}, },
onGameStart: gotoRank1WithIntro, onGameStart: gotoRank1WithIntro,
onRoomRank: updateRankPlayers, onRoomRank: updateRankPlayers,
onRelogin: async () => {
$remove_socket_storage();
await router.replace('/')
}
}) })
const startGameWithMusic = () => { const startGameWithMusic = () => {
......
...@@ -28,8 +28,8 @@ function copyImageAssets() { ...@@ -28,8 +28,8 @@ function copyImageAssets() {
export default defineConfig(({ command }) => ({ export default defineConfig(({ command }) => ({
base: command === 'build' ? '/cc/pc/' : '/', base: command === 'build' ? '/cc/pc/' : '/',
define: { define: {
// __APP_DOMAIN__: JSON.stringify(command === 'build' ? buildDomain : ''), __APP_DOMAIN__: JSON.stringify(command === 'build' ? buildDomain : ''),
__APP_DOMAIN__: JSON.stringify(buildDomain), // __APP_DOMAIN__: JSON.stringify(buildDomain),
}, },
plugins: [ plugins: [
vue(), vue(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment