Pārlūkot izejas kodu

feat: 保存作品修改

TIANYONG 7 mēneši atpakaļ
vecāks
revīzija
fa721e839b

+ 48 - 0
src/page-instrument/evaluat-model/evaluat-result/index.module.less

@@ -177,6 +177,54 @@
     }
 }
 
+.saveBtn {
+    position: relative;
+}
+.noSaveTip {
+    background: rgba(0,0,0,0.7);
+    font-size: 13Px;
+    border-radius: 8Px;
+    display: flex;
+    align-items: center;
+    padding: 8Px 12Px;
+    position: absolute;
+    left: 50%;
+    top: -45Px;
+    transform: translateX(-50%);
+    z-index: 1;
+    color: #fff;
+    width: auto;
+    word-break: keep-all;
+    > i {
+      display: inline-block;
+      min-width: 12Px;
+      width: 12Px;
+      height: 12Px;
+      background-image: url('./icons/close_icon.png');
+      background-size: 100% 100%;
+      background-position: center center;
+      background-repeat: no-repeat;
+      margin-left: 16Px;
+      cursor: pointer;
+    }
+    span {
+      word-break: keep-all;
+      width: max-content;
+    }
+    .arrowIcon {
+      position: absolute;
+      left: 50%;
+      bottom: -8PX;
+      transform: translateX(-50%);
+      width: 0;
+      height: 0;
+      border-top: 8PX solid rgba(0,0,0,0.7);
+      border-right: 8PX solid transparent;
+      border-left: 8PX solid transparent;  
+      z-index: 2;      
+    }
+}
+
 :global {
     .savePopoverClose {
         &.van-popover {

+ 29 - 25
src/page-instrument/evaluat-model/evaluat-result/index.tsx

@@ -1,4 +1,4 @@
-import { defineComponent, onMounted, reactive, watch } from "vue";
+import { defineComponent, onMounted, reactive, watch, computed } from "vue";
 import { Popover } from "vant";
 import styles from "./index.module.less";
 import state from "/src/state";
@@ -78,6 +78,16 @@ export default defineComponent({
       emit("close", "update");
     };
 
+    // 播放倍率不等于1,或者是选段评测,APP暂时不支持保存演奏,需要给出提示
+    const noSaveTips = computed(() => {
+      let tipContent = '';
+      const rate = state.basePlayRate * state.originAudioPlayRate; // 播放倍率
+      if (query.workRecord || state.section.length === 2 || state.isAppPlay || rate != 1 || !state.accompany) {
+        tipContent = query.workRecord ? '评测作业暂不支持保存作品噢~' : (!state.accompany || state.isAppPlay) ? '该曲目暂不支持保存作品噢~' : state.section.length === 2 ? '选段后暂不支持保存作品噢~' : rate != 1 ? '调速后暂不支持保存作品噢~' : '';
+      }
+      return tipContent
+    })
+
     onMounted(() => {
       if (!evaluatingData.isErrorState) {
         handleAddRecord();
@@ -111,12 +121,12 @@ export default defineComponent({
                 {evaluatingData.resultData.score > 79 && <img class={styles.badge} src={iconBadge} />}
                 <div class={[styles.text, evaluatingData.resultData.score > 79 && styles.badgeText]}>
                   <div class={[styles.scoreSection, "evaluting-result-1"]}>
-                    <div class={styles.num}>{evaluatingData.resultData.score}00</div>
+                    <div class={styles.num}>{evaluatingData.resultData.score}</div>
                     <div class={styles.score}>分</div>
                     <div class={styles.level}>
                       <div>{level[evaluatingData.resultData.heardLevel]}</div>
                       <span>|</span>
-                      <div>速度{evaluatingData.resultData.speed}</div>
+                      <div>速度{evaluatingData.resultData.speed || state.speed}</div>
                     </div>
                   </div>
                 </div>
@@ -155,28 +165,22 @@ export default defineComponent({
               <div class={styles.ctrls}>
                 <img src={zlycImg} class={[styles.ctrlsBtn, "evaluting-result-2"]} onClick={() => emit("close", "tryagain")} />
                 {!state.isHideEvaluatReportSaveBtn && evaluatingData.resultData.recordId ? (
-                  <img src={bczpImg} class={[styles.ctrlsBtn, "evaluting-result-3"]} onClick={debounce(saveResult, 300)} />
-                ) : (
-                  <Popover
-                    class={"savePopoverClose"}
-                    placement={"top"}
-                    v-model:show={data.showPopover}
-                    v-slots={{
-                      reference: () => <img src={bczpJzImg} class={[styles.ctrlsBtn, "evaluting-result-3"]} />,
-                    }}
-                    theme="dark"
-                  >
-                    <div class={"popoverClose"}>
-                      <div>该曲目暂不支持保存作品噢~</div>
-                      <img
-                        src={closeImg}
-                        onClick={() => {
-                          data.showPopover = false;
-                        }}
-                      />
-                    </div>
-                  </Popover>
-                )}
+                  <div class={styles.saveBtn}>
+                    <img src={noSaveTips.value ? bczpJzImg : bczpImg} class={[styles.ctrlsBtn, "evaluting-result-3"]} onClick={() => {
+                      if (!noSaveTips.value) {
+                        debounce(saveResult, 300)
+                      }
+                    }} />
+                    {
+                      noSaveTips.value && state.noSavePopShow ? 
+                      <div class={[styles.noSaveTip]}>
+                        <span class={styles.arrowIcon}></span>
+                        <span>{noSaveTips.value}</span>
+                        <i onClick={() => state.noSavePopShow = false}></i>
+                      </div> : null                   
+                    }
+                  </div>
+                ) : null }
                 <img src={ckzpImg} class={[styles.ctrlsBtn, "evaluting-result-4", data.saveLoading ? styles.disablued : ""]} onClick={() => emit("close", "look")} />
               </div>
             </div>

+ 1 - 1
src/page-instrument/header-top/index.tsx

@@ -80,7 +80,7 @@ export const headTopData = reactive({
       state.playIngSpeed = state.originSpeed;
       handleStartEvaluat();
       // 开发模式,把此处打开
-      //state.modeType = "evaluating";
+      state.modeType = "evaluating";
       // evaluatingData.rendered = true;
       // evaluatingData.soundEffectMode = true;
     } else if (value === "follow") {

+ 3 - 0
src/state.ts

@@ -511,6 +511,8 @@ const state = reactive({
   basePlayRate: 1,
   /** 引导页显示状态 */
   hasDriverPop: false,
+  /** 播放倍率不等于1,或者是选段评测,APP暂时不支持保存演奏,需要给出提示 */
+  noSavePopShow: true,
 });
 const browserInfo = browser();
 let offset_duration = 0;
@@ -1222,6 +1224,7 @@ export const isRhythmicExercises = () => {
 /** 重置状态 */
 export const handleRessetState = () => {
   // 切换模式,清除选段
+  state.noSavePopShow = true;
   clearSelection();
   skipNotePlay(0, true);
   resetBaseRate();

+ 3 - 2
src/view/evaluating/index.tsx

@@ -35,7 +35,7 @@ import {
   api_startDelayCheck,
   api_closeDelayCheck,
 } from "/src/helpers/communication";
-import state, { IPlayState, clearSelection, handleStopPlay, onPlay, resetPlaybackToStart, togglePlay } from "/src/state";
+import state, { IPlayState, clearSelection, handleStopPlay, onPlay, resetPlaybackToStart, togglePlay, initSetPlayRate } from "/src/state";
 import { IPostMessage } from "/src/utils/native-message";
 import { usePageVisibility } from "@vant/use";
 import { browser } from "/src/utils";
@@ -351,7 +351,6 @@ export const handleStartBegin = async (preTimes?: number) => {
 	evaluatingData.evaluatings = {};
 	evaluatingData.resultData = {};
 	evaluatingData.backtime = 0;
-	resetPlaybackToStart();
 	evaluatingData.isAudioPlayEnd = false;
 	const res = await startEvaluating(evaluatingData.contentData);
 	if (res?.api !== "startEvaluating") {
@@ -364,6 +363,8 @@ export const handleStartBegin = async (preTimes?: number) => {
 		evaluatingData.startBegin = false;
 		return;
 	}
+  initSetPlayRate();
+	resetPlaybackToStart();
 	evaluatingData.startBegin = true;
 	if (evaluatingData.isDisabledPlayMusic) {
 		evaluatingData.isBeginMask = true