Browse Source

完善CMS视频列表高级查询

main
dark 6 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) => { onSearch: (value: string) => {
setSearch(prev => ({ setSearch(prev => ({
...prev, ...prev,
key: value
title: value
})) }))
}, },
onChange: (e) => { onChange: (e) => {

11
src/store/cms/video_cloud.ts

@ -30,7 +30,16 @@ export const videoCloudsAtom = atomWithQuery((get) => {
return { return {
queryKey: [ 'videoClouds', get(videoCloudSearchAtom) ], queryKey: [ 'videoClouds', get(videoCloudSearchAtom) ],
queryFn: async ({ queryKey: [ , params ] }) => { 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 => { select: res => {
const data = res.data const data = res.data

11
src/store/cms/video_magnet.ts

@ -30,7 +30,16 @@ export const videoMagnetsAtom = atomWithQuery((get) => {
return { return {
queryKey: [ 'videoMagnets', get(videoMagnetSearchAtom) ], queryKey: [ 'videoMagnets', get(videoMagnetSearchAtom) ],
queryFn: async ({ queryKey: [ , params ] }) => { 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 => { select: res => {
const data = res.data const data = res.data

7
src/utils/index.ts

@ -135,8 +135,13 @@ export const getValueCount = (obj: any, filterObj: any = {}) => {
let count = 0 let count = 0
for (const key in obj) { for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key) && obj[key]) { 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++ count++
}
} }
} }
return count return count
Loading…
Cancel
Save