新增: SFTP直连+网站预览+OSS区域嗅探+热键+BGM播放

This commit is contained in:
lxy
2026-05-12 11:06:28 +08:00
parent 545d7a864d
commit 2a363fd729
62 changed files with 6685 additions and 658 deletions
+9 -23
View File
@@ -9,8 +9,8 @@ import type { ConnectionProfile } from './connection-manager'
import {
OssConnect, OssDisconnect, OssListDir, OssReadFile,
OssWriteFile, OssGetFileInfo, OssCreateDir, OssCreateFile,
OssDeletePath, OssRenamePath, OssDownloadToTemp, OssGetCommonPaths,
OssWriteBase64File, OssGetSignedURL,
OssDeletePath, OssRenamePath, OssDownloadToTemp, OssDownloadSiteForPreview,
OssGetCommonPaths, OssWriteBase64File, OssGetSignedURL,
} from '@bindings/u-desk/app'
function transformFile(file: any): FileItem {
@@ -21,13 +21,9 @@ function transformFileList(files: any[]): FileItem[] {
return files.map(transformFile)
}
const PREVIEW_CACHE_MAX = 50
export class OssTransport implements FsTransport {
private profile: ConnectionProfile
private connID: string | null = null
private previewCache = new Map<string, string>()
private previewOrder: string[] = []
constructor(profile: ConnectionProfile) {
this.profile = profile
@@ -35,7 +31,7 @@ export class OssTransport implements FsTransport {
async connect(): Promise<string> {
const result = await OssConnect({
provider: this.profile.type,
provider: this.profile.provider || 'qiniu',
access_key: this.profile.accessKey || '',
secret_key: this.profile.secretKey || '',
endpoint: this.profile.endpoint || '',
@@ -53,8 +49,6 @@ export class OssTransport implements FsTransport {
}
this.connID = null
}
this.previewCache.clear()
this.previewOrder = []
}
private requireConn(): string {
@@ -169,22 +163,14 @@ export class OssTransport implements FsTransport {
// ====== 预览辅助 ======
/** 下载远程文件到本地临时目录用于预览(缓存由 Go 后端管理) */
async downloadForPreview(remotePath: string): Promise<string> {
if (this.previewCache.has(remotePath)) {
this.previewOrder = this.previewOrder.filter(p => p !== remotePath)
this.previewOrder.push(remotePath)
return this.previewCache.get(remotePath)!
}
const localPath = await OssDownloadToTemp(this.requireConn(), remotePath)
return OssDownloadToTemp(this.requireConn(), remotePath)
}
if (this.previewOrder.length >= PREVIEW_CACHE_MAX) {
const oldest = this.previewOrder.shift()!
this.previewCache.delete(oldest)
}
this.previewCache.set(remotePath, localPath)
this.previewOrder.push(remotePath)
return localPath
/** 下载 HTML 及其引用的资源到临时目录用于网站预览 */
async downloadSiteForPreview(remotePath: string): Promise<string> {
return OssDownloadSiteForPreview(this.requireConn(), remotePath)
}
/** 获取预签名 URL(用于直接预览) */