mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-17 06:47:37 +08:00
✨ Feature: picture upload support webdav now
This commit is contained in:
@@ -38,7 +38,8 @@ app.config.globalProperties.$builtInPicBed = [
|
||||
'tcyun',
|
||||
'upyun',
|
||||
'aliyun',
|
||||
'github'
|
||||
'github',
|
||||
'webdavplist'
|
||||
]
|
||||
app.config.unwrapInjectedRef = true
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import ImgurApi from './imgur'
|
||||
import GithubApi from './github'
|
||||
import UpyunApi from './upyun'
|
||||
import AwsS3Api from './awss3'
|
||||
import WebdavApi from './webdav'
|
||||
|
||||
const apiMap: IStringKeyMap = {
|
||||
smms: SmmsApi,
|
||||
@@ -15,7 +16,8 @@ const apiMap: IStringKeyMap = {
|
||||
imgur: ImgurApi,
|
||||
github: GithubApi,
|
||||
upyun: UpyunApi,
|
||||
'aws-s3': AwsS3Api
|
||||
'aws-s3': AwsS3Api,
|
||||
webdavplist: WebdavApi
|
||||
}
|
||||
|
||||
export default class ALLApi {
|
||||
|
||||
28
src/renderer/apis/webdav.ts
Normal file
28
src/renderer/apis/webdav.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { createClient } from 'webdav'
|
||||
import { formatEndpoint } from '~/main/manage/utils/common'
|
||||
|
||||
export default class WebdavApi {
|
||||
static async delete (configMap: IStringKeyMap): Promise<boolean> {
|
||||
const { fileName, config: { host, username, password, path, sslEnabled } } = configMap
|
||||
const endpoint = formatEndpoint(host, sslEnabled)
|
||||
const ctx = createClient(
|
||||
endpoint,
|
||||
{
|
||||
username,
|
||||
password
|
||||
}
|
||||
)
|
||||
let key
|
||||
if (path === '/' || !path) {
|
||||
key = fileName
|
||||
} else {
|
||||
key = `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
|
||||
}
|
||||
try {
|
||||
await ctx.deleteFile(key)
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,7 +425,7 @@ function remove (item: ImgInfo) {
|
||||
}).then(async () => {
|
||||
const file = await $$db.getById(item.id!)
|
||||
await $$db.removeById(item.id!)
|
||||
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3']
|
||||
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist']
|
||||
if (await getConfig('settings.deleteCloudFile')) {
|
||||
if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) {
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user