wip: refactor(client): migrate paging components to composition api

This commit is contained in:
syuilo 2022-01-13 02:46:14 +09:00
parent 2900f998b1
commit bd1f741dad
4 changed files with 55 additions and 108 deletions

View file

@ -8,47 +8,32 @@
</div>
</template>
<script lang="ts">
import { computed, defineComponent } from 'vue';
<script lang="ts" setup>
import { computed } from 'vue';
import * as misskey from 'misskey-js';
import MkUserInfo from '@/components/user-info.vue';
import MkPagination from '@/components/ui/pagination.vue';
export default defineComponent({
components: {
MkPagination,
MkUserInfo,
},
const props = defineProps<{
user: misskey.entities.User;
type: 'following' | 'followers';
}>();
props: {
user: {
type: Object,
required: true
},
type: {
type: String,
required: true
},
},
const followingPagination = {
endpoint: 'users/following' as const,
limit: 20,
params: computed(() => ({
userId: props.user.id,
})),
};
data() {
return {
followingPagination: {
endpoint: 'users/following' as const,
limit: 20,
params: computed(() => ({
userId: this.user.id,
})),
},
followersPagination: {
endpoint: 'users/followers' as const,
limit: 20,
params: computed(() => ({
userId: this.user.id,
})),
},
};
},
});
const followersPagination = {
endpoint: 'users/followers' as const,
limit: 20,
params: computed(() => ({
userId: props.user.id,
})),
};
</script>
<style lang="scss" scoped>

View file

@ -8,27 +8,16 @@
</MkContainer>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import * as os from '@/os';
<script lang="ts" setup>
import { } from 'vue';
import * as misskey from 'misskey-js';
import MkContainer from '@/components/ui/container.vue';
import MkChart from '@/components/chart.vue';
export default defineComponent({
components: {
MkContainer,
MkChart,
},
props: {
user: {
type: Object,
required: true
},
limit: {
type: Number,
required: false,
default: 40
}
},
const props = withDefaults(defineProps<{
user: misskey.entities.User;
limit?: number;
}>(), {
limit: 40,
});
</script>

View file

@ -6,36 +6,23 @@
</div>
</template>
<script lang="ts">
import { computed, defineComponent } from 'vue';
<script lang="ts" setup>
import { computed } from 'vue';
import * as misskey from 'misskey-js';
import MkPagePreview from '@/components/page-preview.vue';
import MkPagination from '@/components/ui/pagination.vue';
export default defineComponent({
components: {
MkPagination,
MkPagePreview,
},
const props = defineProps<{
user: misskey.entities.User;
}>();
props: {
user: {
type: Object,
required: true
},
},
data() {
return {
pagination: {
endpoint: 'users/pages' as const,
limit: 20,
params: computed(() => ({
userId: this.user.id,
})),
},
};
},
});
const pagination = {
endpoint: 'users/pages' as const,
limit: 20,
params: computed(() => ({
userId: props.user.id,
})),
};
</script>
<style lang="scss" scoped>

View file

@ -13,38 +13,24 @@
</div>
</template>
<script lang="ts">
import { computed, defineComponent } from 'vue';
<script lang="ts" setup>
import { computed } from 'vue';
import * as misskey from 'misskey-js';
import MkPagination from '@/components/ui/pagination.vue';
import MkNote from '@/components/note.vue';
import MkReactionIcon from '@/components/reaction-icon.vue';
export default defineComponent({
components: {
MkPagination,
MkNote,
MkReactionIcon,
},
const props = defineProps<{
user: misskey.entities.User;
}>();
props: {
user: {
type: Object,
required: true
},
},
data() {
return {
pagination: {
endpoint: 'users/reactions' as const,
limit: 20,
params: computed(() => ({
userId: this.user.id,
})),
},
};
},
});
const pagination = {
endpoint: 'users/reactions' as const,
limit: 20,
params: computed(() => ({
userId: props.user.id,
})),
};
</script>
<style lang="scss" scoped>