This commit is contained in:
syuilo 2018-02-22 22:51:33 +09:00
parent e651bd12c3
commit 4b228432c1
7 changed files with 92 additions and 87 deletions

View file

@ -16,6 +16,8 @@ import friendsMaker from './friends-maker.vue';
import notification from './notification.vue'; import notification from './notification.vue';
import notifications from './notifications.vue'; import notifications from './notifications.vue';
import notificationPreview from './notification-preview.vue'; import notificationPreview from './notification-preview.vue';
import usersList from './users-list.vue';
import userPreview from './user-preview.vue';
Vue.component('mk-ui', ui); Vue.component('mk-ui', ui);
Vue.component('mk-home', home); Vue.component('mk-home', home);
@ -33,3 +35,5 @@ Vue.component('mk-friends-maker', friendsMaker);
Vue.component('mk-notification', notification); Vue.component('mk-notification', notification);
Vue.component('mk-notifications', notifications); Vue.component('mk-notifications', notifications);
Vue.component('mk-notification-preview', notificationPreview); Vue.component('mk-notification-preview', notificationPreview);
Vue.component('mk-users-list', usersList);
Vue.component('mk-user-preview', userPreview);

View file

@ -1,26 +0,0 @@
<template>
<mk-users-list
:fetch="fetch"
:count="user.followers_count"
:you-know-count="user.followers_you_know_count"
>
%i18n:mobile.tags.mk-user-followers.no-users%
</mk-users-list>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: ['user'],
methods: {
fetch(iknow, limit, cursor, cb) {
(this as any).api('users/followers', {
user_id: this.user.id,
iknow: iknow,
limit: limit,
cursor: cursor ? cursor : undefined
}).then(cb);
}
}
});
</script>

View file

@ -1,26 +0,0 @@
<template>
<mk-users-list
:fetch="fetch"
:count="user.following_count"
:you-know-count="user.following_you_know_count"
>
%i18n:mobile.tags.mk-user-following.no-users%
</mk-users-list>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: ['user'],
methods: {
fetch(iknow, limit, cursor, cb) {
(this as any).api('users/following', {
user_id: this.user.id,
iknow: iknow,
limit: limit,
cursor: cursor ? cursor : undefined
}).then(cb);
}
}
});
</script>

View file

@ -1,11 +1,11 @@
<template> <template>
<div class="mk-user-preview"> <div class="mk-user-preview">
<a class="avatar-anchor" :href="`/${user.username}`"> <router-link class="avatar-anchor" :to="`/${user.username}`">
<img class="avatar" :src="`${user.avatar_url}?thumbnail&size=64`" alt="avatar"/> <img class="avatar" :src="`${user.avatar_url}?thumbnail&size=64`" alt="avatar"/>
</a> </router-link>
<div class="main"> <div class="main">
<header> <header>
<a class="name" :href="`/${user.username}`">{{ user.name }}</a> <router-link class="name" :to="`/${user.username}`">{{ user.name }}</router-link>
<span class="username">@{{ user.username }}</span> <span class="username">@{{ user.username }}</span>
</header> </header>
<div class="body"> <div class="body">

View file

