diff --git a/src/views/attachment/component/detail.vue b/src/views/attachment/component/detail.vue index 2c76646..06a9f69 100644 --- a/src/views/attachment/component/detail.vue +++ b/src/views/attachment/component/detail.vue @@ -5,17 +5,17 @@ - {{ state.data.moduleName }} + {{ state.data.moduleName || '暂无' }} - {{ state.data.labelName }} + {{ state.data.labelName || '暂无' }} - {{ state.data.name }} + {{ state.data.name || '暂无' }} @@ -30,8 +30,9 @@
- 附件图片 @@ -105,14 +106,16 @@ const textContent = ref(''); const determineFileType = async () => { console.log(state.data); if (!state.data.path) return; - const normalizedPath = state.data.path.replace(/\\/g, '/'); // 替换反斜杠为正斜杠 - const extension = normalizedPath.split('.').pop()?.toLowerCase(); + const normalizedPath = encodeURI(state.data.path); // 替换反斜杠为正斜杠 + // const extension = normalizedPath.split('.').pop()?.toLowerCase(); + const extension = normalizedPath?.toLowerCase(); console.log(extension); - if (['mp4', 'avi', 'mov'].includes(extension || '')) { + + if (/\.(mp4|avi|mov)/.test(extension)) { fileType.value = 'video'; - } else if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(extension || '')) { + } else if (/\.(jpg|jpeg|png|gif|bmp)/.test(extension)) { fileType.value = 'image'; - } else if (['txt', 'log', 'md'].includes(extension || '')) { + } else if (/\.(txt|log|md)/.test(extension)) { fileType.value = 'text'; try { const response = await fetch(viteUrl + normalizedPath); @@ -166,6 +169,14 @@ const getAttachmentDetailById = async (id: number) => { } }; +// 图片链接格式化 +const jpgFormatter = (row: any) => { + let newPath = row?.data ? row.data.path : row.path; + newPath = newPath.includes('://')?newPath : encodeURI(newPath); + + return `${newPath}`; +} + // 获取模块列表 const getModuleList = async () => { try { diff --git a/src/views/attachment/index.vue b/src/views/attachment/index.vue index 32d361e..8fa35e8 100644 --- a/src/views/attachment/index.vue +++ b/src/views/attachment/index.vue @@ -43,10 +43,10 @@ ref="tableRef" > - - - - + + + +