瀏覽代碼

Merge remote-tracking branch 'origin/master'

limeng 6 月之前
父節點
當前提交
5de0fa74ba

+ 3 - 0
zhjq-business/src/main/java/com/zhjq/domain/QrCodeGenerateDTO.java

@@ -14,5 +14,8 @@ public class QrCodeGenerateDTO {
 
     private String voiceName;
 
+    /**
+     * 扫描二维码跳转地址
+     */
     private String voiceUrl;
 }

+ 2 - 0
zhjq-business/src/main/java/com/zhjq/domain/ZhjqVoice.java

@@ -1,5 +1,6 @@
 package com.zhjq.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.zhjq.common.annotation.Excel;
 import com.zhjq.common.core.domain.BaseEntity;
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -58,6 +59,7 @@ public class ZhjqVoice extends BaseEntity {
      * 发布时间
      */
     @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date releaseTime;
 
     public void setId(Long id) {

+ 2 - 0
zhjq-system/src/main/java/com/zhjq/system/domain/SysNotice.java

@@ -1,5 +1,6 @@
 package com.zhjq.system.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.zhjq.common.core.domain.BaseEntity;
 import com.zhjq.common.xss.Xss;
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -57,6 +58,7 @@ public class SysNotice extends BaseEntity {
      * 发布时间
      */
     @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date releaseTime;
 
     public Long getNoticeId() {

+ 2 - 0
zhjq-ui/package.json

@@ -45,6 +45,7 @@
     "file-saver": "2.0.5",
     "fuse.js": "6.4.3",
     "highlight.js": "9.18.5",
+    "howler": "^2.2.4",
     "js-beautify": "1.13.0",
     "js-cookie": "3.0.1",
     "jsencrypt": "3.0.0-rc.1",
@@ -54,6 +55,7 @@
     "sortablejs": "1.10.2",
     "splitpanes": "2.4.1",
     "vue": "2.6.12",
+    "vue-aliplayer": "^1.0.0",
     "vue-count-to": "1.0.13",
     "vue-cropper": "0.5.5",
     "vue-meta": "2.4.0",

+ 1 - 1
zhjq-ui/src/permission.js

@@ -9,7 +9,7 @@ import {isRelogin} from '@/utils/request'
 
 NProgress.configure({showSpinner: false})
 
-const whiteList = ['/login', '/register']
+const whiteList = ['/login', '/register', '/details']
 
 const isWhiteList = (path) => {
   return whiteList.some(pattern => isPathMatch(pattern, path))

+ 5 - 0
zhjq-ui/src/router/index.js

@@ -51,6 +51,11 @@ export const constantRoutes = [
     hidden: true
   },
   {
+    path: '/details/:id',
+    component: () => import('@/views/system/voice/details/details'),
+    hidden: true
+  },
+  {
     path: '/404',
     component: () => import('@/views/error/404'),
     hidden: true

+ 124 - 0
zhjq-ui/src/views/system/voice/details/details.vue

@@ -0,0 +1,124 @@
+<template>
+  <div class="attraction-page">
+    <div class="attraction-header">
+      <h1>{{ form.voiceName }}</h1>
+    </div>
+    <div class="author-release">
+      <p>发布人:{{ form.author }}</p>
+      <p>发布时间:{{ form.releaseTime }}</p>
+    </div>
+    <div class="attraction-details">
+      <div class="rich-content" v-html="richContent"></div>
+    </div>
+  </div>
+</template>
+<script>
+import {getVoice} from "@/api/system/voice";
+import {Howl} from 'howler';
+
+export default {
+  name: "Details",
+  data() {
+    return {
+      id: '',
+      form: {},
+      localIp: '',
+      localPort: '',
+      instance: null,
+      sound: null,
+      richContent: ""
+    };
+  },
+
+  mounted() {
+    this.localIp = this.getLocalIp();
+    this.localPort = this.getPort()
+    this.id = this.$route.params.id;
+  },
+
+  created() {
+    this.getDetails()
+  },
+  methods: {
+    playSound(val) {
+      console.log("val", val);
+      if (this.sound) {
+        this.sound.play();
+      } else {
+        this.sound = new Howl({
+          src: [val],
+          html5: true,
+          format: ['mp3']
+        });
+        this.sound.play();
+      }
+    },
+    getLocalIp() {
+      const {hostname} = window.location;
+      return hostname === 'localhost' || hostname === '127.0.0.1'
+        ? 'http://192.168.4.9'
+        : `http://${hostname}`;
+    },
+    getPort() {
+      return window.location.port ? `:${window.location.port}` : '8080';
+    },
+    getDetails() {
+      let that = this
+      getVoice(that.$route.params.id).then(response => {
+        this.form = response.data;
+        this.richContent = this.form.content
+      });
+      setTimeout(() => {
+        this.playSound(this.localIp + ":" + this.localPort + this.form.voiceUrl)
+      }, 1000);
+    }
+  }
+};
+</script>
+<style>
+/* 控制 rich-content 中 img 标签的样式 */
+img {
+  width: 100%; /* 固定宽度 */
+  height: auto; /* 固定高度 */
+  object-fit: cover; /* 保持比例,裁剪多余部分 */
+  display: block; /* 使图片成为块级元素 */
+  margin: 16px 0; /* 上下外边距 */
+}
+</style>
+<style scoped>
+.attraction-page {
+  width: 1000rpx;
+  margin: auto;
+  padding: 16px; /* 添加内边距 */
+}
+.attraction-header {
+  margin-bottom: 20rpx;
+  display: flex;
+  flex-direction: column; /* 垂直排列 */
+  align-items: center; /* 水平居中 */
+  text-align: center; /* 文本居中 */
+}
+.author-release {
+  display: flex; /* 使用 Flexbox */
+  justify-content: center; /* 水平居中 */
+  gap: 50px; /* 设置间距 */
+}
+p {
+  margin: 0; /* 去掉默认的外边距 */
+}
+.attraction-details {
+  width: 200rpx;
+  margin-bottom: 20rpx;
+}
+.rich-content {
+  max-width: 100%; /* 最大宽度为 100% */
+  overflow: auto; /* 允许内容溢出时滚动 */
+  font-size: 16px; /* 设置默认字体大小 */
+}
+/* 响应式样式 */
+@media (max-width: 600px) {
+  .rich-content {
+    font-size: 14px; /* 在手机端字体稍小 */
+  }
+}
+</style>

+ 6 - 5
zhjq-ui/src/views/system/voice/index.vue

@@ -72,7 +72,7 @@
           </el-popover>
         </template>
       </el-table-column>
-      <el-table-column label="作者" align="center" prop="author"/>
+      <el-table-column label="发布人" align="center" prop="author"/>
       <el-table-column align="center" label="发布时间" prop="releaseTime" width="180">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.releaseTime, '{y}-{m}-{d}') }}</span>
@@ -124,8 +124,8 @@
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="作者" prop="author">
-              <el-input v-model="form.author" placeholder="请输入作者"/>
+            <el-form-item label="发布人" prop="author">
+              <el-input v-model="form.author" placeholder="请输入发布人"/>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -209,7 +209,7 @@ export default {
           {required: true, message: "内容不能为空", trigger: "blur"}
         ],
         author: [
-          {required: true, message: "作者不能为空", trigger: "blur"}
+          {required: true, message: "发布人不能为空", trigger: "blur"}
         ],
         releaseTime: [
           {required: true, message: "发布时间不能为空", trigger: "change"}
@@ -255,7 +255,8 @@ export default {
       let params = {
         id: row.id,
         voiceName: row.voiceName,
-        voiceUrl: that.localIp + ":" + that.localPort + row.voiceUrl,
+        // voiceUrl: that.localIp + ":" + that.localPort + "/details?id=" + row.id,
+        voiceUrl: "/details?id=" + row.id,
       }
       createQrCode(params).then(res => {
         if (res.code == 200) {