Fix file browser absolute path copy (#860)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { FileEntry } from '@/api/hermes/files'
|
||||
|
||||
export function getClipboardPathForEntry(entry: FileEntry): string {
|
||||
return entry.absolutePath || entry.path
|
||||
}
|
||||
Reference in New Issue
Block a user