puzzle/public/index.html

56 lines
1.5 KiB
HTML
Raw Normal View History

2020-11-25 22:03:35 +01:00
<html>
<head>
<link rel="stylesheet" href="/style.css" />
<script src="https://unpkg.com/vue@3.0.11"></script>
2021-05-13 16:58:21 +02:00
<script src="https://unpkg.com/vue-router@4.0.8"></script>
2020-12-03 21:42:25 +01:00
<title>🧩 jigsaw.hyottoko.club</title>
2020-11-25 22:03:35 +01:00
</head>
<body>
<div id="app"></div>
<script type="module">
2021-05-13 16:58:21 +02:00
import App from "/App.vue.js"
2021-05-01 08:42:39 +02:00
import Index from "/views/Index.vue.js"
2021-05-13 16:58:21 +02:00
import NewGame from "/views/NewGame.vue.js"
import Game from "/views/Game.vue.js"
import Replay from "/views/Replay.vue.js"
2021-05-13 22:45:55 +02:00
(async () => {
const res = await fetch(`/api/conf`)
const conf = await res.json()
2021-05-13 16:58:21 +02:00
function initme() {
let ID = localStorage.getItem('ID')
if (!ID) {
ID = Util.uniqId()
localStorage.setItem('ID', ID)
}
return ID
}
2021-05-13 22:45:55 +02:00
const router = VueRouter.createRouter({
history: VueRouter.createWebHashHistory(),
routes: [
{ name: 'index', path: '/', component: Index },
{ name: 'new-game', path: '/new-game', component: NewGame },
{ name: 'game', path: '/g/:id', component: Game },
{ name: 'replay', path: '/replay/:id', component: Replay },
],
})
router.beforeEach((to, from) => {
if (from.name !== undefined) {
document.documentElement.classList.remove(`view-${from.name}`)
}
document.documentElement.classList.add(`view-${to.name}`)
})
const app = Vue.createApp(App)
app.config.globalProperties.$config = conf
app.config.globalProperties.$clientId = initme()
2021-05-13 22:45:55 +02:00
app.use(router)
app.mount('#app')
})()
2020-11-25 22:03:35 +01:00
</script>
</body>
</html>