2024-05-24 10:27:45 -04:00
|
|
|
import { deleteFailedLog, deleteLog } from '@/utils/common'
|
2023-10-10 11:54:46 -04:00
|
|
|
import axios, { AxiosResponse } from 'axios'
|
|
|
|
|
|
|
|
export default class PiclistApi {
|
|
|
|
static async delete (configMap: IStringKeyMap): Promise<boolean> {
|
|
|
|
const { config, fullResult } = configMap
|
|
|
|
const { host, port } = config
|
|
|
|
if (!host) {
|
2024-05-24 10:27:45 -04:00
|
|
|
deleteLog(fullResult, 'Piclist', false, 'PiclistApi.delete: invalid params')
|
2023-10-10 11:54:46 -04:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
const url = `http://${host || '127.0.0.1'}:${port || 36677}/delete`
|
|
|
|
|
|
|
|
try {
|
|
|
|
const response: AxiosResponse = await axios.post(
|
|
|
|
url,
|
|
|
|
{
|
|
|
|
list: [fullResult]
|
|
|
|
}
|
|
|
|
)
|
2024-05-24 10:27:45 -04:00
|
|
|
if (response.status === 200 && response.data?.success) {
|
|
|
|
deleteLog(fullResult, 'Piclist')
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
deleteLog(fullResult, 'Piclist', false)
|
|
|
|
return false
|
|
|
|
} catch (error: any) {
|
|
|
|
deleteFailedLog(fullResult, 'Piclist', error)
|
2023-10-10 11:54:46 -04:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|