@ -32,13 +32,18 @@ export default Vue.extend({
next: null next: null
}; };
}, },
watch: {
mode() {
this._fetch();
}
},
mounted() { mounted() {
this._fetch(() => { this._fetch(() => {
this.$emit('loaded'); this.$emit('loaded');
}); });
}, },
methods: { methods: {
_fetch(cb) { _fetch(cb?) {
this.fetching = true; this.fetching = true;
this.fetch(this.mode == 'iknow', this.limit, null, obj => { this.fetch(this.mode == 'iknow', this.limit, null, obj => {
this.users = obj.users; this.users = obj.users;

View file

@ -1,10 +1,18 @@
<template> <template>
<mk-ui> <mk-ui>
<span slot="header" v-if="!fetching"> <template slot="header" v-if="!fetching">
<img :src="`${user.avatar_url}?thumbnail&size=64`" alt=""> <img :src="`${user.avatar_url}?thumbnail&size=64`" alt="">
{{ '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) }} {{ '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) }}
</span> </template>
<mk-user-followers v-if="!fetching" :user="user" @loaded="onLoaded"/> <mk-users-list
v-if="!fetching"
:fetch="fetchUsers"
:count="user.followers_count"
:you-know-count="user.followers_you_know_count"
@loaded="onLoaded"
>
%i18n:mobile.tags.mk-user-followers.no-users%
</mk-users-list>
</mk-ui> </mk-ui>
</template> </template>
@ -13,29 +21,45 @@ import Vue from 'vue';
import Progress from '../../../common/scripts/loading'; import Progress from '../../../common/scripts/loading';
export default Vue.extend({ export default Vue.extend({
props: ['username'],
data() { data() {
return { return {
fetching: true, fetching: true,
user: null user: null
}; };
}, },
watch: {
$route: 'fetch'
},
created() {
this.fetch();
},
mounted() { mounted() {
Progress.start(); document.documentElement.style.background = '#313a42';
(this as any).api('users/show', {
username: this.username
}).then(user => {
this.user = user;
this.fetching = false;
document.title = '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) + ' | Misskey';
document.documentElement.style.background = '#313a42';
});
}, },
methods: { methods: {
fetch() {
Progress.start();
this.fetching = true;
(this as any).api('users/show', {
username: this.$route.params.user
}).then(user => {
this.user = user;
this.fetching = false;
document.title = '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) + ' | Misskey';
});
},
onLoaded() { onLoaded() {
Progress.done(); Progress.done();
},
fetchUsers(iknow, limit, cursor, cb) {
(this as any).api('users/followers', {
user_id: this.user.id,
iknow: iknow,
limit: limit,
cursor: cursor ? cursor : undefined
}).then(cb);
} }
} }
}); });

View file

@ -1,10 +1,18 @@
<template> <template>
<mk-ui> <mk-ui>
<span slot="header" v-if="!fetching"> <template slot="header" v-if="!fetching">
<img :src="`${user.avatar_url}?thumbnail&size=64`" alt=""> <img :src="`${user.avatar_url}?thumbnail&size=64`" alt="">
{{ '%i18n:mobile.tags.mk-user-following-page.following-of'.replace('{}', user.name) }} {{ '%i18n:mobile.tags.mk-user-following-page.following-of%'.replace('{}', user.name) }}
</span> </template>
<mk-user-following v-if="!fetching" :user="user" @loaded="onLoaded"/> <mk-users-list
v-if="!fetching"
:fetch="fetchUsers"
:count="user.following_count"
:you-know-count="user.following_you_know_count"
@loaded="onLoaded"
>
%i18n:mobile.tags.mk-user-following.no-users%
</mk-users-list>
</mk-ui> </mk-ui>
</template> </template>
@ -13,29 +21,45 @@ import Vue from 'vue';
import Progress from '../../../common/scripts/loading'; import Progress from '../../../common/scripts/loading';
export default Vue.extend({ export default Vue.extend({
props: ['username'],
data() { data() {
return { return {
fetching: true, fetching: true,
user: null user: null
}; };
}, },
watch: {
$route: 'fetch'
},
created() {
this.fetch();
},
mounted() { mounted() {
Progress.start(); document.documentElement.style.background = '#313a42';
(this as any).api('users/show', {
username: this.username
}).then(user => {
this.user = user;
this.fetching = false;
document.title = '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) + ' | Misskey';
document.documentElement.style.background = '#313a42';
});
}, },
methods: { methods: {
fetch() {
Progress.start();
this.fetching = true;
(this as any).api('users/show', {
username: this.$route.params.user
}).then(user => {
this.user = user;
this.fetching = false;
document.title = '%i18n:mobile.tags.mk-user-followers-page.followers-of%'.replace('{}', user.name) + ' | Misskey';
});
},
onLoaded() { onLoaded() {
Progress.done(); Progress.done();
},
fetchUsers(iknow, limit, cursor, cb) {
(this as any).api('users/following', {
user_id: this.user.id,
iknow: iknow,
limit: limit,
cursor: cursor ? cursor : undefined
}).then(cb);
} }
} }
}); });