bug修复+请求拦截
This commit is contained in:
parent
58a0257c30
commit
6f45facc1b
@ -11,7 +11,7 @@ const downloadPhoto = (imgSrc:any) => {
|
|||||||
const url = window.URL.createObjectURL(res.data);
|
const url = window.URL.createObjectURL(res.data);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = '下载图片.jpg';
|
a.download = '下载图片.'+ imgSrc.substr(imgSrc.lastIndexOf('.')+1) || 'jpg';
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
|
@ -38,14 +38,21 @@ service.interceptors.response.use(
|
|||||||
const res = response.data;
|
const res = response.data;
|
||||||
if (res.code && res.code !== 0) {
|
if (res.code && res.code !== 0) {
|
||||||
// `token` 过期或者账号已在别处登录
|
// `token` 过期或者账号已在别处登录
|
||||||
if (res.code === 401 || res.code === 4001) {
|
if (res.code === 401 || res.code === 4001 || (res.code === 502 && res.errorMsg==='只有登录成功后才可访问')) {
|
||||||
Session.clear(); // 清除浏览器全部临时缓存
|
// ElMessage.error('该账户已在其它地方登录,请重新登录');
|
||||||
window.location.href = '/'; // 去登录页
|
|
||||||
ElMessageBox.alert('你已被登出,请重新登录', '提示', {})
|
ElMessageBox.alert('你已被登出,请重新登录', '提示', {})
|
||||||
.then(() => {})
|
.then(() => {
|
||||||
.catch(() => {});
|
Session.clear(); // 清除浏览器全部临时缓存
|
||||||
|
window.location.href = '/'; // 去登录页
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
Session.clear(); // 清除浏览器全部临时缓存
|
||||||
|
window.location.href = '/'; // 去登录页
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// else if(res.code === 502 && res.errorMsg){
|
// else if(res.code === 502 && res.errorMsg){
|
||||||
|
// console.log(res.errorMsg);
|
||||||
|
|
||||||
// return res;
|
// return res;
|
||||||
// }
|
// }
|
||||||
return Promise.reject(service.interceptors.response);
|
return Promise.reject(service.interceptors.response);
|
||||||
|
@ -322,15 +322,14 @@ const viteUrl = import.meta.env.VITE_API_URL;
|
|||||||
|
|
||||||
// 图片链接格式化
|
// 图片链接格式化
|
||||||
const jpgFormatter = (row: any) => {
|
const jpgFormatter = (row: any) => {
|
||||||
let newPath;
|
let newPath = row?.data ? row.data.path : row.path;
|
||||||
if (row?.data) {
|
// if (row?.data) {
|
||||||
newPath = row.data.path.replaceAll('\\', '/')
|
// newPath = row.data.path.replaceAll('\\', '/')
|
||||||
} else {
|
// } else {
|
||||||
newPath = row.path.replaceAll('\\\\', '/')
|
// newPath = row.path.replaceAll('\\\\', '/')
|
||||||
}
|
// }
|
||||||
newPath = newPath.includes('http://8.138.171.103/')||newPath.includes('http://guojunjie.oss-cn-hangzhou.aliyuncs.com/') ?
|
newPath = newPath.includes(viteUrl)||newPath.includes('http://8.138.171.103/')||newPath.includes('http://guojunjie.oss-cn-hangzhou.aliyuncs.com/') ?
|
||||||
newPath : encodeURI(viteUrl + newPath)
|
newPath : encodeURI(newPath)
|
||||||
// console.log(newPath);
|
|
||||||
|
|
||||||
return `${newPath}`;
|
return `${newPath}`;
|
||||||
}
|
}
|
||||||
@ -475,13 +474,16 @@ const handleRemove = (file: UploadFile, uploadFiles) => {
|
|||||||
//下载图片
|
//下载图片
|
||||||
const download = async(row:any) =>{
|
const download = async(row:any) =>{
|
||||||
state.formData.loading = true;
|
state.formData.loading = true;
|
||||||
let newPath;
|
// let newPath;
|
||||||
if (row?.data) {
|
// if (row?.data) {
|
||||||
newPath = row.data.path.replaceAll('\\', '/')
|
// newPath = row.data.path.replaceAll('\\', '/')
|
||||||
} else {
|
// } else {
|
||||||
newPath = row.path.replaceAll('\\\\', '/')
|
// newPath = row.path.replaceAll('\\\\', '/')
|
||||||
}
|
// }
|
||||||
newPath = newPath.includes('http://localhost:8888/') ? newPath : viteUrl + newPath
|
// 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{
|
try{
|
||||||
await downloadPhoto(newPath);
|
await downloadPhoto(newPath);
|
||||||
}catch(error){
|
}catch(error){
|
||||||
|
@ -34,18 +34,19 @@
|
|||||||
<!-- <el-table-column prop="type" label="类型" show-overflow-tooltip></el-table-column> -->
|
<!-- <el-table-column prop="type" label="类型" show-overflow-tooltip></el-table-column> -->
|
||||||
<el-table-column prop="reviewStatus" align="center" label="审核结果" show-overflow-tooltip>
|
<el-table-column prop="reviewStatus" align="center" label="审核结果" show-overflow-tooltip>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag v-if="scope.row.reviewStatus === 0">未发布</el-tag>
|
<el-tag v-if="scope.row.reviewStatus === 1" type="warning">审核中</el-tag>
|
||||||
<el-tag v-else-if="scope.row.reviewStatus === 1" type="warning">审核中</el-tag>
|
|
||||||
<el-tag v-else-if="scope.row.reviewStatus === 2" type="success">通过</el-tag>
|
<el-tag v-else-if="scope.row.reviewStatus === 2" type="success">通过</el-tag>
|
||||||
<el-tag v-else-if="scope.row.reviewStatus === 3" type="danger">未通过</el-tag>
|
<el-tag v-else-if="scope.row.reviewStatus === 3" type="danger">未通过</el-tag>
|
||||||
|
<el-tag v-else>未发布</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="createtime" align="center" label="时间" :formatter="dateFormatter" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="createtime" align="center" label="时间" :formatter="dateFormatter" show-overflow-tooltip></el-table-column>
|
||||||
<el-table-column label="操作" width="200" align="center">
|
<el-table-column label="操作" width="200" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<!-- <el-button size="small" text type="primary" @click="toShowDetail(scope.row.id)">查看详情</el-button> -->
|
<!-- <el-button size="small" text type="primary" @click="toShowDetail(scope.row.id)">查看详情</el-button> -->
|
||||||
<el-button size="small" v-if="scope.row.reviewStatus === 0" text type="primary" @click="audit(scope.row)">审核</el-button>
|
<el-button size="small" v-if="scope.row.reviewStatus === 1" text type="primary" @click="audit(scope.row)">审核</el-button>
|
||||||
<el-button size="small" v-else-if="scope.row.reviewStatus === 0" text type="primary" @click="toPublic(scope.row)">发布</el-button>
|
<el-button size="small" v-else-if="scope.row.reviewStatus === null" text type="primary" @click="toPublic(scope.row)">发布</el-button>
|
||||||
|
<el-button size="small" v-else text type="primary" @click="audit(scope.row)">重新审核</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -63,7 +64,7 @@
|
|||||||
>
|
>
|
||||||
</el-pagination>
|
</el-pagination>
|
||||||
</el-card>
|
</el-card>
|
||||||
<MessageDialog ref="messageDialogRef" />
|
<!-- <MessageDialog ref="messageDialogRef" /> -->
|
||||||
<!-- 回复弹窗 -->
|
<!-- 回复弹窗 -->
|
||||||
<el-dialog style="height: 200px;" :title="state.auditDialog.title" v-model="state.auditDialog.show" width="400px">
|
<el-dialog style="height: 200px;" :title="state.auditDialog.title" v-model="state.auditDialog.show" width="400px">
|
||||||
<div class="dialog-content">
|
<div class="dialog-content">
|
||||||
@ -88,8 +89,8 @@ import { sharesApi } from '/@/api/service/shares';
|
|||||||
import { ElMessage, ElMessageBox, TableColumnCtx } from 'element-plus';
|
import { ElMessage, ElMessageBox, TableColumnCtx } from 'element-plus';
|
||||||
|
|
||||||
// 引入组件
|
// 引入组件
|
||||||
const MessageDialog = defineAsyncComponent(() => import('/@/views/message/dialog.vue'));
|
// const MessageDialog = defineAsyncComponent(() => import('/@/views/message/dialog.vue'));
|
||||||
const messageDialogRef = ref();
|
// const messageDialogRef = ref();
|
||||||
|
|
||||||
// 表格数据
|
// 表格数据
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@ -117,7 +118,7 @@ const state = reactive({
|
|||||||
|
|
||||||
// 状态列表
|
// 状态列表
|
||||||
const statusList = ref([
|
const statusList = ref([
|
||||||
{label: '未发布', value: 0},
|
// {label: '未发布', value: ''},
|
||||||
{label: '审核中', value: 1},
|
{label: '审核中', value: 1},
|
||||||
{label: '通过', value: 2},
|
{label: '通过', value: 2},
|
||||||
{label: '未通过', value: 3},
|
{label: '未通过', value: 3},
|
||||||
@ -154,9 +155,9 @@ const reset = () =>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 文章详情
|
// 文章详情
|
||||||
const toShowDetail = (id: any) => {
|
// const toShowDetail = (id: any) => {
|
||||||
messageDialogRef.value.openDialog(id);
|
// messageDialogRef.value.openDialog(id);
|
||||||
}
|
// }
|
||||||
|
|
||||||
const replayFormRef = ref();
|
const replayFormRef = ref();
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ const getVideoDetail = async () => {
|
|||||||
// 下面这里处理一下,因为后端返回的是0和1,而前端需要的是true和false,到时候提交的时候再转换回来
|
// 下面这里处理一下,因为后端返回的是0和1,而前端需要的是true和false,到时候提交的时候再转换回来
|
||||||
// 这个报错没关系的,只是ts的语法检查,不影响运行
|
// 这个报错没关系的,只是ts的语法检查,不影响运行
|
||||||
if (state.data.path) {
|
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.fileArray = never;
|
||||||
state.coverHide = true;
|
state.coverHide = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user