2018-02-14 05:53:52 +00:00
|
|
|
<template>
|
2018-02-23 14:30:30 +00:00
|
|
|
<div class="nav">
|
|
|
|
<transition name="back">
|
|
|
|
<div class="backdrop"
|
|
|
|
v-if="isOpen"
|
|
|
|
@click="$parent.isDrawerOpening = false"
|
|
|
|
@touchstart="$parent.isDrawerOpening = false"
|
|
|
|
></div>
|
|
|
|
</transition>
|
|
|
|
<transition name="nav">
|
|
|
|
<div class="body" v-if="isOpen">
|
2018-05-27 04:49:09 +00:00
|
|
|
<router-link class="me" v-if="$store.getters.isSignedIn" :to="`/@${$store.state.i.username}`">
|
2018-07-24 14:43:14 +00:00
|
|
|
<img class="avatar" :src="$store.state.i.avatarUrl" alt="avatar"/>
|
2018-05-27 04:49:09 +00:00
|
|
|
<p class="name">{{ $store.state.i | userName }}</p>
|
2018-02-23 14:30:30 +00:00
|
|
|
</router-link>
|
|
|
|
<div class="links">
|
|
|
|
<ul>
|
2018-05-29 19:45:27 +00:00
|
|
|
<li><router-link to="/" :data-active="$route.name == 'index'">%fa:home%%i18n:@timeline%%fa:angle-right%</router-link></li>
|
2018-05-28 16:22:39 +00:00
|
|
|
<li><router-link to="/i/notifications" :data-active="$route.name == 'notifications'">%fa:R bell%%i18n:@notifications%<template v-if="hasUnreadNotification">%fa:circle%</template>%fa:angle-right%</router-link></li>
|
2018-05-29 02:32:55 +00:00
|
|
|
<li><router-link to="/i/messaging" :data-active="$route.name == 'messaging'">%fa:R comments%%i18n:@messaging%<template v-if="hasUnreadMessagingMessage">%fa:circle%</template>%fa:angle-right%</router-link></li>
|
2018-06-02 07:13:32 +00:00
|
|
|
<li v-if="$store.getters.isSignedIn && $store.state.i.isLocked"><router-link to="/i/received-follow-requests" :data-active="$route.name == 'received-follow-requests'">%fa:R envelope%%i18n:@follow-requests%<template v-if="$store.getters.isSignedIn && $store.state.i.pendingReceivedFollowRequestsCount">%fa:circle%</template>%fa:angle-right%</router-link></li>
|
2018-06-16 23:10:54 +00:00
|
|
|
<li><router-link to="/reversi" :data-active="$route.name == 'reversi'">%fa:gamepad%%i18n:@game%<template v-if="hasGameInvitation">%fa:circle%</template>%fa:angle-right%</router-link></li>
|
2018-02-23 14:30:30 +00:00
|
|
|
</ul>
|
|
|
|
<ul>
|
2018-05-29 19:45:27 +00:00
|
|
|
<li><router-link to="/i/widgets" :data-active="$route.name == 'widgets'">%fa:R calendar-alt%%i18n:@widgets%%fa:angle-right%</router-link></li>
|
2018-05-29 05:42:29 +00:00
|
|
|
<li><router-link to="/i/favorites" :data-active="$route.name == 'favorites'">%fa:star%%i18n:@favorites%%fa:angle-right%</router-link></li>
|
2018-05-29 19:45:27 +00:00
|
|
|
<li><router-link to="/i/lists" :data-active="$route.name == 'user-lists'">%fa:list%%i18n:@user-lists%%fa:angle-right%</router-link></li>
|
2018-04-27 17:29:17 +00:00
|
|
|
<li><router-link to="/i/drive" :data-active="$route.name == 'drive'">%fa:cloud%%i18n:@drive%%fa:angle-right%</router-link></li>
|
2018-02-23 14:30:30 +00:00
|
|
|
</ul>
|
|
|
|
<ul>
|
2018-04-14 16:04:40 +00:00
|
|
|
<li><a @click="search">%fa:search%%i18n:@search%%fa:angle-right%</a></li>
|
2018-05-22 02:31:06 +00:00
|
|
|
<li><router-link to="/i/settings" :data-active="$route.name == 'settings'">%fa:cog%%i18n:@settings%%fa:angle-right%</router-link></li>
|
2018-05-29 05:42:29 +00:00
|
|
|
<li @click="dark"><p><template v-if="$store.state.device.darkmode">%fa:moon%</template><template v-else>%fa:R moon%</template><span>%i18n:@darkmode%</span></p></li>
|
2018-02-23 14:30:30 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
2018-04-14 16:04:40 +00:00
|
|
|
<a :href="aboutUrl"><p class="about">%i18n:@about%</p></a>
|
2018-02-14 05:53:52 +00:00
|
|
|
</div>
|
2018-02-23 14:30:30 +00:00
|
|
|
</transition>
|
2018-02-14 05:53:52 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-08-22 00:31:35 +00:00
|
|
|
import { lang } from '../../../config';
|
2018-02-14 05:53:52 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-02-21 22:06:47 +00:00
|
|
|
props: ['isOpen'],
|
2018-02-14 05:53:52 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2018-05-28 16:22:39 +00:00
|
|
|
hasGameInvitation: false,
|
2018-02-14 05:53:52 +00:00
|
|
|
connection: null,
|
2018-02-21 22:06:47 +00:00
|
|
|
connectionId: null,
|
2018-08-22 00:31:35 +00:00
|
|
|
aboutUrl: `/docs/${lang}/about`
|
2018-02-14 05:53:52 +00:00
|
|
|
};
|
|
|
|
},
|
2018-05-28 16:22:39 +00:00
|
|
|
computed: {
|
|
|
|
hasUnreadNotification(): boolean {
|
|
|
|
return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadNotification;
|
|
|
|
},
|
|
|
|
hasUnreadMessagingMessage(): boolean {
|
|
|
|
return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadMessagingMessage;
|
|
|
|
}
|
|
|
|
},
|
2018-02-14 05:53:52 +00:00
|
|
|
mounted() {
|
2018-05-27 04:49:09 +00:00
|
|
|
if (this.$store.getters.isSignedIn) {
|
2018-02-18 03:35:18 +00:00
|
|
|
this.connection = (this as any).os.stream.getConnection();
|
|
|
|
this.connectionId = (this as any).os.stream.use();
|
2018-02-14 05:53:52 +00:00
|
|
|
|
2018-06-16 23:10:54 +00:00
|
|
|
this.connection.on('reversi_invited', this.onReversiInvited);
|
|
|
|
this.connection.on('reversi_no_invites', this.onReversiNoInvites);
|
2018-02-14 05:53:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-05-27 04:49:09 +00:00
|
|
|
if (this.$store.getters.isSignedIn) {
|
2018-06-16 23:10:54 +00:00
|
|
|
this.connection.off('reversi_invited', this.onReversiInvited);
|
|
|
|
this.connection.off('reversi_no_invites', this.onReversiNoInvites);
|
2018-02-18 03:35:18 +00:00
|
|
|
(this as any).os.stream.dispose(this.connectionId);
|
2018-02-14 05:53:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
search() {
|
2018-05-20 11:26:38 +00:00
|
|
|
const query = window.prompt('%i18n:@search%');
|
2018-02-14 05:53:52 +00:00
|
|
|
if (query == null || query == '') return;
|
2018-02-21 18:11:24 +00:00
|
|
|
this.$router.push('/search?q=' + encodeURIComponent(query));
|
2018-02-14 05:53:52 +00:00
|
|
|
},
|
2018-06-16 23:10:54 +00:00
|
|
|
onReversiInvited() {
|
2018-05-28 16:22:39 +00:00
|
|
|
this.hasGameInvitation = true;
|
2018-03-11 09:08:26 +00:00
|
|
|
},
|
2018-06-16 23:10:54 +00:00
|
|
|
onReversiNoInvites() {
|
2018-05-28 16:22:39 +00:00
|
|
|
this.hasGameInvitation = false;
|
2018-04-27 17:29:17 +00:00
|
|
|
},
|
|
|
|
dark() {
|
2018-05-23 20:28:46 +00:00
|
|
|
this.$store.commit('device/set', {
|
|
|
|
key: 'darkmode',
|
|
|
|
value: !this.$store.state.device.darkmode
|
|
|
|
});
|
2018-02-14 05:53:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-03-03 04:47:55 +00:00
|
|
|
@import '~const.styl'
|
|
|
|
|
2018-04-27 17:29:17 +00:00
|
|
|
root(isDark)
|
|
|
|
$color = isDark ? #c9d2e0 : #777
|
|
|
|
|
2018-02-14 05:53:52 +00:00
|
|
|
.backdrop
|
|
|
|
position fixed
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
z-index 1025
|
|
|
|
width 100%
|
|
|
|
height 100%
|
2018-04-27 17:29:17 +00:00
|
|
|
background isDark ? rgba(#000, 0.7) : rgba(#000, 0.2)
|
2018-02-14 05:53:52 +00:00
|
|
|
|
|
|
|
.body
|
|
|
|
position fixed
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
z-index 1026
|
|
|
|
width 240px
|
|
|
|
height 100%
|
|
|
|
overflow auto
|
|
|
|
-webkit-overflow-scrolling touch
|
2018-04-27 17:29:17 +00:00
|
|
|
background isDark ? #16191f : #fff
|
2018-02-14 05:53:52 +00:00
|
|
|
|
|
|
|
.me
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 16px
|
|
|
|
|
|
|
|
.avatar
|
|
|
|
display inline
|
|
|
|
max-width 64px
|
|
|
|
border-radius 32px
|
|
|
|
vertical-align middle
|
|
|
|
|
|
|
|
.name
|
|
|
|
display block
|
|
|
|
margin 0 16px
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
left 80px
|
|
|
|
padding 0
|
|
|
|
width calc(100% - 112px)
|
2018-04-27 17:29:17 +00:00
|
|
|
color $color
|
2018-02-14 05:53:52 +00:00
|
|
|
line-height 96px
|
|
|
|
overflow hidden
|
|
|
|
text-overflow ellipsis
|
|
|
|
white-space nowrap
|
|
|
|
|
|
|
|
ul
|
|
|
|
display block
|
|
|
|
margin 16px 0
|
|
|
|
padding 0
|
|
|
|
list-style none
|
|
|
|
|
|
|
|
&:first-child
|
|
|
|
margin-top 0
|
|
|
|
|
2018-05-29 19:45:27 +00:00
|
|
|
&:last-child
|
|
|
|
margin-bottom 0
|
|
|
|
|
|
|
|
> li
|
2018-02-14 05:53:52 +00:00
|
|
|
display block
|
|
|
|
font-size 1em
|
|
|
|
line-height 1em
|
|
|
|
|
2018-04-27 17:29:17 +00:00
|
|
|
a, p
|
2018-02-14 05:53:52 +00:00
|
|
|
display block
|
2018-04-27 17:29:17 +00:00
|
|
|
margin 0
|
2018-02-14 05:53:52 +00:00
|
|
|
padding 0 20px
|
|
|
|
line-height 3rem
|
|
|
|
line-height calc(1rem + 30px)
|
2018-04-27 17:29:17 +00:00
|
|
|
color $color
|
2018-02-14 05:53:52 +00:00
|
|
|
text-decoration none
|
|
|
|
|
2018-04-27 17:29:17 +00:00
|
|
|
&[data-active]
|
|
|
|
color $theme-color-foreground
|
|
|
|
background $theme-color
|
|
|
|
|
|
|
|
> [data-fa]:last-child
|
|
|
|
color $theme-color-foreground
|
|
|
|
|
2018-02-14 05:53:52 +00:00
|
|
|
> [data-fa]:first-child
|
|
|
|
margin-right 0.5em
|
2018-05-29 10:03:03 +00:00
|
|
|
width 20px
|
|
|
|
text-align center
|
2018-02-14 05:53:52 +00:00
|
|
|
|
|
|
|
> [data-fa].circle
|
|
|
|
margin-left 6px
|
|
|
|
font-size 10px
|
|
|
|
color $theme-color
|
|
|
|
|
|
|
|
> [data-fa]:last-child
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
right 0
|
|
|
|
padding 0 20px
|
|
|
|
font-size 1.2em
|
|
|
|
line-height calc(1rem + 30px)
|
2018-04-27 17:29:17 +00:00
|
|
|
color $color
|
2018-04-28 03:00:58 +00:00
|
|
|
opacity 0.5
|
2018-02-14 05:53:52 +00:00
|
|
|
|
|
|
|
.about
|
2018-05-29 19:45:27 +00:00
|
|
|
margin 0 0 8px 0
|
2018-02-14 05:53:52 +00:00
|
|
|
padding 1em 0
|
|
|
|
text-align center
|
|
|
|
font-size 0.8em
|
2018-04-27 17:29:17 +00:00
|
|
|
color $color
|
2018-02-14 05:53:52 +00:00
|
|
|
opacity 0.5
|
|
|
|
|
2018-02-23 14:30:30 +00:00
|
|
|
.nav-enter-active,
|
|
|
|
.nav-leave-active {
|
|
|
|
opacity: 1;
|
|
|
|
transform: translateX(0);
|
|
|
|
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
.nav-enter,
|
|
|
|
.nav-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(-240px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.back-enter-active,
|
|
|
|
.back-leave-active {
|
|
|
|
opacity: 1;
|
|
|
|
transition: opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
.back-enter,
|
|
|
|
.back-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2018-04-27 17:29:17 +00:00
|
|
|
.nav[data-darkmode]
|
|
|
|
root(true)
|
|
|
|
|
|
|
|
.nav:not([data-darkmode])
|
|
|
|
root(false)
|
|
|
|
|
2018-02-14 05:53:52 +00:00
|
|
|
</style>
|