refactor: 调整 eslint.config.js,优化代码格式

This commit is contained in:
2024-10-28 21:20:08 +08:00
parent 0e8fe5ff1f
commit 9e5dff144b
176 changed files with 5956 additions and 5624 deletions

View File

@@ -36,8 +36,8 @@ watch(
selectedKey.value = route.query.type as string || '0'
},
{
immediate: true
}
immediate: true,
},
)
// 点击事件

View File

@@ -34,7 +34,7 @@ const totalData = ref<FileStatisticsResp>({
size: 0,
number: 0,
unit: '',
data: []
data: [],
})
const chartData = ref<Array<{ name: string, value: number, size: string }>>([])
const statisticValueStyle = { 'color': '#5856D6', 'font-size': '18px' }
@@ -44,7 +44,7 @@ const { option } = useChart(() => {
left: 0,
right: 0,
top: 0,
bottom: 0
bottom: 0,
},
legend: {
show: true,
@@ -53,14 +53,14 @@ const { option } = useChart(() => {
itemWidth: 6,
itemHeight: 6,
textStyle: {
color: '#4E5969'
}
color: '#4E5969',
},
},
tooltip: {
show: true,
formatter(params) {
return `总计:${params.value}<br>${params.data.size}`
}
},
},
series: [
{
@@ -69,11 +69,11 @@ const { option } = useChart(() => {
avoidLabelOverlap: true,
label: {
show: false,
position: 'center'
position: 'center',
},
data: chartData.value
}
]
data: chartData.value,
},
],
}
})
@@ -89,14 +89,14 @@ const getStatisticsData = async () => {
size: Number.parseFloat(formatSize[0]),
number: resData.number ?? 0,
unit: formatSize[1],
data: []
data: [],
}
resData.data?.forEach((fs: FileStatisticsResp) => {
const matchedItem = FileTypeList.find((item) => item.value === fs.type)
chartData.value.unshift({
name: matchedItem ? matchedItem.name : '',
value: fs.number,
size: formatFileSize(fs.size)
size: formatFileSize(fs.size),
})
})
} finally {

View File

@@ -53,7 +53,7 @@ interface Props {
const props = withDefaults(defineProps<Props>(), {
data: () => [], // 文件数据
selectedFileIds: () => [], // 批量模式下选中的文件id数组
isBatchMode: false // 是否是批量模式
isBatchMode: false, // 是否是批量模式
})
const emit = defineEmits<{

View File

@@ -26,7 +26,7 @@ const getFileImg = computed<string>(() => {
return props.data.url || ''
}
if (!Object.keys(FileIcon).includes(extension)) {
return FileIcon['other']
return FileIcon.other
}
return FileIcon[extension]
})

View File

@@ -79,7 +79,7 @@ interface Props {
const props = withDefaults(defineProps<Props>(), {
data: () => [], // 文件数据
selectedFileIds: () => [],
isBatchMode: false // 是否是批量模式
isBatchMode: false, // 是否是批量模式
})
const emit = defineEmits<{
@@ -95,7 +95,7 @@ const getFileName = (item: FileItem) => {
const rowSelection: TableRowSelection = reactive({
type: 'checkbox',
showCheckedAll: true
showCheckedAll: true,
})
// 多选

View File

@@ -18,7 +18,7 @@ interface Props {
}
const props = withDefaults(defineProps<Props>(), {
shadow: true
shadow: true,
})
const emit = defineEmits<{

View File

@@ -17,8 +17,10 @@
</a-dropdown>
<a-input-group>
<a-input v-model="queryForm.name" placeholder="请输入文件名" allow-clear style="width: 200px"
@change="search" />
<a-input
v-model="queryForm.name" placeholder="请输入文件名" allow-clear style="width: 200px"
@change="search"
/>
<a-button type="primary" @click="search">
<template #icon>
<icon-search />
@@ -30,8 +32,10 @@
<!-- 右侧区域 -->
<a-space wrap>
<a-button v-if="isBatchMode" :disabled="!selectedFileIds.length" type="primary" status="danger"
@click="handleMulDelete">
<a-button
v-if="isBatchMode" :disabled="!selectedFileIds.length" type="primary" status="danger"
@click="handleMulDelete"
>
<template #icon>
<icon-delete />
</template>
@@ -57,14 +61,18 @@
<!-- 文件列表-宫格模式 -->
<a-spin id="fileMain" class="file-main__list" :loading="loading">
<FileGrid v-show="fileList.length && mode === 'grid'" :data="fileList" :is-batch-mode="isBatchMode"
:selected-file-ids="selectedFileIds" @click="handleClickFile" @select="handleSelectFile"
@right-menu-click="handleRightMenuClick"></FileGrid>
<FileGrid
v-show="fileList.length && mode === 'grid'" :data="fileList" :is-batch-mode="isBatchMode"
:selected-file-ids="selectedFileIds" @click="handleClickFile" @select="handleSelectFile"
@right-menu-click="handleRightMenuClick"
></FileGrid>
<!-- 文件列表-列表模式 -->
<FileList v-show="fileList.length && mode === 'list'" :data="fileList" :is-batch-mode="isBatchMode"
:selected-file-ids="selectedFileIds" @click="handleClickFile" @select="handleSelectFile"
@right-menu-click="handleRightMenuClick"></FileList>
<FileList
v-show="fileList.length && mode === 'list'" :data="fileList" :is-batch-mode="isBatchMode"
:selected-file-ids="selectedFileIds" @click="handleClickFile" @select="handleSelectFile"
@right-menu-click="handleRightMenuClick"
></FileList>
<a-empty v-if="!fileList.length" />
</a-spin>
@@ -82,7 +90,7 @@ import {
openFileDetailModal,
openFileRenameModal,
previewFileAudioModal,
previewFileVideoModal
previewFileVideoModal,
} from '../../components/index'
import FileGrid from './FileGrid.vue'
import useFileManage from './useFileManage'
@@ -101,18 +109,18 @@ const { mode, selectedFileIds, toggleMode, addSelectedFileItem } = useFileManage
const queryForm = reactive<FileQuery>({
name: undefined,
type: route.query.type?.toString() !== '0' ? route.query.type?.toString() : undefined,
sort: ['updateTime,desc']
sort: ['updateTime,desc'],
})
const paginationOption = reactive({
defaultPageSize: 30,
defaultSizeOptions: [30, 40, 50, 100, 120]
defaultSizeOptions: [30, 40, 50, 100, 120],
})
const isBatchMode = ref(false)
const {
tableData: fileList,
loading,
pagination,
search
search,
} = useTable((page) => listFile({ ...queryForm, ...page }), { immediate: false, paginationOption })
const filePreviewRef = ref()
// 点击文件
@@ -124,9 +132,9 @@ const handleClickFile = (item: FileItem) => {
if (imgList.length) {
viewerApi({
options: {
initialViewIndex: index
initialViewIndex: index,
},
images: imgList
images: imgList,
})
}
}
@@ -143,11 +151,11 @@ const handleClickFile = (item: FileItem) => {
},
transformData: (workbookData) => {
return workbookData
}
},
}
filePreviewRef.value.onPreview({
fileInfo: { data: item.url, fileName: item.name, fileType: item.extension },
excelConfig
excelConfig,
})
}
if (item.extension === 'mp4') {
@@ -162,7 +170,7 @@ const onDownload = async (fileInfo: FileItem) => {
const res = await downloadByUrl({
url: fileInfo.url,
target: '_self',
fileName: `${fileInfo.name}.${fileInfo.extension}`
fileName: `${fileInfo.name}.${fileInfo.extension}`,
})
res ? Message.success('下载成功') : Message.error('下载失败')
search()
@@ -180,7 +188,7 @@ const handleRightMenuClick = async (mode: string, fileInfo: FileItem) => {
await deleteFile(fileInfo.id)
Message.success('删除成功')
search()
}
},
})
} else if (mode === 'rename') {
openFileRenameModal(fileInfo, search)
@@ -206,7 +214,7 @@ const handleMulDelete = () => {
await deleteFile(selectedFileIds.value)
Message.success('删除成功')
search()
}
},
})
}
@@ -230,7 +238,7 @@ const handleUpload = (options: RequestOption) => {
return {
abort() {
controller.abort()
}
},
}
}

View File

@@ -28,6 +28,6 @@ export default function () {
selectedFileList,
selectedFileIds,
toggleMode,
addSelectedFileItem
addSelectedFileItem,
}
}