PicList/src/main/utils/getPicBeds.ts
Molunerfinn 3418560c63 🔨 Refactor: most config handle by picgo-core
for config syncing with picgo-core && picgo-plugins
2019-12-26 20:15:41 +08:00

22 lines
594 B
TypeScript

import db from '#/datastore'
import picgo from './picgo'
const getPicBeds = () => {
const picBedTypes = picgo.helper.uploader.getIdList()
const picBedFromDB = db.get('picBed.list') || []
const picBeds = picBedTypes.map((item: string) => {
const visible = picBedFromDB.find((i: IPicBedType) => i.type === item) // object or undefined
return {
type: item,
name: picgo.helper.uploader.get(item).name || item,
visible: visible ? visible.visible : true
}
}) as IPicBedType[]
picgo.cmd.program.removeAllListeners()
return picBeds
}
export {
getPicBeds
}