2020-07-11 03:13:11 +02:00
|
|
|
<template>
|
|
|
|
<div class="mvcprjjd">
|
|
|
|
<transition name="nav-back">
|
2020-07-12 11:14:59 +02:00
|
|
|
<div class="nav-back _modalBg"
|
2020-07-11 03:13:11 +02:00
|
|
|
v-if="showing"
|
|
|
|
@click="showing = false"
|
2020-10-17 13:12:00 +02:00
|
|
|
@touchstart.passive="showing = false"
|
2020-07-11 03:13:11 +02:00
|
|
|
></div>
|
|
|
|
</transition>
|
|
|
|
|
|
|
|
<transition name="nav">
|
2020-08-01 03:53:23 +02:00
|
|
|
<nav class="nav" :class="{ iconOnly, hidden }" v-show="showing">
|
2020-07-11 03:13:11 +02:00
|
|
|
<div>
|
2020-11-03 09:13:21 +01:00
|
|
|
<button class="item _button account" @click="openAccountMenu">
|
2020-12-19 02:55:52 +01:00
|
|
|
<MkAvatar :user="$i" class="avatar"/><MkAcct class="text" :user="$i"/>
|
2020-07-11 03:13:11 +02:00
|
|
|
</button>
|
2020-11-03 09:16:38 +01:00
|
|
|
<MkA class="item index" active-class="active" to="/" exact>
|
2021-04-20 16:22:59 +02:00
|
|
|
<i class="fas fa-home fa-fw"></i><span class="text">{{ $ts.timeline }}</span>
|
2020-10-24 18:21:41 +02:00
|
|
|
</MkA>
|
2020-07-11 03:13:11 +02:00
|
|
|
<template v-for="item in menu">
|
|
|
|
<div v-if="item === '-'" class="divider"></div>
|
2020-10-24 18:21:41 +02:00
|
|
|
<component v-else-if="menuDef[item] && (menuDef[item].show !== false)" :is="menuDef[item].to ? 'MkA' : 'button'" class="item _button" :class="item" active-class="active" v-on="menuDef[item].action ? { click: menuDef[item].action } : {}" :to="menuDef[item].to">
|
2021-04-20 16:22:59 +02:00
|
|
|
<i class="fa-fw" :class="menuDef[item].icon"></i><span class="text">{{ $ts[menuDef[item].title] }}</span>
|
|
|
|
<span v-if="menuDef[item].indicated" class="indicator"><i class="fas fa-circle"></i></span>
|
2020-07-11 03:13:11 +02:00
|
|
|
</component>
|
|
|
|
</template>
|
|
|
|
<div class="divider"></div>
|
2021-04-22 15:29:33 +02:00
|
|
|
<MkA v-if="$i.isAdmin || $i.isModerator" class="item" active-class="active" to="/instance">
|
2021-04-20 16:22:59 +02:00
|
|
|
<i class="fas fa-server fa-fw"></i><span class="text">{{ $ts.instance }}</span>
|
2021-04-22 15:29:33 +02:00
|
|
|
</MkA>
|
2020-07-11 03:13:11 +02:00
|
|
|
<button class="item _button" @click="more">
|
2021-04-20 16:22:59 +02:00
|
|
|
<i class="fa fa-ellipsis-h fa-fw"></i><span class="text">{{ $ts.more }}</span>
|
|
|
|
<span v-if="otherNavItemIndicated" class="indicator"><i class="fas fa-circle"></i></span>
|
2020-07-11 03:13:11 +02:00
|
|
|
</button>
|
2020-10-24 18:21:41 +02:00
|
|
|
<MkA class="item" active-class="active" to="/settings">
|
2021-04-20 16:22:59 +02:00
|
|
|
<i class="fas fa-cog fa-fw"></i><span class="text">{{ $ts.settings }}</span>
|
2020-10-24 18:21:41 +02:00
|
|
|
</MkA>
|
2020-12-27 02:42:38 +01:00
|
|
|
<button class="item _button post" @click="post">
|
2021-04-20 16:22:59 +02:00
|
|
|
<i class="fas fa-pencil-alt fa-fw"></i><span class="text">{{ $ts.note }}</span>
|
2020-12-27 02:42:38 +01:00
|
|
|
</button>
|
2020-07-11 03:13:11 +02:00
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 09:30:14 +01:00
|
|
|
import { host } from '@client/config';
|
|
|
|
import { search } from '@client/scripts/search';
|
|
|
|
import * as os from '@client/os';
|
|
|
|
import { sidebarDef } from '@client/sidebar';
|
|
|
|
import { getAccounts, addAccount, login } from '@client/account';
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2021-02-14 14:26:07 +01:00
|
|
|
props: {
|
|
|
|
defaultHidden: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
host: host,
|
|
|
|
showing: false,
|
|
|
|
accounts: [],
|
|
|
|
connection: null,
|
2020-10-17 13:12:00 +02:00
|
|
|
menuDef: sidebarDef,
|
2020-08-01 03:53:23 +02:00
|
|
|
iconOnly: false,
|
2021-02-14 14:26:07 +01:00
|
|
|
hidden: this.defaultHidden,
|
2020-07-11 03:13:11 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
menu(): string[] {
|
2020-12-19 02:55:52 +01:00
|
|
|
return this.$store.state.menu;
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
otherNavItemIndicated(): boolean {
|
|
|
|
for (const def in this.menuDef) {
|
|
|
|
if (this.menu.includes(def)) continue;
|
|
|
|
if (this.menuDef[def].indicated) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
$route(to, from) {
|
|
|
|
this.showing = false;
|
|
|
|
},
|
2020-08-01 03:53:23 +02:00
|
|
|
|
2020-12-27 02:46:00 +01:00
|
|
|
'$store.reactiveState.sidebarDisplay.value'() {
|
2020-08-01 03:53:23 +02:00
|
|
|
this.calcViewState();
|
|
|
|
},
|
|
|
|
|
|
|
|
iconOnly() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$emit('change-view-mode');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
hidden() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$emit('change-view-mode');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
window.addEventListener('resize', this.calcViewState);
|
|
|
|
this.calcViewState();
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-08-01 03:53:23 +02:00
|
|
|
calcViewState() {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.iconOnly = (window.innerWidth <= 1279) || (this.$store.state.sidebarDisplay === 'icon');
|
2021-02-14 14:26:07 +01:00
|
|
|
if (!this.defaultHidden) {
|
|
|
|
this.hidden = (window.innerWidth <= 650);
|
|
|
|
}
|
2020-08-01 03:53:23 +02:00
|
|
|
},
|
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
show() {
|
|
|
|
this.showing = true;
|
|
|
|
},
|
|
|
|
|
2020-12-27 02:42:38 +01:00
|
|
|
post() {
|
|
|
|
os.post();
|
|
|
|
},
|
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
search() {
|
2021-01-03 15:58:24 +01:00
|
|
|
search();
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
async openAccountMenu(ev) {
|
2021-02-17 13:27:11 +01:00
|
|
|
const storedAccounts = getAccounts().filter(x => x.id !== this.$i.id);
|
|
|
|
const accountsPromise = os.api('users/show', { userIds: storedAccounts.map(x => x.id) });
|
|
|
|
|
|
|
|
const accountItemPromises = storedAccounts.map(a => new Promise(res => {
|
|
|
|
accountsPromise.then(accounts => {
|
|
|
|
const account = accounts.find(x => x.id === a.id);
|
|
|
|
if (account == null) return res(null);
|
|
|
|
res({
|
|
|
|
type: 'user',
|
|
|
|
user: account,
|
|
|
|
action: () => { this.switchAccount(account); }
|
|
|
|
});
|
|
|
|
});
|
2020-07-11 03:13:11 +02:00
|
|
|
}));
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
os.modalMenu([...[{
|
|
|
|
type: 'link',
|
2020-12-26 02:47:36 +01:00
|
|
|
text: this.$ts.profile,
|
2020-12-19 02:55:52 +01:00
|
|
|
to: `/@${ this.$i.username }`,
|
|
|
|
avatar: this.$i,
|
2021-02-17 13:27:11 +01:00
|
|
|
}, null, ...accountItemPromises, {
|
2021-04-20 16:22:59 +02:00
|
|
|
icon: 'fas fa-plus',
|
2021-04-23 06:01:52 +02:00
|
|
|
text: this.$ts.addAccount,
|
2020-10-17 13:12:00 +02:00
|
|
|
action: () => {
|
|
|
|
os.modalMenu([{
|
2021-04-23 06:01:52 +02:00
|
|
|
text: this.$ts.existingAccount,
|
|
|
|
action: () => { this.addAccount(); },
|
2020-10-17 13:12:00 +02:00
|
|
|
}, {
|
2020-12-26 02:47:36 +01:00
|
|
|
text: this.$ts.createAccount,
|
2020-10-17 13:12:00 +02:00
|
|
|
action: () => { this.createAccount(); },
|
|
|
|
}], ev.currentTarget || ev.target);
|
|
|
|
},
|
|
|
|
}]], ev.currentTarget || ev.target, {
|
|
|
|
align: 'left'
|
2020-07-11 03:13:11 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
more(ev) {
|
2021-04-10 05:40:50 +02:00
|
|
|
os.popup(import('@client/components/launch-pad.vue'), {}, {
|
2020-11-17 14:52:07 +01:00
|
|
|
}, 'closed');
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
|
|
|
|
2021-04-23 06:01:52 +02:00
|
|
|
addAccount() {
|
2021-04-10 05:40:50 +02:00
|
|
|
os.popup(import('@client/components/signin-dialog.vue'), {}, {
|
2020-10-17 13:12:00 +02:00
|
|
|
done: res => {
|
2020-12-19 02:55:52 +01:00
|
|
|
addAccount(res.id, res.i);
|
2020-10-17 13:12:00 +02:00
|
|
|
os.success();
|
|
|
|
},
|
|
|
|
}, 'closed');
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
|
|
|
|
2020-11-03 07:22:55 +01:00
|
|
|
createAccount() {
|
2021-04-10 05:40:50 +02:00
|
|
|
os.popup(import('@client/components/signup-dialog.vue'), {}, {
|
2020-10-17 13:12:00 +02:00
|
|
|
done: res => {
|
2020-12-19 02:55:52 +01:00
|
|
|
addAccount(res.id, res.i);
|
2020-10-17 13:12:00 +02:00
|
|
|
this.switchAccountWithToken(res.i);
|
|
|
|
},
|
|
|
|
}, 'closed');
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
|
|
|
|
2020-11-03 07:22:55 +01:00
|
|
|
switchAccount(account: any) {
|
2020-12-19 02:55:52 +01:00
|
|
|
const storedAccounts = getAccounts();
|
|
|
|
const token = storedAccounts.find(x => x.id === account.id).token;
|
2020-07-11 03:13:11 +02:00
|
|
|
this.switchAccountWithToken(token);
|
|
|
|
},
|
|
|
|
|
|
|
|
switchAccountWithToken(token: string) {
|
2020-12-19 02:55:52 +01:00
|
|
|
login(token);
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.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);
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
.nav-enter-from,
|
2020-07-11 03:13:11 +02:00
|
|
|
.nav-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(-240px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav-back-enter-active,
|
|
|
|
.nav-back-leave-active {
|
|
|
|
opacity: 1;
|
|
|
|
transition: opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
.nav-back-enter-from,
|
2020-07-11 03:13:11 +02:00
|
|
|
.nav-back-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.mvcprjjd {
|
|
|
|
$ui-font-size: 1em; // TODO: どこかに集約したい
|
2020-08-01 03:53:23 +02:00
|
|
|
$nav-width: 250px;
|
2020-12-12 05:09:40 +01:00
|
|
|
$nav-icon-only-width: 86px;
|
2020-07-11 03:13:11 +02:00
|
|
|
|
|
|
|
> .nav-back {
|
|
|
|
z-index: 1001;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .nav {
|
|
|
|
$avatar-size: 32px;
|
|
|
|
$avatar-margin: 8px;
|
|
|
|
|
|
|
|
flex: 0 0 $nav-width;
|
|
|
|
width: $nav-width;
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
2020-08-01 03:53:23 +02:00
|
|
|
&.iconOnly {
|
2020-07-11 03:13:11 +02:00
|
|
|
flex: 0 0 $nav-icon-only-width;
|
|
|
|
width: $nav-icon-only-width;
|
2020-08-01 03:53:23 +02:00
|
|
|
|
|
|
|
&:not(.hidden) {
|
|
|
|
> div {
|
|
|
|
width: $nav-icon-only-width;
|
|
|
|
|
|
|
|
> .divider {
|
|
|
|
margin: 8px auto;
|
|
|
|
width: calc(100% - 32px);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .item {
|
|
|
|
padding-left: 0;
|
|
|
|
width: 100%;
|
|
|
|
text-align: center;
|
2020-08-01 09:39:48 +02:00
|
|
|
font-size: $ui-font-size * 1.1;
|
2020-08-01 03:53:23 +02:00
|
|
|
line-height: 3.7rem;
|
|
|
|
|
2021-04-20 16:22:59 +02:00
|
|
|
> i,
|
2020-08-01 03:53:23 +02:00
|
|
|
> .avatar {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
> i {
|
|
|
|
left: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .text {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:first-child {
|
|
|
|
margin-bottom: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
|
2020-08-01 03:53:23 +02:00
|
|
|
&.hidden {
|
2020-07-11 03:13:11 +02:00
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 1001;
|
|
|
|
}
|
|
|
|
|
2020-08-01 03:53:23 +02:00
|
|
|
&:not(.hidden) {
|
2020-07-11 03:13:11 +02:00
|
|
|
display: block !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
> div {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 1001;
|
|
|
|
width: $nav-width;
|
2020-07-15 11:22:19 +02:00
|
|
|
// ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
|
|
height: calc(var(--vh, 1vh) * 100);
|
2020-07-11 03:13:11 +02:00
|
|
|
box-sizing: border-box;
|
|
|
|
overflow: auto;
|
|
|
|
background: var(--navBg);
|
|
|
|
|
|
|
|
> .divider {
|
|
|
|
margin: 16px 0;
|
2021-04-10 05:40:50 +02:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
> .item {
|
|
|
|
position: relative;
|
|
|
|
display: block;
|
2020-11-01 04:32:34 +01:00
|
|
|
padding-left: 24px;
|
2020-07-11 03:13:11 +02:00
|
|
|
font-size: $ui-font-size;
|
2020-11-01 04:26:38 +01:00
|
|
|
line-height: 3rem;
|
2020-07-11 03:13:11 +02:00
|
|
|
text-overflow: ellipsis;
|
2021-03-02 14:57:16 +01:00
|
|
|
overflow: hidden;
|
2020-07-11 03:13:11 +02:00
|
|
|
white-space: nowrap;
|
|
|
|
width: 100%;
|
|
|
|
text-align: left;
|
|
|
|
box-sizing: border-box;
|
|
|
|
color: var(--navFg);
|
|
|
|
|
2021-04-20 16:22:59 +02:00
|
|
|
> i {
|
2020-07-11 03:13:11 +02:00
|
|
|
width: 32px;
|
|
|
|
}
|
|
|
|
|
2021-04-20 16:22:59 +02:00
|
|
|
> i,
|
2020-07-11 03:13:11 +02:00
|
|
|
> .avatar {
|
|
|
|
margin-right: $avatar-margin;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: $avatar-size;
|
|
|
|
height: $avatar-size;
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
|
2021-04-20 16:22:59 +02:00
|
|
|
> .indicator {
|
2020-07-11 03:13:11 +02:00
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 20px;
|
|
|
|
color: var(--navIndicator);
|
|
|
|
font-size: 8px;
|
|
|
|
animation: blink 1s infinite;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
color: var(--navHoverFg);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
color: var(--navActive);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:first-child, &:last-child {
|
|
|
|
position: sticky;
|
|
|
|
z-index: 1;
|
|
|
|
padding-top: 8px;
|
|
|
|
padding-bottom: 8px;
|
|
|
|
background: var(--X14);
|
|
|
|
-webkit-backdrop-filter: blur(8px);
|
|
|
|
backdrop-filter: blur(8px);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:first-child {
|
|
|
|
top: 0;
|
|
|
|
margin-bottom: 16px;
|
2021-04-10 05:40:50 +02:00
|
|
|
border-bottom: solid 0.5px var(--divider);
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
bottom: 0;
|
|
|
|
margin-top: 16px;
|
2021-04-10 05:40:50 +02:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|