Skip to content

Commit

Permalink
fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
陈嘉圣 authored and 陈嘉圣 committed Apr 27, 2022
1 parent dcc114a commit 8dbc1da
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 98 deletions.
33 changes: 33 additions & 0 deletions public/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -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;
});
117 changes: 43 additions & 74 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,81 +1,50 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="viggo" />
<title>WebStack.cc - 设计师网址导航</title>
<meta name="keywords" content="UI设计,UI设计素材,设计导航,网址导航,设计资源,创意导航,创意网站导航,设计师网址大全,设计素材大全,设计师导航,UI设计资源,优秀UI设计欣赏,设计师导航,设计师网址大全,设计师网址导航,产品经理网址导航,交互设计师网址导航,www.webstack.cc">
<meta name="description" content="WebStack - 收集国内外优秀设计网站、UI设计资源网站、灵感创意网站、素材资源网站,定时更新分享优质产品设计书签。www.webstack.cc">
<link rel="shortcut icon" href="favicon.png">

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="viggo" />
<title>WebStack.cc - 设计师网址导航</title>
<meta name="keywords"
content="UI设计,UI设计素材,设计导航,网址导航,设计资源,创意导航,创意网站导航,设计师网址大全,设计素材大全,设计师导航,UI设计资源,优秀UI设计欣赏,设计师导航,设计师网址大全,设计师网址导航,产品经理网址导航,交互设计师网址导航,www.webstack.cc">
<meta name="description" content="WebStack - 收集国内外优秀设计网站、UI设计资源网站、灵感创意网站、素材资源网站,定时更新分享优质产品设计书签。www.webstack.cc">
<link rel="shortcut icon" href="favicon.png">

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- / FB Open Graph -->
<meta property="og:type" content="article">
<meta property="og:url" content="http://www.webstack.cc/">
<meta property="og:title" content="WebStack - 收集国内外优秀设计网站、UI设计资源网站、灵感创意网站、素材资源网站,定时更新分享优质产品设计书签。www.webstack.cc">
<meta property="og:description" content="UI设计,UI设计素材,设计导航,网址导航,设计资源,创意导航,创意网站导航,设计师网址大全,设计素材大全,设计师导航,UI设计资源,优秀UI设计欣赏,设计师导航,设计师网址大全,设计师网址导航,产品经理网址导航,交互设计师网址导航,www.webstack.cc">
<meta property="og:image" content="http://webstack.cc/assets/images/webstack_banner_cn.png">
<meta property="og:site_name" content="WebStack - 收集国内外优秀设计网站、UI设计资源网站、灵感创意网站、素材资源网站,定时更新分享优质产品设计书签。www.webstack.cc">
<!-- / Twitter Cards -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="WebStack - 收集国内外优秀设计网站、UI设计资源网站、灵感创意网站、素材资源网站,定时更新分享优质产品设计书签。www.webstack.cc">
<meta name="twitter:description" content="UI设计,UI设计素材,设计导航,网址导航,设计资源,创意导航,创意网站导航,设计师网址大全,设计素材大全,设计师导航,UI设计资源,优秀UI设计欣赏,设计师导航,设计师网址大全,设计师网址导航,产品经理网址导航,交互设计师网址导航,www.webstack.cc">
<meta name="twitter:image" content="http://www.webstack.cc/assets/images/webstack_banner_cn.png">
</head>

<body class="page-body">
<div id="app"></div>
<!-- built files will be auto injected -->

<script src="./assets/js/jquery-1.11.1.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>
<script src="./assets/js/TweenMax.min.js"></script>
<script src="./assets/js/resizeable.js"></script>
<script src="./assets/js/joinable.js"></script>
<script src="./assets/js/xenon-api.js"></script>
<script src="./assets/js/xenon-toggles.js"></script>
<script src="./assets/js/xenon-custom.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script type="text/javascript">

Vue.nextTick(() => {
$(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);
}
})
}
})
<!-- / FB Open Graph -->
<meta property="og:type" content="article">
<meta property="og:url" content="http://www.webstack.cc/">
<meta property="og:title" content="WebStack - 收集国内外优秀设计网站、UI设计资源网站、灵感创意网站、素材资源网站,定时更新分享优质产品设计书签。www.webstack.cc">
<meta property="og:description"
content="UI设计,UI设计素材,设计导航,网址导航,设计资源,创意导航,创意网站导航,设计师网址大全,设计素材大全,设计师导航,UI设计资源,优秀UI设计欣赏,设计师导航,设计师网址大全,设计师网址导航,产品经理网址导航,交互设计师网址导航,www.webstack.cc">
<meta property="og:image" content="http://webstack.cc/assets/images/webstack_banner_cn.png">
<meta property="og:site_name" content="WebStack - 收集国内外优秀设计网站、UI设计资源网站、灵感创意网站、素材资源网站,定时更新分享优质产品设计书签。www.webstack.cc">
<!-- / Twitter Cards -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="WebStack - 收集国内外优秀设计网站、UI设计资源网站、灵感创意网站、素材资源网站,定时更新分享优质产品设计书签。www.webstack.cc">
<meta name="twitter:description"
content="UI设计,UI设计素材,设计导航,网址导航,设计资源,创意导航,创意网站导航,设计师网址大全,设计素材大全,设计师导航,UI设计资源,优秀UI设计欣赏,设计师导航,设计师网址大全,设计师网址导航,产品经理网址导航,交互设计师网址导航,www.webstack.cc">
<meta name="twitter:image" content="http://www.webstack.cc/assets/images/webstack_banner_cn.png">
</head>

