From ef37c59e055a990ce247b265b27d3fcef430a243 Mon Sep 17 00:00:00 2001
From: 杨磊 <505174330@qq.com>
Date: 星期五, 15 八月 2025 10:19:18 +0800
Subject: [PATCH] first submit

---
 src/views/preview/audio.vue |   74 +++++++++++++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/src/views/preview/audio.vue b/src/views/preview/audio.vue
new file mode 100644
index 0000000..528cec3
--- /dev/null
+++ b/src/views/preview/audio.vue
@@ -0,0 +1,74 @@
+<template>
+  <div class="contentBox">
+    <div class="videoName">{{ $route.query.titleName }}</div>
+
+    <audio
+      @canplay="getDuration"
+      controls
+      v-if="audioSrc"
+      @timeupdate="updateTime"
+      ref="audio"
+      :src="audioSrc"
+      oncontextmenu="return false"
+      controlsList="nodownload"
+    ></audio>
+  </div>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      audioSrc: "",
+    };
+  },
+  created() {
+    scrollTo(0, 0);
+    this.audioSrc =
+      this.config.requestCtx +
+      "/file/api/ApiDownload?md5=" +
+      this.$route.query.md5;
+  },
+  methods: {
+    getDuration() {
+      this.audio = this.$refs.audio;
+      this.duration = this.timeFormat(this.$refs.audio.duration);
+    },
+
+    updateTime() {
+      if (!this.$refs.progress) return;
+      this.currentDuration = this.timeFormat(this.audio.currentTime);
+      //濡傛灉涓嶆槸姝e湪绉诲姩 鍜� 娌℃湁鏆傚仠鎾斁灏辨墽琛�
+      if (!this.isMoveIn || !this.audio.paused) {
+        // 璁剧疆褰撳墠鏃堕棿
+        let MoveX =
+          this.$refs.progress.clientWidth *
+          (this.audio.currentTime / this.audio.duration);
+        //鎾斁鏃舵洿鏂拌窛绂�
+        this.$refs.currentProgress.style.width = MoveX + "px";
+        this.$refs.circle.style.left =
+          MoveX - this.$refs.circle.clientWidth / 2 + "px";
+      }
+    },
+    timeFormat(number) {
+      let minute = parseInt(number / 60);
+      let second = parseInt(number % 60);
+      minute = minute >= 10 ? minute : "0" + minute;
+      second = second >= 10 ? second : "0" + second;
+      return minute + ":" + second;
+    },
+  },
+};
+</script>
+
+<style>
+audio {
+  width: 100%;
+  height: 80px;
+}
+.videoName {
+  text-align: center;
+  margin-top: 20px;
+  font-size: 30px;
+}
+</style>

--
Gitblit v1.9.1