mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-08-06 10:57:26 +08:00
feat: 新增全局布局样式并提升组件响应式表现
- 在 global-layout.scss 中引入全局布局样式,统一页面宽度与对齐方式 - 更新多个组件与页面以优化响应式,包括宽度、间距及 flex 布局等调整 - 在 API 请求中增加 loading 状态管理,改善用户体验 - 优化领券中心与商品详情页,提升功能与 UI 一致性
This commit is contained in:
@@ -133,6 +133,150 @@ util.oneOf = function (ele, targetArr) {
|
||||
return targetArr.indexOf(ele) >= 0;
|
||||
};
|
||||
|
||||
util.getRouterObjByName = function (routers, name) {
|
||||
if (!name || !routers || !routers.length) {
|
||||
return null;
|
||||
}
|
||||
let routerObj = null;
|
||||
for (let item of routers) {
|
||||
if (item.name == name) {
|
||||
return item;
|
||||
}
|
||||
routerObj = util.getRouterObjByName(item.children, name);
|
||||
if (routerObj) {
|
||||
return routerObj;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
util.handleTitle = function (vm, item) {
|
||||
if (!item) {
|
||||
return "";
|
||||
}
|
||||
if (typeof item.title == "object") {
|
||||
return item.title;
|
||||
}
|
||||
return item.title;
|
||||
};
|
||||
|
||||
util.setCurrentPath = function (vm, name) {
|
||||
let title = "";
|
||||
let isOtherRouter = false;
|
||||
vm.$store.state.app.routers.forEach((item) => {
|
||||
if (item.children.length == 1) {
|
||||
if (item.children[0].name == name) {
|
||||
title = util.handleTitle(vm, item);
|
||||
if (item.name == "otherRouter") {
|
||||
isOtherRouter = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.children.forEach((child) => {
|
||||
if (child.name == name) {
|
||||
title = util.handleTitle(vm, child);
|
||||
if (item.name == "otherRouter") {
|
||||
isOtherRouter = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
let currentPathArr = [];
|
||||
if (name == "home_index") {
|
||||
currentPathArr = [
|
||||
{
|
||||
title: util.handleTitle(
|
||||
vm,
|
||||
util.getRouterObjByName(vm.$store.state.app.routers, "home_index")
|
||||
),
|
||||
path: "",
|
||||
name: "home_index",
|
||||
},
|
||||
];
|
||||
} else if ((name.indexOf("_index") >= 0 || isOtherRouter) && name !== "home_index") {
|
||||
currentPathArr = [
|
||||
{
|
||||
title: util.handleTitle(
|
||||
vm,
|
||||
util.getRouterObjByName(vm.$store.state.app.routers, "home_index")
|
||||
),
|
||||
path: "/home",
|
||||
name: "home_index",
|
||||
},
|
||||
{
|
||||
title: title,
|
||||
path: "",
|
||||
name: name,
|
||||
},
|
||||
];
|
||||
} else {
|
||||
let currentPathObj = vm.$store.state.app.routers.filter((item) => {
|
||||
if (item.children.length <= 1) {
|
||||
return item.children[0].name == name;
|
||||
}
|
||||
let i = 0;
|
||||
let childArr = item.children;
|
||||
let len = childArr.length;
|
||||
while (i < len) {
|
||||
if (childArr[i].name == name) {
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
})[0];
|
||||
if (!currentPathObj) {
|
||||
currentPathArr = [];
|
||||
} else if (currentPathObj.children.length <= 1 && currentPathObj.name == "home") {
|
||||
currentPathArr = [
|
||||
{
|
||||
title: "首页",
|
||||
path: "",
|
||||
name: "home_index",
|
||||
},
|
||||
];
|
||||
} else if (currentPathObj.children.length <= 1 && currentPathObj.name !== "home") {
|
||||
currentPathArr = [
|
||||
{
|
||||
title: "首页",
|
||||
path: "/home",
|
||||
name: "home_index",
|
||||
},
|
||||
{
|
||||
title: currentPathObj.title,
|
||||
path: "",
|
||||
name: name,
|
||||
},
|
||||
];
|
||||
} else {
|
||||
let childObj = currentPathObj.children.filter((child) => {
|
||||
return child.name == name;
|
||||
})[0];
|
||||
currentPathArr = [
|
||||
{
|
||||
title: "首页",
|
||||
path: "/home",
|
||||
name: "home_index",
|
||||
},
|
||||
{
|
||||
title: currentPathObj.title,
|
||||
path: "",
|
||||
name: currentPathObj.name,
|
||||
},
|
||||
{
|
||||
title: childObj.title,
|
||||
path: currentPathObj.path + "/" + childObj.path,
|
||||
name: name,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
vm.$store.commit("setCurrentPath", currentPathArr);
|
||||
|
||||
return currentPathArr;
|
||||
};
|
||||
|
||||
util.openNewPage = function (vm, name, argu, query) {
|
||||
if (!vm.$store) {
|
||||
return;
|
||||
@@ -229,11 +373,6 @@ util.initRouter = function (vm) {
|
||||
util.initMenuData(vm, menuData);
|
||||
window.localStorage.setItem("menuData", JSON.stringify(menuData));
|
||||
vm.$store.commit("setAdded", true);
|
||||
if (vm.$store.state.app.refMenu) {
|
||||
vm.$nextTick(() => {
|
||||
vm.$store.state.app.refMenu.updateActiveName();
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let data = window.localStorage.getItem("menuData");
|
||||
@@ -244,11 +383,6 @@ util.initRouter = function (vm) {
|
||||
let menuData = JSON.parse(data);
|
||||
util.registerDynamicRoutes(menuData);
|
||||
util.initMenuData(vm, menuData);
|
||||
if (vm.$store.state.app.refMenu) {
|
||||
vm.$nextTick(() => {
|
||||
vm.$store.state.app.refMenu.updateActiveName();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user