forked from FoundKeyGang/FoundKey
refactor: header.vue to composition api
This commit is contained in:
parent
6c8eb4c4df
commit
16833b8cd8
1 changed files with 94 additions and 105 deletions
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div class="sqxihjet">
|
||||
<div ref="header" class="sqxihjet">
|
||||
<div v-if="narrow === false" class="wide">
|
||||
<div class="content">
|
||||
<MkA to="/" class="link" active-class="active"><i class="fas fa-home icon"></i>{{ $ts.home }}</MkA>
|
||||
|
@ -13,7 +13,9 @@
|
|||
<span v-if="info.title" class="text">{{ info.title }}</span>
|
||||
<MkUserName v-else-if="info.userName" :user="info.userName" :nowrap="false" class="text"/>
|
||||
</div>
|
||||
<button v-if="info.action" class="_button action" @click.stop="info.action.handler"><!-- TODO --></button>
|
||||
<button v-if="info.action" class="_button action" @click.stop="info.action.handler">
|
||||
<!-- TODO -->
|
||||
</button>
|
||||
</div>
|
||||
<div class="right">
|
||||
<button class="_button search" @click="search()"><i class="fas fa-search icon"></i><span>{{ $ts.search }}</span></button>
|
||||
|
@ -22,8 +24,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="narrow === true" class="narrow">
|
||||
<button class="menu _button" @click="$parent.showMenu = true">
|
||||
<div v-else-if="narrow" class="narrow">
|
||||
<button class="menu _button" @click="showMenu = true">
|
||||
<i class="fas fa-bars icon"></i>
|
||||
</button>
|
||||
<div v-if="info" class="title">
|
||||
|
@ -39,47 +41,38 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref, Ref } from 'vue';
|
||||
import XSigninDialog from '@/components/signin-dialog.vue';
|
||||
import XSignupDialog from '@/components/signup-dialog.vue';
|
||||
import * as os from '@/os';
|
||||
import { search } from '@/scripts/search';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
info: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
defineProps<{
|
||||
info: any;
|
||||
}>();
|
||||
|
||||
data() {
|
||||
return {
|
||||
narrow: null,
|
||||
showMenu: false,
|
||||
};
|
||||
},
|
||||
const narrow = ref(false);
|
||||
const showMenu = ref(false);
|
||||
const header: Ref<HTMLElement | null> = ref(null);
|
||||
|
||||
mounted() {
|
||||
this.narrow = this.$el.clientWidth < 1300;
|
||||
},
|
||||
|
||||
methods: {
|
||||
signin() {
|
||||
os.popup(XSigninDialog, {
|
||||
autoSet: true
|
||||
}, {}, 'closed');
|
||||
},
|
||||
|
||||
signup() {
|
||||
os.popup(XSignupDialog, {
|
||||
autoSet: true
|
||||
}, {}, 'closed');
|
||||
},
|
||||
|
||||
search
|
||||
onMounted(() => {
|
||||
if (header.value) {
|
||||
narrow.value = header.value.clientWidth < 1300;
|
||||
}
|
||||
});
|
||||
|
||||
function signin(): void {
|
||||
os.popup(XSigninDialog, {
|
||||
autoSet: true,
|
||||
}, {}, 'closed');
|
||||
}
|
||||
|
||||
function signup(): void {
|
||||
os.popup(XSignupDialog, {
|
||||
autoSet: true,
|
||||
}, {}, 'closed');
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -151,14 +144,8 @@ export default defineComponent({
|
|||
box-shadow: 0 -2px 0 0 var(--accent) inset;
|
||||
color: var(--fgHighlighted);
|
||||
}
|
||||
}
|
||||
|
||||
> .action {
|
||||
padding: 0 0 0 16px;
|
||||
}
|
||||
}
|
||||
|
||||
> .right {
|
||||
el>.right {
|
||||
margin-left: auto;
|
||||
|
||||
>.search {
|
||||
|
@ -225,4 +212,6 @@ export default defineComponent({
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in a new issue