文件管理添加剩余空间显示

This commit is contained in:
fangxiang 2022-03-21 19:31:34 +08:00
parent 792ff15885
commit 9b3b785ac6
3 changed files with 65 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "media_player_client", "name": "media_player_client",
"version": "1.3.1", "version": "1.3.2",
"description": "A Quasar Framework app", "description": "A Quasar Framework app",
"productName": "MediaPlayerClient", "productName": "MediaPlayerClient",
"author": "fangxiang <fangxiang@cloudview.work>", "author": "fangxiang <fangxiang@cloudview.work>",

View File

@ -13,7 +13,7 @@
> >
<q-card <q-card
class="overflow-hidden" class="overflow-hidden"
style="overflow-y: scroll; max-width: 70vw; max-height: 80vh" style="overflow-y: scroll; max-width: 70vw; max-height: 85vh"
> >
<q-card-section class="q-ma-none q-pa-sm"> <q-card-section class="q-ma-none q-pa-sm">
<div class="row"> <div class="row">
@ -174,11 +174,12 @@
<q-separator /> <q-separator />
<q-card-section <q-card-section
style="max-height: 50vh; width: 70vw; max-height: 80vh" style="width: 70vw; max-height: 85vh"
class="scroll q-pa-none q-ma-none" class="scroll q-pa-none q-ma-none"
> >
<q-table <q-table
style="height: 69vh" style="height: 68vh"
class="q-mb-md"
v-show="!uploading" v-show="!uploading"
:rows="files" :rows="files"
:columns="columns" :columns="columns"
@ -260,6 +261,28 @@
</div> </div>
</q-td> </q-td>
</template> </template>
<template v-slot:pagination="scope">
<div class="col-2 text-h6">
{{ $t("file count") }}: {{ file_count }}
</div>
<div class="col-2 text-h6 q-mx-md">&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div class="col-2 text-h6">
{{ $t("directoriy count") }}: {{ directory_count }}
</div>
<div v-if="free_space" class="col-2 text-h6 q-mx-md">
&nbsp;&nbsp;&nbsp;&nbsp;
</div>
<div class="col-2 text-h6" v-if="free_space">
{{ $t("free space") }}:
<span v-if="free_space / 1024 / 1024 / 1024 > 0">
{{ (free_space / 1024 / 1024 / 1024).toFixed(1) }}GB
</span>
<span v-else>
{{ (free_space / 1024 / 1024).toFixed(1) }}MB
</span>
</div>
</template>
</q-table> </q-table>
<div v-show="uploading" class="row q-ma-sm"> <div v-show="uploading" class="row q-ma-sm">
<q-space /> <q-space />
@ -460,6 +483,10 @@ export default defineComponent({
let resolve_value: any = null; let resolve_value: any = null;
const filters: Ref<string[]> = ref([]); const filters: Ref<string[]> = ref([]);
const free_space = ref(0);
const file_count = ref(0);
const directory_count = ref(0);
const clipboard = reactive(new _ClipboardType()); // const clipboard = reactive(new _ClipboardType()); //
const disk_options = ref([ const disk_options = ref([
@ -550,20 +577,47 @@ export default defineComponent({
const _show_files = (response: any) => { const _show_files = (response: any) => {
if (response) { if (response) {
if (response.status == 200) { if (response.status == 200) {
const file_entitys = response.data as FileEntity[]; interface IRsponseData {
files: FileEntity[];
free: number;
}
let file_entitys: FileEntity[] = [];
let free = 0;
if (Array.isArray(response.data)) {
file_entitys = response.data as FileEntity[];
} else {
const resposne_data = response.data as IRsponseData;
file_entitys = resposne_data.files;
free = resposne_data.free;
}
free_space.value = free;
if (Array.isArray(file_entitys)) { if (Array.isArray(file_entitys)) {
directory_count.value = 0;
file_count.value = 0;
if (filters.value.length == 0) { if (filters.value.length == 0) {
files.value = file_entitys; files.value = file_entitys;
for (const item of file_entitys) {
if (item) {
if (item.is_directory) {
++directory_count.value;
} else {
++file_count.value;
}
}
}
} else { } else {
files.value = []; files.value = [];
for (const item of file_entitys) { for (const item of file_entitys) {
if (item) { if (item) {
if (item.is_directory) { if (item.is_directory) {
files.value.push(item); files.value.push(item);
++directory_count.value;
} else { } else {
for (const filter of filters.value) { for (const filter of filters.value) {
if (item.name.endsWith(filter)) { if (item.name.endsWith(filter)) {
files.value.push(item); files.value.push(item);
++file_count.value;
break; break;
} }
} }
@ -711,6 +765,9 @@ export default defineComponent({
path, path,
prev_path, prev_path,
paths, paths,
free_space,
file_count,
directory_count,
target_dom, target_dom,
upload_url, upload_url,
uploader, uploader,

View File

@ -434,4 +434,7 @@ export default {
"请使用粘贴命令粘贴到其它目录", "请使用粘贴命令粘贴到其它目录",
_cut2: "移动", _cut2: "移动",
"cut to colipboard success": "成功剪切到剪切板", "cut to colipboard success": "成功剪切到剪切板",
"file count": "文件数量",
"directoriy count": "文件夹数量",
"free space": "剩余空间",
}; };