let applyInfo = null

/**
 * 设置申请资料缓存
 * @param {Object} applyInfo - 申请资料
 */
export function setApplyInfo(data) {
  applyInfo = data

  // 可选：存储到localStorage以便持久化
  if (data) {
    localStorage.setItem('applyInfo', JSON.stringify(data))
  } else {
    localStorage.removeItem('applyInfo')
  }
}

/**
 * 获取申请资料
 * @returns {Object|null}
 */
export function getApplyInfo() {
  if (applyInfo) {
    return applyInfo
  }

  // 从localStorage恢复
  const stored = localStorage.getItem('applyInfo')
  if (stored) {
    try {
      applyInfo = JSON.parse(stored)
      return applyInfo
    } catch (error) {
      console.error('解析申请资料缓存失败:', error)
    }
  }

  return null
}
