Browse Source

fix(account): 修复个人文档路径拼接错误

pull/1014/head
colin 1 year ago
parent
commit
de064194c1
  1. 42
      apps/vue/src/views/account/center/Cloud.vue

42
apps/vue/src/views/account/center/Cloud.vue

@ -6,6 +6,7 @@
<template #description> <template #description>
<DirectoryTree <DirectoryTree
:tree-data="folderTree" :tree-data="folderTree"
:loadedKeys="loadedKeys"
:expandedKeys="expandedKeys" :expandedKeys="expandedKeys"
@expand="fetchFolders" @expand="fetchFolders"
@select="handleSelectFolder" @select="handleSelectFolder"
@ -29,7 +30,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, ref, shallowRef } from 'vue'; import { computed, ref, shallowRef } from 'vue';
import { Card, Tree } from 'ant-design-vue'; import { Card, Tree } from 'ant-design-vue';
import { TreeDataItem } from 'ant-design-vue/es/tree/Tree'; import { AntTreeNodeBaseEvent, TreeDataItem } from 'ant-design-vue/es/tree/Tree';
import { useLocalization } from '/@/hooks/abp/useLocalization'; import { useLocalization } from '/@/hooks/abp/useLocalization';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
import { OssObject } from '/@/api/oss-management/objects/model'; import { OssObject } from '/@/api/oss-management/objects/model';
@ -52,6 +53,12 @@
dataRef: any; dataRef: any;
} }
interface NodeInfo {
path?: string;
node: NodeInfo;
parent?: NodeInfo;
}
const { hasPermission } = usePermission(); const { hasPermission } = usePermission();
const { L } = useLocalization(['AbpOssManagement', 'AbpUi']); const { L } = useLocalization(['AbpOssManagement', 'AbpUi']);
const folderTreeRef = ref<{ [key: string]: TreeDataItem }>({ const folderTreeRef = ref<{ [key: string]: TreeDataItem }>({
@ -97,28 +104,36 @@
return false; return false;
} }
}); });
const loadedKeys = ref<string[]>([]);
const expandedKeys = ref<string[]>([]); const expandedKeys = ref<string[]>([]);
function fetchFolders(keys) { function fetchFolders(keys, e) {
expandedKeys.value = keys; expandedKeys.value = keys;
if (!e.expanded) {
const keys = loadedKeys.value;
const findIndex = keys.findLastIndex((key) => key === e.node.key);
findIndex >= 0 && keys.splice(findIndex);
loadedKeys.value = keys;
}
} }
function handleSelectFolder(_, e) { function handleSelectFolder(_, e: AntTreeNodeBaseEvent) {
switch (e.node.dataRef.group) { const path = calculateFilePath(e.node as any);
switch (e.node.group) {
case 'private': case 'private':
case 'public': case 'public':
switchComponent.value = { switchComponent.value = {
name: 'FileList', name: 'FileList',
group: e.node.dataRef.group, group: e.node.group,
path: e.node.dataRef.path, path: path,
dataRef: e.node.dataRef, dataRef: e.node.dataRef,
}; };
break; break;
case 'share': case 'share':
switchComponent.value = { switchComponent.value = {
name: 'ShareList', name: 'ShareList',
group: e.node.dataRef.group, group: e.node.group,
path: e.node.dataRef.path, path: path,
dataRef: e.node.dataRef, dataRef: e.node.dataRef,
}; };
break; break;
@ -128,7 +143,7 @@
function handleAppendFolder(folders: OssObject[]) { function handleAppendFolder(folders: OssObject[]) {
switchComponent.value.dataRef.children = folders.map((obj) => { switchComponent.value.dataRef.children = folders.map((obj) => {
return { return {
key: obj.name, key: switchComponent.value.path + obj.name,
group: switchComponent.value.group, group: switchComponent.value.group,
title: obj.name, title: obj.name,
path: obj.name, path: obj.name,
@ -136,4 +151,13 @@
}; };
}); });
} }
function calculateFilePath(e: NodeInfo) {
let path = e.path ?? '';
if (e.parent?.node?.path) {
path = e.parent.node.path + path;
path = calculateFilePath(e.parent) + path;
}
return path;
}
</script> </script>

Loading…
Cancel
Save