🚧 WIP: working on build-in sftp picbed

This commit is contained in:
萌萌哒赫萝
2023-08-05 04:59:10 -07:00
parent b882d42e10
commit bdc11dad43
12 changed files with 225 additions and 87 deletions

View File

@@ -8,6 +8,7 @@ import UpyunApi from './upyun'
import AwsS3Api from './awss3'
import WebdavApi from './webdav'
import LocalApi from './local'
import SftpPlistApi from './sftpplist'
const apiMap: IStringKeyMap = {
smms: SmmsApi,
@@ -19,7 +20,8 @@ const apiMap: IStringKeyMap = {
upyun: UpyunApi,
'aws-s3': AwsS3Api,
webdavplist: WebdavApi,
local: LocalApi
local: LocalApi,
sftpplist: SftpPlistApi
}
export default class ALLApi {

View File

@@ -0,0 +1,18 @@
import { ipcRenderer } from 'electron'
import { getRawData } from '~/renderer/utils/common'
export default class SftpPlistApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const { fileName, config } = configMap
try {
const deleteResult = await ipcRenderer.invoke('delete-sftp-file',
getRawData(config),
fileName
)
return deleteResult
} catch (error) {
console.error(error)
return false
}
}
}

View File

@@ -664,7 +664,7 @@ function remove (item: ImgInfo) {
type: 'warning'
}).then(async () => {
const file = await $$db.getById(item.id!)
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist', 'local']
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist', 'local', 'sftpplist']
if (await getConfig('settings.deleteCloudFile')) {
if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) {
const result = await ALLApi.delete(item)
@@ -774,7 +774,7 @@ function multiRemove () {
const files: IResult<ImgInfo>[] = []
const imageIDList = Object.keys(choosedList)
const isDeleteCloudFile = await getConfig('settings.deleteCloudFile')
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist', 'local']
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist', 'local', 'sftpplist']
if (isDeleteCloudFile) {
for (let i = 0; i < imageIDList.length; i++) {
const key = imageIDList[i]

View File

@@ -1448,6 +1448,7 @@
</div>
</template>
<script lang="ts" setup>
// @ts-ignore
import { ElForm, ElMessage as $message, ElMessage, ElMessageBox, FormRules } from 'element-plus'
import { Reading, Close, Edit, InfoFilled } from '@element-plus/icons-vue'
import pkg from 'root/package.json'