fix: type problems

This commit is contained in:
IchliebedichZhu 2024-09-25 12:32:01 +08:00
parent 5f37f0e4b0
commit 2cdf950844
3 changed files with 7 additions and 4 deletions

View File

@ -96,7 +96,7 @@ type TGetCompListParam = {
search?: string
page?: number
type?: number
pageSize: number
pageSize?: number
cate?: number | string
}
@ -109,6 +109,7 @@ export type TGetCompListResult = {
title: string
width: number
name?: string
cate?: string
}
type getCompListReturn = TPageRequestResult<TGetCompListResult[]>

View File

@ -55,7 +55,7 @@ type TState = {
list: TGetCompListResult[]
searchValue: string
currentCategory: TGetCompListResult | null
types: []
types: {cate: string, name: string}[]
showList: TGetCompListResult[][]
}
@ -129,7 +129,7 @@ const load = async (init: boolean = false) => {
const res = await api.home.getCompList({
...pageOptions,
cate: state.currentCategory?.id,
cate: state.currentCategory?.id || state.currentCategory?.cate,
})
if (init) {
state.list = res?.list

View File

@ -72,6 +72,7 @@ type TState = {
type TCurrentCategory = {
name: string
cate?: string | number
id?: number
}
@ -149,7 +150,7 @@ const load = async (init: boolean = false) => {
state.loading = true
pageOptions.page += 1
const list = await api.material.getList({
...{ cate: state.currentCategory?.id, search: state.searchKeyword, ...pageOptions },
...{ cate: state.currentCategory?.id || state.currentCategory?.cate, search: state.searchKeyword, ...pageOptions },
})
if (init) {
state.list = list?.list
@ -168,6 +169,7 @@ const searchChange = (_: Event) => {
}
const selectTypes = (item: TCurrentCategory) => {
console.log(item)
state.currentCategory = item
load(true)
}