chore: add loading animation

This commit is contained in:
engigu
2026-03-30 17:19:25 +08:00
parent 5df2d6868d
commit 27e144410d
4 changed files with 27 additions and 6 deletions
+5
View File
@@ -27,6 +27,7 @@ const selectedFile = ref<string | null>(null)
const fileContent = ref('')
const originalContent = ref('')
const isLoading = ref(false)
const isRefreshing = ref(false)
const isEditMode = ref(false)
const hasChanges = computed(() => fileContent.value !== originalContent.value)
@@ -142,10 +143,13 @@ function handleResize() {
}
async function loadTree() {
isRefreshing.value = true
try {
fileTree.value = await api.files.tree()
} catch {
toast.error('加载文件树失败')
} finally {
isRefreshing.value = false
}
}
@@ -438,6 +442,7 @@ onUnmounted(() => {
:file-tree="fileTree"
:expanded-dirs="expandedDirs"
:selected-path="selectedPath"
:is-refreshing="isRefreshing"
@refresh="loadTree"
@select="handleSelect"
@delete="confirm => dialogsRef?.openDelete(confirm)"
@@ -9,6 +9,7 @@ defineProps<{
fileTree: FileNode[]
expandedDirs: Set<string>
selectedPath: string | null
isRefreshing?: boolean
}>()
const emit = defineEmits<{
@@ -67,8 +68,8 @@ function handleFilesUpload(e: Event) {
<div class="flex items-center justify-between p-2 border-b">
<span class="text-xs font-medium">脚本文件</span>
<div class="flex gap-1">
<Button variant="ghost" size="icon" class="h-6 w-6" @click="emit('refresh')" title="刷新">
<RefreshCw class="h-3 w-3" />
<Button variant="ghost" size="icon" class="h-6 w-6" @click="emit('refresh')" :disabled="isRefreshing" title="刷新">
<RefreshCw class="h-3 w-3" :class="{ 'animate-spin': isRefreshing }" />
</Button>
<Button variant="ghost" size="icon" class="h-6 w-6" @click="triggerFilesUpload('')" title="上传文件/文件夹(放在根目录)">
<FolderUp class="h-3 w-3" />