2018-03-10 01:48:16 +09:00
|
|
|
<template>
|
|
|
|
<component :is="ui ? 'mk-ui' : 'div'">
|
2018-06-17 08:10:54 +09:00
|
|
|
<mk-reversi v-if="!fetching" :init-game="game" @gamed="onGamed"/>
|
2018-03-10 01:48:16 +09:00
|
|
|
</component>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import Progress from '../../../common/scripts/loading';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
props: {
|
|
|
|
ui: {
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: false,
|
|
|
|
game: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route: 'fetch'
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
if (this.$route.params.game == null) return;
|
|
|
|
|
|
|
|
Progress.start();
|
|
|
|
this.fetching = true;
|
|
|
|
|
2018-06-17 08:10:54 +09:00
|
|
|
(this as any).api('reversi/games/show', {
|
2018-03-29 14:48:47 +09:00
|
|
|
gameId: this.$route.params.game
|
2018-03-10 01:48:16 +09:00
|
|
|
}).then(game => {
|
|
|
|
this.game = game;
|
|
|
|
this.fetching = false;
|
|
|
|
|
|
|
|
Progress.done();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onGamed(game) {
|
2018-06-17 08:10:54 +09:00
|
|
|
history.pushState(null, null, '/reversi/' + game.id);
|
2018-03-10 01:48:16 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|