Fix file browser absolute path copy (#860)

This commit is contained in:
Zhicheng Han
2026-05-20 04:36:49 +02:00
committed by GitHub
parent 7f6b691238
commit 5fc7dce9c8
8 changed files with 181 additions and 6 deletions
+3 -1
View File
@@ -3,6 +3,7 @@ import { request, getApiKey, getBaseUrlValue } from '../client'
export interface FileEntry {
name: string
path: string
absolutePath?: string
isDir: boolean
size: number
modTime: string
@@ -11,13 +12,14 @@ export interface FileEntry {
export interface FileStat {
name: string
path: string
absolutePath?: string
isDir: boolean
size: number
modTime: string
permissions?: string
}
export async function listFiles(path: string = ''): Promise<{ entries: FileEntry[]; path: string }> {
export async function listFiles(path: string = ''): Promise<{ entries: FileEntry[]; path: string; absolutePath?: string }> {
const params = new URLSearchParams()
if (path) params.set('path', path)
const query = params.toString()
@@ -6,6 +6,7 @@ import { useFilesStore, isTextFile, isImageFile, isMarkdownFile } from '@/stores
import { downloadFile } from '@/api/hermes/download'
import type { FileEntry } from '@/api/hermes/files'
import { copyToClipboard } from '@/utils/clipboard'
import { getClipboardPathForEntry } from '@/utils/file-path'
const { t } = useI18n()
const message = useMessage()
@@ -74,7 +75,7 @@ async function handleSelect(key: string) {
try { await downloadFile(entry.path, entry.name) } catch (err: any) { message.error(err.message) }
break
case 'copyPath': {
const ok = await copyToClipboard(entry.path)
const ok = await copyToClipboard(getClipboardPathForEntry(entry))
if (ok) {
message.success(t('files.pathCopied'))
} else {
+5
View File
@@ -0,0 +1,5 @@
import type { FileEntry } from '@/api/hermes/files'
export function getClipboardPathForEntry(entry: FileEntry): string {
return entry.absolutePath || entry.path
}