Browse Source

完善CMS视频列表高级查询

main
dark 5 months ago
parent
commit
abc0bbf182
  1. 2
      src/pages/cms/video_cloud/index.tsx
  2. 11
      src/store/cms/video_cloud.ts
  3. 11
      src/store/cms/video_magnet.ts
  4. 7
      src/utils/index.ts

2
src/pages/cms/video_cloud/index.tsx

@ -647,7 +647,7 @@ const VideoCloud = () => {
onSearch: (value: string) => {
setSearch(prev => ({
...prev,
key: value
title: value
}))
},
onChange: (e) => {

11
src/store/cms/video_cloud.ts

@ -30,7 +30,16 @@ export const videoCloudsAtom = atomWithQuery((get) => {
return {
queryKey: [ 'videoClouds', get(videoCloudSearchAtom) ],
queryFn: async ({ queryKey: [ , params ] }) => {
return await cmsServ.videoCloud.list(params as SearchParams)
const p = {} as SearchParams
Object.keys(params as any).forEach(key=>{
const value =(params as any)[key]
if (Array.isArray(value)) {
p[key] = value.join(',')
} else {
p[key] = value
}
})
return await cmsServ.videoCloud.list(p)
},
select: res => {
const data = res.data

11
src/store/cms/video_magnet.ts

@ -30,7 +30,16 @@ export const videoMagnetsAtom = atomWithQuery((get) => {
return {
queryKey: [ 'videoMagnets', get(videoMagnetSearchAtom) ],
queryFn: async ({ queryKey: [ , params ] }) => {
return await cmsServ.videoMagnet.list(params as SearchParams)
const p = {} as SearchParams
Object.keys(params as any).forEach(key=>{
const value =(params as any)[key]
if (Array.isArray(value)) {
p[key] = value.join(',')
} else {
p[key] = value
}
})
return await cmsServ.videoMagnet.list(p)
},
select: res => {
const data = res.data

7
src/utils/index.ts

@ -135,9 +135,14 @@ export const getValueCount = (obj: any, filterObj: any = {}) => {
let count = 0
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key) && obj[key]) {
if (!filterObj?.[key])
//如果是数组,则必须长度大于0
if (!filterObj?.[key]) {
if (Array.isArray(obj[key]) && obj[key].length === 0) {
continue
}
count++
}
}
}
return count
}
Loading…
Cancel
Save