2026-04-23 12:09:39 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { NButton, NSpace, useMessage } from 'naive-ui'
|
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
import { useFilesStore } from '@/stores/hermes/files'
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const message = useMessage()
|
|
|
|
|
const filesStore = useFilesStore()
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
(e: 'showNewFile'): void
|
|
|
|
|
(e: 'showNewFolder'): void
|
|
|
|
|
(e: 'showUpload'): void
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
async function handleRefresh() {
|
|
|
|
|
try {
|
|
|
|
|
await filesStore.fetchEntries()
|
|
|
|
|
} catch {
|
|
|
|
|
message.error(t('files.backendError'))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="file-toolbar">
|
2026-05-03 22:10:40 +08:00
|
|
|
<NSpace :size="8" :wrap="true" class="toolbar-space">
|
|
|
|
|
<NButton size="small" @click="emit('showNewFile')" class="toolbar-btn">
|
2026-04-23 12:09:39 +08:00
|
|
|
{{ t('files.newFile') }}
|
|
|
|
|
</NButton>
|
2026-05-03 22:10:40 +08:00
|
|
|
<NButton size="small" @click="emit('showNewFolder')" class="toolbar-btn">
|
2026-04-23 12:09:39 +08:00
|
|
|
{{ t('files.newFolder') }}
|
|
|
|
|
</NButton>
|
2026-05-03 22:10:40 +08:00
|
|
|
<NButton size="small" @click="emit('showUpload')" class="toolbar-btn">
|
2026-04-23 12:09:39 +08:00
|
|
|
{{ t('files.upload') }}
|
|
|
|
|
</NButton>
|
2026-05-03 22:10:40 +08:00
|
|
|
<NButton size="small" @click="handleRefresh" class="toolbar-btn">
|
2026-04-23 12:09:39 +08:00
|
|
|
{{ t('files.refresh') }}
|
|
|
|
|
</NButton>
|
|
|
|
|
</NSpace>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2026-05-03 22:10:40 +08:00
|
|
|
@use '@/styles/variables' as *;
|
|
|
|
|
|
2026-04-23 12:09:39 +08:00
|
|
|
.file-toolbar {
|
|
|
|
|
padding: 12px 16px;
|
2026-05-03 22:10:40 +08:00
|
|
|
|
|
|
|
|
@media (max-width: $breakpoint-mobile) {
|
|
|
|
|
padding: 8px 4px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.toolbar-space {
|
|
|
|
|
@media (max-width: $breakpoint-mobile) {
|
|
|
|
|
:deep(.n-space) {
|
|
|
|
|
gap: 4px !important;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.toolbar-btn {
|
|
|
|
|
@media (max-width: $breakpoint-mobile) {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
padding: 0 8px;
|
|
|
|
|
height: 32px;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
2026-04-23 12:09:39 +08:00
|
|
|
}
|
|
|
|
|
</style>
|