forked from FoundKeyGang/FoundKey
client: refactor sidebar-for-mobile.vue to composition api
This commit is contained in:
parent
f4b9244a88
commit
846ca03a7c
1 changed files with 24 additions and 39 deletions
|
@ -1,13 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="kmwsukvl">
|
<div class="kmwsukvl">
|
||||||
<div>
|
<div>
|
||||||
<button v-click-anime class="item _button account" @click="openAccountMenu">
|
<button v-click-anime class="item _button account" @click="openAccountMenuWrapper">
|
||||||
<MkAvatar :user="$i" class="avatar"/><MkAcct class="text" :user="$i"/>
|
<MkAvatar :user="$i" class="avatar"/><MkAcct class="text" :user="$i"/>
|
||||||
</button>
|
</button>
|
||||||
<MkA v-click-anime class="item index" active-class="active" to="/" exact>
|
<MkA v-click-anime class="item index" active-class="active" to="/" exact>
|
||||||
<i class="fas fa-home fa-fw"></i><span class="text">{{ $ts.timeline }}</span>
|
<i class="fas fa-home fa-fw"></i><span class="text">{{ $ts.timeline }}</span>
|
||||||
</MkA>
|
</MkA>
|
||||||
<template v-for="item in menu">
|
<template v-for="item in menu" :key="item">
|
||||||
<div v-if="item === '-'" class="divider"></div>
|
<div v-if="item === '-'" class="divider"></div>
|
||||||
<component :is="menuDef[item].to ? 'MkA' : 'button'" v-else-if="menuDef[item] && (menuDef[item].show !== false)" v-click-anime class="item _button" :class="[item, { active: menuDef[item].active }]" active-class="active" :to="menuDef[item].to" v-on="menuDef[item].action ? { click: menuDef[item].action } : {}">
|
<component :is="menuDef[item].to ? 'MkA' : 'button'" v-else-if="menuDef[item] && (menuDef[item].show !== false)" v-click-anime class="item _button" :class="[item, { active: menuDef[item].active }]" active-class="active" :to="menuDef[item].to" v-on="menuDef[item].action ? { click: menuDef[item].action } : {}">
|
||||||
<i class="fa-fw" :class="menuDef[item].icon"></i><span class="text">{{ $ts[menuDef[item].title] }}</span>
|
<i class="fa-fw" :class="menuDef[item].icon"></i><span class="text">{{ $ts[menuDef[item].title] }}</span>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
</component>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<MkA v-if="$i.isAdmin || $i.isModerator" v-click-anime class="item" active-class="active" to="/admin">
|
<MkA v-if="iAmModerator" v-click-anime class="item" active-class="active" to="/admin">
|
||||||
<i class="fas fa-door-open fa-fw"></i><span class="text">{{ $ts.controlPanel }}</span>
|
<i class="fas fa-door-open fa-fw"></i><span class="text">{{ $ts.controlPanel }}</span>
|
||||||
</MkA>
|
</MkA>
|
||||||
<button v-click-anime class="item _button" @click="more">
|
<button v-click-anime class="item _button" @click="more">
|
||||||
|
@ -32,47 +32,32 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { computed, defineAsyncComponent, defineComponent, ref, toRef, watch } from 'vue';
|
import { defineAsyncComponent, toRef } from 'vue';
|
||||||
import { host } from '@/config';
|
|
||||||
import { search } from '@/scripts/search';
|
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { menuDef } from '@/menu';
|
import { menuDef } from '@/menu';
|
||||||
import { openAccountMenu } from '@/account';
|
import { openAccountMenu, $i, iAmModerator } from '@/account';
|
||||||
import { defaultStore } from '@/store';
|
import { defaultStore } from '@/store';
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
setup(props, context) {
|
|
||||||
const menu = toRef(defaultStore.state, 'menu');
|
const menu = toRef(defaultStore.state, 'menu');
|
||||||
const otherMenuItemIndicated = computed(() => {
|
const otherMenuItemIndicated = $computed(() => {
|
||||||
for (const def in menuDef) {
|
for (const def in menuDef) {
|
||||||
if (menu.value.includes(def)) continue;
|
if (menu.value.includes(def)) continue;
|
||||||
if (menuDef[def].indicated) return true;
|
if (menuDef[def].indicated) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
const post = $ref(os.post);
|
||||||
|
|
||||||
return {
|
function openAccountMenuWrapper(ev: MouseEvent): void {
|
||||||
host,
|
|
||||||
accounts: [],
|
|
||||||
connection: null,
|
|
||||||
menu,
|
|
||||||
menuDef,
|
|
||||||
otherMenuItemIndicated,
|
|
||||||
post: os.post,
|
|
||||||
search,
|
|
||||||
openAccountMenu: (ev) => {
|
|
||||||
openAccountMenu({
|
openAccountMenu({
|
||||||
withExtraOperation: true,
|
withExtraOperation: true,
|
||||||
}, ev);
|
}, ev);
|
||||||
},
|
}
|
||||||
more: () => {
|
|
||||||
os.popup(defineAsyncComponent(() => import('@/components/launch-pad.vue')), {}, {
|
function more(): void {
|
||||||
}, 'closed');
|
os.popup(defineAsyncComponent(() => import('@/components/launch-pad.vue')), {}, {}, 'closed');
|
||||||
},
|
}
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in a new issue