From 8dbc1dab67131d01eb848ca712179f99780a2e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E5=9C=A3?= Date: Thu, 28 Apr 2022 00:18:29 +0800 Subject: [PATCH] fix #4 --- public/assets/js/app.js | 33 ++++++++++++ public/index.html | 117 +++++++++++++++------------------------- src/assets/js/app.js | 32 +++++++++++ src/main.js | 8 +++ src/views/index.vue | 69 +++++++++++++++--------- 5 files changed, 161 insertions(+), 98 deletions(-) create mode 100644 public/assets/js/app.js create mode 100644 src/assets/js/app.js diff --git a/public/assets/js/app.js b/public/assets/js/app.js new file mode 100644 index 0000000..e6ef5f0 --- /dev/null +++ b/public/assets/js/app.js @@ -0,0 +1,33 @@ +$(document).ready(function () { + $(document).on('click', '.has-sub', function () { + var _this = $(this) + if (!$(this).hasClass('expanded')) { + setTimeout(function () { + _this.find('ul').attr("style", "") + }, 300); + + } else { + $('.has-sub ul').each(function (id, ele) { + var _that = $(this) + if (_this.find('ul')[0] != ele) { + setTimeout(function () { + _that.attr("style", "") + }, 300); + } + }) + } + }) + $('.user-info-menu .hidden-sm').click(function () { + if ($('.sidebar-menu').hasClass('collapsed')) { + $('.has-sub.expanded > ul').attr("style", "") + } else { + $('.has-sub.expanded > ul').show() + } + }) + $("#main-menu li ul li").click(function () { + $(this).siblings('li').removeClass('active'); // 删除其他兄弟元素的样式 + $(this).addClass('active'); // 添加当前元素的样式 + }); + + return false; +}); diff --git a/public/index.html b/public/index.html index 94b95d8..668c528 100644 --- a/public/index.html +++ b/public/index.html @@ -1,81 +1,50 @@ - - - - - - WebStack.cc - 设计师网址导航 - - - - - - + - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/assets/js/app.js b/src/assets/js/app.js new file mode 100644 index 0000000..d086993 --- /dev/null +++ b/src/assets/js/app.js @@ -0,0 +1,32 @@ +export function loadJs() { + const jsArr = [ + { id: "js-1", src: "./assets/js/jquery-1.11.1.min.js" }, + { id: "js-2", src: "./assets/js/bootstrap.min.js" }, + { id: "js-3", src: "./assets/js/TweenMax.min.js" }, + { id: "js-4", src: "./assets/js/resizeable.js" }, + { id: "js-5", src: "./assets/js/joinable.js" }, + { id: "js-6", src: "./assets/js/xenon-api.js" }, + { id: "js-7", src: "./assets/js/xenon-toggles.js" }, + { id: "js-8", src: "./assets/js/xenon-custom.js" }, + { id: "js-9", src: "./assets/js/app.js" }, + ]; + const srcArr = document.getElementsByTagName("script"); + for (let i = 0; i < srcArr.length; i++) { + for (let j = 0; j < jsArr.length; j++) { + // console.log(`srcArr[${i}]`, srcArr[i]); + // console.log(`jsArr[${j}]`, jsArr[j]); + if (srcArr[i].id == jsArr[j].id) { + srcArr[i].remove(); + } + } + } + + const body = document.getElementsByTagName('body')[0]; + for (let i = 0; i < jsArr.length; i++) { + const script = document.createElement("script"); + script.src = jsArr[i].src; + script.id = jsArr[i].id; + script.defer = true; + body.append(script); + } +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index f801a90..7b124d6 100644 --- a/src/main.js +++ b/src/main.js @@ -11,6 +11,7 @@ import './assets/css/xenon-core.css' import './assets/css/xenon-components.css' import './assets/css/xenon-skins.css' import './assets/css/nav.css' +import { loadJs } from './assets/js/app.js' Vue.config.productionTip = false Vue.use(VueRouter) @@ -25,6 +26,13 @@ const router = new VueRouter({ mode: 'history' }) +router.afterEach((to, from, next) => { + console.log("to => ", to, "from => ", from, "next => ", next); + if (to.path == '/' && to.hash == '') { + loadJs(); + } +}) + new Vue({ render: h => h(App), router diff --git a/src/views/index.vue b/src/views/index.vue index fc9da19..8c3271a 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -9,7 +9,11 @@ - +
@@ -24,15 +28,19 @@ @@ -60,7 +70,11 @@ {{ lang.name }}