fix: 解决排序之后获取文件夹大小导致排序失效的问题 (#2804)

This commit is contained in:
zhengkunwang 2023-11-05 21:33:40 +08:00 committed by GitHub
parent dedfe1e1e1
commit 1fc75ac000
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View file

@ -254,7 +254,6 @@ const getAppDetail = async (version: string) => {
req.appDetailId = res.data.id; req.appDetailId = res.data.id;
req.dockerCompose = res.data.dockerCompose; req.dockerCompose = res.data.dockerCompose;
isHostMode.value = res.data.hostMode; isHostMode.value = res.data.hostMode;
console.log(res.data);
installData.value.params = res.data.params; installData.value.params = res.data.params;
paramKey.value++; paramKey.value++;
} catch (error) { } catch (error) {

View file

@ -52,7 +52,7 @@
<div class="btn-container"> <div class="btn-container">
<div class="left-section"> <div class="left-section">
<el-dropdown @command="handleCreate"> <el-dropdown @command="handleCreate">
<el-button type="primary"> <el-button type="primary" size="small">
{{ $t('commons.button.create') }} {{ $t('commons.button.create') }}
<el-icon><arrow-down /></el-icon> <el-icon><arrow-down /></el-icon>
</el-button> </el-button>
@ -69,7 +69,7 @@
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<el-button-group> <el-button-group size="small">
<el-button plain @click="openUpload">{{ $t('file.upload') }}</el-button> <el-button plain @click="openUpload">{{ $t('file.upload') }}</el-button>
<el-button plain @click="openWget">{{ $t('file.remoteFile') }}</el-button> <el-button plain @click="openWget">{{ $t('file.remoteFile') }}</el-button>
<el-button plain @click="openMove('copy')" :disabled="selects.length === 0"> <el-button plain @click="openMove('copy')" :disabled="selects.length === 0">
@ -89,11 +89,11 @@
</el-button> </el-button>
</el-button-group> </el-button-group>
<el-button class="btn" @click="toTerminal"> <el-button class="btn" @click="toTerminal" size="small">
{{ $t('menu.terminal') }} {{ $t('menu.terminal') }}
</el-button> </el-button>
<el-button-group class="copy-button" v-if="moveOpen"> <el-button-group class="copy-button" v-if="moveOpen" size="small">
<el-tooltip class="box-item" effect="dark" :content="$t('file.paste')" placement="bottom"> <el-tooltip class="box-item" effect="dark" :content="$t('file.paste')" placement="bottom">
<el-button plain @click="openPaste">{{ $t('file.paste') }}</el-button> <el-button plain @click="openPaste">{{ $t('file.paste') }}</el-button>
</el-tooltip> </el-tooltip>
@ -108,7 +108,7 @@
<div class="right-section"> <div class="right-section">
<el-popover placement="bottom" :width="200" trigger="hover" @before-enter="getFavoriates"> <el-popover placement="bottom" :width="200" trigger="hover" @before-enter="getFavoriates">
<template #reference> <template #reference>
<el-button @click="openFavorite" :icon="Star"> <el-button @click="openFavorite" :icon="Star" size="small">
{{ $t('file.favorite') }} {{ $t('file.favorite') }}
</el-button> </el-button>
</template> </template>
@ -139,7 +139,7 @@
</div> </div>
</el-popover> </el-popover>
<el-button class="btn" @click="openRecycleBin" :icon="Delete"> <el-button class="btn" @click="openRecycleBin" :icon="Delete" size="small">
{{ $t('file.recycleBin') }} {{ $t('file.recycleBin') }}
</el-button> </el-button>
<div class="search-button"> <div class="search-button">
@ -149,6 +149,7 @@
@clear="search()" @clear="search()"
@keydown.enter="search()" @keydown.enter="search()"
:placeholder="$t('file.search')" :placeholder="$t('file.search')"
size="small"
> >
<template #prepend> <template #prepend>
<el-checkbox v-model="req.containSub"> <el-checkbox v-model="req.containSub">
@ -240,9 +241,9 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('file.size')" prop="size" max-width="50" sortable> <el-table-column :label="$t('file.size')" prop="size" max-width="50" sortable>
<template #default="{ row }"> <template #default="{ row, $index }">
<span v-if="row.isDir"> <span v-if="row.isDir">
<el-button type="primary" link small @click="getDirSize(row)"> <el-button type="primary" link small @click="getDirSize(row, $index)">
<span v-if="row.dirSize == undefined"> <span v-if="row.dirSize == undefined">
{{ $t('file.calculate') }} {{ $t('file.calculate') }}
</span> </span>
@ -564,14 +565,16 @@ const getFileSize = (size: number) => {
return computeSize(size); return computeSize(size);
}; };
const getDirSize = async (row: any) => { const getDirSize = async (row: any, index: number) => {
const req = { const req = {
path: row.path, path: row.path,
}; };
loading.value = true; loading.value = true;
await ComputeDirSize(req) await ComputeDirSize(req)
.then(async (res) => { .then(async (res) => {
row.dirSize = res.data.size; let newData = [...data.value];
newData[index].dirSize = res.data.size;
data.value = newData;
}) })
.finally(() => { .finally(() => {
loading.value = false; loading.value = false;