mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-07 05:02:43 +08:00
🐛 Fix(custom): fix alist delete bugs when used in api
ISSUES CLOSED: #337
This commit is contained in:
@@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user