misskey/src/client/app/mobile/views/pages/home.vue

250 lines
6.8 KiB
Vue
Raw Normal View History

2018-02-15 09:50:19 +01:00
<template>
2018-02-23 18:46:09 +01:00
<mk-ui>
2019-02-18 03:13:56 +01:00
<template #header>
2019-02-18 01:48:00 +01:00
<span @click="showNav = true">
<span :class="$style.title">
<span v-if="src == 'home'"><fa icon="home"/>{{ $t('home') }}</span>
<span v-if="src == 'local'"><fa :icon="['far', 'comments']"/>{{ $t('local') }}</span>
2019-04-08 16:05:41 +02:00
<span v-if="src == 'hybrid'"><fa icon="share-alt"/>{{ $t('hybrid') }}</span>
2019-02-18 01:48:00 +01:00
<span v-if="src == 'global'"><fa icon="globe"/>{{ $t('global') }}</span>
<span v-if="src == 'mentions'"><fa icon="at"/>{{ $t('mentions') }}</span>
<span v-if="src == 'messages'"><fa :icon="['far', 'envelope']"/>{{ $t('messages') }}</span>
Use PostgreSQL instead of MongoDB (#4572) * wip * Update note.ts * Update timeline.ts * Update core.ts * wip * Update generate-visibility-query.ts * wip * wip * wip * wip * wip * Update global-timeline.ts * wip * wip * wip * Update vote.ts * wip * wip * Update create.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update files.ts * wip * wip * Update CONTRIBUTING.md * wip * wip * wip * wip * wip * wip * wip * wip * Update read-notification.ts * wip * wip * wip * wip * wip * wip * wip * Update cancel.ts * wip * wip * wip * Update show.ts * wip * wip * Update gen-id.ts * Update create.ts * Update id.ts * wip * wip * wip * wip * wip * wip * wip * Docker: Update files about Docker (#4599) * Docker: Use cache if files used by `yarn install` was not updated This patch reduces the number of times to installing node_modules. For example, `yarn install` step will be skipped when only ".config/default.yml" is updated. * Docker: Migrate MongoDB to Postgresql Misskey uses Postgresql as a database instead of Mongodb since version 11. * Docker: Uncomment about data persistence This patch will save a lot of databases. * wip * wip * wip * Update activitypub.ts * wip * wip * wip * Update logs.ts * wip * Update drive-file.ts * Update register.ts * wip * wip * Update mentions.ts * wip * wip * wip * Update recommendation.ts * wip * Update index.ts * wip * Update recommendation.ts * Doc: Update docker.ja.md and docker.en.md (#1) (#4608) Update how to set up misskey. * wip * :v: * wip * Update note.ts * Update postgre.ts * wip * wip * wip * wip * Update add-file.ts * wip * wip * wip * Clean up * Update logs.ts * wip * :pizza: * wip * Ad notes * wip * Update api-visibility.ts * Update note.ts * Update add-file.ts * tests * tests * Update postgre.ts * Update utils.ts * wip * wip * Refactor * wip * Refactor * wip * wip * Update show-users.ts * Update update-instance.ts * wip * Update feed.ts * Update outbox.ts * Update outbox.ts * Update user.ts * wip * Update list.ts * Update update-hashtag.ts * wip * Update update-hashtag.ts * Refactor * Update update.ts * wip * wip * :v: * clean up * docs * Update push.ts * wip * Update api.ts * wip * :v: * Update make-pagination-query.ts * :v: * Delete hashtags.ts * Update instances.ts * Update instances.ts * Update create.ts * Update search.ts * Update reversi-game.ts * Update signup.ts * Update user.ts * id * Update example.yml * :art: * objectid * fix * reversi * reversi * Fix bug of chart engine * Add test of chart engine * Improve test * Better testing * Improve chart engine * Refactor * Add test of chart engine * Refactor * Add chart test * Fix bug * コミットし忘れ * Refactoring * :v: * Add tests * Add test * Extarct note tests * Refactor * 存在しないユーザーにメンションできなくなっていた問題を修正 * Fix bug * Update update-meta.ts * Fix bug * Update mention.vue * Fix bug * Update meta.ts * Update CONTRIBUTING.md * Fix bug * Fix bug * Fix bug * Clean up * Clean up * Update notification.ts * Clean up * Add mute tests * Add test * Refactor * Add test * Fix test * Refactor * Refactor * Add tests * Update utils.ts * Update utils.ts * Fix test * Update package.json * Update update.ts * Update manifest.ts * Fix bug * Fix bug * Add test * :art: * Update endpoint permissions * Updaye permisison * Update person.ts #4299 * データベースと同期しないように * Fix bug * Fix bug * Update reversi-game.ts * Use a feature of Node v11.7.0 to extract a public key (#4644) * wip * wip * :v: * Refactoring #1540 * test * test * test * test * test * test * test * Fix bug * Fix test * :sushi: * wip * #4471 * Add test for #4335 * Refactor * Fix test * Add tests * :clock4: * Fix bug * Add test * Add test * rename * Fix bug
2019-04-07 14:50:36 +02:00
<span v-if="src == 'list'"><fa icon="list"/>{{ list.name }}</span>
2019-02-18 01:48:00 +01:00
<span v-if="src == 'tag'"><fa icon="hashtag"/>{{ tagTl.title }}</span>
</span>
<span style="margin-left:8px">
<template v-if="!showNav"><fa icon="angle-down"/></template>
<template v-else><fa icon="angle-up"/></template>
</span>
<i :class="$style.badge" v-if="$store.state.i.hasUnreadMentions || $store.state.i.hasUnreadSpecifiedNotes"><fa icon="circle"/></i>
2018-04-26 07:01:41 +02:00
</span>
2019-02-18 01:48:00 +01:00
</template>
2018-04-26 07:01:41 +02:00
2019-02-18 03:13:56 +01:00
<template #func>
<button @click="fn"><fa icon="pencil-alt"/></button>
2018-02-23 18:46:09 +01:00
</template>
2018-04-26 07:01:41 +02:00
2018-09-28 07:26:20 +02:00
<main>
2018-04-26 07:01:41 +02:00
<div class="nav" v-if="showNav">
<div class="bg" @click="showNav = false"></div>
<div class="pointer"></div>
2018-04-26 07:01:41 +02:00
<div class="body">
2018-04-26 07:38:37 +02:00
<div>
<span :data-active="src == 'home'" @click="src = 'home'"><fa icon="home"/> {{ $t('home') }}</span>
<span :data-active="src == 'local'" @click="src = 'local'" v-if="enableLocalTimeline"><fa :icon="['far', 'comments']"/> {{ $t('local') }}</span>
2019-04-08 16:05:41 +02:00
<span :data-active="src == 'hybrid'" @click="src = 'hybrid'" v-if="enableLocalTimeline"><fa icon="share-alt"/> {{ $t('hybrid') }}</span>
2019-01-16 06:54:14 +01:00
<span :data-active="src == 'global'" @click="src = 'global'" v-if="enableGlobalTimeline"><fa icon="globe"/> {{ $t('global') }}</span>
<div class="hr"></div>
<span :data-active="src == 'mentions'" @click="src = 'mentions'"><fa icon="at"/> {{ $t('mentions') }}<i class="badge" v-if="$store.state.i.hasUnreadMentions"><fa icon="circle"/></i></span>
<span :data-active="src == 'messages'" @click="src = 'messages'"><fa :icon="['far', 'envelope']"/> {{ $t('messages') }}<i class="badge" v-if="$store.state.i.hasUnreadSpecifiedNotes"><fa icon="circle"/></i></span>
2018-04-26 07:38:37 +02:00
<template v-if="lists">
2018-09-18 06:12:41 +02:00
<div class="hr" v-if="lists.length > 0"></div>
2019-04-15 04:59:25 +02:00
<span v-for="l in lists" :data-active="src == 'list' && list == l" @click="src = 'list'; list = l" :key="l.id"><fa icon="list"/> {{ l.name }}</span>
2018-04-26 07:38:37 +02:00
</template>
<div class="hr" v-if="$store.state.settings.tagTimelines && $store.state.settings.tagTimelines.length > 0"></div>
<span v-for="tl in $store.state.settings.tagTimelines" :data-active="src == 'tag' && tagTl == tl" @click="src = 'tag'; tagTl = tl" :key="tl.id"><fa icon="hashtag"/> {{ tl.title }}</span>
2018-04-26 07:38:37 +02:00
</div>
2018-04-26 07:01:41 +02:00
</div>
2018-02-23 18:46:09 +01:00
</div>
2018-04-26 07:01:41 +02:00
<div class="tl">
2018-05-26 17:18:44 +02:00
<x-tl v-if="src == 'home'" ref="tl" key="home" src="home"/>
2018-04-26 07:01:41 +02:00
<x-tl v-if="src == 'local'" ref="tl" key="local" src="local"/>
2019-04-08 16:05:41 +02:00
<x-tl v-if="src == 'hybrid'" ref="tl" key="hybrid" src="hybrid"/>
2018-04-26 07:01:41 +02:00
<x-tl v-if="src == 'global'" ref="tl" key="global" src="global"/>
<x-tl v-if="src == 'mentions'" ref="tl" key="mentions" src="mentions"/>
<x-tl v-if="src == 'messages'" ref="tl" key="messages" src="messages"/>
<x-tl v-if="src == 'tag'" ref="tl" key="tag" src="tag" :tag-tl="tagTl"/>
2018-05-26 17:18:44 +02:00
<mk-user-list-timeline v-if="src == 'list'" ref="tl" :key="list.id" :list="list"/>
2018-02-23 18:46:09 +01:00
</div>
</main>
2018-02-15 09:50:19 +01:00
</mk-ui>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
2018-02-15 09:50:19 +01:00
import Progress from '../../../common/scripts/loading';
2018-04-26 07:01:41 +02:00
import XTl from './home.timeline.vue';
2018-02-15 09:50:19 +01:00
export default Vue.extend({
i18n: i18n('mobile/views/pages/home.vue'),
2018-02-23 18:46:09 +01:00
components: {
2018-04-26 07:01:41 +02:00
XTl
2018-02-23 18:46:09 +01:00
},
2018-04-26 07:01:41 +02:00
2018-02-15 09:50:19 +01:00
data() {
return {
2018-04-26 07:01:41 +02:00
src: 'home',
list: null,
2018-04-26 07:38:37 +02:00
lists: null,
tagTl: null,
2018-09-11 19:48:19 +02:00
showNav: false,
2019-01-16 06:54:14 +01:00
enableLocalTimeline: false,
enableGlobalTimeline: false,
2018-02-15 09:50:19 +01:00
};
},
2018-02-23 19:03:26 +01:00
2018-04-26 07:38:37 +02:00
watch: {
src() {
this.showNav = false;
2018-05-26 19:56:54 +02:00
this.saveSrc();
2018-05-26 17:18:44 +02:00
},
list(x) {
2018-05-26 17:18:44 +02:00
this.showNav = false;
2018-05-26 19:56:54 +02:00
this.saveSrc();
if (x != null) this.tagTl = null;
},
tagTl(x) {
this.showNav = false;
this.saveSrc();
if (x != null) this.list = null;
2018-04-26 07:38:37 +02:00
},
showNav(v) {
if (v && this.lists === null) {
2018-11-09 00:13:34 +01:00
this.$root.api('users/lists/list').then(lists => {
2018-04-26 07:38:37 +02:00
this.lists = lists;
});
}
}
},
created() {
this.$root.getMeta().then((meta: Record<string, any>) => {
if (!(
this.enableGlobalTimeline = !meta.disableGlobalTimeline || this.$store.state.i.isModerator || this.$store.state.i.isAdmin
) && this.src === 'global') this.src = 'local';
if (!(
this.enableLocalTimeline = !meta.disableLocalTimeline || this.$store.state.i.isModerator || this.$store.state.i.isAdmin
2019-04-08 16:05:41 +02:00
) && ['local', 'hybrid'].includes(this.src)) this.src = 'home';
2018-09-11 19:48:19 +02:00
});
2018-05-26 17:18:44 +02:00
if (this.$store.state.device.tl) {
this.src = this.$store.state.device.tl.src;
if (this.src == 'list') {
this.list = this.$store.state.device.tl.arg;
} else if (this.src == 'tag') {
this.tagTl = this.$store.state.device.tl.arg;
2018-05-26 17:18:44 +02:00
}
}
},
2018-02-15 09:50:19 +01:00
mounted() {
2018-11-09 00:26:32 +01:00
document.title = this.$root.instanceName;
2018-02-15 09:50:19 +01:00
Progress.start();
2018-05-26 17:18:44 +02:00
(this.$refs.tl as any).$once('loaded', () => {
Progress.done();
});
2018-02-15 09:50:19 +01:00
},
2018-04-26 07:01:41 +02:00
2018-02-15 09:50:19 +01:00
methods: {
fn() {
this.$post();
2018-02-15 09:50:19 +01:00
},
2018-04-26 07:01:41 +02:00
2018-05-26 19:56:54 +02:00
saveSrc() {
this.$store.commit('device/setTl', {
src: this.src,
arg: this.src == 'list' ? this.list : this.tagTl
2018-05-26 19:56:54 +02:00
});
},
2018-02-23 18:46:09 +01:00
warp() {
2018-02-15 09:50:19 +01:00
}
}
});
</script>
2018-02-23 18:46:09 +01:00
<style lang="stylus" scoped>
2018-09-28 04:49:32 +02:00
main
2018-04-26 07:01:41 +02:00
> .nav
> .pointer
position fixed
z-index 10002
top 56px
left 0
right 0
$size = 16px
&:after
content ""
display block
position absolute
top -($size * 2)
left s('calc(50% - %s)', $size)
border-top solid $size transparent
border-left solid $size transparent
border-right solid $size transparent
2018-09-28 04:49:32 +02:00
border-bottom solid $size var(--popupBg)
2018-04-26 07:01:41 +02:00
> .bg
position fixed
z-index 10000
top 0
left 0
width 100%
height 100%
background rgba(#000, 0.5)
> .body
position fixed
z-index 10001
2018-04-26 07:38:37 +02:00
top 56px
2018-04-26 07:01:41 +02:00
left 0
2018-04-26 07:38:37 +02:00
right 0
width 300px
max-height calc(100% - 70px)
2018-04-26 07:38:37 +02:00
margin 0 auto
overflow auto
-webkit-overflow-scrolling touch
2018-09-28 04:49:32 +02:00
background var(--popupBg)
2018-04-26 07:01:41 +02:00
border-radius 8px
2018-04-29 01:51:17 +02:00
box-shadow 0 0 16px rgba(#000, 0.1)
2018-04-26 07:38:37 +02:00
> div
padding 8px 0
> .hr
margin 8px 0
2018-09-28 04:49:32 +02:00
border-top solid 1px var(--faceDivider)
> *:not(.hr)
2018-04-26 07:38:37 +02:00
display block
padding 8px 16px
2018-09-28 04:49:32 +02:00
color var(--text)
2018-04-26 07:38:37 +02:00
&[data-active]
2018-09-26 13:19:35 +02:00
color var(--primaryForeground)
background var(--primary)
2018-04-26 07:38:37 +02:00
&:not([data-active]):hover
2018-09-28 04:49:32 +02:00
background var(--mobileHomeTlItemHover)
2018-02-23 18:46:09 +01:00
2018-09-19 07:18:34 +02:00
> .badge
margin-left 6px
font-size 10px
2018-12-30 17:15:32 +01:00
color var(--notificationIndicator)
2018-09-19 07:18:34 +02:00
2018-02-23 18:46:09 +01:00
</style>
2018-09-19 07:18:34 +02:00
<style lang="stylus" module>
.title
[data-icon]
2018-09-19 07:18:34 +02:00
margin-right 4px
.badge
margin-left 6px
font-size 10px
2018-12-30 17:15:32 +01:00
color var(--notificationIndicator)
2018-09-19 07:18:34 +02:00
vertical-align middle
</style>