import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
import '@/utils/headers-polyfill.js'
import { PropsWithChildren } from 'react'
import { useLaunch } from '@tarojs/taro'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { AuthProvider } from './utils/auth'
import { CartProvider } from './contexts/CartContext'

import './app.css'

// 创建新的 QueryClient 实例
const queryClient = new QueryClient()

function App({ children }: PropsWithChildren<any>) {
  useLaunch(() => {
    console.log('App launched.')
  })

  // children 是将要会渲染的页面
  return (
    <QueryClientProvider client={queryClient}>
      <AuthProvider>
        <CartProvider>{children}</CartProvider>
      </AuthProvider>
    </QueryClientProvider>
  )
}

export default App
