Jelajahi Sumber

Merge branch 'iteraion-20240914-pdf'

lex-xin 9 bulan lalu
induk
melakukan
ca3458c8c0

+ 3 - 4
src/tenant/music/music-detail/imageFunction.ts

@@ -77,18 +77,17 @@ export const addWatermark = async (canvas, text) => {
 export const addMusicTitle = (canvas, info) => {
   canvas.getContext('2d')
   const water = document.createElement('canvas')
-
   // 小水印画布大小
   water.width = canvas.width
-  water.height = canvas.height + 40
+  water.height = canvas.height + 80
   const waterCtx = water.getContext('2d') as CanvasRenderingContext2D
   waterCtx.fillStyle = '#fff'
-  waterCtx.fillRect(0, 0, canvas.width, canvas.height + 40)
+  waterCtx.fillRect(0, 0, water.width, water.height)
   waterCtx.font = `26pt Calibri`
   waterCtx.fillStyle = '#000'
   waterCtx.textAlign = 'center'
   waterCtx.drawImage(canvas, 0, 40)
-  waterCtx.fillText(info.title, canvas.width / 2, 80)
+  waterCtx.fillText(info.title, canvas.width / 2, 40)
   return water
 }
 

+ 17 - 15
src/tenant/music/music-detail/new-index.tsx

@@ -109,11 +109,11 @@ export default defineComponent({
       staff.radio = type
       staff.status = false
       
-      if (type == 'first' && (!defaultImgs.value.first || musicDetail.value?.firstPdfUrl)) {
+      if (type == 'first') {
         loading.value = false
         const tempPdf = musicDetail.value?.firstPdfUrl
         initIframe(tempPdf, 'first', staffData.musicXml)
-      } else if (type == 'fixed' && (!defaultImgs.value.fixed || musicDetail.value?.jianPdfUrl)) {
+      } else if (type == 'fixed') {
         loading.value = false
         const tempPdf = musicDetail.value?.jianPdfUrl
         initIframe(tempPdf, 'first', staffData.musicXml)
@@ -522,17 +522,17 @@ export default defineComponent({
       try {
         nextTick(() => {
           if (musicPdfUrl.value) {
-            const url = `${location.origin}${
-                location.pathname
-              }pdf/web/viewer-pdf.html?file=${encodeURIComponent(
-                musicPdfUrl.value
-              )}&t=${Date.now()}`
+            // const url = `${location.origin}${
+            //     location.pathname
+            //   }pdf/web/viewer-pdf.html?file=${encodeURIComponent(
+            //     musicPdfUrl.value
+            //   )}&t=${Date.now()}`
 
 
-              // const url = '/pdf/web/viewer-pdf.html?file=' +
-              //   encodeURIComponent(musicPdfUrl.value) +
-              //   '&t=' +
-              //   Date.now()
+              const url = '/pdf/web/viewer-pdf.html?file=' +
+                encodeURIComponent(musicPdfUrl.value) +
+                '&t=' +
+                Date.now()
             
             const iframeRef = document.querySelector('#staffIframeRef') as any
             iframeRef.contentWindow.location.replace(
@@ -540,8 +540,8 @@ export default defineComponent({
             )
             staffData.iframeSrc = url
           } else {
-            const url = `${location.origin}${location.pathname}osmd/index.html`
-            // const url = `${location.origin}/osmd/index.html`
+            // const url = `${location.origin}${location.pathname}osmd/index.html`
+            const url = `${location.origin}/osmd/index.html`
 
             const iframeRef = document.querySelector('#staffIframeRef') as any
             iframeRef.contentWindow.location.replace(url)
@@ -890,7 +890,8 @@ export default defineComponent({
                 <iframe
                   id="staffIframeRef"
                   style={{
-                    opacity: loading.value ? 0 : 1
+                    opacity: loading.value ? 0 : 1,
+                    flex: "1 auto"
                   }}
                   // src={staffData.iframeSrc}
                   onLoad={() => {
@@ -920,7 +921,8 @@ export default defineComponent({
                   <iframe
                     id="staffIframeRef"
                     style={{
-                      opacity: loading.value ? 0 : 1
+                      opacity: loading.value ? 0 : 1,
+                      flex: "1 auto"
                     }}
                     // src={staffData.iframeSrc}
                     onLoad={() => {

+ 3 - 4
src/views/music/music-detail/imageFunction.ts

@@ -78,18 +78,17 @@ export const addWatermark = async (canvas, text) => {
 export const addMusicTitle = (canvas, info) => {
   canvas.getContext('2d')
   const water = document.createElement('canvas')
-
   // 小水印画布大小
   water.width = canvas.width
-  water.height = canvas.height + 40
+  water.height = canvas.height + 80
   const waterCtx = water.getContext('2d') as CanvasRenderingContext2D
   waterCtx.fillStyle = '#fff'
-  waterCtx.fillRect(0, 0, canvas.width, canvas.height + 40)
+  waterCtx.fillRect(0, 0, water.width, water.height)
   waterCtx.font = `26pt Calibri`
   waterCtx.fillStyle = '#000'
   waterCtx.textAlign = 'center'
   waterCtx.drawImage(canvas, 0, 40)
-  waterCtx.fillText(info.title, canvas.width / 2, 80)
+  waterCtx.fillText(info.title, canvas.width / 2, 40)
   return water
 }
 

+ 5 - 2
src/views/music/music-detail/index.module.less

@@ -445,16 +445,19 @@
   padding-bottom: 18px !important;
 
   .coomposer {
-    padding-top: 2px;
     padding-left: 6px;
     max-width: 120px;
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
-    color: var(--van-primary);
+    color: #999999;
     display: flex;
     align-items: center;
+    &.links {
+      color:  var(--van-primary);
+    }
     span {
+      padding-top: 2px;
       line-height: 1;
     }
 

+ 50 - 28
src/views/music/music-detail/index.tsx

@@ -136,16 +136,15 @@ export default defineComponent({
     const onChangeStaff = (type: string) => {
       staff.radio = type
       staff.status = false
-      if (type == 'first' && (!defaultImgs.value.first || musicDetail.value?.firstPdfUrl )) {
+      console.log(type)
+      if (type == 'first') {
         loading.value = false
         const tempPdf = musicDetail.value?.firstPdfUrl
         initIframe(tempPdf, 'first', staffData.musicXml)
-      } else if (
-        type == 'fixed' &&
-        (!defaultImgs.value.fixed || musicDetail.value?.jianPdfUrl)
-      ) {
+      } else if (type == 'fixed') {
         loading.value = false
         const tempPdf = musicDetail.value?.jianPdfUrl
+        console.log(tempPdf, 'tempPdf')
         initIframe(tempPdf, 'fixed', staffData.musicXml)
       } else {
         loading.value = false
@@ -609,7 +608,6 @@ export default defineComponent({
         } else {
           musicPdfUrl.value = staffData.partList[0]?.musicPdfUrl
         }
-
       } catch (error) {
         //
         console.log(error, 'error')
@@ -811,23 +809,31 @@ export default defineComponent({
                             src={getAssetsHomeFile('icon_album_active.png')}
                           />
                         )}
-                        <span class={styles.coomposer} onClick={() => {
-                          if (
-                            browser().isApp &&
+                        <span
+                          class={[styles.coomposer, browser().isApp &&
                             musicDetail.value?.sourceType === 'TEACHER' &&
-                            state.platformType === 'STUDENT'
-                          ) {
-                            router.push({
-                              path: '/teacherHome',
-                              query: {
-                                teacherId: musicDetail.value?.userId,
-                                tabs: 'music'
-                              }
-                            })
-                          }
-                        }}>
+                            state.platformType === 'STUDENT' && styles.links]}
+                          onClick={() => {
+                            if (
+                              browser().isApp &&
+                              musicDetail.value?.sourceType === 'TEACHER' &&
+                              state.platformType === 'STUDENT'
+                            ) {
+                              router.push({
+                                path: '/teacherHome',
+                                query: {
+                                  teacherId: musicDetail.value?.userId,
+                                  tabs: 'music'
+                                }
+                              })
+                            }
+                          }}
+                        >
                           <img class={styles.iconAlbum2} src={iconAlbum2} />
-                          <span>{musicDetail.value?.userName || '游客' + ( musicDetail.value?.userId  || '')}</span>
+                          <span>
+                            {musicDetail.value?.userName ||
+                              '游客' + (musicDetail.value?.userId || '')}
+                          </span>
                         </span>
                       </p>
                     </div>
@@ -836,7 +842,10 @@ export default defineComponent({
                     <>
                       <span
                         style={{
-                          visibility: state.platformType === 'TEACHER' ? "visible" : "hidden"
+                          visibility:
+                            state.platformType === 'TEACHER'
+                              ? 'visible'
+                              : 'hidden'
                         }}
                         class={styles.download}
                         onClick={() => {
@@ -847,8 +856,18 @@ export default defineComponent({
                           }
                         }}
                       >
-                        <img src={musicDetail.value?.coursewareStatus?iconRemoveCourse: iconAddCourse} />
-                        <span>{musicDetail.value?.coursewareStatus ? '移出课件':'添加课件'}</span>
+                        <img
+                          src={
+                            musicDetail.value?.coursewareStatus
+                              ? iconRemoveCourse
+                              : iconAddCourse
+                          }
+                        />
+                        <span>
+                          {musicDetail.value?.coursewareStatus
+                            ? '移出课件'
+                            : '添加课件'}
+                        </span>
                       </span>
                       <span
                         class={styles.download}
@@ -938,7 +957,8 @@ export default defineComponent({
             </div>
 
             <div class={styles.musicContent}>
-              {musicDetail.value?.musicSheetType === 'CONCERT' || musicPdfUrl.value ||
+              {musicDetail.value?.musicSheetType === 'CONCERT' ||
+              musicPdfUrl.value ||
               !defaultImgs.value[staff.radio] ? (
                 <>
                   {musicPdfUrl.value ? (
@@ -977,7 +997,7 @@ export default defineComponent({
                         style={{
                           opacity: loading.value ? 0 : 1
                         }}
-                        src={staffData.iframeSrc}
+                        // src={staffData.iframeSrc}
                         onLoad={() => {
                           musicIframeLoad()
                         }}
@@ -1189,10 +1209,12 @@ export default defineComponent({
             {downloadStatus.value && (
               <Download
                 imgList={JSON.parse(JSON.stringify(showImg.value))}
-                musicSheetName={musicDetail.value?.musicSheetName +
+                musicSheetName={
+                  musicDetail.value?.musicSheetName +
                   (staffData.instrumentName
                     ? `(${staffData.instrumentName})`
-                    : '')}
+                    : '')
+                }
               />
             )}
           </Popup>