// 从url获取配置进行一些设置

import { ref } from 'vue'
import { useOriginSearch } from './use-query'
import runtime, * as RuntimeUtils from '/src/pages/detail/runtime'
import detailState from '/src/pages/detail/state'
import SettingState from '/src/pages/detail/setting-state'

export const useActivity = () => {
  const showFingering = ref(true)
  const frozenMode = ref(false)
  const compulsionEvaluating = ref(false)
  try {
    const search = useOriginSearch()
    const setting = (search.setting || {}) as any
    if (setting.mode === 'EVALUATING') {
      compulsionEvaluating.value = true
      showFingering.value = false
      frozenMode.value = true
    }
    if (setting.difficulty) {
      SettingState.eva.difficulty = setting.difficulty
    }
    detailState.setting = setting
  } catch (error) {
    console.error('设置活动配置失败，请检查传入配置是否正确')
    console.error(error)
  }
  return {
    showFingering,
    frozenMode,
    compulsionEvaluating,
  }
}
