// 测试数据存储
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { useDataStore } from './stores/data.js'

// 创建应用和Pinia实例
const app = createApp({})
const pinia = createPinia()
app.use(pinia)

// 测试数据存储
async function testDataStore() {
  console.log('=== 开始测试数据存储 ===')
  
  const dataStore = useDataStore()
  
  console.log('初始设备数量:', dataStore.devices.length)
  
  try {
    console.log('开始获取设备数据...')
    await dataStore.fetchDevices()
    
    console.log('获取完成，设备数量:', dataStore.devices.length)
    console.log('前3个设备:', dataStore.devices.slice(0, 3))
    
    // 统计状态
    const statusCount = {}
    dataStore.devices.forEach(device => {
      statusCount[device.status] = (statusCount[device.status] || 0) + 1
    })
    console.log('状态分布:', statusCount)
    
  } catch (error) {
    console.error('测试失败:', error)
  }
  
  console.log('=== 测试完成 ===')
}

// 运行测试
testDataStore()