init
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
(self["webpackChunkliu_official"] = self["webpackChunkliu_official"] || []).push([[792],{
|
||||
|
||||
/***/ 4741:
|
||||
/***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
|
||||
|
||||
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7569);
|
||||
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var _utils_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1639);
|
||||
|
||||
|
||||
|
||||
|
||||
jquery__WEBPACK_IMPORTED_MODULE_0___default()(function () {
|
||||
// 设备检测和重定向
|
||||
if ((0,_utils_common__WEBPACK_IMPORTED_MODULE_1__/* .isMobileDevice */ .Xb)() && !(0,_utils_common__WEBPACK_IMPORTED_MODULE_1__/* .shouldSkipRedirect */ .fZ)()) {
|
||||
window.location.replace("/mobile");
|
||||
return;
|
||||
}
|
||||
const nav = jquery__WEBPACK_IMPORTED_MODULE_0___default()(".header__nav");
|
||||
jquery__WEBPACK_IMPORTED_MODULE_0___default()('#app-left-logo').on('click', () => {
|
||||
// 点击首页logo 返回首页
|
||||
console.log('点击');
|
||||
window.location.href = window.location.origin + '/';
|
||||
});
|
||||
|
||||
// 根据当前URL hash设置活跃导航项
|
||||
function setActiveNav() {
|
||||
nav.removeClass("header__nav--active");
|
||||
const currentHash = window.location.hash;
|
||||
const pathname = window.location.pathname;
|
||||
const hash = window.location.hash;
|
||||
if (pathname !== '/' && hash === '#qcgl') {
|
||||
window.location.href = '/#qcgl';
|
||||
return;
|
||||
}
|
||||
let targetName = "";
|
||||
if (!hash && pathname) {
|
||||
switch (pathname) {
|
||||
case '/':
|
||||
targetName = 'main';
|
||||
break;
|
||||
case '/stadium-reserve.html':
|
||||
targetName = 'stadium-reserve';
|
||||
break;
|
||||
case '/tournament.html':
|
||||
targetName = 'tournament';
|
||||
break;
|
||||
case '/register.html':
|
||||
targetName = 'register';
|
||||
break;
|
||||
case '/about.html':
|
||||
targetName = 'about';
|
||||
break;
|
||||
}
|
||||
} else if (hash) {
|
||||
switch (hash) {
|
||||
case '#qcgl':
|
||||
targetName = 'cggl';
|
||||
break;
|
||||
}
|
||||
}
|
||||
const targetNav = nav.filter(`[data-link="${targetName}"]`);
|
||||
if (targetNav.length > 0) {
|
||||
targetNav.addClass("header__nav--active");
|
||||
} else {
|
||||
// 如果找不到对应的导航项,默认激活首页
|
||||
nav.filter('[href="#"]').addClass("header__nav--active");
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载时设置活跃状态
|
||||
setActiveNav();
|
||||
|
||||
// 监听hash变化
|
||||
jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on("hashchange", function () {
|
||||
setActiveNav();
|
||||
});
|
||||
jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on("popstate", function () {
|
||||
setActiveNav();
|
||||
});
|
||||
|
||||
// 导航点击事件
|
||||
// nav.on("click", function () {
|
||||
// if ($(this).data("name") === "业务合作") {
|
||||
// return;
|
||||
// }
|
||||
// nav.removeClass("header__nav--active");
|
||||
// $(this).addClass("header__nav--active");
|
||||
// });
|
||||
});
|
||||
|
||||
/***/ })
|
||||
|
||||
},
|
||||
/******/ function(__webpack_require__) { // webpackRuntimeModules
|
||||
/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
||||
/******/ __webpack_require__.O(0, [810,361,76], function() { return __webpack_exec__(4741); });
|
||||
/******/ var __webpack_exports__ = __webpack_require__.O();
|
||||
/******/ }
|
||||
]);
|
||||
//# sourceMappingURL=main.js.map?hash=b446ba1443bc4913f472
|
||||
Reference in New Issue
Block a user