This commit is contained in:
syuilo 2018-03-15 19:53:46 +09:00
parent f02fcd0e2a
commit 1439c3245b
22 changed files with 446 additions and 101 deletions

View file

@ -10,6 +10,7 @@ import pollEditor from './poll-editor.vue';
import reactionIcon from './reaction-icon.vue';
import reactionsViewer from './reactions-viewer.vue';
import time from './time.vue';
import timer from './timer.vue';
import images from './images.vue';
import uploader from './uploader.vue';
import specialMessage from './special-message.vue';
@ -33,6 +34,7 @@ Vue.component('mk-poll-editor', pollEditor);
Vue.component('mk-reaction-icon', reactionIcon);
Vue.component('mk-reactions-viewer', reactionsViewer);
Vue.component('mk-time', time);
Vue.component('mk-timer', timer);
Vue.component('mk-images', images);
Vue.component('mk-uploader', uploader);
Vue.component('mk-special-message', specialMessage);

View file

@ -66,7 +66,7 @@ export default Vue.extend({
},
mounted() {
this.connection = new MessagingStream((this as any).os.i, this.user.id);
this.connection = new MessagingStream((this as any).os, (this as any).os.i, this.user.id);
this.connection.on('message', this.onMessage);
this.connection.on('read', this.onRead);

View file

@ -25,7 +25,7 @@ export default Vue.extend({
},
created() {
this.g = this.game;
this.connection = new OthelloGameStream((this as any).os.i, this.game);
this.connection = new OthelloGameStream((this as any).os, (this as any).os.i, this.game);
this.connection.on('started', this.onStarted);
},
beforeDestroy() {

View file

@ -135,44 +135,6 @@ export default Vue.extend({
if (this.game.user1_id != (this as any).os.i.id && this.game.settings.form1) this.form = this.game.settings.form1;
if (this.game.user2_id != (this as any).os.i.id && this.game.settings.form2) this.form = this.game.settings.form2;
// for debugging
if ((this as any).os.i.username == 'test1') {
setTimeout(() => {
this.connection.send({
type: 'init-form',
body: [{
id: 'button1',
type: 'button',
label: 'Enable hoge',
value: false
}, {
id: 'radio1',
type: 'radio',
label: '強さ',
value: 2,
items: [{
label: '弱',
value: 1
}, {
label: '中',
value: 2
}, {
label: '強',
value: 3
}]
}]
});
this.connection.send({
type: 'message',
body: {
text: 'Hey',
type: 'info'
}
});
}, 2000);
}
},
beforeDestroy() {

View file

@ -0,0 +1,49 @@
<template>
<time class="mk-time">
{{ hh }}:{{ mm }}:{{ ss }}
</time>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
time: {
type: [Date, String],
required: true
}
},
data() {
return {
tickId: null,
hh: null,
mm: null,
ss: null
};
},
computed: {
_time(): Date {
return typeof this.time == 'string' ? new Date(this.time) : this.time;
}
},
created() {
this.tick();
this.tickId = setInterval(this.tick, 1000);
},
destroyed() {
clearInterval(this.tickId);
},
methods: {
tick() {
const now = new Date().getTime();
const start = this._time.getTime();
const ago = Math.floor((now - start) / 1000);
this.hh = Math.floor(ago / (60 * 60)).toString().padStart(2, '0');
this.mm = Math.floor(ago / 60).toString().padStart(2, '0');
this.ss = (ago % 60).toString().padStart(2, '0');
}
}
});
</script>