2022-08-17 17:46:49 +08:00
|
|
|
<template>
|
2023-02-01 19:02:24 +08:00
|
|
|
<div>
|
|
|
|
<el-row>
|
|
|
|
<el-col :span="2">
|
|
|
|
<div>
|
2023-02-09 15:36:42 +08:00
|
|
|
<el-button :icon="Back" @click="back" circle :disabled="paths.length == 0" />
|
2023-02-01 19:02:24 +08:00
|
|
|
<el-button :icon="Refresh" circle @click="search" />
|
|
|
|
</div>
|
|
|
|
</el-col>
|
|
|
|
<el-col :span="22">
|
|
|
|
<div class="path" ref="pathRef">
|
|
|
|
<span ref="breadCrumbRef">
|
|
|
|
<span class="root">
|
2023-02-09 15:36:42 +08:00
|
|
|
<el-link @click="jump('/')">
|
|
|
|
<el-icon :size="20"><HomeFilled /></el-icon>
|
|
|
|
</el-link>
|
2023-02-01 19:02:24 +08:00
|
|
|
</span>
|
2023-02-09 16:13:06 +08:00
|
|
|
<span v-for="item in paths" :key="item.url" class="other">
|
2023-02-01 19:02:24 +08:00
|
|
|
<span class="split">></span>
|
|
|
|
<el-link @click="jump(item.url)">{{ item.name }}</el-link>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
<LayoutContent :title="$t('file.file')" v-loading="loading">
|
|
|
|
<template #toolbar>
|
|
|
|
<el-dropdown @command="handleCreate">
|
|
|
|
<el-button type="primary">
|
|
|
|
{{ $t('commons.button.create') }}
|
|
|
|
<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
|
|
|
</el-button>
|
|
|
|
<template #dropdown>
|
|
|
|
<el-dropdown-menu>
|
|
|
|
<el-dropdown-item command="dir">
|
|
|
|
<svg-icon iconName="p-file-folder"></svg-icon>
|
|
|
|
{{ $t('file.dir') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item command="file">
|
|
|
|
<svg-icon iconName="p-file-normal"></svg-icon>
|
|
|
|
{{ $t('file.file') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</template>
|
|
|
|
</el-dropdown>
|
2023-03-07 15:43:12 +08:00
|
|
|
<el-button-group style="margin-left: 10px">
|
|
|
|
<el-button plain @click="openUpload">{{ $t('file.upload') }}</el-button>
|
|
|
|
<el-button plain @click="openWget">{{ $t('file.remoteFile') }}</el-button>
|
|
|
|
<el-button plain @click="openMove('copy')" :disabled="selects.length === 0">
|
|
|
|
{{ $t('file.copy') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button plain @click="openMove('cut')" :disabled="selects.length === 0">
|
|
|
|
{{ $t('file.move') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button plain @click="openCompress(selects)" :disabled="selects.length === 0">
|
|
|
|
{{ $t('file.compress') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button plain @click="openDownload" :disabled="selects.length === 0">
|
|
|
|
{{ $t('file.download') }}
|
|
|
|
</el-button>
|
|
|
|
</el-button-group>
|
2023-02-06 16:58:45 +08:00
|
|
|
<div class="search search-button">
|
|
|
|
<el-input
|
|
|
|
v-model="req.search"
|
|
|
|
clearable
|
|
|
|
@clear="search()"
|
|
|
|
suffix-icon="Search"
|
|
|
|
@blur="search()"
|
|
|
|
:placeholder="$t('file.search')"
|
|
|
|
>
|
2023-03-10 11:44:58 +08:00
|
|
|
<!-- <template #prepend>
|
2023-02-09 15:36:42 +08:00
|
|
|
<el-checkbox :disabled="req.path == '/'" v-model="req.containSub">
|
|
|
|
{{ $t('file.sub') }}
|
|
|
|
</el-checkbox>
|
2023-03-10 11:44:58 +08:00
|
|
|
</template> -->
|
2023-02-06 16:58:45 +08:00
|
|
|
</el-input>
|
|
|
|
</div>
|
2023-02-01 19:02:24 +08:00
|
|
|
</template>
|
|
|
|
<template #main>
|
|
|
|
<ComplexTable
|
|
|
|
:pagination-config="paginationConfig"
|
|
|
|
v-model:selects="selects"
|
|
|
|
:data="data"
|
|
|
|
@search="search"
|
|
|
|
>
|
|
|
|
<el-table-column type="selection" width="55" />
|
|
|
|
<el-table-column :label="$t('commons.table.name')" min-width="250" fix show-overflow-tooltip>
|
|
|
|
<template #default="{ row }">
|
|
|
|
<svg-icon v-if="row.isDir" className="table-icon" iconName="p-file-folder"></svg-icon>
|
|
|
|
<svg-icon v-else className="table-icon" :iconName="getIconName(row.extension)"></svg-icon>
|
2023-03-16 10:51:17 +08:00
|
|
|
<span class="file-name" @click="open(row)" type="primary">{{ row.name }}</span>
|
2023-02-01 19:02:24 +08:00
|
|
|
<span v-if="row.isSymlink">-> {{ row.linkPath }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column :label="$t('file.mode')" prop="mode">
|
|
|
|
<template #default="{ row }">
|
2023-02-14 15:33:23 +08:00
|
|
|
<el-link :underline="false" @click="openMode(row)" type="primary">{{ row.mode }}</el-link>
|
2023-02-01 19:02:24 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2023-02-15 15:09:47 +08:00
|
|
|
<!-- <el-table-column :label="$t('file.user')" prop="user" show-overflow-tooltip></el-table-column>
|
|
|
|
<el-table-column :label="$t('file.group')" prop="group"></el-table-column> -->
|
2023-02-01 19:02:24 +08:00
|
|
|
<el-table-column :label="$t('file.size')" prop="size">
|
|
|
|
<template #default="{ row }">
|
|
|
|
<span v-if="row.isDir">
|
|
|
|
<el-button type="primary" link small @click="getDirSize(row)">
|
|
|
|
<span v-if="row.dirSize == undefined">
|
|
|
|
{{ $t('file.calculate') }}
|
|
|
|
</span>
|
|
|
|
<span v-else>{{ getFileSize(row.dirSize) }}</span>
|
|
|
|
</el-button>
|
|
|
|
</span>
|
|
|
|
<span v-else>{{ getFileSize(row.size) }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
|
|
:label="$t('file.updateTime')"
|
|
|
|
prop="modTime"
|
|
|
|
:formatter="dateFormat"
|
|
|
|
min-width="150"
|
|
|
|
show-overflow-tooltip
|
|
|
|
></el-table-column>
|
|
|
|
|
|
|
|
<fu-table-operations
|
|
|
|
:ellipsis="1"
|
|
|
|
:buttons="buttons"
|
|
|
|
:label="$t('commons.table.operate')"
|
|
|
|
fixed="right"
|
|
|
|
fix
|
|
|
|
/>
|
|
|
|
</ComplexTable>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<CreateFile ref="createRef" @close="search" />
|
|
|
|
<ChangeRole ref="roleRef" @close="search" />
|
|
|
|
<Compress ref="compressRef" @close="search" />
|
|
|
|
<Decompress ref="deCompressRef" @close="search" />
|
|
|
|
<CodeEditor ref="codeEditorRef" @close="search" />
|
|
|
|
<FileRename ref="renameRef" @close="search" />
|
|
|
|
<Upload ref="uploadRef" @close="search" />
|
|
|
|
<Wget ref="wgetRef" @close="closeWget" />
|
|
|
|
<Move ref="moveRef" @close="search" />
|
|
|
|
<Download ref="downloadRef" @close="search" />
|
|
|
|
<Process :open="processPage.open" @close="closeProcess" />
|
2023-02-15 15:09:47 +08:00
|
|
|
<!-- <Detail ref="detailRef" /> -->
|
2023-02-01 19:02:24 +08:00
|
|
|
</LayoutContent>
|
|
|
|
</div>
|
2022-08-17 17:46:49 +08:00
|
|
|
</template>
|
|
|
|
|
2022-08-19 16:02:58 +08:00
|
|
|
<script setup lang="ts">
|
2023-02-01 19:02:24 +08:00
|
|
|
import { nextTick, onMounted, reactive, ref } from '@vue/runtime-core';
|
2023-03-06 18:12:31 +08:00
|
|
|
import { GetFilesList, DeleteFile, GetFileContent, ComputeDirSize, DownloadFile } from '@/api/modules/files';
|
2023-01-16 15:55:53 +08:00
|
|
|
import { computeSize, dateFormat, getIcon, getRandomStr } from '@/utils/util';
|
2022-09-06 17:48:49 +08:00
|
|
|
import { File } from '@/api/interface/file';
|
|
|
|
import { useDeleteData } from '@/hooks/use-delete-data';
|
2022-08-19 16:02:58 +08:00
|
|
|
import LayoutContent from '@/layout/layout-content.vue';
|
|
|
|
import ComplexTable from '@/components/complex-table/index.vue';
|
|
|
|
import i18n from '@/lang';
|
2022-08-31 13:59:02 +08:00
|
|
|
import CreateFile from './create/index.vue';
|
|
|
|
import ChangeRole from './change-role/index.vue';
|
|
|
|
import Compress from './compress/index.vue';
|
|
|
|
import Decompress from './decompress/index.vue';
|
2022-09-03 18:41:52 +08:00
|
|
|
import Upload from './upload/index.vue';
|
2022-09-06 10:35:35 +08:00
|
|
|
import FileRename from './rename/index.vue';
|
2022-09-01 19:02:33 +08:00
|
|
|
import CodeEditor from './code-editor/index.vue';
|
2022-09-06 17:48:49 +08:00
|
|
|
import Wget from './wget/index.vue';
|
2022-09-06 10:35:35 +08:00
|
|
|
import Move from './move/index.vue';
|
2022-09-06 17:48:49 +08:00
|
|
|
import Download from './download/index.vue';
|
2023-03-13 17:00:28 +08:00
|
|
|
import { Mimetypes, Languages } from '@/global/mimetype';
|
2022-09-14 19:09:39 +08:00
|
|
|
import Process from './process/index.vue';
|
2023-02-15 15:09:47 +08:00
|
|
|
// import Detail from './detail/index.vue';
|
2022-12-27 15:36:09 +08:00
|
|
|
import { useRouter } from 'vue-router';
|
2023-01-30 10:10:40 +08:00
|
|
|
import { Back, Refresh } from '@element-plus/icons-vue';
|
2023-02-14 17:14:03 +08:00
|
|
|
import { MsgWarning } from '@/utils/message';
|
2022-08-24 17:34:21 +08:00
|
|
|
|
2023-02-01 19:02:24 +08:00
|
|
|
interface FilePaths {
|
|
|
|
url: string;
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
2022-12-27 15:36:09 +08:00
|
|
|
const router = useRouter();
|
2022-09-06 17:48:49 +08:00
|
|
|
const data = ref();
|
2022-09-09 18:10:41 +08:00
|
|
|
let selects = ref<any>([]);
|
2023-02-06 16:58:45 +08:00
|
|
|
let req = reactive({
|
|
|
|
path: '/',
|
|
|
|
expand: true,
|
2023-03-13 13:38:29 +08:00
|
|
|
showHidden: true,
|
2023-02-06 16:58:45 +08:00
|
|
|
page: 1,
|
|
|
|
pageSize: 100,
|
|
|
|
search: '',
|
|
|
|
containSub: false,
|
|
|
|
});
|
2022-09-09 18:10:41 +08:00
|
|
|
let loading = ref(false);
|
2023-02-01 19:02:24 +08:00
|
|
|
const paths = ref<FilePaths[]>([]);
|
|
|
|
let pathWidth = ref(0);
|
2022-08-24 17:34:21 +08:00
|
|
|
|
2023-01-31 14:02:29 +08:00
|
|
|
const fileCreate = reactive({ path: '/', isDir: false, mode: 0o755 });
|
|
|
|
const fileCompress = reactive({ files: [''], name: '', dst: '', operate: 'compress' });
|
|
|
|
const fileDeCompress = reactive({ path: '', name: '', dst: '', mimeType: '' });
|
2023-03-14 14:42:09 +08:00
|
|
|
const fileEdit = reactive({ content: '', path: '', name: '', language: 'plaintext' });
|
2022-09-15 10:44:43 +08:00
|
|
|
const codeReq = reactive({ path: '', expand: false, page: 1, pageSize: 100 });
|
2023-01-31 14:02:29 +08:00
|
|
|
const fileUpload = reactive({ path: '' });
|
|
|
|
const fileRename = reactive({ path: '', oldName: '' });
|
|
|
|
const fileWget = reactive({ path: '' });
|
|
|
|
const fileMove = reactive({ oldPaths: [''], type: '' });
|
|
|
|
const fileDownload = reactive({ paths: [''], name: '' });
|
2022-09-14 19:09:39 +08:00
|
|
|
const processPage = reactive({ open: false });
|
2023-01-31 14:02:29 +08:00
|
|
|
|
|
|
|
const createRef = ref();
|
|
|
|
const roleRef = ref();
|
2023-02-15 15:09:47 +08:00
|
|
|
// const detailRef = ref();
|
2023-01-31 14:02:29 +08:00
|
|
|
const compressRef = ref();
|
|
|
|
const deCompressRef = ref();
|
|
|
|
const codeEditorRef = ref();
|
|
|
|
const renameRef = ref();
|
|
|
|
const uploadRef = ref();
|
|
|
|
const wgetRef = ref();
|
|
|
|
const moveRef = ref();
|
|
|
|
const downloadRef = ref();
|
2023-02-01 19:02:24 +08:00
|
|
|
const pathRef = ref();
|
|
|
|
const breadCrumbRef = ref();
|
2022-08-30 17:59:59 +08:00
|
|
|
|
2022-08-19 16:02:58 +08:00
|
|
|
const paginationConfig = reactive({
|
2022-12-01 10:54:45 +08:00
|
|
|
currentPage: 1,
|
2022-09-15 10:44:43 +08:00
|
|
|
pageSize: 100,
|
2022-08-19 16:02:58 +08:00
|
|
|
total: 0,
|
|
|
|
});
|
|
|
|
|
2022-12-01 10:54:45 +08:00
|
|
|
const search = async () => {
|
2022-08-24 11:10:50 +08:00
|
|
|
loading.value = true;
|
2022-12-01 10:54:45 +08:00
|
|
|
req.page = paginationConfig.currentPage;
|
2022-09-15 10:44:43 +08:00
|
|
|
req.pageSize = paginationConfig.pageSize;
|
2022-08-24 17:34:21 +08:00
|
|
|
await GetFilesList(req)
|
2022-08-24 11:10:50 +08:00
|
|
|
.then((res) => {
|
2022-09-15 10:44:43 +08:00
|
|
|
paginationConfig.total = res.data.itemTotal;
|
2022-08-24 11:10:50 +08:00
|
|
|
data.value = res.data.items;
|
2022-08-24 15:33:38 +08:00
|
|
|
req.path = res.data.path;
|
2022-08-24 11:10:50 +08:00
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
loading.value = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-08-24 17:58:58 +08:00
|
|
|
const open = async (row: File.File) => {
|
|
|
|
if (row.isDir) {
|
|
|
|
const name = row.name;
|
2022-09-01 19:02:33 +08:00
|
|
|
if (req.path.endsWith('/')) {
|
2022-08-24 17:58:58 +08:00
|
|
|
req.path = req.path + name;
|
|
|
|
} else {
|
|
|
|
req.path = req.path + '/' + name;
|
|
|
|
}
|
2023-02-01 19:02:24 +08:00
|
|
|
paths.value.push({
|
|
|
|
url: req.path,
|
|
|
|
name: name,
|
|
|
|
});
|
|
|
|
|
|
|
|
jump(req.path);
|
2022-09-01 19:02:33 +08:00
|
|
|
} else {
|
|
|
|
openCodeEditor(row);
|
2022-08-24 11:10:50 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-01 19:02:24 +08:00
|
|
|
const handlePath = () => {
|
|
|
|
if (breadCrumbRef.value.offsetWidth > pathWidth.value) {
|
|
|
|
paths.value.splice(0, 1);
|
|
|
|
paths.value[0].name = '..';
|
|
|
|
nextTick(function () {
|
|
|
|
handlePath();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-09 15:36:42 +08:00
|
|
|
const back = () => {
|
|
|
|
if (paths.value.length > 0) {
|
|
|
|
let url = '/';
|
|
|
|
if (paths.value.length >= 2) {
|
|
|
|
url = paths.value[paths.value.length - 2].url;
|
|
|
|
}
|
|
|
|
jump(url);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-01 19:02:24 +08:00
|
|
|
const jump = async (url: string) => {
|
|
|
|
req.path = url;
|
2023-02-06 16:58:45 +08:00
|
|
|
req.containSub = false;
|
|
|
|
req.search = '';
|
2023-02-01 19:02:24 +08:00
|
|
|
await search();
|
|
|
|
getPaths(req.path);
|
|
|
|
nextTick(function () {
|
|
|
|
handlePath();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const getPaths = (reqPath: string) => {
|
|
|
|
const pathArray = reqPath.split('/');
|
|
|
|
paths.value = [];
|
|
|
|
let base = '/';
|
|
|
|
for (const p of pathArray) {
|
|
|
|
if (p != '') {
|
|
|
|
if (base.endsWith('/')) {
|
|
|
|
base = base + p;
|
2022-09-06 17:48:49 +08:00
|
|
|
} else {
|
2023-02-01 19:02:24 +08:00
|
|
|
base = base + '/' + p;
|
2022-09-06 17:48:49 +08:00
|
|
|
}
|
2023-02-01 19:02:24 +08:00
|
|
|
paths.value.push({
|
|
|
|
url: base,
|
|
|
|
name: p,
|
|
|
|
});
|
2022-08-24 11:10:50 +08:00
|
|
|
}
|
|
|
|
}
|
2022-08-19 16:02:58 +08:00
|
|
|
};
|
|
|
|
|
2022-08-25 17:54:52 +08:00
|
|
|
const handleCreate = (commnad: string) => {
|
2023-01-31 14:02:29 +08:00
|
|
|
fileCreate.path = req.path;
|
|
|
|
fileCreate.isDir = false;
|
2022-08-25 17:54:52 +08:00
|
|
|
if (commnad === 'dir') {
|
2023-01-31 14:02:29 +08:00
|
|
|
fileCreate.isDir = true;
|
2022-08-25 17:54:52 +08:00
|
|
|
}
|
2023-01-31 14:02:29 +08:00
|
|
|
createRef.value.acceptParams(fileCreate);
|
2022-08-25 17:54:52 +08:00
|
|
|
};
|
|
|
|
|
2022-08-25 18:48:03 +08:00
|
|
|
const delFile = async (row: File.File | null) => {
|
2022-12-02 10:59:07 +08:00
|
|
|
await useDeleteData(DeleteFile, row as File.FileDelete, 'commons.msg.delete');
|
2022-12-01 10:54:45 +08:00
|
|
|
search();
|
2022-08-25 18:48:03 +08:00
|
|
|
};
|
|
|
|
|
2022-09-09 18:10:41 +08:00
|
|
|
const getFileSize = (size: number) => {
|
|
|
|
return computeSize(size);
|
|
|
|
};
|
|
|
|
|
|
|
|
const getDirSize = async (row: any) => {
|
|
|
|
const req = {
|
|
|
|
path: row.path,
|
|
|
|
};
|
|
|
|
loading.value = true;
|
|
|
|
await ComputeDirSize(req)
|
|
|
|
.then(async (res) => {
|
|
|
|
row.dirSize = res.data.size;
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
loading.value = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-09-09 18:27:50 +08:00
|
|
|
const getIconName = (extension: string) => {
|
|
|
|
return getIcon(extension);
|
|
|
|
};
|
|
|
|
|
2022-08-29 15:26:36 +08:00
|
|
|
const openMode = (item: File.File) => {
|
2023-01-31 14:02:29 +08:00
|
|
|
roleRef.value.acceptParams(item);
|
2022-08-29 15:26:36 +08:00
|
|
|
};
|
|
|
|
|
2022-09-06 17:48:49 +08:00
|
|
|
const openCompress = (items: File.File[]) => {
|
|
|
|
const paths = [];
|
|
|
|
for (const item of items) {
|
|
|
|
paths.push(item.path);
|
|
|
|
}
|
2023-01-31 14:02:29 +08:00
|
|
|
fileCompress.files = paths;
|
2022-09-06 17:48:49 +08:00
|
|
|
if (paths.length === 1) {
|
2023-01-31 14:02:29 +08:00
|
|
|
fileCompress.name = items[0].name;
|
2022-09-06 17:48:49 +08:00
|
|
|
} else {
|
2023-01-31 14:02:29 +08:00
|
|
|
fileCompress.name = getRandomStr(6);
|
2022-09-06 17:48:49 +08:00
|
|
|
}
|
2023-01-31 14:02:29 +08:00
|
|
|
fileCompress.dst = req.path;
|
2022-08-30 17:59:59 +08:00
|
|
|
|
2023-01-31 14:02:29 +08:00
|
|
|
compressRef.value.acceptParams(fileCompress);
|
2022-08-30 17:59:59 +08:00
|
|
|
};
|
2022-08-31 13:59:02 +08:00
|
|
|
|
|
|
|
const openDeCompress = (item: File.File) => {
|
2022-09-09 18:39:56 +08:00
|
|
|
if (Mimetypes.get(item.mimeType) == undefined) {
|
2023-02-14 17:14:03 +08:00
|
|
|
MsgWarning(i18n.global.t('file.canNotDeCompress'));
|
2022-09-09 18:39:56 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-31 14:02:29 +08:00
|
|
|
fileDeCompress.name = item.name;
|
|
|
|
fileDeCompress.path = item.path;
|
|
|
|
fileDeCompress.dst = req.path;
|
|
|
|
fileDeCompress.mimeType = item.mimeType;
|
2022-08-31 13:59:02 +08:00
|
|
|
|
2023-01-31 14:02:29 +08:00
|
|
|
deCompressRef.value.acceptParams(fileDeCompress);
|
2022-08-31 13:59:02 +08:00
|
|
|
};
|
|
|
|
|
2022-09-01 19:02:33 +08:00
|
|
|
const openCodeEditor = (row: File.File) => {
|
|
|
|
codeReq.path = row.path;
|
|
|
|
codeReq.expand = true;
|
2023-03-13 17:00:28 +08:00
|
|
|
|
|
|
|
if (row.extension != '') {
|
|
|
|
Languages.forEach((language) => {
|
|
|
|
const ext = row.extension.substring(1);
|
|
|
|
if (language.value == ext) {
|
|
|
|
fileEdit.language = language.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
GetFileContent(codeReq)
|
|
|
|
.then((res) => {
|
|
|
|
fileEdit.content = res.data.content;
|
|
|
|
fileEdit.path = res.data.path;
|
|
|
|
fileEdit.name = res.data.name;
|
|
|
|
|
|
|
|
codeEditorRef.value.acceptParams(fileEdit);
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
2022-09-01 19:02:33 +08:00
|
|
|
};
|
|
|
|
|
2022-09-03 18:41:52 +08:00
|
|
|
const openUpload = () => {
|
2023-01-31 14:02:29 +08:00
|
|
|
fileUpload.path = req.path;
|
|
|
|
uploadRef.value.acceptParams(fileUpload);
|
2022-09-03 18:41:52 +08:00
|
|
|
};
|
|
|
|
|
2022-09-06 17:48:49 +08:00
|
|
|
const openWget = () => {
|
2023-01-31 14:02:29 +08:00
|
|
|
fileWget.path = req.path;
|
|
|
|
wgetRef.value.acceptParams(fileWget);
|
2022-09-05 16:25:26 +08:00
|
|
|
};
|
|
|
|
|
2023-02-06 15:00:15 +08:00
|
|
|
const closeWget = (submit: Boolean) => {
|
2022-12-01 10:54:45 +08:00
|
|
|
search();
|
2022-09-14 19:09:39 +08:00
|
|
|
if (submit) {
|
|
|
|
openProcess();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const openProcess = () => {
|
|
|
|
processPage.open = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
const closeProcess = () => {
|
|
|
|
processPage.open = false;
|
2022-09-05 16:25:26 +08:00
|
|
|
};
|
|
|
|
|
2022-09-03 22:22:40 +08:00
|
|
|
const openRename = (item: File.File) => {
|
2023-01-31 14:02:29 +08:00
|
|
|
fileRename.path = req.path;
|
|
|
|
fileRename.oldName = item.name;
|
|
|
|
renameRef.value.acceptParams(fileRename);
|
2022-09-03 22:22:40 +08:00
|
|
|
};
|
|
|
|
|
2022-09-06 10:35:35 +08:00
|
|
|
const openMove = (type: string) => {
|
2023-01-31 14:02:29 +08:00
|
|
|
fileMove.type = type;
|
2022-09-06 10:35:35 +08:00
|
|
|
const oldpaths = [];
|
|
|
|
for (const s of selects.value) {
|
|
|
|
oldpaths.push(s['path']);
|
|
|
|
}
|
2023-01-31 14:02:29 +08:00
|
|
|
fileMove.oldPaths = oldpaths;
|
|
|
|
moveRef.value.acceptParams(fileMove);
|
2022-09-06 10:35:35 +08:00
|
|
|
};
|
|
|
|
|
2022-09-06 17:48:49 +08:00
|
|
|
const openDownload = () => {
|
|
|
|
const paths = [];
|
|
|
|
for (const s of selects.value) {
|
|
|
|
paths.push(s['path']);
|
|
|
|
}
|
2023-01-31 14:02:29 +08:00
|
|
|
fileDownload.paths = paths;
|
2023-03-06 18:12:31 +08:00
|
|
|
if (selects.value.length > 1 || selects.value[0].isDir) {
|
|
|
|
fileDownload.name = selects.value.length > 1 ? getRandomStr(6) : selects.value[0].name;
|
|
|
|
downloadRef.value.acceptParams(fileDownload);
|
|
|
|
} else {
|
2023-03-14 23:04:53 +08:00
|
|
|
loading.value = true;
|
2023-03-06 18:12:31 +08:00
|
|
|
fileDownload.name = selects.value[0].name;
|
|
|
|
DownloadFile(fileDownload as File.FileDownload)
|
|
|
|
.then((res) => {
|
|
|
|
const downloadUrl = window.URL.createObjectURL(new Blob([res], { type: 'application/octet-stream' }));
|
|
|
|
const a = document.createElement('a');
|
|
|
|
a.style.display = 'none';
|
|
|
|
a.href = downloadUrl;
|
|
|
|
a.download = fileDownload.name;
|
|
|
|
const event = new MouseEvent('click');
|
|
|
|
a.dispatchEvent(event);
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
loading.value = false;
|
|
|
|
});
|
|
|
|
}
|
2023-01-31 14:02:29 +08:00
|
|
|
};
|
|
|
|
|
2023-02-15 15:09:47 +08:00
|
|
|
// const openDetail = (row: File.File) => {
|
|
|
|
// detailRef.value.acceptParams({ path: row.path });
|
|
|
|
// };
|
2022-08-25 18:48:03 +08:00
|
|
|
|
2022-08-24 17:58:58 +08:00
|
|
|
const buttons = [
|
|
|
|
{
|
|
|
|
label: i18n.global.t('file.open'),
|
|
|
|
click: open,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: i18n.global.t('file.mode'),
|
2022-08-29 15:26:36 +08:00
|
|
|
click: openMode,
|
2022-08-24 17:58:58 +08:00
|
|
|
},
|
|
|
|
{
|
2022-08-31 13:59:02 +08:00
|
|
|
label: i18n.global.t('file.compress'),
|
2022-09-06 17:48:49 +08:00
|
|
|
click: (row: File.File) => {
|
|
|
|
openCompress([row]);
|
|
|
|
},
|
2022-08-24 17:58:58 +08:00
|
|
|
},
|
2022-08-31 13:59:02 +08:00
|
|
|
{
|
|
|
|
label: i18n.global.t('file.deCompress'),
|
|
|
|
click: openDeCompress,
|
2022-09-09 18:39:56 +08:00
|
|
|
disabled: (row: File.File) => {
|
|
|
|
return row.isDir;
|
|
|
|
},
|
2022-08-31 13:59:02 +08:00
|
|
|
},
|
2022-08-24 17:58:58 +08:00
|
|
|
{
|
|
|
|
label: i18n.global.t('file.rename'),
|
2022-09-03 22:22:40 +08:00
|
|
|
click: openRename,
|
2022-08-24 17:58:58 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: i18n.global.t('commons.button.delete'),
|
2022-08-25 18:48:03 +08:00
|
|
|
click: delFile,
|
2022-08-24 17:58:58 +08:00
|
|
|
},
|
2023-02-15 15:09:47 +08:00
|
|
|
// {
|
|
|
|
// label: i18n.global.t('file.info'),
|
|
|
|
// click: openDetail,
|
|
|
|
// },
|
2022-08-24 17:58:58 +08:00
|
|
|
];
|
2022-12-04 15:29:55 +08:00
|
|
|
|
|
|
|
onMounted(() => {
|
2022-12-27 15:36:09 +08:00
|
|
|
if (router.currentRoute.value.query.path) {
|
|
|
|
req.path = String(router.currentRoute.value.query.path);
|
2023-02-01 19:02:24 +08:00
|
|
|
getPaths(req.path);
|
2022-12-27 15:36:09 +08:00
|
|
|
}
|
2023-02-01 19:02:24 +08:00
|
|
|
pathWidth.value = pathRef.value.offsetWidth * 0.7;
|
2022-12-04 15:29:55 +08:00
|
|
|
search();
|
|
|
|
});
|
2022-08-19 16:02:58 +08:00
|
|
|
</script>
|
|
|
|
|
2023-02-01 19:02:24 +08:00
|
|
|
<style scoped lang="scss">
|
2022-08-19 16:02:58 +08:00
|
|
|
.path {
|
2023-02-01 19:02:24 +08:00
|
|
|
border: 1px solid #ebeef5;
|
2023-02-13 18:47:00 +08:00
|
|
|
background-color: var(--panel-path-bg);
|
2023-02-01 19:02:24 +08:00
|
|
|
height: 30px;
|
|
|
|
border-radius: 2px !important;
|
|
|
|
|
|
|
|
.root {
|
2023-02-09 16:13:06 +08:00
|
|
|
vertical-align: middle;
|
2023-02-01 19:02:24 +08:00
|
|
|
margin-left: 10px;
|
|
|
|
}
|
2023-02-09 16:13:06 +08:00
|
|
|
.other {
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
2023-02-01 19:02:24 +08:00
|
|
|
.split {
|
|
|
|
margin-left: 5px;
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
2022-08-19 16:02:58 +08:00
|
|
|
}
|
2023-01-30 10:10:40 +08:00
|
|
|
|
2023-02-06 16:58:45 +08:00
|
|
|
.search {
|
2023-01-30 10:10:40 +08:00
|
|
|
float: right;
|
|
|
|
display: inline;
|
2023-02-06 16:58:45 +08:00
|
|
|
width: 20%;
|
2023-01-30 10:10:40 +08:00
|
|
|
}
|
2023-03-16 10:51:17 +08:00
|
|
|
|
|
|
|
.file-name {
|
|
|
|
color: $primary-color;
|
|
|
|
font-weight: bold;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.file-name:hover {
|
|
|
|
opacity: 0.6;
|
|
|
|
}
|
2022-08-19 16:02:58 +08:00
|
|
|
</style>
|