Browse Source

单元评测1.0

skyblued 2 years ago
parent
commit
d0fa3078c3
1 changed files with 20 additions and 14 deletions
  1. 20 14
      src/subpages/colexiu/buttons/evaluating.tsx

+ 20 - 14
src/subpages/colexiu/buttons/evaluating.tsx

@@ -5,9 +5,7 @@ import ButtonIcon from './icon'
 import detailState from '/src/pages/detail/state'
 import SettingState from '/src/pages/detail/setting-state'
 import appState from '/src/state'
-import {
-  Fraction
-} from '/osmd-extended/src'
+import { Fraction } from '/osmd-extended/src'
 import {
   IPostMessage,
   listenerMessage,
@@ -33,7 +31,6 @@ import styles from './index.module.less'
 
 let backtime = 0
 
-
 const initBehaviorId = '' + new Date().valueOf()
 const evaluating = ref(false)
 const playStatus: Ref<'connecting' | 'play' | 'stop'> = ref('stop')
@@ -87,7 +84,8 @@ const formatTimes = () => {
     // const fixtime = 0
     const start = difftime + (item.sourceRelativeTime || item.relativeTime)
     const end = difftime + (item.sourceRelaEndtime || item.relaEndtime)
-    const isStaccato = typeof note.voiceEntry.isStaccato === 'function' ? note.voiceEntry.isStaccato() : note.voiceEntry.isStaccato
+    const isStaccato =
+      typeof note.voiceEntry.isStaccato === 'function' ? note.voiceEntry.isStaccato() : note.voiceEntry.isStaccato
     const noteRate = isStaccato ? 0.5 : 1
     if (note.formatLyricsEntries.contains('Play') || note.formatLyricsEntries.contains('Play...')) {
       ListenMode = false
@@ -124,7 +122,7 @@ const formatTimes = () => {
       dontEvaluating: ListenMode || dontEvaluatingMode || item.skipMode,
       musicalNotesIndex: item.i,
       denominator: note.noteElement?.Length.denominator,
-      isOrnament: !!note?.voiceEntry?.ornamentContainer
+      isOrnament: !!note?.voiceEntry?.ornamentContainer,
     }
     datas.push(data)
   }
@@ -230,7 +228,7 @@ const cancelTheEvaluation = () => {
 
 const stopPlay = (show: boolean = true) => {
   console.log('调用stopPlay')
-  if (show){
+  if (show) {
     // Toast({
     //   duration: 0,
     //   message: '评分中...',
@@ -441,19 +439,23 @@ const canSubmit = ref(false)
 const setUnitReuslt = () => {
   // 评测结束,如果是单元测验
   const search = useOriginSearch()
-  if (search.unitId){
+  if (search.unitId) {
     postMessage({
       api: 'setCache',
-      content:{
+      content: {
         key: 'h5-orchestra-unit',
-        value: (endResult.value as any)?.score || 0
-      }
+        value: JSON.stringify({
+          musicId: search.id || '',
+          unitId: search.unitId || '',
+          score: (endResult.value as any)?.score || 0,
+        }),
+      },
     })
   }
 }
 
 const sendResult = (evt?: IPostMessage) => {
-  console.log('评测返回',evt?.content)
+  console.log('评测返回', evt?.content)
   if (evt?.content) {
     const data = evt?.content?.body
     if (evt?.content.header.commond === 'overall') {
@@ -507,7 +509,11 @@ const sendResult = (evt?: IPostMessage) => {
             for (const item of time.noteElement.tie.notes) {
               const note = getParentNote(item)
               if (!note) continue
-              setEvaluatings(note, data, item.NoteToGraphicalNoteObjectId !== time.noteElement.tie.StartNote?.NoteToGraphicalNoteObjectId)
+              setEvaluatings(
+                note,
+                data,
+                item.NoteToGraphicalNoteObjectId !== time.noteElement.tie.StartNote?.NoteToGraphicalNoteObjectId
+              )
             }
           }
           break
@@ -572,7 +578,7 @@ export default defineComponent({
       evaluating,
       connentLoading,
       playStatus,
-      cancelTheEvaluation
+      cancelTheEvaluation,
     })
 
     return () => {