|
@@ -1,47 +1,49 @@
|
|
|
<template>
|
|
|
- <iframe
|
|
|
- id="iframe"
|
|
|
- class="home-iframe"
|
|
|
- src="./three/index.html"
|
|
|
- frameborder="0"
|
|
|
- ></iframe>
|
|
|
-
|
|
|
- <div ref="txtDom" class="txt" :style="{ opacity: txt.show ? '0.8' : '0' }">
|
|
|
- <h2>{{ txt.title }}</h2>
|
|
|
- <p>{{ txt.con }}</p>
|
|
|
- </div>
|
|
|
+ <div class="home">
|
|
|
+ <iframe
|
|
|
+ id="iframe"
|
|
|
+ class="home-iframe"
|
|
|
+ src="./three/index.html"
|
|
|
+ frameborder="0"
|
|
|
+ ></iframe>
|
|
|
+
|
|
|
+ <div ref="txtDom" class="txt" :style="{ opacity: txt.show ? '0.8' : '0' }">
|
|
|
+ <h2>{{ txt.title }}</h2>
|
|
|
+ <p>{{ txt.con }}</p>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="home-main">
|
|
|
- <img
|
|
|
- class="home-main__logo"
|
|
|
- draggable="false"
|
|
|
- src="@/assets/images/logo_01-min.png"
|
|
|
- />
|
|
|
-
|
|
|
- <div class="home-search">
|
|
|
- <input
|
|
|
- v-model="keyword"
|
|
|
- class="home-search__input"
|
|
|
- type="text"
|
|
|
- placeholder="请输入关键词..."
|
|
|
- @keyup.enter="handleSearch"
|
|
|
+ <div class="home-main">
|
|
|
+ <img
|
|
|
+ class="home-main__logo"
|
|
|
+ draggable="false"
|
|
|
+ src="@/assets/images/logo_01-min.png"
|
|
|
/>
|
|
|
- <button class="home-search__btn" @click="handleSearch">搜索</button>
|
|
|
- </div>
|
|
|
|
|
|
- <div class="home-view" @click="$router.push({ name: 'stack' })">
|
|
|
- <p class="limit-line">共收录{{ total }}件藏品,查看书库</p>
|
|
|
+ <div class="home-search">
|
|
|
+ <input
|
|
|
+ v-model="keyword"
|
|
|
+ class="home-search__input"
|
|
|
+ type="text"
|
|
|
+ placeholder="请输入关键词..."
|
|
|
+ @keyup.enter="handleSearch"
|
|
|
+ />
|
|
|
+ <button class="home-search__btn" @click="handleSearch">搜索</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="home-view" @click="$router.push({ name: 'stack' })">
|
|
|
+ <p class="limit-line">共收录{{ total }}件藏品,查看书库</p>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
- <router-link class="home-more" :to="{ name: 'home2' }">
|
|
|
- <img draggable="false" src="@/assets/images/icon_click.png" />
|
|
|
- <p>查看更多</p>
|
|
|
- </router-link>
|
|
|
+ <router-link class="home-more" :to="{ name: 'home2' }">
|
|
|
+ <p>查看更多</p>
|
|
|
+ </router-link>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import { onMounted, ref } from "vue";
|
|
|
+import { compressImages } from "@dage/utils";
|
|
|
import { getRecommendListApi, getBookCountApi } from "@/api";
|
|
|
import { useRouter } from "vue-router";
|
|
|
import { getBaseUrl } from "@/utils";
|
|
@@ -57,18 +59,18 @@ const keyword = ref("");
|
|
|
onMounted(() => {
|
|
|
// 点击图片
|
|
|
window.clickObject = (val) => {
|
|
|
- const item = list.value.find((i) => i.thumb.indexOf(val) > -1);
|
|
|
+ const item = list.value.find((i) => i._thumb.indexOf(val) > -1);
|
|
|
router.push({
|
|
|
name: "detail",
|
|
|
params: {
|
|
|
- id: item.id,
|
|
|
+ id: item.bookId,
|
|
|
type: "reader",
|
|
|
},
|
|
|
});
|
|
|
};
|
|
|
// 鼠标移入
|
|
|
window.hoverObject = (val) => {
|
|
|
- const item = list.value.find((i) => i.thumb.indexOf(val.imgName) > -1);
|
|
|
+ const item = list.value.find((i) => i._thumb.indexOf(val.imgName) > -1);
|
|
|
if (!item) return;
|
|
|
|
|
|
txt.value = {
|
|
@@ -103,19 +105,29 @@ onMounted(() => {
|
|
|
});
|
|
|
|
|
|
const getRecommendList = async () => {
|
|
|
- const data = await getRecommendListApi({
|
|
|
+ let data = await getRecommendListApi({
|
|
|
pageNum: 1,
|
|
|
pageSize: 20,
|
|
|
type: "index",
|
|
|
});
|
|
|
|
|
|
+ data = await compressImages({
|
|
|
+ list: data.map((i) => ({
|
|
|
+ ...i,
|
|
|
+ thumb: `${baseUrl}${i.thumb}`,
|
|
|
+ })),
|
|
|
+ maxWidth: 1000,
|
|
|
+ qualityRatio: 0.8,
|
|
|
+ });
|
|
|
+
|
|
|
+ const imgList = data.map((i) => i._thumb);
|
|
|
const iframe = document.getElementById("iframe");
|
|
|
const iframeDoc = iframe?.contentDocument || iframe?.contentWindow.document;
|
|
|
if (iframeDoc?.readyState === "complete") {
|
|
|
- iframe.contentWindow.initViewer(data.map((i) => `${baseUrl}${i.thumb}`));
|
|
|
+ iframe.contentWindow.initViewer(imgList);
|
|
|
} else {
|
|
|
iframe.onload = () => {
|
|
|
- iframe.contentWindow.initViewer(data.map((i) => `${baseUrl}${i.thumb}`));
|
|
|
+ iframe.contentWindow.initViewer(imgList);
|
|
|
};
|
|
|
}
|
|
|
list.value = data;
|