// 搜索关键字
export const SubjectEnum = {
  SEARCH: 'music-songbook-subject',
  // ALBUM: 'music-album-subject',
  // MUSIC: 'music-subject',
  // LIVE: 'live-subject',
  VIDEO: 'video-subject'
  // ELEGANT: 'elegant-subject'
}
/**
 * 获取声部编号 | 保存声部编号
 */
export const useSubjectId = (
  key: string,
  value?: any,
  type = 'get' as 'get' | 'set'
) => {
  // 判断是否在关键字
  // console.log(key, value, type)
  if (!key) return ''
  if (type === 'get') {
    let subject = localStorage.getItem(key)
    subject = subject ? JSON.parse(subject) : { name: '', id: '' }
    return subject
  } else {
    localStorage.setItem(key, value)
    return ''
  }
}

export const useSubjectClearly = (key?: string) => {
  if (key) {
    localStorage.removeItem(key)
  } else {
    localStorage.removeItem(SubjectEnum.SEARCH)
    localStorage.removeItem(SubjectEnum.VIDEO)
  }
}
