<script lang="ts" setup>
import { SiteMessage } from "@/types/student-client";
import { store } from "@/store/store";
import { useRoute } from "vue-router";
import { onMounted } from "vue";

let notice: SiteMessage | undefined = $ref();
const route = useRoute();

const toBack = () => {
  window.history.go(-1);
};

onMounted(() => {
  const curNoticeId = Number(route.params.noticeId);
  const curNotice = store.siteMessage.messages.find(
    (item) => item.id === curNoticeId
  );
  notice = curNotice;
});
</script>

<template>
  <div class="box-justify qm-mb-20">
    <div></div>
    <n-button @click="toBack"
      ><i class="icon icon-back qm-mr-10"></i> 返回列表</n-button
    >
  </div>
  <div v-if="notice" class="part-box">
    <div class="message-title tw-text-center">
      <h3 class="text-4xl">{{ notice.title }}</h3>
      <p class="tips-info">发布时间: {{ notice.publishTime }}</p>
    </div>
    <div class="message-desc" v-html="notice.content"></div>
  </div>
</template>
