feat: file copy url
parent
110a352a1c
commit
dc98ffb224
|
@ -2,7 +2,7 @@ import { BasicColumn, FormSchema, useRender } from '@/components/Table'
|
|||
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '日志编号',
|
||||
title: '编号',
|
||||
dataIndex: 'id',
|
||||
width: 100
|
||||
},
|
||||
|
@ -11,15 +11,10 @@ export const columns: BasicColumn[] = [
|
|||
dataIndex: 'name',
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
title: '文件路径',
|
||||
dataIndex: 'path',
|
||||
width: 250
|
||||
},
|
||||
{
|
||||
title: '文件 URL',
|
||||
dataIndex: 'url',
|
||||
width: 300,
|
||||
width: 180,
|
||||
customRender: ({ text }) => {
|
||||
return useRender.renderImg(text)
|
||||
}
|
||||
|
@ -32,7 +27,7 @@ export const columns: BasicColumn[] = [
|
|||
{
|
||||
title: '文件大小',
|
||||
dataIndex: 'size',
|
||||
width: 180,
|
||||
width: 120,
|
||||
customRender: ({ text }) => {
|
||||
const unitArr = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
const srcSize = parseFloat(text)
|
||||
|
@ -44,7 +39,10 @@ export const columns: BasicColumn[] = [
|
|||
{
|
||||
title: '文件类型',
|
||||
dataIndex: 'type',
|
||||
width: 180
|
||||
width: 100,
|
||||
customRender: ({ text }) => {
|
||||
return useRender.renderTag(text)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '文件内容',
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<template v-if="column.key === 'action'">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{ icon: IconEnum.VIEW, label: '复制链接', onClick: handleCopy.bind(null, record) },
|
||||
{
|
||||
icon: IconEnum.DELETE,
|
||||
color: 'error',
|
||||
|
@ -36,9 +37,10 @@
|
|||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="InfraFile">
|
||||
import { ref } from 'vue'
|
||||
import { ref, unref } from 'vue'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useMessage } from '@/hooks/web/useMessage'
|
||||
import { useCopyToClipboard } from '@/hooks/web/useCopyToClipboard'
|
||||
import { IconEnum } from '@/enums/appEnum'
|
||||
import { BasicUpload } from '@/components/Upload'
|
||||
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
||||
|
@ -49,6 +51,7 @@ import { uploadApi } from '@/api/base/upload'
|
|||
|
||||
const { t } = useI18n()
|
||||
const { createMessage } = useMessage()
|
||||
const { clipboardRef, copiedRef } = useCopyToClipboard()
|
||||
|
||||
const uploadParams = ref({
|
||||
Authorization: 'Bearer ' + getAccessToken(),
|
||||
|
@ -75,6 +78,13 @@ function handleChange() {
|
|||
reload()
|
||||
}
|
||||
|
||||
function handleCopy(record: Recordable) {
|
||||
clipboardRef.value = record.url
|
||||
if (unref(copiedRef)) {
|
||||
createMessage.warning('复制成功')
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
await deleteFile(record.id)
|
||||
createMessage.success(t('common.delSuccessText'))
|
||||
|
|
Loading…
Reference in New Issue