fix aliyunpan ui

This commit is contained in:
jxxghp
2024-06-18 12:01:38 +08:00
parent 9e9e940dfd
commit e003b6f9a7
4 changed files with 12 additions and 6 deletions

View File

@@ -112,6 +112,7 @@ async function load() {
.replace(/{path}/g, encodeURIComponent(inProps.path || ''))
.replace(/{sort}/g, inProps.sort || 'name')
.replace(/{fileid}/g, inProps.fileid || '')
.replace(/{filetype}/g, isDir.value ? 'dir' : 'file')
const config = {
url,
method: inProps.endpoints?.list.method || 'get',
@@ -134,7 +135,7 @@ async function deleteItem(item: FileItem) {
const url = inProps.endpoints?.delete.url
.replace(/{storage}/g, inProps.storage)
.replace(/{path}/g, encodeURIComponent(item.path))
.replace(/{fileid}/g, inProps.fileid || '')
.replace(/{fileid}/g, item.fileid || '')
const config = {
url,
@@ -151,6 +152,7 @@ async function deleteItem(item: FileItem) {
// 切换路径
function changePath(item: FileItem) {
item.path = inProps.path + item.name + (item.type === 'dir' ? '/' : '')
emit('pathchanged', item)
}
@@ -191,8 +193,9 @@ async function rename() {
const url = inProps.endpoints?.rename.url
.replace(/{storage}/g, inProps.storage)
.replace(/{path}/g, encodeURIComponent(currentItem.value?.path || ''))
.replace(/{fileid}/g, inProps.fileid || '')
.replace(/{fileid}/g, currentItem.value?.fileid || '')
.replace(/{newname}/g, encodeURIComponent(newName.value))
.replace(/{filetype}/g, currentItem.value?.type || 'file')
const config = {
url,

View File

@@ -148,7 +148,7 @@ const sortIcon = computed(() => {
variant="text"
:input-value="index === pathSegments.length - 1"
class="px-1 d-none d-md-block"
@click="changePath(segment.path, inProps.fileidstack[index])"
@click="changePath(segment.path, inProps.fileidstack[index + 1])"
>
<VIcon icon=" mdi-chevron-right" />
{{ segment.name }}

View File

@@ -32,13 +32,15 @@ const treeItems = ref<FileItem[]>([
extension: '',
size: 0,
modify_time: 0,
fileid: '',
parent_fileid: '',
},
])
// 拉取子目录
async function fetchDirs(item: any) {
return api
.get('/filebrowser/listdir?path=' + item.path)
.get('/filebrowser/local/listdir?path=' + item.path)
.then((data: any) => {
item.children.push(...data)
})

View File

@@ -5,7 +5,7 @@ import FileBrowser from '@/components/FileBrowser.vue'
const endpoints = {
list: {
url: '/filebrowser/{storage}/list?path={path}&sort={sort}&fileid={fileid}',
url: '/filebrowser/{storage}/list?path={path}&sort={sort}&fileid={fileid}&filetype={filetype}',
method: 'get',
},
mkdir: {
@@ -25,7 +25,7 @@ const endpoints = {
method: 'get',
},
rename: {
url: '/filebrowser/{storage}/rename?path={path}&new_name={newname}&fileid={fileid}',
url: '/filebrowser/{storage}/rename?path={path}&new_name={newname}&fileid={fileid}&filetype={filetype}',
method: 'get',
},
}
@@ -93,6 +93,7 @@ async function loadDownloadDirectories() {
function pathChanged(item: FileItem) {
path.value = item.path
fileid.value = item.fileid
if (item.fileid == 'root') return
if (fileidstack.value.includes(item.fileid)) {
fileidstack.value = fileidstack.value.slice(0, fileidstack.value.indexOf(item.fileid) + 1)
} else {