新增: 云OSS存储集成(七牛云+阿里云)+多桶导航+GBK编码自动转换
This commit is contained in:
@@ -9,6 +9,7 @@ import { normalizeFilePath, getExt } from '@/utils/fileUtils'
|
||||
import { detectFileTypeByContent } from '@/api/system'
|
||||
import { connectionManager } from '@/api/connection-manager'
|
||||
import { SftpTransport } from '@/api/sftp-transport'
|
||||
import { OssTransport } from '@/api/oss-transport'
|
||||
import { getFileServerBaseURL } from '@/api/file-server'
|
||||
import {
|
||||
isImageFile, isVideoFile, isAudioFile, isPdfFile,
|
||||
@@ -106,22 +107,25 @@ export function useFilePreview(options: UseFilePreviewOptions = {}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新预览 URL(SFTP 模式会先下载到本地临时目录)
|
||||
* 更新预览 URL
|
||||
* SFTP/OSS:下载到本地临时目录后用本地文件服务器预览
|
||||
*/
|
||||
const updatePreviewUrl = async (path: string) => {
|
||||
if (!path) { previewUrl.value = ''; return }
|
||||
const transport = connectionManager.getTransport()
|
||||
|
||||
// SFTP 模式:下载到本地临时目录后用本地文件服务器预览
|
||||
if (connectionManager.isSftp()) {
|
||||
const transport = connectionManager.getTransport()
|
||||
if (transport instanceof SftpTransport) {
|
||||
try {
|
||||
const tempPath = await transport.downloadForPreview(path)
|
||||
previewUrl.value = getPreviewUrl(tempPath)
|
||||
return
|
||||
} catch {
|
||||
// 下载失败,回退显示原始路径(会无法预览但不会崩溃)
|
||||
}
|
||||
// SFTP / OSS:下载到本地临时目录后用本地文件服务器预览
|
||||
if (transport instanceof SftpTransport || transport instanceof OssTransport) {
|
||||
try {
|
||||
const tempPath = await transport.downloadForPreview(path)
|
||||
// 临时文件通过本地文件服务器提供,始终用 localfs 路径
|
||||
const base = getLocalServerURL()
|
||||
const normalized = normalizeFilePath(tempPath, true)
|
||||
const sep = base.endsWith('/') ? '' : '/'
|
||||
previewUrl.value = `${base}${sep}localfs/${normalized}`
|
||||
return
|
||||
} catch {
|
||||
// 下载失败,回退
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user