浏览代码

诗歌列表页 做了一半

任一存 1 年之前
父节点
当前提交
1afb46428d
共有 12 个文件被更改,包括 277 次插入1 次删除
  1. 1 0
      .eslintrc.js
  2. 1 0
      package.json
  3. 1 0
      public/index.html
  4. 10 1
      src/App.vue
  5. 二进制
      src/assets/images/icon_close.png
  6. 二进制
      src/assets/images/icon_menu.png
  7. 4 0
      src/main.js
  8. 6 0
      src/router/index.js
  9. 5 0
      src/views/HomeView.vue
  10. 38 0
      src/views/MoreContent.vue
  11. 206 0
      src/views/PoemList.vue
  12. 5 0
      yarn.lock

+ 1 - 0
.eslintrc.js

@@ -53,5 +53,6 @@ module.exports = {
     defineProps: true,
     defineEmits: true,
     configText: true,
+    configExcel: true,
   }
 }

+ 1 - 0
package.json

@@ -18,6 +18,7 @@
     "js-base64": "^3.7.5",
     "lodash": "^4.17.21",
     "mitt": "^3.0.0",
+    "swiper": "^11.1.4",
     "v-viewer": "^3.0.11",
     "viewerjs": "^1.11.6",
     "vue": "^3.2.13",

+ 1 - 0
public/index.html

@@ -9,6 +9,7 @@
   </head>
   <body>
     <script src="./configText.js"></script>
+    <script src="./configExcel.js"></script>
     <!-- <script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script> -->
     <noscript>
       <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>

+ 10 - 1
src/App.vue

@@ -1,5 +1,14 @@
 <template>
-  <router-view />
+  <!-- <router-view /> -->
+  <router-view v-slot="{ Component }">
+    <transition
+      name="fade-in-out"
+    >
+      <component
+        :is="Component"
+      />
+    </transition>
+  </router-view>
 </template>
 
 <script setup>

二进制
src/assets/images/icon_close.png


二进制
src/assets/images/icon_menu.png


+ 4 - 0
src/main.js

@@ -10,6 +10,8 @@ import 'viewerjs/dist/viewer.css'
 import VueViewer from 'v-viewer'
 import ElementPlus from 'element-plus'
 import 'element-plus/dist/index.css'
+import { Swiper, SwiperSlide } from 'swiper/vue'
+import 'swiper/css'
 
 import BtnBack from '@/components/BtnBack.vue'
 import OperationTip from '@/components/OperationTip.vue'
@@ -82,6 +84,8 @@ app.use(store)
   .component('BtnBack', BtnBack)
   .component('OperationTip', OperationTip)
   .component('HotspotComp', HotspotComp)
+  .component('Swiper', Swiper)
+  .component('SwiperSlide', SwiperSlide)
   .mount('#app')
 
 //  you can reset the default options at any other time

+ 6 - 0
src/router/index.js

@@ -1,5 +1,6 @@
 import { createRouter, createWebHashHistory } from 'vue-router'
 import HomeView from '../views/HomeView.vue'