$('.user-info-menu .hidden-sm').click(function(){
if($('.sidebar-menu').hasClass('collapsed')) {
$('.has-sub.expanded > ul').attr("style","")
} else {
$('.has-sub.expanded > ul').show()
}
})
<body class="page-body">
<div id="app"></div>
<!-- built files will be auto injected -->
<!-- <script src="./assets/js/jquery-1.11.1.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>
<script src="./assets/js/TweenMax.min.js"></script>
<script src="./assets/js/resizeable.js"></script>
<script src="./assets/js/joinable.js"></script>
<script src="./assets/js/xenon-api.js"></script>
<script src="./assets/js/xenon-toggles.js"></script>
<script src="./assets/js/xenon-custom.js"></script>
<script src="./assets/js/app.js"></script> -->
</body>

$("#main-menu li ul li").click(function() {
$(this).siblings('li').removeClass('active'); // 删除其他兄弟元素的样式
$(this).addClass('active'); // 添加当前元素的样式
});
})
</script>
</body>
</html>
</html>
32 changes: 32 additions & 0 deletions src/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
8 changes: 8 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
69 changes: 45 additions & 24 deletions src/views/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
<img src="../assets/images/[email protected]" width="100%" alt="" />
</a>
<a href="#" class="logo-collapsed">
<img src="../assets/images/[email protected]" width="40" alt="" />
<img
src="../assets/images/[email protected]"
width="40"
alt=""
/>
</a>
</div>
<div class="mobile-menu-toggle visible-xs">
Expand All @@ -24,15 +28,19 @@
<!-- 侧边栏 -->
<ul id="main-menu" class="main-menu">
<li v-for="(menu, idx) in items" :key="idx">
<a :href="'#'+transName(menu)" class="smooth" @click="moveSlow">
<a :href="'#' + transName(menu)" class="smooth">
<i :class="menu.icon"></i>
<span class="title">{{transName(menu)}}</span>
<span class="title">{{ transName(menu) }}</span>
</a>
<ul v-if="menu.children">
<li v-for="(submenu, idx) in menu.children" :key="idx">
<a :href="'#'+transName(submenu)" class="smooth" @click="moveSlow">
<span class="title">{{transName(submenu)}}</span>
<span v-show="submenu.is_hot" class="label label-pink pull-right hidden-collapsed">Hot</span>
<a :href="'#' + transName(submenu)" class="smooth">
<span class="title">{{ transName(submenu) }}</span>
<span
v-show="submenu.is_hot"
class="label label-pink pull-right hidden-collapsed"
>Hot</span
>
</a>
</li>
</ul>
Expand All @@ -42,7 +50,9 @@
<router-link to="/about">
<i class="linecons-heart"></i>
<span class="tooltip-blue">关于本站</span>
<span class="label label-Primary pull-right hidden-collapsed">♥︎</span>
<span class="label label-Primary pull-right hidden-collapsed"
>♥︎</span
>
</router-link>
</li>
</ul>
Expand All @@ -60,7 +70,11 @@
<img :src="lang.flag" /> {{ lang.name }}
</a>
<ul class="dropdown-menu languages">
<li :class="{active: langItem.key === lang.key}" v-for="langItem in langList" :key="langItem.key">
<li
:class="{ active: langItem.key === lang.key }"
v-for="langItem in langList"
:key="langItem.key"
>
<a href="#" @click="lang = langItem">
<img :src="langItem.flag" /> {{ langItem.name }}
</a>
Expand Down Expand Up @@ -92,38 +106,45 @@
</template>

<script>
import WebItem from '../components/WebItem.vue'
import Footer from '../components/Footer.vue'
import itemsData from '../assets/data.json'
import WebItem from "../components/WebItem.vue";
import Footer from "../components/Footer.vue";
import itemsData from "../assets/data.json";
// import { loadJs } from '../assets/js/app.js'
export default {
name: 'Index',
name: "Index",
components: {
WebItem,
Footer
Footer,
},
data() {
return {
items: itemsData,
lang: {},
langList: [
{key: 'zh', name: '简体中文', flag: './assets/images/flags/flag-cn.png'},
{key: 'en', name: 'English', flag: './assets/images/flags/flag-us.png'}
]
}
{
key: "zh",
name: "简体中文",
flag: "./assets/images/flags/flag-cn.png",
},
{
key: "en",
name: "English",
flag: "./assets/images/flags/flag-us.png",
},
],
};
},
created() {
this.lang = this.langList[0]
this.lang = this.langList[0];
// loadJs();
},
methods: {
transName(webItem) {
return this.lang.key === 'en' ? webItem.en_name : webItem.name;
return this.lang.key === "en" ? webItem.en_name : webItem.name;
},
moveSlow() {
}
}
}
},
};
</script>

<style>
Expand Down

0 comments on commit 8dbc1da

Please sign in to comment.