aamin 1 year ago
parent
commit
21fdd31e33
5 changed files with 66 additions and 85 deletions
  1. 45 45
      src/data/data.ts
  2. 3 3
      src/store/index.ts
  3. 17 9
      src/view/audioDetail/index.vue
  4. 1 4
      src/view/exhibitionList/index.vue
  5. 0 24
      src/view/home/index.vue

File diff suppressed because it is too large
+ 45 - 45
src/data/data.ts


+ 3 - 3
src/store/index.ts

@@ -1,17 +1,17 @@
 
 import { defineStore } from "pinia";
 
-type Paragraph = {
+export type Paragraph = {
   paragraphName: string;
   contentText: string;
 };
 
-type Part = {
+export type Part = {
   partName: string;
   paragraphs: Paragraph[];
 };
 
-type Exhibition = {
+export type Exhibition = {
   id: number;
   name: string;
   parts: Part[];

+ 17 - 9
src/view/audioDetail/index.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
 import dataList from "@/data/data";
-import { useStore } from "@/store/index";
+import { Exhibition, Paragraph, Part, useStore } from "@/store/index";
 import { showToast } from "vant";
 import AudioBoxVue from "@/components/AudioBox.vue";
 
@@ -23,11 +23,11 @@ const goBack = () => {
 // 上一个
 const prev = () => {
   // 当前段落下标
-  let indexPP = store.currentPart.paragraphs.findIndex((item: any) => {
+  let indexPP = store.currentPart.paragraphs.findIndex((item: Paragraph) => {
     return item.paragraphName == currentP.value.paragraphName;
   });
   // 当前Part的下标
-  let indexP = store.currentScene.parts.findIndex((item: any) => {
+  let indexP = store.currentScene.parts.findIndex((item: Part) => {
     return item.partName == store.currentPart.partName;
   });
   //console.log(indexPP, indexP);
@@ -53,11 +53,11 @@ const prev = () => {
 // 下一个
 const next = () => {
   // 当前段落下标
-  let indexPP = store.currentPart.paragraphs.findIndex((item: any) => {
+  let indexPP = store.currentPart.paragraphs.findIndex((item: Paragraph) => {
     return item.paragraphName == currentP.value.paragraphName;
   });
   // 当前Part的下标
-  let indexP = store.currentScene.parts.findIndex((item: any) => {
+  let indexP = store.currentScene.parts.findIndex((item: Part) => {
     return item.partName == store.currentPart.partName;
   });
   //console.log(indexPP, indexP);
@@ -87,7 +87,7 @@ const next = () => {
 };
 
 const audiobox = ref(null);
-watch(currentP, (newValue: any) => {
+watch(currentP, () => {
   console.log(audiobox.value);
   if (audiobox.value == null) {
     return;
@@ -102,15 +102,15 @@ onMounted(() => {
   const pNumb = route.query.pNum;
   console.log(route.query.sName, route.query.pNum);
   if (sName != "" && pNumb) {
-    const s = dataList.find((item: any) => {
+    const s = dataList.find((item: Exhibition) => {
       // return item.name == sName;
       return item.name.indexOf(sName) != -1 || sName.indexOf(item.name) != -1;
     });
     // console.log(dataList);
     // console.log(s);
     // 遍历所有的part
-    s?.parts.forEach((item: any) => {
-      const res = item.paragraphs.find((p: any) => {
+    s?.parts.forEach((item: Part) => {
+      const res = item.paragraphs.find((p: Paragraph) => {
         return p.paragraphName.indexOf(pNumb) != -1;
       });
       if (res) {
@@ -123,6 +123,8 @@ onMounted(() => {
   }
   currentP.value = store.currentParagraph;
 });
+
+const htmlD = ref("<div>献给所有为了梦想狂奔的人</div><br />你好");
 </script>
 
 <template>
@@ -202,6 +204,12 @@ onMounted(() => {
         font-weight: 500;
         white-space: pre-wrap;
         margin-top: 10px;
+
+        .html-box {
+          div {
+            text-indent: 2em;
+          }
+        }
       }
     }
 

+ 1 - 4
src/view/exhibitionList/index.vue

@@ -20,7 +20,7 @@ const goDetail = (item: string, index: number) => {
     path: "/audioDetail",
   });
 };
-
+const currentPart = ref(-1);
 const open = (partIndex: number) => {
   if (currentPart.value == partIndex) {
     currentPart.value = 0;
@@ -29,15 +29,12 @@ const open = (partIndex: number) => {
   }
 };
 
-const currentPart = ref(-1);
-
 const getAssetURL = (image: string) => {
   return new URL(`../../assets/img/${image}`, import.meta.url).href;
 };
 
 const currentScene = ref();
 
-
 onMounted(() => {
   if (route.query.id) {
     currentScene.value = dataList.find((item) => {

+ 0 - 24
src/view/home/index.vue

@@ -7,30 +7,6 @@ const getAssetURL = (image: string) => {
 
 const router = useRouter();
 const goDetail = (id: string) => {
-  // // 初始化Aduio
-  // var audio = new Audio(
-  //   "https://houseoss.4dkankan.com/project/yueYang/dongtingchangge/part1/001-1.mp3"
-  // );
-  // audio.muted = false;
-  // var playPromise = audio.play();
-  // // audio.muted = true;
-  // if (playPromise) {
-  //   playPromise
-  //     .then(() => {
-  //       // 音频加载成功
-  //       // 音频的播放需要耗时
-  //       setTimeout(() => {
-  //         // 后续操作
-  //         audio.pause();
-  //         console.log("成功");
-  //       }, 50); // audio.duration 为音频的时长单位为秒
-  //     })
-  //     .catch((e) => {
-  //       // 音频加载失败
-  //       audio.pause();
-  //       console.log("失败");
-  //     });
-  // }
 
   router.push(
     {