/** 前台直播弹幕账号（localStorage，与后台管理 JWT 无关） */
const TOKEN_KEY = 'yh_site_dm_token'
const USER_KEY = 'yh_site_dm_username'

export function getSiteDmToken() {
  try {
    return localStorage.getItem(TOKEN_KEY) || ''
  } catch {
    return ''
  }
}

export function getSiteDmUsername() {
  try {
    return localStorage.getItem(USER_KEY) || ''
  } catch {
    return ''
  }
}

export function setSiteDmSession(token, username) {
  try {
    if (token) localStorage.setItem(TOKEN_KEY, token)
    else localStorage.removeItem(TOKEN_KEY)
    if (username) localStorage.setItem(USER_KEY, username)
    else localStorage.removeItem(USER_KEY)
  } catch (_) {}
}

export function clearSiteDmSession() {
  try {
    localStorage.removeItem(TOKEN_KEY)
    localStorage.removeItem(USER_KEY)
  } catch (_) {}
}
