Skip to content

Commit e4c4a6f

Browse files
committed
✨ Feature(custom): optimize upload api
1 parent ec92be8 commit e4c4a6f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/server/routerManager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ router.post('/upload', async ({
4646
urlparams?: URLSearchParams
4747
}): Promise<void> => {
4848
try {
49+
const picbed = urlparams?.get('picbed')
4950
const passedKey = urlparams?.get('key')
5051
const serverKey = picgo.getConfig<string>(configPaths.settings.serverKey) || ''
5152
if (serverKey && passedKey !== serverKey) {
@@ -58,17 +59,16 @@ router.post('/upload', async ({
5859
})
5960
return
6061
}
61-
const picbed = urlparams?.get('picbed')
6262
let currentPicBedType = ''
6363
let currentPicBedConfig = {} as IStringKeyMap
6464
let currentPicBedConfigId = ''
6565
let needRestore = false
6666
if (picbed) {
67-
const configName = urlparams?.get('configName') || 'Default'
6867
const currentPicBed = picgo.getConfig<IStringKeyMap>('picBed') || {} as IStringKeyMap
69-
currentPicBedType = currentPicBed?.current
70-
currentPicBedConfig = currentPicBed?.[currentPicBedType]
71-
currentPicBedConfigId = currentPicBedConfig?._id
68+
currentPicBedType = currentPicBed.current || ''
69+
currentPicBedConfig = currentPicBed[currentPicBedType] || {} as IStringKeyMap
70+
currentPicBedConfigId = currentPicBedConfig._id
71+
const configName = urlparams?.get('configName') || currentPicBed[picbed]?._configName
7272
if (picbed === currentPicBedType && configName === currentPicBedConfig._configName) {
7373
// do nothing
7474
} else {

0 commit comments

Comments
 (0)