import { defineNuxtPlugin } from '#imports'

export default defineNuxtPlugin(() => {
  // 只在客户端执行
  if (typeof window !== 'undefined') {
    // 从服务端渲染的HTML中获取静态数据
    const staticDataScript = document.getElementById('__NUXT_STATIC_DATA__')
    if (staticDataScript) {
      try {
        const data = JSON.parse(staticDataScript.textContent)
        window.__NUXT_STATIC_DATA__ = data
      } catch (error) {
        console.warn('解析静态数据失败:', error)
      }
    }
  }
})
