fix(files): close preview on navigation/delete/rename + backfill i18n (#150)

* i18n: backfill files/download translations for de, es, fr, ja, ko, pt

Add nav.files, files.* (39 keys), and download.* (9 keys) so the file
browser UI is fully localized in these six locales instead of falling
back to English.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(files): close preview when navigating or affected file changes

Opening a preview and then navigating directories, deleting the
previewed file, or renaming it left the preview pane stuck on stale
content because previewFile was never cleared.

- stores/hermes/files.ts:
  - fetchEntries clears previewFile on path change (in-place refresh
    keeps the preview).
  - deleteEntry / renameEntry clear preview/editor state when the
    affected entry matches the previewed/edited file or its parent.
  - Add isAffected(target, changed, isDir) helper.
- components/hermes/files/FilePreview.vue: replace the misleading
  common.cancel close button with a dedicated files.closePreview key
  plus an X icon and quaternary style.
- i18n: add files.closePreview to all 8 locales.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
ww
2026-04-23 14:10:14 +08:00
committed by GitHub
parent 93719fb04b
commit a4bfd8edd3
10 changed files with 427 additions and 39 deletions
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { NButton } from 'naive-ui'
import { h } from 'vue'
import { NButton, NIcon } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import { useFilesStore } from '@/stores/hermes/files'
import { getFileDownloadUrl } from '@/api/hermes/files'
@@ -12,14 +13,24 @@ function getImageUrl(): string {
if (!filesStore.previewFile) return ''
return getFileDownloadUrl(filesStore.previewFile.path)
}
const CloseIcon = () =>
h(
'svg',
{ viewBox: '0 0 24 24', width: '14', height: '14', fill: 'currentColor' },
[h('path', { d: 'M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z' })],
)
</script>
<template>
<div class="file-preview" v-if="filesStore.previewFile">
<div class="preview-header">
<span class="preview-filename">{{ filesStore.previewFile.path }}</span>
<NButton size="small" @click="filesStore.closePreview()">
{{ t('common.cancel') }}
<NButton size="small" quaternary @click="filesStore.closePreview()">
<template #icon>
<NIcon><CloseIcon /></NIcon>
</template>
{{ t('files.closePreview') }}
</NButton>
</div>
<div class="preview-content">