Skip to content

Commit

Permalink
fix splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
crashmax-dev committed Oct 15, 2024
1 parent aea9552 commit 65db1fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
6 changes: 5 additions & 1 deletion apps/frontend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import { splashScreen } from './splash-screen'
import '@/styles/splash-screen.scss'

splashScreen.init()
splashScreen.onInit(() => import('./main'))
splashScreen.onInit(() => {
const app = document.querySelector<HTMLElement>('#app')
if (app) app.style.display = 'block'
import('./main')
})
8 changes: 4 additions & 4 deletions apps/frontend/src/splash-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class SplashScreen {

onInit(callback: () => void) {
this.#callback = callback
// if (import.meta.env.DEV) {
// this.#callback()
// }
if (import.meta.env.DEV) {
this.#callback()
}
}

init() {
// if (import.meta.env.DEV) return
if (import.meta.env.DEV) return
if (this.#el) return

this.#playAudio()
Expand Down
24 changes: 11 additions & 13 deletions apps/frontend/src/stores/use-game.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { defineStore } from 'pinia'
import { useBoard } from './use-board.js'
import { useOpenedElements } from './use-opened-elements.js'
Expand Down Expand Up @@ -29,19 +29,17 @@ export const useGame = defineStore('game', () => {
openedElements.$reset()
}

onMounted(() => {
document.addEventListener('DOMContentLoaded', () => {
basicElements.value = recipes.slice(0, 4).map((element) => {
return {
uuid: crypto.randomUUID(),
id: element.id,
name: element.name,
ended: element.ended ?? false,
position: getRandomPosition()
}
})
watch(board.boardSize, () => {
basicElements.value = recipes.slice(0, 4).map((element) => {
return {
uuid: crypto.randomUUID(),
id: element.id,
name: element.name,
ended: element.ended ?? false,
position: getRandomPosition()
}
})
})
}, { deep: true, once: true })

return {
availableRecipes,
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ body, html {

#app {
height: inherit;
display: none;
}

::-webkit-scrollbar {
Expand Down

0 comments on commit 65db1fa

Please sign in to comment.