🐛 Fix(custom): fix alist delete bugs when used in api

ISSUES CLOSED: #337
This commit is contained in:
Kuingsmile
2025-06-15 12:05:48 +08:00
parent 73810b8bd8
commit 4ac24c8ef8

View File

@@ -1,7 +1,6 @@
import axios from 'axios' import axios from 'axios'
import path from 'path' import path from 'path'
import { getConfig, saveConfig } from '@/utils/dataSender'
import { deleteFailedLog, deleteLog } from '#/utils/deleteLog' import { deleteFailedLog, deleteLog } from '#/utils/deleteLog'
interface IConfigMap { interface IConfigMap {
@@ -16,23 +15,12 @@ interface IConfigMap {
} }
const getAListToken = async (url: string, username: string, password: string) => { const getAListToken = async (url: string, username: string, password: string) => {
const tokenStore = await getConfig<IStringKeyMap>('picgo-plugin-buildin-alistplist')
if (tokenStore && tokenStore.refreshedAt && Date.now() - tokenStore.refreshedAt < 3600000 && tokenStore.token) {
return tokenStore.token
}
const res = await axios.post(`${url}/api/auth/login`, { const res = await axios.post(`${url}/api/auth/login`, {
username, username,
password password
}) })
if (res.data.code === 200 && res.data.message === 'success') { if (res.data.code === 200 && res.data.message === 'success') {
const token = res.data.data.token return res.data.data.token
saveConfig({
'picgo-plugin-buildin-alistplist': {
token,
refreshedAt: Date.now()
}
})
return token
} }
} }