refactor(client): use composition api

This commit is contained in:
syuilo 2022-01-07 15:02:25 +09:00
parent f06ded9433
commit 6558cd2f27
6 changed files with 43 additions and 97 deletions

View File

@ -5,28 +5,17 @@
</span>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import * as misskey from 'misskey-js';
import { toUnicode } from 'punycode/';
import { host } from '@/config';
import { host as hostRaw } from '@/config';
export default defineComponent({
props: {
user: {
type: Object,
required: true
},
detail: {
type: Boolean,
default: false
},
},
data() {
return {
host: toUnicode(host),
};
}
});
defineProps<{
user: misskey.entities.UserDetailed;
detail?: boolean;
}>();
const host = toUnicode(hostRaw);
</script>
<style lang="scss" scoped>

View File

@ -8,19 +8,8 @@
</transition>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import MkButton from '@/components/ui/button.vue';
export default defineComponent({
components: {
MkButton,
},
data() {
return {
};
},
});
</script>
<style lang="scss" scoped>

View File

@ -22,26 +22,16 @@
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import * as os from '@/os';
<script lang="ts" setup>
import { ref } from 'vue';
import * as misskey from 'misskey-js';
import { defaultStore } from '@/store';
export default defineComponent({
props: {
video: {
type: Object,
required: true
}
},
data() {
return {
hide: true,
};
},
created() {
this.hide = (this.$store.state.nsfw === 'force') ? true : this.video.isSensitive && (this.$store.state.nsfw !== 'ignore');
},
});
const props = defineProps<{
video: misskey.entities.DriveFile;
}>();
const hide = ref((defaultStore.state.nsfw === 'force') ? true : props.video.isSensitive && (defaultStore.state.nsfw !== 'ignore'));
</script>
<style lang="scss" scoped>

View File

@ -1,6 +1,6 @@
<template>
<div class="mk-toast">
<transition name="toast" appear @after-leave="$emit('closed')">
<transition name="toast" appear @after-leave="emit('closed')">
<div v-if="showing" class="body _acrylic" :style="{ zIndex }">
<div class="message">
{{ message }}
@ -10,29 +10,25 @@
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import * as os from '@/os';
export default defineComponent({
props: {
message: {
type: String,
required: true,
},
},
emits: ['closed'],
data() {
return {
showing: true,
zIndex: os.claimZIndex('high'),
};
},
mounted() {
setTimeout(() => {
this.showing = false;
}, 4000);
}
defineProps<{
message: string;
}>();
const emit = defineEmits<{
(e: 'closed'): void;
}>();
const showing = ref(true);
const zIndex = os.claimZIndex('high');
onMounted(() => {
setTimeout(() => {
showing.value = false;
}, 4000);
});
</script>

View File

@ -76,7 +76,7 @@ export default defineComponent({
tweetExpanded: this.detail,
embedId: `embed${Math.random().toString().replace(/\D/,'')}`,
tweetHeight: 150,
tweetLeft: 0,
tweetLeft: 0,
playerEnabled: false,
self: self,
attr: self ? 'to' : 'href',

View File

@ -27,32 +27,14 @@
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import * as misskey from 'misskey-js';
import MkFollowButton from './follow-button.vue';
import { userPage } from '@/filters/user';
export default defineComponent({
components: {
MkFollowButton
},
props: {
user: {
type: Object,
required: true
},
},
data() {
return {
};
},
methods: {
userPage,
}
});
defineProps<{
user: misskey.entities.UserDetailed;
}>();
</script>
<style lang="scss" scoped>