Fix duplicate routes + Home.vue use currentUser

This commit is contained in:
Warren
2026-06-30 10:37:39 +08:00
parent 8ac3177384
commit 8c9c0217c9
2 changed files with 10 additions and 13 deletions
+10 -4
View File
@@ -1,5 +1,5 @@
<script setup>
import { ref, onMounted, watch } from 'vue'
import { ref, onMounted, watch, computed } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '../stores/app'
import { invoke } from '@tauri-apps/api/tauri'
@@ -10,6 +10,8 @@ import { open } from '@tauri-apps/api/dialog'
const router = useRouter()
const appStore = useAppStore()
const currentUser = computed(() => appStore.user || 'demo')
const treeData = ref([])
const treeProps = {
label: 'name',
@@ -35,7 +37,7 @@ const formatFileSize = (bytes) => {
const loadTree = async () => {
try {
const tree = await invoke('get_tree', {
userId: 'demo',
userId: currentUser.value,
treeType: currentTreeType.value
})
treeData.value = [tree]
@@ -49,7 +51,7 @@ const handleNodeClick = async (data) => {
if (data.node_type === 'file') {
try {
const filePath = await invoke('download_file', {
userId: 'demo',
userId: currentUser.value,
fileUuid: data.id
})
@@ -85,7 +87,7 @@ const handleUpload = async () => {
ElMessage.info(`Uploading ${fileName}...`)
const result = await invoke('upload_file', {
userId: 'demo',
userId: currentUser.value,
sourcePath: sourcePath,
targetPath: targetPath,
treeType: currentTreeType.value
@@ -111,6 +113,10 @@ watch(currentTreeType, () => {
loadTree()
})
watch(currentUser, () => {
loadTree()
})
onMounted(async () => {
await appStore.initializeApp()
await loadTree()