Browse Source

恢复原始代码

pull/54/head
zq 1 week ago
parent
commit
91db9fab7f
  1. 77
      src/components/Breadcrumb copy.vue
  2. 22
      src/utils/request.js

77
src/components/Breadcrumb copy.vue

@ -1,77 +0,0 @@
<template>
<el-breadcrumb v-if="showBreadcrumb" separator="/">
<el-breadcrumb-item
v-for="(item, index) in breadcrumbList"
:key="index"
>
<i v-if="item.icon" :class="item.icon"></i>
<span>{{ item.title }}</span>
</el-breadcrumb-item>
</el-breadcrumb>
</template>
<script>
export default {
data() {
return {
breadcrumbList: [],
showBreadcrumb: false //
};
},
watch: {
$route() {
this.updateBreadcrumb();
}
},
mounted() {
this.updateBreadcrumb();
},
methods: {
updateBreadcrumb() {
const currentPath = this.$route.path;
//
if(!this.$parent.menuData)return
const isSubPage = this.isSubPage(currentPath);
this.showBreadcrumb = isSubPage;
if (isSubPage) {
this.breadcrumbList = this.getBreadcrumbList(currentPath);
} else {
this.breadcrumbList = [];
}
},
isSubPage(path) {
console.log(this.$parent.menuData,'this.$parent.menuData==');
//
for (const menu of this.$parent.menuData) {
for (const subMenu of menu.children) {
if (subMenu.path === path) {
return true;
}
}
}
return false;
},
getBreadcrumbList(path) {
const breadcrumbList = [];
//
for (const menu of this.$parent.menuData) {
for (const subMenu of menu.children) {
if (subMenu.path === path) {
breadcrumbList.push({ title: menu.title, icon: menu.icon });
breadcrumbList.push({ title: subMenu.title });
break;
}
}
}
return breadcrumbList;
}
}
};
</script>
<style scoped>
.el-breadcrumb {
margin-bottom: 20px;
}
</style>

22
src/utils/request.js

@ -1,14 +1,12 @@
// src/utils/request.js
import axios from "axios";
// import store from '@/store'
// let loadingTimer = null
// 创建 axios 实例
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // 从环境变量中读取 API 基础地址
timeout: 60000, // 请求超时时间
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'AUTH': '3c901fa4a19a7ad9d01238890863d499'
'Content-Type': 'application/x-www-form-urlencoded'
},
});
@ -18,20 +16,11 @@ service.interceptors.request.use(
// 在发送请求之前做一些处理,例如添加 token
const token = localStorage.getItem("token");
if (token) {
config.headers["AUTH"] = `${token}`;
config.headers["Auth"] = `${token}`;
}
// 如果配置里传了 loading: false,则不显示 loading
// if (config.loading !== false) {
// loadingTimer = setTimeout(() => {
// store.dispatch('showLoading')
// }, 300)
// }
return config;
},
(error) => {
// clearTimeout(loadingTimer)
// // 请求错误时也要关闭 loading
// store.dispatch('hideLoading')
// 对请求错误做些什么
return Promise.reject(error);
}
@ -43,12 +32,9 @@ service.interceptors.response.use(
// 对响应数据做一些处理
const res = response.data;
if (!res.status) {
// 如果返回的 status 不是 true,则视为错误
// return Promise.reject(new Error(res.info || "请求失败"));
}
// clearTimeout(loadingTimer)
// store.dispatch('hideLoading')
return res;
},
(error) => {
@ -71,8 +57,6 @@ service.interceptors.response.use(
console.error("请求失败", error.message);
}
}
// clearTimeout(loadingTimer)
// store.dispatch('hideLoading')
return Promise.reject(error);
}
);

Loading…
Cancel
Save