-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e82cbaf
commit 7e2ae0e
Showing
8 changed files
with
529 additions
and
392 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { createApp } from 'vue'; | ||
|
||
import App from './App.vue'; | ||
|
||
import { router } from './router'; | ||
|
||
const app = createApp(App); | ||
|
||
app.mount('#app'); | ||
app.use(router).mount('#app'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<script setup> | ||
import { ref, watch } from 'vue'; | ||
import { useRoute, useRouter } from 'vue-router'; | ||
import Navbar from '../components/Navbar.vue'; | ||
import AboutModal from '../components/AboutModal.vue'; | ||
import Game from '../components/Game.vue'; | ||
const route = useRoute(); | ||
const router = useRouter(); | ||
const date = new Date(); | ||
const dateToSeed = date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate(); | ||
const seed = ref(); | ||
function handleSeed() { | ||
if (route.path === '/') { | ||
seed.value = dateToSeed; | ||
} | ||
else if (route.query.seed && validHex(route.query.seed)) { | ||
seed.value = hexToSeed(route.query.seed); | ||
} | ||
else { | ||
const hexSeed = getRandomSeed(); | ||
router.push({ query: { seed: hexSeed } }); | ||
} | ||
} | ||
handleSeed(); | ||
function validHex(hex) { | ||
return /^[0-9a-fA-F]+$/.test(hex); | ||
} | ||
function hexToSeed(hex) { | ||
return Number.parseInt(hex, 16); | ||
} | ||
function getRandomSeed() { | ||
return [...Array(6)].map(() => Math.floor(Math.random() * 16).toString(16)).join(''); | ||
} | ||
watch(() => route.query.seed, () => { | ||
handleSeed(); | ||
}); | ||
watch(() => route.path, () => { | ||
handleSeed(); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<Navbar /> | ||
<AboutModal /> | ||
<Game :seed="seed" /> | ||
</template> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createRouter, createWebHistory } from 'vue-router'; | ||
import Index from './pages/Index.vue'; | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(), | ||
routes: [ | ||
{ path: '/', name: 'Index', component: Index }, | ||
{ path: '/practice', name: 'Practice', component: Index }, | ||
], | ||
}); | ||
|
||
export { router }; |