import { reactive } from 'vue'
import { postMessage } from './native-message'
import request from './request'

// 搜索关键字
export const SubjectEnum = {
  SEARCH: 'music-songbook-subject',
  ALBUM: 'music-album-subject',
  MUSIC: 'music-subject',
  LIVE: 'live-subject',
  VIDEO: 'video-subject',
  ELEGANT: 'elegant-subject',
  MUSIC_FREE: 'music-list-free'
}
/**
 * 获取声部编号 | 保存声部编号
 */
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 ''
  }
}