Sharkey/src/client/app/mobile/views/pages/othello.vue

51 lines
926 B
Vue
Raw Normal View History

2018-03-07 11:55:02 +02:00
<template>
<mk-ui>
<span slot="header">%fa:gamepad%オセロ</span>
2018-03-09 18:48:16 +02:00
<mk-othello v-if="!fetching" :init-game="game" @gamed="onGamed"/>
2018-03-07 11:55:02 +02:00
</mk-ui>
</template>
<script lang="ts">
import Vue from 'vue';
2018-03-09 18:48:16 +02:00
import Progress from '../../../common/scripts/loading';
2018-03-07 11:55:02 +02:00
export default Vue.extend({
2018-03-09 18:48:16 +02:00
data() {
return {
fetching: false,
game: null
};
},
watch: {
$route: 'fetch'
},
created() {
this.fetch();
},
2018-03-07 11:55:02 +02:00
mounted() {
document.title = 'Misskey オセロ';
document.documentElement.style.background = '#fff';
2018-03-09 18:48:16 +02:00
},
methods: {
fetch() {
if (this.$route.params.game == null) return;
Progress.start();
this.fetching = true;
(this as any).api('othello/games/show', {
2018-03-29 08:48:47 +03:00
gameId: this.$route.params.game
2018-03-09 18:48:16 +02:00
}).then(game => {
this.game = game;
this.fetching = false;
Progress.done();
});
},
onGamed(game) {
history.pushState(null, null, '/othello/' + game.id);
}
2018-03-07 11:55:02 +02:00
}
});
</script>