prettier: 代码格式化

This commit is contained in:
ah--desktop
2025-10-31 22:42:03 +08:00
parent 91ee49f45f
commit dfc6de49e0
62 changed files with 6814 additions and 5256 deletions
@@ -1,21 +1,34 @@
<script lang="ts" setup>
import { ref, computed } from 'vue';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { FileDTO, FileVO } from '#/api/media/file/types';
import type { PageQueryDTO } from '#/types/common';
import { computed, ref } from 'vue';
import { Page } from '@vben/common-ui';
import {
Button,
Upload,
message,
Tag,
Space,
Popconfirm,
Tooltip
} from 'ant-design-vue';
import { createIconifyIcon } from '@vben/icons';
import {
Button,
message,
Popconfirm,
Space,
Tag,
Tooltip,
Upload,
} from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import type { VxeGridProps } from '#/adapter/vxe-table';
import {
batchUploadFilesApi,
deleteFileApi,
getFilePageApi,
uploadFileApi,
} from '#/api/media/file';
import FileEditModal from './components/FileEditModal.vue';
defineOptions({ name: 'FileRepository' });
// 创建图标组件
const UploadIcon = createIconifyIcon('lucide:upload');
const DeleteIcon = createIconifyIcon('lucide:trash-2');
@@ -23,17 +36,6 @@ const EditIcon = createIconifyIcon('lucide:edit');
const DownloadIcon = createIconifyIcon('lucide:download');
const EyeIcon = createIconifyIcon('lucide:eye');
import {
uploadFileApi,
batchUploadFilesApi,
deleteFileApi,
getFilePageApi,
} from '#/api/media/file';
import type { FileVO, FileDTO } from '#/api/media/file/types';
import type { PageQueryDTO } from '#/types/common';
defineOptions({ name: 'FileRepository' });
// 响应式数据
const loading = ref(false);
const fileList = ref<FileVO.Info[]>([]);
@@ -48,7 +50,6 @@ const searchForm = ref({
fileFormat: undefined as string | undefined,
});
// 文件格式选项
const fileFormatOptions = [
{ label: 'PDF', value: 'pdf' },
@@ -117,7 +118,25 @@ const gridOptions: VxeGridProps<any> = {
pagerConfig: {
enabled: true,
pageSizes: [10, 20, 50, 100],
layouts: ['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total'] as ('PrevJump' | 'PrevPage' | 'Number' | 'NextPage' | 'NextJump' | 'Sizes' | 'FullJump' | 'Total')[],
layouts: [
'PrevJump',
'PrevPage',
'Number',
'NextPage',
'NextJump',
'Sizes',
'FullJump',
'Total',
] as (
| 'FullJump'
| 'NextJump'
| 'NextPage'
| 'Number'
| 'PrevJump'
| 'PrevPage'
| 'Sizes'
| 'Total'
)[],
},
// 配置远程加载
proxyConfig: {
@@ -195,7 +214,7 @@ const handleUpload = async (file: File) => {
await uploadFileApi(file);
message.success('文件上传成功');
refreshTable();
} catch (error) {
} catch {
message.error('文件上传失败');
} finally {
uploadLoading.value = false;
@@ -208,7 +227,7 @@ const handleBatchUpload = async (files: File[]) => {
await batchUploadFilesApi(files);
message.success(`成功上传 ${files.length} 个文件`);
refreshTable();
} catch (error) {
} catch {
message.error('批量上传失败');
} finally {
uploadLoading.value = false;
@@ -236,7 +255,7 @@ const handleDelete = async (id: number) => {
await deleteFileApi(id);
message.success('删除成功');
refreshTable();
} catch (error) {
} catch {
message.error('删除失败');
}
};
@@ -300,8 +319,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
<!-- 文件名列 -->
<template #filename="{ row }: { row: any }">
<div style="display: flex; align-items: center; gap: 8px;">
<span style="font-weight: 500;">{{ row.filename }}</span>
<div style="display: flex; align-items: center; gap: 8px">
<span style="font-weight: 500">{{ row.filename }}</span>
<Tag color="blue" size="small">{{ row.fileFormat || '未知' }}</Tag>
</div>
</template>
@@ -313,12 +332,12 @@ const [Grid, gridApi] = useVbenVxeGrid({
<!-- 标签列 -->
<template #tags="{ row }: { row: any }">
<div v-if="!row.tags" style="color: #999;">无标签</div>
<div v-else style="display: flex; flex-wrap: wrap; gap: 4px;">
<Tag
v-for="tag in row.tags.split(',').filter((t: string) => t.trim())"
:key="tag"
color="green"
<div v-if="!row.tags" style="color: #999">无标签</div>
<div v-else style="display: flex; flex-wrap: wrap; gap: 4px">
<Tag
v-for="tag in row.tags.split(',').filter((t: string) => t.trim())"
:key="tag"
color="green"
size="small"
>
{{ tag.trim() }}
@@ -329,11 +348,19 @@ const [Grid, gridApi] = useVbenVxeGrid({
<!-- 描述列 -->
<template #remark="{ row }: { row: any }">
<Tooltip v-if="row.remark" :title="row.remark">
<span style="display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
<span
style="
display: block;
max-width: 150px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
"
>
{{ row.remark }}
</span>
</Tooltip>
<span v-else style="color: #999;">无描述</span>
<span v-else style="color: #999">无描述</span>
</template>
<!-- 操作列 -->
@@ -341,23 +368,26 @@ const [Grid, gridApi] = useVbenVxeGrid({
<Space>
<Tooltip title="预览">
<Button type="text" size="small" @click="handlePreview(row)">
<EyeIcon class="w-4 h-4" />
<EyeIcon class="h-4 w-4" />
</Button>
</Tooltip>
<Tooltip title="下载">
<Button type="text" size="small" @click="handleDownload(row)">
<DownloadIcon class="w-4 h-4" />
<DownloadIcon class="h-4 w-4" />
</Button>
</Tooltip>
<Tooltip title="编辑">
<Button type="text" size="small" @click="handleEdit(row)">
<EditIcon class="w-4 h-4" />
<EditIcon class="h-4 w-4" />
</Button>
</Tooltip>
<Popconfirm title="确定要删除这个文件吗?" @confirm="handleDelete(row.id)">
<Popconfirm
title="确定要删除这个文件吗?"
@confirm="handleDelete(row.id)"
>
<Tooltip title="删除">
<Button type="text" size="small" danger>
<DeleteIcon class="w-4 h-4" />
<DeleteIcon class="h-4 w-4" />
</Button>
</Tooltip>
</Popconfirm>