2020-04-10 11:28:46 -04:00
|
|
|
import picgo from '@core/picgo'
|
2018-12-23 10:15:00 -05:00
|
|
|
|
2019-12-26 07:15:41 -05:00
|
|
|
const getPicBeds = () => {
|
2018-12-23 10:15:00 -05:00
|
|
|
const picBedTypes = picgo.helper.uploader.getIdList()
|
2020-06-28 03:28:44 -04:00
|
|
|
const picBedFromDB = picgo.getConfig<IPicBedType[]>('picBed.list') || []
|
2019-12-19 06:17:21 -05:00
|
|
|
const picBeds = picBedTypes.map((item: string) => {
|
2019-12-21 04:28:29 -05:00
|
|
|
const visible = picBedFromDB.find((i: IPicBedType) => i.type === item) // object or undefined
|
2018-12-23 10:15:00 -05:00
|
|
|
return {
|
|
|
|
type: item,
|
2020-06-28 03:28:44 -04:00
|
|
|
name: picgo.helper.uploader.get(item)!.name || item,
|
2018-12-23 10:15:00 -05:00
|
|
|
visible: visible ? visible.visible : true
|
|
|
|
}
|
2019-12-21 04:28:29 -05:00
|
|
|
}) as IPicBedType[]
|
2018-12-23 10:15:00 -05:00
|
|
|
return picBeds
|
|
|
|
}
|
|
|
|
|
2020-01-08 06:26:25 -05:00
|
|
|
export default getPicBeds
|