refactor(client): refactor components

This commit is contained in:
syuilo 2022-07-24 15:45:16 +09:00
parent bd8db402e6
commit 92f9392bcf
3 changed files with 93 additions and 119 deletions

View file

@ -1,5 +1,6 @@
<template> <template>
<button v-if="canRenote" <button
v-if="canRenote"
ref="buttonRef" ref="buttonRef"
class="eddddedb _button canRenote" class="eddddedb _button canRenote"
@click="renote()" @click="renote()"
@ -12,8 +13,9 @@
</button> </button>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { computed, defineComponent, ref } from 'vue'; import { computed, ref } from 'vue';
import * as misskey from 'misskey-js';
import XDetails from '@/components/users-tooltip.vue'; import XDetails from '@/components/users-tooltip.vue';
import { pleaseLogin } from '@/scripts/please-login'; import { pleaseLogin } from '@/scripts/please-login';
import * as os from '@/os'; import * as os from '@/os';
@ -21,19 +23,11 @@ import { $i } from '@/account';
import { useTooltip } from '@/scripts/use-tooltip'; import { useTooltip } from '@/scripts/use-tooltip';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
export default defineComponent({ const props = defineProps<{
props: { note: misskey.entities.Note;
count: { count: number;
type: Number, }>();
required: true,
},
note: {
type: Object,
required: true,
},
},
setup(props) {
const buttonRef = ref<HTMLElement>(); const buttonRef = ref<HTMLElement>();
const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id); const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id);
@ -41,7 +35,7 @@ export default defineComponent({
useTooltip(buttonRef, async (showing) => { useTooltip(buttonRef, async (showing) => {
const renotes = await os.api('notes/renotes', { const renotes = await os.api('notes/renotes', {
noteId: props.note.id, noteId: props.note.id,
limit: 11 limit: 11,
}); });
const users = renotes.map(x => x.user); const users = renotes.map(x => x.user);
@ -52,7 +46,7 @@ export default defineComponent({
showing, showing,
users, users,
count: props.count, count: props.count,
targetElement: buttonRef.value targetElement: buttonRef.value,
}, {}, 'closed'); }, {}, 'closed');
}); });
@ -63,9 +57,9 @@ export default defineComponent({
icon: 'fas fa-retweet', icon: 'fas fa-retweet',
action: () => { action: () => {
os.api('notes/create', { os.api('notes/create', {
renoteId: props.note.id renoteId: props.note.id,
}); });
} },
}, { }, {
text: i18n.ts.quote, text: i18n.ts.quote,
icon: 'fas fa-quote-right', icon: 'fas fa-quote-right',
@ -73,19 +67,11 @@ export default defineComponent({
os.post({ os.post({
renote: props.note, renote: props.note,
}); });
}
}], buttonRef.value, {
viaKeyboard
});
};
return {
buttonRef,
canRenote,
renote,
};
}, },
}], buttonRef.value, {
viaKeyboard,
}); });
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View file

@ -63,12 +63,9 @@
</span> </span>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, onMounted, onUnmounted, ref } from 'vue'; import { onMounted, onUnmounted, ref } from 'vue';
import * as os from '@/os';
export default defineComponent({
setup() {
const particles = ref([]); const particles = ref([]);
const el = ref<HTMLElement>(); const el = ref<HTMLElement>();
const width = ref(0); const width = ref(0);
@ -112,15 +109,6 @@ export default defineComponent({
if (ro) ro.disconnect(); if (ro) ro.disconnect();
stop = true; stop = true;
}); });
return {
el,
width,
height,
particles,
};
},
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View file

@ -18,13 +18,13 @@ export default defineComponent({
disabled: this.modelValue === option.props.value, disabled: this.modelValue === option.props.value,
onClick: () => { onClick: () => {
this.$emit('update:modelValue', option.props.value); this.$emit('update:modelValue', option.props.value);
} },
}, option.children), [ }, option.children), [
[resolveDirective('click-anime')] [resolveDirective('click-anime')],
]))), [ ]))), [
[resolveDirective('size'), { max: [500] }] [resolveDirective('size'), { max: [500] }],
]); ]);
} },
}); });
</script> </script>