PicList/src/main/utils/getPicBeds.ts

23 lines
639 B
TypeScript
Raw Normal View History

import picgo from '@core/picgo'
2018-12-23 10:15:00 -05:00
const getPicBeds = () => {
2018-12-23 10:15:00 -05:00
const picBedTypes = picgo.helper.uploader.getIdList()
const picBedFromDB = picgo.getConfig<IPicBedType[]>('picBed.list') || []
2019-12-19 06:17:21 -05:00
const picBeds = picBedTypes.map((item: string) => {
const visible = picBedFromDB.find((i: IPicBedType) => i.type === item) // object or undefined
2018-12-23 10:15:00 -05:00
return {
type: item,
name: picgo.helper.uploader.get(item)!.name || item,
2018-12-23 10:15:00 -05:00
visible: visible ? visible.visible : true
}
}).sort((a) => {
if (a.type === 'tcyun') {
return -1
}
return 0
}) as IPicBedType[]
2018-12-23 10:15:00 -05:00
return picBeds
}
export default getPicBeds