[Client] Some optimizations
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
import Vue from 'vue';
|
||||
|
||||
import followButton from './follow-button.vue';
|
||||
import muteAndBlock from './mute-and-block.vue';
|
||||
import error from './error.vue';
|
||||
import apiSettings from './api-settings.vue';
|
||||
import passwordSettings from './password-settings.vue';
|
||||
import profileEditor from './profile-editor.vue';
|
||||
import noteSkeleton from './note-skeleton.vue';
|
||||
import theme from './theme.vue';
|
||||
import instance from './instance.vue';
|
||||
import cwButton from './cw-button.vue';
|
||||
import tagCloud from './tag-cloud.vue';
|
||||
@@ -27,7 +22,6 @@ 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 mediaList from './media-list.vue';
|
||||
import uploader from './uploader.vue';
|
||||
import streamIndicator from './stream-indicator.vue';
|
||||
@@ -52,13 +46,8 @@ import formButton from './ui/form/button.vue';
|
||||
import formRadio from './ui/form/radio.vue';
|
||||
|
||||
Vue.component('mk-follow-button', followButton);
|
||||
Vue.component('mk-mute-and-block', muteAndBlock);
|
||||
Vue.component('mk-error', error);
|
||||
Vue.component('mk-api-settings', apiSettings);
|
||||
Vue.component('mk-password-settings', passwordSettings);
|
||||
Vue.component('mk-profile-editor', profileEditor);
|
||||
Vue.component('mk-note-skeleton', noteSkeleton);
|
||||
Vue.component('mk-theme', theme);
|
||||
Vue.component('mk-instance', instance);
|
||||
Vue.component('mk-cw-button', cwButton);
|
||||
Vue.component('mk-tag-cloud', tagCloud);
|
||||
@@ -78,7 +67,6 @@ 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-media-list', mediaList);
|
||||
Vue.component('mk-uploader', uploader);
|
||||
Vue.component('mk-stream-indicator', streamIndicator);
|
||||
|
@@ -1,49 +0,0 @@
|
||||
<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>
|
Reference in New Issue
Block a user