refactor(types): add TypeScript type assertion for channel API response
All checks were successful
Admin CI / build-and-push-web (push) Successful in 4m53s

Add explicit type casting to handle potential channel data response formats, improving type safety and IDE autocomplete for Channel data structures.
This commit is contained in:
lafay
2026-04-04 00:43:09 +08:00
parent bfb018b766
commit 00b79681a0

View File

@@ -55,7 +55,7 @@ export default function Channels() {
setLoading(true)
try {
const response = await channelsApi.getChannels()
const data = response.data.data
const data = response.data.data as Channel[] | { list: Channel[] } | undefined
const list = Array.isArray(data) ? data : (data?.list || [])
list.sort((a: Channel, b: Channel) => a.sort_order - b.sort_order)
setChannels(list)