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