bb67aaf5a6
Squashed commit of the following: commit 146f106fbece251606f358141bda3d9c524c3e93 Author: Sun <95302870@qq.com> Date: Thu Dec 28 19:39:36 2023 +0800 修改默认宽度 commit 827197e295b2b0997902b8f965d14ab2598c5c1b Author: Sun <95302870@qq.com> Date: Thu Dec 28 17:54:25 2023 +0800 修复升级掉登录的问题 commit 2e54326f5fe2b8fac4eed488a14b04b8133c41bb Author: Sun <95302870@qq.com> Date: Thu Dec 28 17:21:49 2023 +0800 优化边距等提示 commit 469c6fd644a2a23d96405d15456980edfdfb17b0 Author: Sun <95302870@qq.com> Date: Thu Dec 28 17:21:34 2023 +0800 搜索栏选择搜索引擎后关闭选择器 commit 632da9635a4a434d361495dfcb83f8b650cb4a3c Author: Sun <95302870@qq.com> Date: Thu Dec 28 16:54:28 2023 +0800 增加 内容左右边距和最大宽度 commit f1cc3dce2a51ec60c1b04f21954b99b284b2df61 Author: Sun <95302870@qq.com> Date: Thu Dec 28 14:24:23 2023 +0800 分组标题增加阴影 commit 7615a29678037362c18632f38caad72e07a32d1a Author: Sun <95302870@qq.com> Date: Thu Dec 28 14:18:41 2023 +0800 更改版本号1.2.1 commit b605374e951d3fb2ca52d36bd0fa82aec4a5e89b Author: Sun <95302870@qq.com> Date: Thu Dec 28 14:11:06 2023 +0800 优化小部分网站图标获取失败的问题 commit c8141184a14fb02f941bbec03ac98f59f8b12d4b Author: Sun <95302870@qq.com> Date: Thu Dec 28 13:00:56 2023 +0800 优化上传管理界面
190 lines
6.1 KiB
Vue
190 lines
6.1 KiB
Vue
<script setup lang="ts">
|
|
import { NAlert, NButton, NButtonGroup, NCard, NEllipsis, NGrid, NGridItem, NImage, NImageGroup, NSpin, useDialog, useMessage } from 'naive-ui'
|
|
import { onMounted, ref } from 'vue'
|
|
import { deletes, getList } from '@/api/system/file'
|
|
import { set as savePanelConfig } from '@/api/panel/userConfig'
|
|
import { RoundCardModal, SvgIcon } from '@/components/common'
|
|
import { copyToClipboard, timeFormat } from '@/utils/cmn'
|
|
import { t } from '@/locales'
|
|
import { usePanelState } from '@/store'
|
|
|
|
interface InfoModalState {
|
|
title: string
|
|
show: boolean
|
|
fileInfo: File.Info | null
|
|
}
|
|
const imageList = ref<File.Info[]>([])
|
|
const ms = useMessage()
|
|
const dialog = useDialog()
|
|
const panelStore = usePanelState()
|
|
const loading = ref(false)
|
|
const infoModalState = ref<InfoModalState>({
|
|
show: false,
|
|
title: '',
|
|
fileInfo: null,
|
|
})
|
|
|
|
async function getFileList() {
|
|
loading.value = true
|
|
const { data } = await getList<Common.ListResponse<File.Info[]>>()
|
|
imageList.value = data.list
|
|
loading.value = false
|
|
}
|
|
|
|
async function copyImageUrl(text: string) {
|
|
const res = await copyToClipboard(text)
|
|
if (res)
|
|
ms.success(t('apps.uploadsFileManager.copySuccess'))
|
|
|
|
else
|
|
ms.error(t('apps.uploadsFileManager.copyFailed'))
|
|
}
|
|
|
|
function handleDelete(id: number) {
|
|
dialog.warning({
|
|
title: t('common.warning'),
|
|
content: t('apps.uploadsFileManager.deleteWarningText'),
|
|
positiveText: t('common.confirm'),
|
|
negativeText: t('common.cancel'),
|
|
onPositiveClick: () => {
|
|
deletesImges(id)
|
|
},
|
|
})
|
|
}
|
|
|
|
async function deletesImges(id: number) {
|
|
try {
|
|
const { code, msg } = await deletes([id])
|
|
if (code === 0) {
|
|
getFileList()
|
|
ms.success(t('common.success'))
|
|
}
|
|
else {
|
|
ms.error(`${t('common.failed')}:${msg}`)
|
|
}
|
|
}
|
|
catch (error) {
|
|
ms.error(t('common.failed'))
|
|
}
|
|
}
|
|
|
|
function handleInfoClick(fileInfo: File.Info) {
|
|
infoModalState.value.fileInfo = fileInfo
|
|
infoModalState.value.show = true
|
|
}
|
|
|
|
function handleSetWallpaper(imgSrc: string) {
|
|
panelStore.panelConfig.backgroundImageSrc = imgSrc
|
|
savePanelConfig({ panel: panelStore.panelConfig })
|
|
}
|
|
|
|
onMounted(() => {
|
|
getFileList()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="bg-slate-200 p-2 h-full">
|
|
<NSpin v-show="loading" size="small" />
|
|
<NAlert type="info" :bordered="false">
|
|
{{ $t('apps.uploadsFileManager.alertText') }}
|
|
</NAlert>
|
|
<div class="flex justify-center mt-2">
|
|
<div v-if="imageList.length === 0 && !loading" class="flex">
|
|
{{ $t('apps.uploadsFileManager.nothingText') }}
|
|
</div>
|
|
<NImageGroup v-else>
|
|
<NGrid cols="2 300:2 600:4 900:6 1100:9" :x-gap="5" :y-gap="5">
|
|
<NGridItem v-for=" item, index in imageList" :key="index">
|
|
<NCard size="small" style="border-radius: 5px;" :bordered="true">
|
|
<template #cover>
|
|
<div class="card transparent-grid">
|
|
<NImage :lazy="true" style="object-fit: contain;height: 100%;" :src="item.src" />
|
|
</div>
|
|
</template>
|
|
<template #footer>
|
|
<span class="text-xs">
|
|
<NEllipsis>
|
|
{{ item.fileName }}
|
|
</NEllipsis>
|
|
</span>
|
|
<div class="flex justify-center mt-[10px]">
|
|
<NButtonGroup>
|
|
<NButton size="tiny" tertiary style="cursor: pointer;" :title="$t('apps.uploadsFileManager.copyLink')" @click="copyImageUrl(item.src)">
|
|
<template #icon>
|
|
<SvgIcon icon="ion-copy" />
|
|
</template>
|
|
</NButton>
|
|
<NButton size="tiny" tertiary style="cursor: pointer;" :title="timeFormat(item.createTime)" @click="handleInfoClick(item)">
|
|
<template #icon>
|
|
<SvgIcon icon="mdi-information-box-outline" />
|
|
</template>
|
|
</NButton>
|
|
<NButton size="tiny" tertiary style="cursor: pointer;" :title="$t('apps.uploadsFileManager.setWallpaper')" @click="handleSetWallpaper(item.src)">
|
|
<template #icon>
|
|
<SvgIcon icon="lucide:wallpaper" />
|
|
</template>
|
|
</NButton>
|
|
<NButton size="tiny" tertiary type="error" style="cursor: pointer;" :title="$t('common.delete')" @click="handleDelete(item.id as number)">
|
|
<template #icon>
|
|
<SvgIcon icon="material-symbols-delete" />
|
|
</template>
|
|
</NButton>
|
|
</NButtonGroup>
|
|
</div>
|
|
</template>
|
|
</NCard>
|
|
</NGridItem>
|
|
</NGrid>
|
|
</NImageGroup>
|
|
</div>
|
|
|
|
<RoundCardModal v-model:show="infoModalState.show" style="max-width: 300px;" size="small" :title="$t('apps.uploadsFileManager.infoTitle')">
|
|
<div>
|
|
<div>
|
|
<div class="mb-2">
|
|
<span class="text-slate-500">
|
|
{{ $t('apps.uploadsFileManager.fileName') }}
|
|
</span>
|
|
<div class="text-xs">
|
|
{{ infoModalState.fileInfo?.fileName }}
|
|
</div>
|
|
</div>
|
|
<div class="mb-2">
|
|
<span class="text-slate-500">
|
|
{{ $t('apps.uploadsFileManager.path') }}
|
|
</span>
|
|
<div class="text-xs">
|
|
{{ infoModalState.fileInfo?.src }}
|
|
</div>
|
|
</div>
|
|
<div class="mb-2">
|
|
<span class="text-slate-500">
|
|
{{ $t('apps.uploadsFileManager.uploadTime') }}
|
|
</span>
|
|
<div class="text-xs">
|
|
{{ timeFormat(infoModalState.fileInfo?.createTime) }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</RoundCardModal>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.card {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 80px;
|
|
}
|
|
|
|
.transparent-grid {
|
|
background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%),
|
|
linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%);
|
|
background-size: 16px 16px;
|
|
background-position: 0 0, 8px 8px;
|
|
}
|
|
</style>
|