Browse Source

Merge branch 'iteration-20240729' into online

lex 9 months ago
parent
commit
d2e9f312fa
5 changed files with 146 additions and 76 deletions
  1. 1 1
      dev-dist/sw.js
  2. 1 1
      public/version.json
  3. 115 50
      src/views/xiaoku-music/index.tsx
  4. 28 23
      src/views/xiaoku-music/type.ts
  5. 1 1
      vite.config.ts

+ 1 - 1
dev-dist/sw.js

@@ -82,7 +82,7 @@ define(['./workbox-bb0550c6'], (function (workbox) { 'use strict';
     "revision": "3ca0b8505b4bec776b69afdba2768812"
   }, {
     "url": "index.html",
-    "revision": "0.rmqt4d91upg"
+    "revision": "0.f0i7vtfproo"
   }], {});
   workbox.cleanupOutdatedCaches();
   workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

+ 1 - 1
public/version.json

@@ -1 +1 @@
-{"version":1722339386306}
+{"version":1722414471585}

+ 115 - 50
src/views/xiaoku-music/index.tsx

@@ -242,7 +242,7 @@ export default defineComponent({
         //   'data.list[data.listActive]'
         // );
         musicsrc = `${vaildMusicScoreUrl()}/instrument/?modelType=practise&id=${
-          data.list[data.listActive].xmlFileUrl
+          data.list[data.listActive]?.xmlFileUrl
         }&Authorization=${userStore.getToken}/#/preview`;
       } else {
         musicsrc = '';
@@ -309,6 +309,21 @@ export default defineComponent({
       }
     });
 
+    // 判断是否可转谱 - 为空也可以转谱
+    const checkConverTible = (isConvertibleScore: any, scoreType: string) => {
+      if (
+        isConvertibleScore ||
+        isConvertibleScore === '' ||
+        isConvertibleScore === undefined ||
+        isConvertibleScore === null ||
+        (['JIAN', 'FIRST'].includes(scoreType) && !isConvertibleScore)
+      ) {
+        return true;
+      } else {
+        return false;
+      }
+    };
+
     const musicIframeLoad = () => {
       const token = userStore.getToken;
       const details = data.list[data.listActive];
@@ -356,20 +371,48 @@ export default defineComponent({
       }
     };
 
-    const _actions = [
-      {
-        value: 'staff',
-        label: '五线谱'
-      },
-      {
-        value: 'first',
-        label: '首调'
-      },
-      {
-        value: 'fixed',
-        label: '固定调'
+    const _actions = computed(() => {
+      const details = data.list[data.listActive];
+      const { scoreType, isConvertibleScore } = details || {};
+
+      const action: any[] = [
+        {
+          value: 'first',
+          label: '首调'
+        },
+        {
+          value: 'fixed',
+          label: '固定调'
+        }
+      ];
+      // 首调 固定调 并且 不显示可转谱 则不显示五线谱
+      if (
+        !(
+          ['JIAN', 'FIRST'].includes(scoreType) && isConvertibleScore === false
+        ) &&
+        !(isConvertibleScore === undefined || isConvertibleScore === null)
+      ) {
+        action.unshift({
+          value: 'staff',
+          label: '五线谱'
+        });
       }
-    ];
+      return action;
+    });
+    // const _actions = [
+    //   {
+    //     value: 'staff',
+    //     label: '五线谱'
+    //   },
+    //   {
+    //     value: 'first',
+    //     label: '首调'
+    //   },
+    //   {
+    //     value: 'fixed',
+    //     label: '固定调'
+    //   }
+    // ];
 
     // 解析xml,获取分轨信息
     const analyzeXml = async () => {
@@ -400,24 +443,33 @@ export default defineComponent({
         //   );
         // }
         // showMusicImg: 'first' as 'staff' | 'first' | 'fixed',
-        const { defaultScore, transferFlag } =
-          details.musicalInstruments[0] || {};
-        // console.log(
-        //   details.musicalInstruments[0],
-        //   'details.musicalInstruments[0]'
-        // );
-        let musicImgType: 'staff' | 'first' | 'fixed' = 'staff';
+
+        // const { defaultScore, transferFlag } =
+        //   details.musicalInstruments[0] || {};
+        // let musicImgType: 'staff' | 'first' | 'fixed' = 'staff';
+        // musicImgType =
+        //   defaultScore === 'STAVE'
+        //     ? 'staff'
+        //     : defaultScore === 'JIAN'
+        //     ? 'fixed'
+        //     : defaultScore === 'FIRST'
+        //     ? 'first'
+        //     : 'staff';
+        // console.log(musicImgType, 'musicImgType1');
+        // data.showMusicImg = musicImgType;
+        // data.showTransBtn = transferFlag;
+        const { scoreType, isConvertibleScore } = details || {};
+        let musicImgType: 'staff' | 'first' | 'fixed' = 'first';
         musicImgType =
-          defaultScore === 'STAVE'
+          scoreType === 'STAVE'
             ? 'staff'
-            : defaultScore === 'JIAN'
+            : scoreType === 'JIAN'
             ? 'fixed'
-            : defaultScore === 'FIRST'
+            : scoreType === 'FIRST'
             ? 'first'
-            : 'staff';
-        console.log(musicImgType, 'musicImgType1');
+            : 'first';
         data.showMusicImg = musicImgType;
-        data.showTransBtn = transferFlag;
+        data.showTransBtn = checkConverTible(isConvertibleScore, scoreType);
       }
     };
 
@@ -432,7 +484,7 @@ export default defineComponent({
         item =>
           item.getElementsByTagName('part-name')?.[0]?.textContent?.trim() || ''
       );
-      const parts: any = xmlParse.getElementsByTagName('part');
+      // const parts: any = xmlParse.getElementsByTagName('part');
 
       /** 第一分谱如果是约定的配置分谱则跳过 */
       if (partListNames[0]?.toLocaleUpperCase?.() === 'COMMON') {
@@ -465,31 +517,44 @@ export default defineComponent({
         .filter((item: any) => item.canselect)
         .sort((a: any, b: any) => a.sortId - b.sortId);
       data.trackList = arr;
-      let track = arr.find(
-        (item: any) => item.value === data.musicInstrumentIndex
-      )?.track;
+      // let track = arr.find(
+      //   (item: any) => item.value === data.musicInstrumentIndex
+      // )?.track;
       // track = track
       //   .replace(/[0-9]+/g, '')
       //   .replace(/\s/g, '')
       //   .toLocaleLowerCase();
-      track = trackToCode(track);
-      let musicRenderType: 'staff' | 'first' | 'fixed' = 'staff';
-      let canTrans = true;
-      data.list[data.listActive]?.musicalInstruments.forEach((item: any) => {
-        if (item.code.toLocaleLowerCase() === track.toLocaleLowerCase()) {
-          musicRenderType =
-            item.defaultScore === 'STAVE'
-              ? 'staff'
-              : item.defaultScore === 'JIAN'
-              ? 'fixed'
-              : item.defaultScore === 'FIRST'
-              ? 'first'
-              : 'staff';
-          canTrans = item.transferFlag;
-        }
-      });
-      data.showTransBtn = canTrans;
-      data.showMusicImg = musicRenderType;
+      // track = trackToCode(track);
+      // let musicRenderType: 'staff' | 'first' | 'fixed' = 'staff';
+      // let canTrans = true;
+      // data.list[data.listActive]?.musicalInstruments.forEach((item: any) => {
+      //   if (item.code.toLocaleLowerCase() === track.toLocaleLowerCase()) {
+      //     musicRenderType =
+      //       item.defaultScore === 'STAVE'
+      //         ? 'staff'
+      //         : item.defaultScore === 'JIAN'
+      //         ? 'fixed'
+      //         : item.defaultScore === 'FIRST'
+      //         ? 'first'
+      //         : 'staff';
+      //     canTrans = item.transferFlag;
+      //   }
+      // });
+      // data.showTransBtn = canTrans;
+      // data.showMusicImg = musicRenderType;
+      const details = data.list[data.listActive];
+      const { scoreType, isConvertibleScore } = details || {};
+      let musicImgType: 'staff' | 'first' | 'fixed' = 'first';
+      musicImgType =
+        scoreType === 'STAVE'
+          ? 'staff'
+          : scoreType === 'JIAN'
+          ? 'fixed'
+          : scoreType === 'FIRST'
+          ? 'first'
+          : 'first';
+      data.showMusicImg = musicImgType;
+      data.showTransBtn = checkConverTible(isConvertibleScore, scoreType);
     };
     watch(
       () => data.listActive,
@@ -839,7 +904,7 @@ export default defineComponent({
                   {/* 转谱按钮 */}
                   {data.showTransBtn && (
                     <NPopselect
-                      options={_actions}
+                      options={_actions.value}
                       trigger="hover"
                       v-model:value={data.showMusicImg}
                       onUpdate:value={async (val: any) => {

+ 28 - 23
src/views/xiaoku-music/type.ts

@@ -1,23 +1,28 @@
-import { ref } from 'vue';
-
-/** 曲谱信息 */
-export interface IMusicItem {
-  id: number | string;
-  musicSheetName: string;
-  composer: string;
-  titleImg: string;
-  audioFileUrl: string;
-  /** 伴奏 */
-  metronomeUrl: string;
-  /** 首调 */
-  firstTone: string;
-  delFlag: boolean;
-  favitor: boolean;
-  musicSvg: string;
-  musicImg: string;
-  musicFirstSvg: string;
-  musicFirstImg: string;
-  musicJianSvg: string;
-  musicJianImg: string;
-  musicSheetType: string;
-}
+import { ref } from 'vue';
+
+/** 曲谱信息 */
+export interface IMusicItem {
+  id: number | string;
+  musicSheetName: string;
+  composer: string;
+  titleImg: string;
+  audioFileUrl: string;
+  /** 伴奏 */
+  metronomeUrl: string;
+  /** 首调 */
+  firstTone: string;
+  delFlag: boolean;
+  favitor: boolean;
+  musicSvg: string;
+  musicImg: string;
+  musicFirstSvg: string;
+  musicFirstImg: string;
+  musicJianSvg: string;
+  musicJianImg: string;
+  musicSheetType: string;
+  xmlFileUrl?: string;
+  multiTracksSelection?: string;
+  musicalInstruments?: any[];
+  scoreType: string;
+  isConvertibleScore: boolean;
+}

+ 1 - 1
vite.config.ts

@@ -24,7 +24,7 @@ function resolve(dir: string) {
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
 // const proxyUrl = 'https://dev.kt.colexiu.com/';
-const proxyUrl = 'https://test.kt.colexiu.com';
+const proxyUrl = 'https://dev.kt.colexiu.com';
 // const proxyUrl = 'http://192.168.3.14:7989';
 const now = new Date().getTime();
 export default defineConfig(() => {