event for notice bar
This commit is contained in:
@@ -1,25 +1,45 @@
|
||||
<template>
|
||||
<t-notice-bar
|
||||
v-if="noticeContent"
|
||||
:key="noticeContent"
|
||||
v-if="noticeContent.length"
|
||||
:key="noticeContent.join(',')"
|
||||
class="pending-notice"
|
||||
theme="warning"
|
||||
:visible="true"
|
||||
direction="horizontal"
|
||||
marquee
|
||||
:content="noticeContent"
|
||||
/>
|
||||
direction="vertical"
|
||||
:content="1 < noticeContent.length ? noticeContent : noticeContent[0]"
|
||||
@change="currentIndex = $event"
|
||||
@click="openNotice"
|
||||
>
|
||||
<template #suffix-icon>
|
||||
<t-icon name="chevron-right" />
|
||||
</template>
|
||||
</t-notice-bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { usePendingNoticeStore } from "@/store/pendingNoticeStore";
|
||||
|
||||
const pendingNoticeStore = usePendingNoticeStore();
|
||||
const noticeContent = computed(() => pendingNoticeStore.pendingNoticeList.join(","));
|
||||
const router = useRouter();
|
||||
const currentIndex = ref(0);
|
||||
const noticeContent = computed(() => pendingNoticeStore.pendingNoticeList.map(notice => notice.content));
|
||||
|
||||
watch(noticeContent, () => { currentIndex.value = 0; });
|
||||
|
||||
async function openNotice(): Promise<void> {
|
||||
const notice = pendingNoticeStore.pendingNoticeList[currentIndex.value];
|
||||
if (notice) {
|
||||
await router.push({ name: notice.name, query: notice.query });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.pending-notice {
|
||||
margin-top: -1rem;
|
||||
|
||||
:deep(.t-swiper-nav__dots) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user