<template>
  <div>
    <div class="nav"></div>
    <BookReader :pages="pages" :bookmarks="bookmarks" />
  </div>
</template>
<script setup>
import { getDocumentDetail } from "@/api";
import BookReader from "@/components/BookReader.vue";
const route = useRoute();
/* props */
/* emit */
/* data */
const pages = ref([]);
const bookmarks = ref([]);
/* computed */
/* methods */
async function loadData(id) {
  const res = await getDocumentDetail(id);
  pages.value = res.map((item) => {
    return {
      ...item,
      page_url: import.meta.env.VITE_API_BASE_URL + "/static/" + item.page_url,
      images: item.images.map((img) => {
        return {
          ...img,
          url: import.meta.env.VITE_API_BASE_URL + "/static/" + img.url,
        };
      }),
    };
  });
}
onMounted(() => {
  const { id } = route.params;
  bookmarks.value = JSON.parse(route.query.bookmarks);
  loadData(id);
});
</script>
<style lang="scss" scoped></style>