+import MoreContent from '../views/MoreContent.vue'
 // import store from '@/store/index.js'
 
 const routes = [
@@ -12,6 +13,11 @@ const routes = [
     name: 'HomeView',
     component: HomeView,
   },
+  {
+    path: '/more-content',
+    name: 'MoreContent',
+    component: MoreContent,
+  },
 ]
 
 const router = createRouter({

+ 5 - 0
src/views/HomeView.vue

@@ -239,6 +239,11 @@ watch(descElScrollTop, (v) => {
   if (v > 0) {
     isShowOperationTip.value = false
   }
+  if (Math.abs(v - (descEl.value.scrollHeight - descEl.value.clientHeight)) <= 1) {
+    router.push({
+      name: 'MoreContent',
+    })
+  }
 })
 
 const isStartupInvisible = computed(() => {

+ 38 - 0
src/views/MoreContent.vue

@@ -0,0 +1,38 @@
+<template>
+  <div class="more-content">
+    <button @click="isShowPoemList = true">
+      诗词
+    </button>
+    <button>画作</button>
+
+    <PoemList
+      v-if="isShowPoemList"
+      @close="isShowPoemList = false"
+    />
+  </div>
+</template>
+
+<script setup>
+import { ref, computed, watch, onMounted, inject } from "vue"
+import { useRoute, useRouter } from "vue-router"
+import { useStore } from "vuex"
+import PoemList from '@/views/PoemList.vue'
+
+const route = useRoute()
+const router = useRouter()
+const store = useStore()
+
+const $env = inject('$env')
+
+const isShowPoemList = ref(false)
+</script>
+
+<style lang="less" scoped>
+.more-content{
+  position: absolute;
+  left: 0;
+  top: 0;
+  width: 100%;
+  height: 100%;
+}
+</style>

+ 206 - 0
src/views/PoemList.vue

@@ -0,0 +1,206 @@
+<template>
+  <div class="poem-list">
+    <Swiper
+      class="poem-list"
+      :slides-per-view="1"
+      direction="vertical"
+      @swiper="onSwiper"
+      @slideChange="onSlideChange"
+    >
+      <SwiperSlide
+        v-for="(item, index) in poemList"
+        :key="index"
+        class="poem-item"
+      >
+        {{ item }}
+      </SwiperSlide>
+    </Swiper>
+
+    <BtnBack
+      v-show="!isShowMenu"
+      class="button-back"
+      @click="emit('close')"
+    />
+    <OperationTip
+      v-show="!isShowMenu"
+      class="operation-tip"
+      text="下一首"
+      :is-show="isShowOperationTip"
+    />
+    <button
+      v-show="!isShowMenu"
+      class="menu-btn"
+      @click="isShowMenu = true"
+    >
+      <img
+        class=""
+        src="@/assets/images/icon_menu.png"
+        alt=""
+        draggable="false"
+      >
+    </button>
+
+    <Transition name="fade-in-out">
+      <menu v-show="isShowMenu">
+        <ul>
+          <li
+            v-for="(item, index) in menuList"
+            :key="index"
+            @click="onClickMenuItem(item)"
+          >
+            {{ item }}
+          </li>
+        </ul>
+        <button
+          class="close"
+          @click="isShowMenu = false"
+        >
+          <img
+            class=""
+            src="@/assets/images/icon_close.png"
+            alt=""
+            draggable="false"
+          >
+        </button>
+      </menu>
+    </Transition>
+  </div>
+</template>
+
+<script setup>
+import { ref, computed, watch, onMounted, inject } from "vue"
+import { useRoute, useRouter } from "vue-router"
+import { useStore } from "vuex"
+import useSizeAdapt from "@/useFunctions/useSizeAdapt"
+
+const route = useRoute()
+const router = useRouter()
+const store = useStore()
+
+const $env = inject('$env')
+
+const {
+  windowSizeInCssForRef,
+  windowSizeWhenDesignForRef,
+} = useSizeAdapt()
+
+const emit = defineEmits(['close'])
+
+const poemList = configExcel['诗词']
+
+let swiper = null
+const currentIdx = ref(0)
+const onSwiper = (swiperP) => {
+  swiper = swiperP
+}
+const onSlideChange = (e) => {
+  currentIdx.value = e.activeIndex
+}
+
+const isShowOperationTip = ref(true)
+watch(currentIdx, (v) => {
+  if (isShowOperationTip.value) {
+    isShowOperationTip.value = false
+  }
+})
+
+const isShowMenu = ref(false)
+const temp = configExcel['诗词'].map((item) => {
+  return item['朝代']
+})
+const menuList = Array.from(new Set(temp))
+function onClickMenuItem(menuItemName) {
+  const targetIdx = poemList.findIndex((item) => {
+    return item['朝代'] === menuItemName
+  })
+  swiper.slideTo(targetIdx)
+  isShowMenu.value = false
+}
+</script>
+
+<style lang="less" scoped>
+.poem-list{
+  position: absolute;
+  left: 0;
+  top: 0;
+  width: 100%;
+  height: 100%;
+  background-color: #555;
+  ::-webkit-scrollbar { width: 0; height: 0; }
+  >.poem-list{
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    overflow: auto;
+    >.poem-item{
+      display: block;
+      width: 100%;
+      height: 100%;
+    }
+  }
+  >.button-back{
+    z-index: 10;
+  }
+  >.operation-tip{
+    position: absolute;
+    left: 50%;
+    bottom: calc(17 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+    transform: translateX(-50%);
+    z-index: 10;
+  }
+  >.menu-btn{
+    position: absolute;
+    right: calc(17 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+    bottom: calc(17 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+    z-index: 10;
+    width: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+    height: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+    >img{
+      width: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      height: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+    }
+  }
+  >menu{
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    background: rgba(38,55,38,0.6);
+    border-radius: 0px 0px 0px 0px;
+    backdrop-filter: blur(calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef')));
+    z-index: 15;
+    >ul{
+      position: absolute;
+      left: 50%;
+      top: 50%;
+      transform: translate(-50%, -50%);
+      display: flex;
+      flex-direction: column;
+      justify-content: center;
+      align-items: center;
+      gap: calc(39 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      >li{
+        font-family: KingHwa_OldSong, KingHwa_OldSong;
+        font-weight: 400;
+        font-size: calc(36 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        color: #FFFFFF;
+      }
+    }
+    >button.close{
+      position: absolute;
+      right: calc(17 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      bottom: calc(17 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      z-index: 10;
+      width: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      height: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      >img{
+        width: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        height: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      }
+    }
+  }
+}
+</style>

+ 5 - 0
yarn.lock

@@ -6007,6 +6007,11 @@ svgo@^2.7.0:
     picocolors "^1.0.0"
     stable "^0.1.8"
 
+swiper@^11.1.4:
+  version "11.1.4"
+  resolved "https://registry.npmmirror.com/swiper/-/swiper-11.1.4.tgz#2f8e303e8bf9e5bc40a3885fc637ae60ff27996c"
+  integrity sha512-1n7kbYJB2dFEpUHRFszq7gys/ofIBrMNibwTiMvPHwneKND/t9kImnHt6CfGPScMHgI+dWMbGTycCKGMoOO1KA==
+
 table@^6.0.9:
   version "6.8.2"
   resolved "https://registry.npmmirror.com/table/-/table-6.8.2.tgz#c5504ccf201213fa227248bdc8c5569716ac6c58"