Feature: picbeds config can be reseted to empty now

This commit is contained in:
萌萌哒赫萝
2023-03-24 13:32:16 +08:00
parent f0daf97028
commit 086b2871e7
9 changed files with 72 additions and 8 deletions

View File

@@ -167,3 +167,23 @@ export const updateUploaderConfig = (type: string, id: string, config: IStringKe
[`picBed.${type}`]: updatedConfig
})
}
/**
* Reset selected congfig id to default
*/
export const resetUploaderConfig = (type: string, id: string) => {
const { configList } = getUploaderConfigList(type)
configList.forEach((item: IStringKeyMap) => {
if (item._id === id) {
Object.keys(item).forEach(key => {
if (!['_configName', '_id', '_createdAt', '_updatedAt'].includes(key)) {
delete item[key]
}
})
}
})
picgo.saveConfig({
[`uploader.${type}.configList`]: configList
})
}