feat: 图片文件支持缩略图 (#17)

This commit is contained in:
kils
2024-05-13 16:55:39 +08:00
committed by GitHub
parent 861f6203cc
commit c82dc9083b
3 changed files with 57 additions and 16 deletions

View File

@@ -18,18 +18,22 @@ export interface UserResp {
deptName: string deptName: string
disabled: boolean disabled: boolean
} }
export type UserDetailResp = UserResp & { export type UserDetailResp = UserResp & {
roleIds?: Array<number> roleIds?: Array<number>
roleNames: string roleNames: string
pwdResetTime?: string pwdResetTime?: string
} }
export interface UserQuery { export interface UserQuery {
description?: string description?: string
status?: number status?: number
deptId?: string deptId?: string
sort: Array<string> sort: Array<string>
} }
export interface UserPageQuery extends UserQuery, PageQuery {}
export interface UserPageQuery extends UserQuery, PageQuery {
}
/** 系统角色类型 */ /** 系统角色类型 */
export interface RoleResp { export interface RoleResp {
@@ -46,6 +50,7 @@ export interface RoleResp {
updateTime: string updateTime: string
disabled: boolean disabled: boolean
} }
export interface RoleDetailResp { export interface RoleDetailResp {
id: string id: string
name: string name: string
@@ -62,11 +67,14 @@ export interface RoleDetailResp {
updateTime: string updateTime: string
disabled: boolean disabled: boolean
} }
export interface RoleQuery { export interface RoleQuery {
description?: string description?: string
sort: Array<string> sort: Array<string>
} }
export interface RolePageQuery extends RoleQuery, PageQuery {}
export interface RolePageQuery extends RoleQuery, PageQuery {
}
/** 系统菜单类型 */ /** 系统菜单类型 */
export interface MenuResp { export interface MenuResp {
@@ -91,6 +99,7 @@ export interface MenuResp {
updateTime: string updateTime: string
children: MenuResp[] children: MenuResp[]
} }
export interface MenuQuery { export interface MenuQuery {
title?: string title?: string
status?: number status?: number
@@ -112,6 +121,7 @@ export interface DeptResp {
parentId: string parentId: string
children: DeptResp[] children: DeptResp[]
} }
export interface DeptQuery { export interface DeptQuery {
description?: string description?: string
status?: number status?: number
@@ -130,11 +140,15 @@ export interface DictResp {
updateUserString: string updateUserString: string
updateTime: string updateTime: string
} }
export interface DictQuery { export interface DictQuery {
description?: string description?: string
sort: Array<string> sort: Array<string>
} }
export interface DictPageQuery extends DictQuery, PageQuery {}
export interface DictPageQuery extends DictQuery, PageQuery {
}
export type DictItemResp = { export type DictItemResp = {
id: string id: string
label: string label: string
@@ -149,13 +163,16 @@ export type DictItemResp = {
updateUserString: string updateUserString: string
updateTime: string updateTime: string
} }
export interface DictItemQuery { export interface DictItemQuery {
description?: string description?: string
status?: number status?: number
sort: Array<string> sort: Array<string>
dictId: string dictId: string
} }
export interface DictItemPageQuery extends DictItemQuery, PageQuery {}
export interface DictItemPageQuery extends DictItemQuery, PageQuery {
}
/** 系统公告类型 */ /** 系统公告类型 */
export interface NoticeResp { export interface NoticeResp {
@@ -171,12 +188,15 @@ export interface NoticeResp {
updateUserString: string updateUserString: string
updateTime: string updateTime: string
} }
export interface NoticeQuery { export interface NoticeQuery {
title?: string title?: string
type?: string type?: string
sort: Array<string> sort: Array<string>
} }
export interface NoticePageQuery extends NoticeQuery, PageQuery {}
export interface NoticePageQuery extends NoticeQuery, PageQuery {
}
/** 系统文件类型 */ /** 系统文件类型 */
export type FileItem = { export type FileItem = {
@@ -184,6 +204,8 @@ export type FileItem = {
name: string name: string
size: number size: number
url: string url: string
thumbnailSize: number
thumbnailUrl: string
extension: string extension: string
type: number type: number
storageId: string storageId: string
@@ -192,19 +214,24 @@ export type FileItem = {
updateUserString: string updateUserString: string
updateTime: string updateTime: string
} }
/** 文件资源统计信息 */ /** 文件资源统计信息 */
export interface FileStatisticsResp { export interface FileStatisticsResp {
type: string type: string
size: number size: any
number: number number: number
unit: string
data: Array<FileStatisticsResp> data: Array<FileStatisticsResp>
} }
export interface FileQuery { export interface FileQuery {
name?: string name?: string
type?: string type?: string
sort: Array<string> sort: Array<string>
} }
export interface FilePageQuery extends FileQuery, PageQuery {}
export interface FilePageQuery extends FileQuery, PageQuery {
}
/** 系统存储类型 */ /** 系统存储类型 */
export type StorageResp = { export type StorageResp = {
@@ -226,12 +253,15 @@ export type StorageResp = {
updateUserString: string updateUserString: string
updateTime: string updateTime: string
} }
export interface StorageQuery { export interface StorageQuery {
description?: string description?: string
status?: number status?: number
sort: Array<string> sort: Array<string>
} }
export interface StoragePageQuery extends StorageQuery, PageQuery {}
export interface StoragePageQuery extends StorageQuery, PageQuery {
}
/** 系统参数类型 */ /** 系统参数类型 */
export interface OptionResp { export interface OptionResp {
@@ -240,9 +270,11 @@ export interface OptionResp {
value: string value: string
description: string description: string
} }
export interface OptionQuery { export interface OptionQuery {
code: Array<string> code: Array<string>
} }
/** 基础配置类型 */ /** 基础配置类型 */
export interface BasicConfigResp { export interface BasicConfigResp {
site_favicon: string site_favicon: string

View File

@@ -9,8 +9,10 @@
</a-statistic> </a-statistic>
<a-statistic class="statistic-item" title="数量" :value="totalData.number" :value-style="statisticValueStyle" /> <a-statistic class="statistic-item" title="数量" :value="totalData.number" :value-style="statisticValueStyle" />
</a-space> </a-space>
<a-divider /> <div v-if="chartData.length > 0">
<VCharts :option="option" autoresize :style="{ height: '120px', width: '150px' }" /> <a-divider />
<VCharts :option="option" autoresize :style="{ height: '120px', width: '150px' }" />
</div>
</section> </section>
</template> </template>
@@ -27,8 +29,14 @@ import { formatFileSize } from '@/utils'
use([TitleComponent, TooltipComponent, LegendComponent, PieChart, CanvasRenderer]) use([TitleComponent, TooltipComponent, LegendComponent, PieChart, CanvasRenderer])
const totalData = ref<FileStatisticsResp>({}) const totalData = ref<FileStatisticsResp>({
const chartData = ref<Array<FileStatisticsResp>>([]) type: '',
size: 0,
number: 0,
unit: '',
data: []
})
const chartData = ref<Array<{ name: string, value: number, size: string }>>([])
const statisticValueStyle = { 'color': '#5856D6', 'font-size': '18px' } const statisticValueStyle = { 'color': '#5856D6', 'font-size': '18px' }
const { option } = useChart(() => { const { option } = useChart(() => {
return { return {
@@ -74,13 +82,14 @@ const getStatisticsData = async () => {
try { try {
loading.value = true loading.value = true
chartData.value = [] chartData.value = []
totalData.value = {}
const { data: resData } = await getFileStatistics() const { data: resData } = await getFileStatistics()
const formatSize = formatFileSize(resData.size).split(' ') const formatSize = formatFileSize(resData.size).split(' ')
totalData.value = { totalData.value = {
type: '',
size: Number.parseFloat(formatSize[0]), size: Number.parseFloat(formatSize[0]),
number: resData.number, number: resData.number ?? 0,
unit: formatSize[1] unit: formatSize[1],
data: []
} }
resData.data.forEach((fs: FileStatisticsResp) => { resData.data.forEach((fs: FileStatisticsResp) => {
const matchedItem = FileTypeList.find((item) => item.value === fs.type) const matchedItem = FileTypeList.find((item) => item.value === fs.type)

View File

@@ -1,5 +1,5 @@
<template> <template>
<img v-if="isImage" class="file-image" :src="props.data.url" alt="" /> <img v-if="isImage" class="file-image" :src="props.data.thumbnailUrl" alt="" />
<GiSvgIcon v-else size="100%" :name="getFileImg"></GiSvgIcon> <GiSvgIcon v-else size="100%" :name="getFileImg"></GiSvgIcon>
</template> </template>