mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-17 03:04:46 +08:00
fix: 解决分页BUG,修改按钮样式
This commit is contained in:
parent
0d95cee924
commit
8f6b664a53
@ -149,10 +149,14 @@ func (f *FileInfo) listChildren(dir, showHidden bool, page, pageSize int) error
|
|||||||
start := (page - 1) * pageSize
|
start := (page - 1) * pageSize
|
||||||
end := pageSize + start
|
end := pageSize + start
|
||||||
var result []*FileInfo
|
var result []*FileInfo
|
||||||
if start < 0 || start > f.ItemTotal || end < 0 || start > end || end > f.ItemTotal {
|
if start < 0 || start > f.ItemTotal || end < 0 || start > end {
|
||||||
result = items
|
result = items
|
||||||
} else {
|
} else {
|
||||||
result = items[start:end]
|
if end > f.ItemTotal {
|
||||||
|
result = items[start:]
|
||||||
|
} else {
|
||||||
|
result = items[start:end]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Items = result
|
f.Items = result
|
||||||
|
@ -53,6 +53,7 @@ defineProps({
|
|||||||
const emit = defineEmits(['search', 'update:selects']);
|
const emit = defineEmits(['search', 'update:selects']);
|
||||||
const condition = ref({});
|
const condition = ref({});
|
||||||
function search(conditions: any, e: any) {
|
function search(conditions: any, e: any) {
|
||||||
|
console.log(conditions);
|
||||||
if (conditions) {
|
if (conditions) {
|
||||||
condition.value = conditions;
|
condition.value = conditions;
|
||||||
}
|
}
|
||||||
|
@ -43,45 +43,41 @@
|
|||||||
v-model:selects="selects"
|
v-model:selects="selects"
|
||||||
:data="data"
|
:data="data"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
@search="search(req)"
|
@search="search"
|
||||||
>
|
>
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<el-button-group>
|
<el-dropdown @command="handleCreate">
|
||||||
<el-dropdown split-button type="primary" @command="handleCreate">
|
<el-button type="primary" icon="Plus">
|
||||||
{{ $t('commons.button.create') }}
|
{{ $t('commons.button.create') }}
|
||||||
<template #dropdown>
|
<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||||
<el-dropdown-menu>
|
</el-button>
|
||||||
<el-dropdown-item command="dir">
|
<template #dropdown>
|
||||||
<svg-icon iconName="p-file-folder"></svg-icon>
|
<el-dropdown-menu>
|
||||||
{{ $t('file.dir') }}
|
<el-dropdown-item command="dir">
|
||||||
</el-dropdown-item>
|
<svg-icon iconName="p-file-folder"></svg-icon>
|
||||||
<el-dropdown-item command="file">
|
{{ $t('file.dir') }}
|
||||||
<svg-icon iconName="p-file-normal"></svg-icon>
|
</el-dropdown-item>
|
||||||
{{ $t('file.file') }}
|
<el-dropdown-item command="file">
|
||||||
</el-dropdown-item>
|
<svg-icon iconName="p-file-normal"></svg-icon>
|
||||||
</el-dropdown-menu>
|
{{ $t('file.file') }}
|
||||||
</template>
|
</el-dropdown-item>
|
||||||
</el-dropdown>
|
</el-dropdown-menu>
|
||||||
</el-button-group>
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
<el-button-group style="margin-left: 5px">
|
<el-button-group style="margin-left: 5px">
|
||||||
<el-button type="primary" plain @click="openUpload">{{ $t('file.upload') }}</el-button>
|
<el-button plain @click="openUpload">{{ $t('file.upload') }}</el-button>
|
||||||
<!-- <el-button type="primary" plain> {{ $t('file.search') }}</el-button> -->
|
<!-- <el-button type="primary" plain> {{ $t('file.search') }}</el-button> -->
|
||||||
<el-button type="primary" plain @click="openWget">{{ $t('file.remoteFile') }}</el-button>
|
<el-button plain @click="openWget">{{ $t('file.remoteFile') }}</el-button>
|
||||||
<el-button type="primary" plain @click="openMove('copy')" :disabled="selects.length === 0">
|
<el-button plain @click="openMove('copy')" :disabled="selects.length === 0">
|
||||||
{{ $t('file.copy') }}
|
{{ $t('file.copy') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" plain @click="openMove('cut')" :disabled="selects.length === 0">
|
<el-button plain @click="openMove('cut')" :disabled="selects.length === 0">
|
||||||
{{ $t('file.move') }}
|
{{ $t('file.move') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button plain @click="openCompress(selects)" :disabled="selects.length === 0">
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
@click="openCompress(selects)"
|
|
||||||
:disabled="selects.length === 0"
|
|
||||||
>
|
|
||||||
{{ $t('file.compress') }}
|
{{ $t('file.compress') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" plain @click="openDownload" :disabled="selects.length === 0">
|
<el-button plain @click="openDownload" :disabled="selects.length === 0">
|
||||||
{{ $t('file.download') }}
|
{{ $t('file.download') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-button-group>
|
</el-button-group>
|
||||||
@ -239,14 +235,14 @@ const defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const paginationConfig = reactive({
|
const paginationConfig = reactive({
|
||||||
page: 1,
|
currentPage: 1,
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
total: 0,
|
total: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const search = async (req: File.ReqFile) => {
|
const search = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
req.page = paginationConfig.page;
|
req.page = paginationConfig.currentPage;
|
||||||
req.pageSize = paginationConfig.pageSize;
|
req.pageSize = paginationConfig.pageSize;
|
||||||
await GetFilesList(req)
|
await GetFilesList(req)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -275,7 +271,7 @@ const open = async (row: File.File) => {
|
|||||||
} else {
|
} else {
|
||||||
req.path = req.path + '/' + name;
|
req.path = req.path + '/' + name;
|
||||||
}
|
}
|
||||||
search(req);
|
search();
|
||||||
} else {
|
} else {
|
||||||
openCodeEditor(row);
|
openCodeEditor(row);
|
||||||
}
|
}
|
||||||
@ -294,7 +290,7 @@ const jump = async (index: number) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.path = path;
|
req.path = path;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTree = async (req: File.ReqFile, node: File.FileTree | null) => {
|
const getTree = async (req: File.ReqFile, node: File.FileTree | null) => {
|
||||||
@ -319,7 +315,7 @@ const getTree = async (req: File.ReqFile, node: File.FileTree | null) => {
|
|||||||
const clickNode = async (node: any) => {
|
const clickNode = async (node: any) => {
|
||||||
if (node.path) {
|
if (node.path) {
|
||||||
req.path = node.path;
|
req.path = node.path;
|
||||||
search(req);
|
search();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -346,7 +342,7 @@ const handleCreate = (commnad: string) => {
|
|||||||
|
|
||||||
const delFile = async (row: File.File | null) => {
|
const delFile = async (row: File.File | null) => {
|
||||||
await useDeleteData(DeleteFile, row as File.FileDelete, 'commons.msg.delete', loading.value);
|
await useDeleteData(DeleteFile, row as File.FileDelete, 'commons.msg.delete', loading.value);
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFileSize = (size: number) => {
|
const getFileSize = (size: number) => {
|
||||||
@ -373,7 +369,7 @@ const getIconName = (extension: string) => {
|
|||||||
|
|
||||||
const closeCreate = () => {
|
const closeCreate = () => {
|
||||||
filePage.open = false;
|
filePage.open = false;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openMode = (item: File.File) => {
|
const openMode = (item: File.File) => {
|
||||||
@ -383,7 +379,7 @@ const openMode = (item: File.File) => {
|
|||||||
|
|
||||||
const closeMode = () => {
|
const closeMode = () => {
|
||||||
modePage.open = false;
|
modePage.open = false;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openCompress = (items: File.File[]) => {
|
const openCompress = (items: File.File[]) => {
|
||||||
@ -403,7 +399,7 @@ const openCompress = (items: File.File[]) => {
|
|||||||
|
|
||||||
const closeCompress = () => {
|
const closeCompress = () => {
|
||||||
compressPage.open = false;
|
compressPage.open = false;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openDeCompress = (item: File.File) => {
|
const openDeCompress = (item: File.File) => {
|
||||||
@ -421,7 +417,7 @@ const openDeCompress = (item: File.File) => {
|
|||||||
|
|
||||||
const closeDeCompress = () => {
|
const closeDeCompress = () => {
|
||||||
deCompressPage.open = false;
|
deCompressPage.open = false;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openCodeEditor = (row: File.File) => {
|
const openCodeEditor = (row: File.File) => {
|
||||||
@ -444,7 +440,7 @@ const openUpload = () => {
|
|||||||
|
|
||||||
const closeUpload = () => {
|
const closeUpload = () => {
|
||||||
uploadPage.open = false;
|
uploadPage.open = false;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openWget = () => {
|
const openWget = () => {
|
||||||
@ -455,7 +451,7 @@ const openWget = () => {
|
|||||||
const closeWget = (submit: any) => {
|
const closeWget = (submit: any) => {
|
||||||
console.log(submit);
|
console.log(submit);
|
||||||
wgetPage.open = false;
|
wgetPage.open = false;
|
||||||
search(req);
|
search();
|
||||||
if (submit) {
|
if (submit) {
|
||||||
openProcess();
|
openProcess();
|
||||||
}
|
}
|
||||||
@ -477,7 +473,7 @@ const openRename = (item: File.File) => {
|
|||||||
|
|
||||||
const closeRename = () => {
|
const closeRename = () => {
|
||||||
renamePage.open = false;
|
renamePage.open = false;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openMove = (type: string) => {
|
const openMove = (type: string) => {
|
||||||
@ -492,7 +488,7 @@ const openMove = (type: string) => {
|
|||||||
|
|
||||||
const clodeMove = () => {
|
const clodeMove = () => {
|
||||||
movePage.open = false;
|
movePage.open = false;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openDownload = () => {
|
const openDownload = () => {
|
||||||
@ -507,7 +503,7 @@ const openDownload = () => {
|
|||||||
|
|
||||||
const closeDownload = () => {
|
const closeDownload = () => {
|
||||||
downloadPage.open = false;
|
downloadPage.open = false;
|
||||||
search(req);
|
search();
|
||||||
};
|
};
|
||||||
const saveContent = (content: string) => {
|
const saveContent = (content: string) => {
|
||||||
editorPage.loading = true;
|
editorPage.loading = true;
|
||||||
@ -527,7 +523,7 @@ const quickSave = (content: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
search(req);
|
search();
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO button增加v-if判断
|
//TODO button增加v-if判断
|
||||||
|
Loading…
x
Reference in New Issue
Block a user