2021-03-14 03:54:43 +00:00
|
|
|
<template>
|
|
|
|
<div class="menu">
|
|
|
|
<ul class="menu-items noselect">
|
|
|
|
<router-link
|
2021-03-16 03:12:05 +00:00
|
|
|
v-if="auth && me"
|
2021-03-14 03:54:43 +00:00
|
|
|
:to="{ name: 'user', params: { username: me.username } }"
|
|
|
|
class="menu-username"
|
|
|
|
>{{ me.username }}</router-link>
|
|
|
|
|
|
|
|
<router-link
|
2021-03-16 03:12:05 +00:00
|
|
|
v-else-if="auth"
|
2021-03-16 01:31:23 +00:00
|
|
|
:to="{ name: 'login', query: { ref: $route.path } }"
|
2021-03-14 03:54:43 +00:00
|
|
|
class="menu-item"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<Icon icon="enter2" />Log in
|
|
|
|
</router-link>
|
|
|
|
|
|
|
|
<li
|
2021-03-16 03:12:05 +00:00
|
|
|
v-if="auth && me"
|
2021-03-14 03:54:43 +00:00
|
|
|
class="menu-item"
|
|
|
|
@click.stop="$store.dispatch('logout')"
|
|
|
|
>
|
|
|
|
<Icon icon="enter2" />Log out
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li
|
|
|
|
v-show="!sfw"
|
|
|
|
class="menu-item"
|
|
|
|
@click.stop="setSfw(true)"
|
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
icon="flower"
|
|
|
|
class="toggle noselect"
|
|
|
|
/>Safe mode
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li
|
|
|
|
v-show="sfw"
|
|
|
|
class="menu-item"
|
|
|
|
@click.stop="setSfw(false)"
|
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
icon="fire"
|
|
|
|
class="toggle noselect"
|
|
|
|
/>Filth mode
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li
|
|
|
|
v-show="theme === 'light'"
|
|
|
|
class="menu-item"
|
|
|
|
@click.stop="setTheme('dark')"
|
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
icon="moon"
|
|
|
|
class="toggle noselect"
|
|
|
|
/>Dark theme
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li
|
|
|
|
v-show="theme === 'dark'"
|
|
|
|
class="menu-item"
|
|
|
|
@click.stop="setTheme('light')"
|
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
icon="sun"
|
|
|
|
class="toggle noselect"
|
|
|
|
/>Light theme
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li
|
|
|
|
class="menu-item"
|
|
|
|
@click="$emit('showFilters', true)"
|
|
|
|
>
|
|
|
|
<Icon icon="filter" />Filters
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapState } from 'vuex';
|
|
|
|
|
|
|
|
function sfw(state) {
|
|
|
|
return state.ui.sfw;
|
|
|
|
}
|
|
|
|
|
|
|
|
function theme(state) {
|
|
|
|
return state.ui.theme;
|
|
|
|
}
|
|
|
|
|
2021-03-16 03:12:05 +00:00
|
|
|
function auth(state) {
|
|
|
|
return state.auth.enabled;
|
|
|
|
}
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
function me(state) {
|
|
|
|
return state.auth.user;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setTheme(newTheme) {
|
|
|
|
this.$store.dispatch('setTheme', newTheme);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSfw(enabled) {
|
|
|
|
this.$store.dispatch('setSfw', enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
2021-03-16 03:12:05 +00:00
|
|
|
auth,
|
2021-03-14 03:54:43 +00:00
|
|
|
sfw,
|
|
|
|
theme,
|
|
|
|
me,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setSfw,
|
|
|
|
setTheme,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import 'breakpoints';
|
|
|
|
|
|
|
|
.menu-items {
|
|
|
|
list-style: none;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-item {
|
|
|
|
display: flex;
|
|
|
|
padding: .75rem 1rem .75rem .75rem;
|
|
|
|
color: inherit;
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
fill: var(--darken);
|
|
|
|
margin: 0 1rem 0 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
color: var(--darken-weak);
|
|
|
|
cursor: default;
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
fill: var(--darken-weak);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover:not(.disabled) {
|
|
|
|
cursor: pointer;
|
|
|
|
color: var(--primary);
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
fill: var(--primary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-username {
|
|
|
|
display: block;
|
|
|
|
font-weight: bold;
|
|
|
|
color: var(--shadow-strong);
|
|
|
|
font-size: .9rem;
|
|
|
|
padding: .75rem 1rem;
|
|
|
|
border-bottom: solid 1px var(--shadow-hint);
|
|
|
|
text-align: center;
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
</style>
|