上传文件401提示登录

main
吕天方 5 months ago
parent 7296b32051
commit a263a2adb0

@ -8,7 +8,7 @@ ENV = 'development'
# VUE_APP_BASE_API = 'http://localhost:9035'
# VUE_APP_BASE_API = 'https://vue.ruoyi.vip/prod-api'
# VUE_APP_BASE_API = 'http://39.101.188.84:9035'
VUE_APP_BASE_API = 'http://192.168.0.109:9035'
VUE_APP_BASE_API = 'http://192.168.0.108:9035'

@ -41,7 +41,7 @@
<script>
import { getToken } from "@/utils/auth";
import { MessageBox } from 'element-ui'
export default {
name: "FileUpload",
props: {
@ -150,11 +150,25 @@ export default {
this.uploadList.push({ name: res.originalFilename, url: res.fileName });
this.uploadedSuccessfully();
} else {
this.number--;
this.$modal.closeLoading();
this.$modal.msgError(res.msg);
this.$refs.fileUpload.handleRemove(file);
this.uploadedSuccessfully();
if(res.code == 401) {
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
this.$store.dispatch('LogOut').then(() => {
location.href = '/tczzpc';
})
}).catch(err=>{
this.number--;
this.$refs.fileUpload.handleRemove(file);
this.uploadedSuccessfully();
})
} else {
this.number--;
this.$modal.closeLoading();
this.$modal.msgError(res.msg);
this.$refs.fileUpload.handleRemove(file);
this.uploadedSuccessfully();
}
}
},
//

@ -85,15 +85,15 @@ service.interceptors.response.use(res => {
if (code === 401) {
if (!isRelogin.show) {
isRelogin.show = true;
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
isRelogin.show = false;
store.dispatch('LogOut').then(() => {
location.href = '/index';
})
}).catch(() => {
isRelogin.show = false;
store.dispatch('LogOut').then(() => {
location.href = '/index';
})
}).catch(() => {
isRelogin.show = false;
});
}
});
}
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
Message({ message: msg, type: 'error' })

Loading…
Cancel
Save