mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-08-06 10:57:26 +08:00
feat: 更新 API 请求参数与组件样式优化
- 在 account.js 和 member.js 中添加 loading 和 skipMessage 参数,提升 API 调用的用户体验。 - 在 ShowGoods.vue 中优化商品详情展示样式,增强可读性和交互性。 - 在 Cart.vue 中重构购物车商品列表结构,提升布局一致性。 - 在多个页面中修复了提示信息的内容,确保用户操作的清晰反馈。
This commit is contained in:
@@ -29,6 +29,16 @@ export const sellerUrl =
|
||||
let isRefreshToken = 0;
|
||||
const refreshToken = getTokenDebounce();
|
||||
|
||||
/** 会员中心(/home/*)页面使用局部 loading,不启用全屏遮罩 */
|
||||
function isMemberCenterRoute() {
|
||||
try {
|
||||
const path = router.currentRoute?.value?.path || "";
|
||||
return path === "/home" || path.startsWith("/home/");
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const service = axios.create({
|
||||
timeout: 10000,
|
||||
baseURL: buyerUrl,
|
||||
@@ -56,7 +66,8 @@ service.interceptors.request.use(
|
||||
const method = (config.method || "get").toLowerCase();
|
||||
const isReadRequest = method === "get" || method === "head";
|
||||
const shouldShowLoading =
|
||||
loading === true || (!isReadRequest && loading !== false);
|
||||
loading === true ||
|
||||
(!isReadRequest && loading !== false && !isMemberCenterRoute());
|
||||
|
||||
if (typeof window !== "undefined" && shouldShowLoading) {
|
||||
config.loading = ElLoading.service({ fullscreen: true });
|
||||
@@ -166,7 +177,7 @@ service.interceptors.response.use(
|
||||
if (errorResponse.status === 404) {
|
||||
return Promise.reject(buildRejectError(error, { message: "请求的资源不存在" }));
|
||||
}
|
||||
if (error.message) {
|
||||
if (error.message && !error.config?.skipMessage) {
|
||||
const _message =
|
||||
error.code === "ECONNABORTED"
|
||||
? "连接超时,请稍候再试!"
|
||||
|
||||
Reference in New Issue
Block a user