<!-- 公告页面 -->
<script setup>
import { ref } from "vue";
import { useWsStore } from "../store";
const emit = defineEmits(["home"]);

// load 公告
const vertical_content = ref("公告加载中...");
const horizontal_content = ref("公告加载中...");
const store = useWsStore();
store.$subscribe((mutation, state) => {
  vertical_content.value =
    (state.data3.deliveryNotification || [])
      .map((item) => item.deliveryContent || "")
      .join("")
      .replaceAll(/<br(\s?)\/>/g, "") || "暂无公告";
  horizontal_content.value =
    (state.data2.deliveryMsg || [])
      .map((item) => item.deliveryContent || "")
      .join("\t") || "暂无公告";
});

// handlers
const handleClose = () => {
  emit("home");
};
</script>

<template>
  <div class="announcement-page">
    <h1 class="announcement-title">公告栏</h1>
    <main class="announcement-content">
      <ScrollText :vertical="true" :duration="10" :pause-on-hover="true">
        <div v-html="vertical_content"></div>
      </ScrollText>
    </main>
    <div class="announcement-footer">
      <button
        style="position: absolute; left: 0; bottom: 10px"
        @click="handleClose"
      >
        返回
      </button>
      <ScrollText> {{ horizontal_content }} </ScrollText>
    </div>
  </div>
</template>

<style scoped>
.announcement-page {
  flex: 1;
  height: 100%;
  width: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  color: #f00;
}

.announcement-title {
  color: #fff;
  font-size: 72px;
  font-weight: 500;
  letter-spacing: 2px;
  text-align: center;
}

.announcement-content {
  /* background: #ccc3; */
  flex: 1;
  padding: 8px 80px;
  font-size: 72px;
  font-family: serif;
  overflow: hidden;
  user-select: none;
}

.announcement-footer {
  height: 128px;
  /* background: #ccc1; */
  font-size: 64px;
  padding: 0 80px;
  line-height: 128px;
  font-family: sans-serif;
  position: relative;
  user-select: none;
}
</style>
