mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-05 23:47:43 +08:00
✨ Feature: picture upload support webdav now
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@
|
|||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
"mitt": "^3.0.0",
|
"mitt": "^3.0.0",
|
||||||
"nodejs-file-downloader": "^4.10.6",
|
"nodejs-file-downloader": "^4.10.6",
|
||||||
"piclist": "^0.0.8",
|
"piclist": "^0.0.9",
|
||||||
"pinia": "^2.0.32",
|
"pinia": "^2.0.32",
|
||||||
"pinia-plugin-persistedstate": "^3.1.0",
|
"pinia-plugin-persistedstate": "^3.1.0",
|
||||||
"qiniu": "^7.8.0",
|
"qiniu": "^7.8.0",
|
||||||
|
|||||||
+2
-1
@@ -38,7 +38,8 @@ app.config.globalProperties.$builtInPicBed = [
|
|||||||
'tcyun',
|
'tcyun',
|
||||||
'upyun',
|
'upyun',
|
||||||
'aliyun',
|
'aliyun',
|
||||||
'github'
|
'github',
|
||||||
|
'webdavplist'
|
||||||
]
|
]
|
||||||
app.config.unwrapInjectedRef = true
|
app.config.unwrapInjectedRef = true
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import ImgurApi from './imgur'
|
|||||||
import GithubApi from './github'
|
import GithubApi from './github'
|
||||||
import UpyunApi from './upyun'
|
import UpyunApi from './upyun'
|
||||||
import AwsS3Api from './awss3'
|
import AwsS3Api from './awss3'
|
||||||
|
import WebdavApi from './webdav'
|
||||||
|
|
||||||
const apiMap: IStringKeyMap = {
|
const apiMap: IStringKeyMap = {
|
||||||
smms: SmmsApi,
|
smms: SmmsApi,
|
||||||
@@ -15,7 +16,8 @@ const apiMap: IStringKeyMap = {
|
|||||||
imgur: ImgurApi,
|
imgur: ImgurApi,
|
||||||
github: GithubApi,
|
github: GithubApi,
|
||||||
upyun: UpyunApi,
|
upyun: UpyunApi,
|
||||||
'aws-s3': AwsS3Api
|
'aws-s3': AwsS3Api,
|
||||||
|
webdavplist: WebdavApi
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ALLApi {
|
export default class ALLApi {
|
||||||
|
|||||||
@@ -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 () => {
|
}).then(async () => {
|
||||||
const file = await $$db.getById(item.id!)
|
const file = await $$db.getById(item.id!)
|
||||||
await $$db.removeById(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 (await getConfig('settings.deleteCloudFile')) {
|
||||||
if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) {
|
if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@@ -10919,10 +10919,10 @@ performance-now@^2.1.0:
|
|||||||
resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||||
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
|
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
|
||||||
|
|
||||||
piclist@^0.0.8:
|
piclist@^0.0.9:
|
||||||
version "0.0.8"
|
version "0.0.9"
|
||||||
resolved "https://registry.npmjs.org/piclist/-/piclist-0.0.8.tgz#99d78cb4f288915b8056849c6d4c718704b2df2f"
|
resolved "https://registry.npmjs.org/piclist/-/piclist-0.0.9.tgz#1c610728480594fc7cfd04d3bde5b542ecc910ee"
|
||||||
integrity sha512-aZVSWoP2A78ZMKoGd3HFQP/+EsCpbUcQ8xcaswu7UB4jSUdlkUWDp/Mp0VmvUcgPSlpFFJR7DEcDJ/Q6HMMcJg==
|
integrity sha512-ZDNP1uQT3JACUG1s1RhRlB35DuZPFuDlDPrv8aBPdVlfAjO9nuY7ICEZ3qj8AHPQb7R98R8fSJZq8juYMqXPzw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@picgo/i18n" "^1.0.0"
|
"@picgo/i18n" "^1.0.0"
|
||||||
"@picgo/store" "^2.0.4"
|
"@picgo/store" "^2.0.4"
|
||||||
|
|||||||
Reference in New Issue
Block a user