🚧 WIP: sftp manage

This commit is contained in:
萌萌哒赫萝
2023-08-19 21:06:28 -07:00
parent 1629dcaef0
commit e89b3ca6d1
7 changed files with 493 additions and 16 deletions

View File

@@ -497,7 +497,7 @@ https://www.baidu.com/img/bd_logo1.png"
shadow="hover"
>
<el-image
v-if="!item.isDir && currentPicBedName !== 'webdavplist'"
v-if="!item.isDir && currentPicBedName !== 'webdavplist' && currentPicBedName !== 'sftp'"
:src="isShowThumbnail && item.isImage ?
item.url
: require(`./assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
@@ -519,13 +519,20 @@ https://www.baidu.com/img/bd_logo1.png"
</template>
</el-image>
<ImageWebdav
v-else-if="!item.isDir && currentPicBedName === 'webdavplist'"
v-else-if="!item.isDir && currentPicBedName === 'webdavplist' && item.isImage"
:is-show-thumbnail="isShowThumbnail"
:item="item"
:headers="getBase64ofWebdav()"
:url="item.url"
@click="handleClickFile(item)"
/>
<el-image
v-else-if="!item.isDir"
:src="require(`./assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
fit="contain"
style="height: 100px;width: 100%;margin: 0 auto;"
@click="handleClickFile(item)"
/>
<el-image
v-else
:src="require('./assets/icons/folder.webp')"
@@ -1578,7 +1585,7 @@ const lastChoosed = ref<number>(-1)
const customDomainList = ref([] as any[])
const currentCustomDomain = ref('')
const isShowCustomDomainSelectList = computed(() => ['tcyun', 'aliyun', 'qiniu', 'github'].includes(currentPicBedName.value))
const isShowCustomDomainInput = computed(() => ['aliyun', 'qiniu', 'tcyun', 's3plist', 'webdavplist', 'local'].includes(currentPicBedName.value))
const isShowCustomDomainInput = computed(() => ['aliyun', 'qiniu', 'tcyun', 's3plist', 'webdavplist', 'local', 'sftp'].includes(currentPicBedName.value))
const isAutoCustomDomain = computed(() => manageStore.config.picBed[configMap.alias].isAutoCustomUrl === undefined ? true : manageStore.config.picBed[configMap.alias].isAutoCustomUrl)
// 文件预览相关
const isShowMarkDownDialog = ref(false)
@@ -1589,7 +1596,7 @@ const isShowVideoFileDialog = ref(false)
const videoFileUrl = ref('')
const videoPlayerHeaders = ref({})
// 重命名相关
const isShowRenameFileIcon = computed(() => ['tcyun', 'aliyun', 'qiniu', 'upyun', 's3plist', 'webdavplist', 'local'].includes(currentPicBedName.value))
const isShowRenameFileIcon = computed(() => ['tcyun', 'aliyun', 'qiniu', 'upyun', 's3plist', 'webdavplist', 'local', 'sftp'].includes(currentPicBedName.value))
const isShowBatchRenameDialog = ref(false)
const batchRenameMatch = ref('')
const batchRenameReplace = ref('')
@@ -1607,9 +1614,9 @@ const isAutoRefresh = computed(() => manageStore.config.settings.isAutoRefresh ?
const isIgnoreCase = computed(() => manageStore.config.settings.isIgnoreCase ?? false)
// 新建文件夹相关
const isShowCreateNewFolder = computed(() => ['aliyun', 'github', 'local', 'qiniu', 'tcyun', 's3plist', 'upyun', 'webdavplist'].includes(currentPicBedName.value))
const isShowCreateNewFolder = computed(() => ['aliyun', 'github', 'local', 'qiniu', 'tcyun', 's3plist', 'upyun', 'webdavplist', 'sftp'].includes(currentPicBedName.value))
const isShowPresignedUrl = computed(() => ['aliyun', 'github', 'qiniu', 's3plist', 'tcyun', 'webdavplist'].includes(currentPicBedName.value))
const isShowPresignedUrl = computed(() => ['aliyun', 'github', 'qiniu', 's3plist', 'tcyun', 'webdavplist', 'sftp'].includes(currentPicBedName.value))
// 上传相关函数
@@ -2000,7 +2007,7 @@ async function handleChangeCustomUrl () {
isShowLoadingPage.value = true
await resetParam(true)
isShowLoadingPage.value = false
} else if (['aliyun', 'tcyun', 'qiniu', 's3plist', 'webdavplist'].includes(currentPicBedName.value)) {
} else if (['aliyun', 'tcyun', 'qiniu', 's3plist', 'webdavplist', 'local', 'sftp'].includes(currentPicBedName.value)) {
const currentConfigs = await getConfig<any>('picBed')
const currentConfig = currentConfigs[configMap.alias]
const currentTransformedConfig = JSON.parse(currentConfig.transformedConfig ?? '{}')
@@ -2105,7 +2112,7 @@ async function initCustomDomainList () {
currentCustomDomain.value = endpoint
}
handleChangeCustomUrl()
} else if (currentPicBedName.value === 'local') {
} else if (currentPicBedName.value === 'local' || currentPicBedName.value === 'sftp') {
const currentConfigs = await getConfig<any>('picBed')
const currentConfig = currentConfigs[configMap.alias]
const currentTransformedConfig = JSON.parse(currentConfig.transformedConfig ?? '{}')
@@ -2799,7 +2806,8 @@ async function getBucketFileListBackStage () {
const fileTransferStore = useFileTransferStore()
fileTransferStore.resetFileTransferList()
if (currentPicBedName.value === 'webdavplist' ||
currentPicBedName.value === 'local') {
currentPicBedName.value === 'local' ||
currentPicBedName.value === 'sftp') {
param.baseDir = configMap.baseDir
param.webPath = configMap.webPath
}

View File

@@ -730,7 +730,14 @@ async function transUpToManage (config: IUploaderConfigListItem, picBedName: str
...commonConfig,
baseDir: config.path,
webPath: config.webpath || '',
customUrl: config.customUrl || ''
customUrl: config.customUrl || '',
transformedConfig: JSON.stringify({
local: {
customUrl: config.customUrl || '',
baseDir: config.path,
webPath: config.webpath || ''
}
})
})
delete resultMap.paging
break
@@ -749,7 +756,22 @@ async function transUpToManage (config: IUploaderConfigListItem, picBedName: str
webPath: config.webPath || '',
customUrl: config.customUrl || '',
fileMode: config.fileMode || '0664',
dirMode: config.dirMode || '0775'
dirMode: config.dirMode || '0775',
transformedConfig: JSON.stringify({
sftp: {
host: config.host,
port: config.port || 22,
username: config.username,
password: config.password,
privateKey: config.privateKey,
passphrase: config.passphrase,
baseDir: config.uploadPath || '/',
webPath: config.webPath || '',
customUrl: config.customUrl || '',
fileMode: config.fileMode || '0664',
dirMode: config.dirMode || '0775'
}
})
})
delete resultMap.paging
break

View File

@@ -27,19 +27,19 @@ export class FileCacheDb extends Dexie {
qiniu: Table<IFileCache, string>
smms: Table<IFileCache, string>
s3plist: Table<IFileCache, string>
sftpplist: Table<IFileCache, string>
sftp: Table<IFileCache, string>
upyun: Table<IFileCache, string>
webdavplist: Table<IFileCache, string>
constructor () {
super('bucketFileDb')
const tableNames = ['aliyun', 'github', 'imgur', 'local', 'qiniu', 's3plist', 'sftpplist', 'smms', 'tcyun', 'upyun', 'webdavplist']
const tableNames = ['aliyun', 'github', 'imgur', 'local', 'qiniu', 's3plist', 'sftp', 'smms', 'tcyun', 'upyun', 'webdavplist']
const tableNamesMap = tableNames.reduce((acc, cur) => {
acc[cur] = '&key, value'
return acc
}, {} as IStringKeyMap)
this.version(4).stores(tableNamesMap)
this.version(5).stores(tableNamesMap)
this.aliyun = this.table('aliyun')
this.github = this.table('github')
this.imgur = this.table('imgur')
@@ -47,7 +47,7 @@ export class FileCacheDb extends Dexie {
this.qiniu = this.table('qiniu')
this.tcyun = this.table('tcyun')
this.s3plist = this.table('s3plist')
this.sftpplist = this.table('sftpplist')
this.sftp = this.table('sftp')
this.smms = this.table('smms')
this.upyun = this.table('upyun')
this.webdavplist = this.table('webdavplist')