|
|
@@ -10,15 +10,11 @@ import { receiveCoupon } from '@/utils/coupon-api'
|
|
|
import { Navbar } from '@/components/ui/navbar'
|
|
|
import { TabBarLayout } from '@/layouts/tab-bar-layout'
|
|
|
import { useAuth } from '@/utils/auth'
|
|
|
+import type { InferResponseType } from 'hono/client'
|
|
|
|
|
|
-interface Advertisement {
|
|
|
- id: number
|
|
|
- title: string
|
|
|
- imageUrl: string
|
|
|
- linkUrl: string
|
|
|
- description: string
|
|
|
- sortOrder: number
|
|
|
-}
|
|
|
+// 使用RPC类型安全提取广告响应类型
|
|
|
+type AdvertisementResponse = InferResponseType<typeof publicAdvertisementClient.$get, 200>
|
|
|
+type Advertisement = AdvertisementResponse['data'][0]
|
|
|
|
|
|
interface WechatCouponStock {
|
|
|
id: number
|
|
|
@@ -51,7 +47,7 @@ export default function IndexPage() {
|
|
|
})
|
|
|
if (response.status !== 200) throw new Error('获取广告失败')
|
|
|
const result = await response.json()
|
|
|
- return result.data as Advertisement[]
|
|
|
+ return result.data
|
|
|
},
|
|
|
})
|
|
|
|