Browse Source

✨ feat(app): 添加全局状态管理和数据请求支持

- 重命名app.ts为app.tsx以支持JSX语法
- 引入QueryClientProvider提供全局数据请求管理
- 添加AuthProvider实现全局认证状态管理
- 调整应用根组件结构,嵌套Provider组件包裹页面内容
yourname 4 months ago
parent
commit
da9ab8c43e
1 changed files with 7 additions and 3 deletions
  1. 7 3
      mini/src/app.tsx

+ 7 - 3
mini/src/app.ts → mini/src/app.tsx

@@ -1,5 +1,7 @@
 import { PropsWithChildren } from 'react'
 import { useLaunch } from '@tarojs/taro'
+import { QueryClientProvider } from '@tanstack/react-query'
+import { AuthProvider, queryClient } from './utils/auth'
 
 import './app.css'
 
@@ -9,9 +11,11 @@ function App({ children }: PropsWithChildren<any>) {
   })
 
   // children 是将要会渲染的页面
-  return children
+  return (
+    <QueryClientProvider client={queryClient}>
+      <AuthProvider>{children}</AuthProvider>
+    </QueryClientProvider>
+  )
 }
-  
-
 
 export default App