From 6f45facc1becf4f74b00f3bac78ced8bb23f16b7 Mon Sep 17 00:00:00 2001 From: Double-_-Z <2492419643@qq.com> Date: Thu, 26 Dec 2024 20:16:59 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D+=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/download/index.ts | 2 +- src/utils/request.ts | 17 ++++++++++---- src/views/photos/index.vue | 34 +++++++++++++++------------- src/views/service/shares/index.vue | 23 ++++++++++--------- src/views/video/component/upload.vue | 2 +- 5 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/api/download/index.ts b/src/api/download/index.ts index 305a116..9eb29d9 100644 --- a/src/api/download/index.ts +++ b/src/api/download/index.ts @@ -11,7 +11,7 @@ const downloadPhoto = (imgSrc:any) => { const url = window.URL.createObjectURL(res.data); const a = document.createElement('a'); a.href = url; - a.download = '下载图片.jpg'; + a.download = '下载图片.'+ imgSrc.substr(imgSrc.lastIndexOf('.')+1) || 'jpg'; document.body.appendChild(a); a.click(); document.body.removeChild(a); diff --git a/src/utils/request.ts b/src/utils/request.ts index 1b4c424..b9c5aeb 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -38,14 +38,21 @@ service.interceptors.response.use( const res = response.data; if (res.code && res.code !== 0) { // `token` 过期或者账号已在别处登录 - if (res.code === 401 || res.code === 4001) { - Session.clear(); // 清除浏览器全部临时缓存 - window.location.href = '/'; // 去登录页 + if (res.code === 401 || res.code === 4001 || (res.code === 502 && res.errorMsg==='只有登录成功后才可访问')) { + // ElMessage.error('该账户已在其它地方登录,请重新登录'); ElMessageBox.alert('你已被登出,请重新登录', '提示', {}) - .then(() => {}) - .catch(() => {}); + .then(() => { + Session.clear(); // 清除浏览器全部临时缓存 + window.location.href = '/'; // 去登录页 + }) + .catch(() => { + Session.clear(); // 清除浏览器全部临时缓存 + window.location.href = '/'; // 去登录页 + }); } // else if(res.code === 502 && res.errorMsg){ + // console.log(res.errorMsg); + // return res; // } return Promise.reject(service.interceptors.response); diff --git a/src/views/photos/index.vue b/src/views/photos/index.vue index 3bcb476..7bdaef5 100644 --- a/src/views/photos/index.vue +++ b/src/views/photos/index.vue @@ -322,15 +322,14 @@ const viteUrl = import.meta.env.VITE_API_URL; // 图片链接格式化 const jpgFormatter = (row: any) => { - let newPath; - if (row?.data) { - newPath = row.data.path.replaceAll('\\', '/') - } else { - newPath = row.path.replaceAll('\\\\', '/') - } - newPath = newPath.includes('http://8.138.171.103/')||newPath.includes('http://guojunjie.oss-cn-hangzhou.aliyuncs.com/') ? - newPath : encodeURI(viteUrl + newPath) - // console.log(newPath); + let newPath = row?.data ? row.data.path : row.path; + // if (row?.data) { + // newPath = row.data.path.replaceAll('\\', '/') + // } else { + // newPath = row.path.replaceAll('\\\\', '/') + // } + newPath = newPath.includes(viteUrl)||newPath.includes('http://8.138.171.103/')||newPath.includes('http://guojunjie.oss-cn-hangzhou.aliyuncs.com/') ? + newPath : encodeURI(newPath) return `${newPath}`; } @@ -475,13 +474,16 @@ const handleRemove = (file: UploadFile, uploadFiles) => { //下载图片 const download = async(row:any) =>{ state.formData.loading = true; - let newPath; - if (row?.data) { - newPath = row.data.path.replaceAll('\\', '/') - } else { - newPath = row.path.replaceAll('\\\\', '/') - } - newPath = newPath.includes('http://localhost:8888/') ? newPath : viteUrl + newPath + // let newPath; + // if (row?.data) { + // newPath = row.data.path.replaceAll('\\', '/') + // } else { + // newPath = row.path.replaceAll('\\\\', '/') + // } + // newPath = newPath.includes('http://localhost:8888/') ? newPath : viteUrl + newPath + let newPath = row?.data ? row.data.path : row.path; + newPath = newPath.includes(viteUrl)||newPath.includes('http://8.138.171.103/')||newPath.includes('http://guojunjie.oss-cn-hangzhou.aliyuncs.com/') ? + newPath : encodeURI(newPath); try{ await downloadPhoto(newPath); }catch(error){ diff --git a/src/views/service/shares/index.vue b/src/views/service/shares/index.vue index 0180cd8..50dd230 100644 --- a/src/views/service/shares/index.vue +++ b/src/views/service/shares/index.vue @@ -34,18 +34,19 @@ @@ -63,7 +64,7 @@ > - +
@@ -88,8 +89,8 @@ import { sharesApi } from '/@/api/service/shares'; import { ElMessage, ElMessageBox, TableColumnCtx } from 'element-plus'; // 引入组件 -const MessageDialog = defineAsyncComponent(() => import('/@/views/message/dialog.vue')); -const messageDialogRef = ref(); +// const MessageDialog = defineAsyncComponent(() => import('/@/views/message/dialog.vue')); +// const messageDialogRef = ref(); // 表格数据 const state = reactive({ @@ -117,7 +118,7 @@ const state = reactive({ // 状态列表 const statusList = ref([ - {label: '未发布', value: 0}, + // {label: '未发布', value: ''}, {label: '审核中', value: 1}, {label: '通过', value: 2}, {label: '未通过', value: 3}, @@ -154,9 +155,9 @@ const reset = () =>{ } // 文章详情 -const toShowDetail = (id: any) => { - messageDialogRef.value.openDialog(id); -} +// const toShowDetail = (id: any) => { +// messageDialogRef.value.openDialog(id); +// } const replayFormRef = ref(); diff --git a/src/views/video/component/upload.vue b/src/views/video/component/upload.vue index e22025a..b8b667b 100644 --- a/src/views/video/component/upload.vue +++ b/src/views/video/component/upload.vue @@ -169,7 +169,7 @@ const getVideoDetail = async () => { // 下面这里处理一下,因为后端返回的是0和1,而前端需要的是true和false,到时候提交的时候再转换回来 // 这个报错没关系的,只是ts的语法检查,不影响运行 if (state.data.path) { - const never: any = [{ name: state.data.name, url: viteUrl + state.data.path }]; + const never: any = [{ name: state.data.name, url: state.data.path }]; state.fileArray = never; state.coverHide = true; }