diff --git a/src/components/FileBrowser.vue b/src/components/FileBrowser.vue
index 44166d85..02ea3d4c 100644
--- a/src/components/FileBrowser.vue
+++ b/src/components/FileBrowser.vue
@@ -1,9 +1,8 @@
-
-
+
+
{
/>
,
axios: Object as PropType,
refreshpending: Boolean,
@@ -81,10 +82,10 @@ const nameTestResult = ref()
const nameTestDialog = ref(false)
// 目录过滤
-const dirs = computed(() => items.value.filter(item => item.type === 'dir' && item.basename.includes(filter.value)))
+const dirs = computed(() => items.value.filter(item => item.type === 'dir' && item.name.includes(filter.value)))
// 文件过滤
-const files = computed(() => items.value.filter(item => item.type === 'file' && item.basename.includes(filter.value)))
+const files = computed(() => items.value.filter(item => item.type === 'file' && item.name.includes(filter.value)))
// 是否目录
const isDir = computed(() => inProps.path?.endsWith('/'))
@@ -107,6 +108,7 @@ async function load() {
.replace(/{storage}/g, inProps.storage)
.replace(/{path}/g, encodeURIComponent(inProps.path || ''))
.replace(/{sort}/g, inProps.sort || 'name')
+ .replace(/{fileid}/g, inProps.fileid || '')
const config = {
url,
method: inProps.endpoints?.list.method || 'get',
@@ -121,7 +123,7 @@ async function load() {
async function deleteItem(item: FileItem) {
const confirmed = await createConfirm({
title: '确认',
- content: `是否确认删除${item.type === 'dir' ? '目录' : '文件'} ${item.basename}?`,
+ content: `是否确认删除${item.type === 'dir' ? '目录' : '文件'} ${item.name}?`,
})
if (confirmed) {
@@ -129,6 +131,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 || '')
const config = {
url,
@@ -144,8 +147,8 @@ async function deleteItem(item: FileItem) {
}
// 切换路径
-function changePath(_path: string) {
- emit('pathchanged', _path)
+function changePath(item: FileItem) {
+ emit('pathchanged', item)
}
// 新窗口中下载文件
@@ -155,6 +158,7 @@ function download(path: string) {
const url_path = inProps.endpoints?.download.url
.replace(/{storage}/g, inProps.storage)
.replace(/{path}/g, encodeURIComponent(path))
+ .replace(/{fileid}/g, inProps.fileid || '')
const url = `${import.meta.env.VITE_API_BASE_URL}${url_path.slice(1)}&token=${token}`
// 下载文件
window.open(url, '_blank')
@@ -167,6 +171,7 @@ function getImgLink(path: string) {
const url_path = inProps.endpoints?.image.url
.replace(/{storage}/g, inProps.storage)
.replace(/{path}/g, encodeURIComponent(path))
+ .replace(/{fileid}/g, inProps.fileid || '')
return `${import.meta.env.VITE_API_BASE_URL}${url_path.slice(1)}&token=${token}`
}
@@ -183,6 +188,7 @@ 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(/{newname}/g, encodeURIComponent(newName.value))
const config = {
@@ -214,7 +220,7 @@ function formatTime(timestape: number) {
// 监听path变化或者storage变化
watch(
- [() => inProps.path, () => inProps.storage],
+ [() => inProps.path, () => inProps.fileid, () => inProps.storage],
async () => {
items.value = []
nameTestResult.value = undefined
@@ -358,7 +364,9 @@ onMounted(() => {
- 选择目录或文件
+
+ 选择目录或文件
+
{{ items[0]?.name }}
@@ -366,7 +374,7 @@ onMounted(() => {
修改时间:{{ formatTime(items[0]?.modify_time || 0) }}
-
+
@@ -381,7 +389,7 @@ onMounted(() => {
-
+
,
storage: String,
path: String,
+ fileid: String,
+ fileidstack: {
+ type: Array as PropType,
+ default: () => [],
+ },
endpoints: Object as PropType,
axios: Object as PropType,
})
@@ -36,13 +41,14 @@ const pathSegments = computed(() => {
let path_str = ''
const isFolder = inProps.path?.endsWith('/')
const segments = inProps.path?.split('/').filter(item => item)
-
+ const fileids = inProps.fileidstack ?? []
return (
segments?.map((item, index) => {
path_str += item + (index < segments.length - 1 || isFolder ? '/' : '')
return {
name: item,
path: path_str,
+ fileid: fileids[index],
}
}) ?? []
)
@@ -56,20 +62,27 @@ const storageObject = computed(() => {
function changeStorage(code: string) {
if (inProps.storage !== code) {
emit('storagechanged', code)
- emit('pathchanged', '/')
+ emit('pathchanged', {
+ path: '/',
+ fileid: 'root',
+ })
}
}
// 路径变化
-function changePath(_path: string) {
- emit('pathchanged', _path)
+function changePath(_path: string, _fileid: string) {
+ emit('pathchanged', {
+ path: _path,
+ fileid: _fileid,
+ })
}
// 返回上一级
function goUp() {
const segments = pathSegments.value ?? []
const path = segments?.length === 1 ? '/' : segments[segments.length - 2].path
- changePath(path)
+ const fileid = segments?.length === 1 ? 'root' : segments[segments.length - 2].fileid
+ changePath(path, fileid)
}
// 创建目录
@@ -78,6 +91,7 @@ async function mkdir() {
const url = inProps.endpoints?.mkdir.url
.replace(/{storage}/g, inProps.storage)
.replace(/{path}/g, encodeURIComponent(inProps.path + newFolderName.value))
+ .replace(/{fileid}/g, inProps.fileid || '')
const config = {
url,
@@ -125,7 +139,7 @@ const sortIcon = computed(() => {
-
+
{{ storageObject?.name }}
@@ -134,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)"
+ @click="changePath(segment.path, inProps.fileidstack[index])"
>
{{ segment.name }}
diff --git a/src/views/reorganize/FileBrowserView.vue b/src/views/reorganize/FileBrowserView.vue
index 78480aab..b15b9aab 100644
--- a/src/views/reorganize/FileBrowserView.vue
+++ b/src/views/reorganize/FileBrowserView.vue
@@ -1,37 +1,43 @@