优化错误码弹窗

This commit is contained in:
likun 2025-05-08 18:13:42 +08:00
parent 9d2f572c35
commit 902059e11b
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,27 @@
<script setup>
const props = defineProps({
data: {}
})
console.log("打开errcodeDetaildata:", props.data)
let tipContent = "<span style='font-size: 20px;color: red'>错误详情:</span><span style='font-size: 20px'>"
tipContent += props.data.detail_msg
tipContent += "<br/>"
tipContent += "<span style='font-size: 20px;color: red'>出错代码:</span>"
tipContent += props.data.stack
tipContent += "</span>"
</script>
<template>
<div>
<el-tooltip :content="tipContent" raw-content placement="bottom" effect="light" style="font-size: 20px">
<span style="font-size: 20px">原因{{ data.msg }}</span>
</el-tooltip>
</div>
</template>
<style scoped>
</style>

View File

@ -5,6 +5,8 @@ import {useRouter} from "vue-router";
import LocalCache from "@/stores/localCache.js";
// import ExpireCache from "@/stores/expireCache";
import errcodeDetail from '@/components/widget/errcodeDetail.vue'
// 创建axios实例
const service = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_API,
@ -71,10 +73,21 @@ const resInterceptor = (res) => {
})
} else {
console.log("interceptor err code", res)
ElMessageBox.alert(res.data.msg, "服务器错误码[" + code + "]", {
ElMessageBox({
title: "服务器错误码[" + code + "]",
message: () =>
h(errcodeDetail, {
data: res.data,
}),
type: "warning",
confirmButtonText: '知道了',
}).then((action) => {
})
// ElMessageBox.alert(res.data.msg, "服务器错误码[" + code + "]", {
// type: "warning",
// confirmButtonText: '知道了',
// })
}
return Promise.reject(res.data)