-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f69e088
Showing
74 changed files
with
5,844 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 StickmY | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
<template> | ||
<div> | ||
<div class="wrap"> | ||
<div class="theme-container container" | ||
:class="pageClasses" | ||
@touchstart="onTouchStart" | ||
@touchend="onTouchEnd"> | ||
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar"/> | ||
<div class="sidebar-mask" @click="toggleSidebar(false)"></div> | ||
<Sidebar :items="sidebarItems" @toggle-sidebar="toggleSidebar"/> | ||
<div class="page-container" :style="pageContainerClasses"> | ||
<!-- custom layout --> | ||
<div class="custom-layout" v-if="$page.frontmatter.layout"> | ||
<component :is="$page.frontmatter.layout"/> | ||
</div> | ||
<!-- Activity layout --> | ||
<Activity v-else-if="$page.frontmatter.activity"/> | ||
<!-- article list --> | ||
<ArticleGroup v-else-if="isRoot" :page-items="pageItems" /> | ||
<!-- nav with layout list --> | ||
<ArticleGroup v-else-if="isNavLayout" :page-items="pageItems" /> | ||
<!-- tags --> | ||
<Tags v-else-if="isTag" /> | ||
<!-- article page --> | ||
<Page v-else :sidebar-items="sidebarItems"/> | ||
<!-- pagation selector --> | ||
<Pagation v-if="isRoot || isNavLayout" | ||
:page-items="pages" | ||
@change="page => currentPage = page" /> | ||
</div> | ||
<ToolGroup v-if="!isNoToolGroup" /> | ||
</div> | ||
<SWUpdatePopup :updateEvent="swUpdateEvent" /> | ||
</div> | ||
<div class="background-mask" :style="wrapClasses"></div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Vue from "vue"; | ||
import nprogress from "nprogress"; | ||
import Activity from "./layout/Activity.vue"; | ||
import Navbar from "./components/Navbar.vue"; | ||
import Page from "./Page.vue"; | ||
import Sidebar from "./components/Sidebar.vue"; | ||
import ToolGroup from "./components/ToolGroup.vue"; | ||
import ArticleGroup from './components/ArticleGroup.vue' | ||
import LeetCodeGroup from './components/LeetCodeGroup.vue' | ||
import Pagation from './components/Pagation.vue' | ||
import SWUpdatePopup from './components/SWUpdatePopup.vue' | ||
import Tags from './components/Tags.vue' | ||
import navLayoutMixin from './lib/navLayout.mixin' | ||
import { resolveSidebarItems, getTitle } from "./lib/util"; | ||
export default { | ||
mixins: [navLayoutMixin], | ||
components: { | ||
Activity, | ||
Page, | ||
Sidebar, | ||
Navbar, | ||
ToolGroup, | ||
ArticleGroup, | ||
LeetCodeGroup, | ||
Pagation, | ||
Tags, | ||
SWUpdatePopup | ||
}, | ||
data() { | ||
return { | ||
isSidebarOpen: false, | ||
currentPage: 1, | ||
swUpdateEvent: null | ||
}; | ||
}, | ||
computed: { | ||
isRoot() { | ||
return this.$route.meta.root || this.$route.path === this.$rootOptions.path; | ||
}, | ||
isTag() { | ||
return this.$route.meta.tag; | ||
}, | ||
isNoToolGroup() { | ||
return this.$page.frontmatter.layout || this.$page.frontmatter.activity | ||
}, | ||
pageItems() { | ||
const start = (this.currentPage - 1) * this.perPage | ||
const end = this.currentPage * this.perPage | ||
return this.pages.filter((page, i) => (i >= start && i < end)) | ||
}, | ||
shouldShowNavbar() { | ||
const { themeConfig } = this.$site; | ||
return ( | ||
this.$site.title || | ||
themeConfig.logo || | ||
themeConfig.repo || | ||
themeConfig.nav | ||
); | ||
}, | ||
shouldShowSidebar() { | ||
const { themeConfig } = this.$site; | ||
const { frontmatter } = this.$page; | ||
return ( | ||
!frontmatter.layout && | ||
!frontmatter.activity && | ||
frontmatter.sidebar !== false && | ||
this.sidebarItems.length | ||
); | ||
}, | ||
sidebarItems() { | ||
return resolveSidebarItems( | ||
this.$page, | ||
this.$route, | ||
this.$site, | ||
this.$localePath | ||
); | ||
}, | ||
// when Activity Component, dont show tool group and expand the page container's width to 100% | ||
pageContainerClasses() { | ||
return !this.isNoToolGroup ? {} : { width: '100%' } | ||
}, | ||
pageClasses() { | ||
const userPageClass = this.$page.frontmatter.pageClass; | ||
return [ | ||
{ | ||
"no-navbar": !this.shouldShowNavbar, | ||
"sidebar-open": this.isSidebarOpen, | ||
"no-sidebar": !this.shouldShowSidebar, | ||
}, | ||
userPageClass | ||
]; | ||
}, | ||
wrapClasses() { | ||
const { themeConfig } = this.$site; | ||
return themeConfig.background | ||
? { | ||
background: | ||
'url("' + | ||
`${this.$withBase(themeConfig.background)}` + | ||
'") no-repeat fixed' | ||
} | ||
: { background: "#f6f6f6" }; | ||
} | ||
}, | ||
created() { | ||
if (this.$ssrContext) { | ||
this.$ssrContext.title = getTitle(this.$title, this.$page); | ||
this.$ssrContext.lang = this.$lang; | ||
this.$ssrContext.description = | ||
this.$page.description || this.$description; | ||
} | ||
}, | ||
mounted() { | ||
// when swtich tab, change the current page | ||
const updateCurPage = () => { | ||
this.currentPage = 1 | ||
} | ||
this.$watch('pages', updateCurPage) | ||
// configure progress bar | ||
nprogress.configure({ showSpinner: false }); | ||
this.$router.beforeEach((to, from, next) => { | ||
if (to.path !== from.path && !Vue.component(to.name)) { | ||
nprogress.start(); | ||
} | ||
next(); | ||
}); | ||
this.$router.afterEach(() => { | ||
nprogress.done(); | ||
this.isSidebarOpen = false; | ||
}); | ||
this.$on('sw-updated', this.onSWUpdated); | ||
}, | ||
methods: { | ||
toggleSidebar(to) { | ||
this.isSidebarOpen = typeof to === "boolean" ? to : !this.isSidebarOpen; | ||
}, | ||
// side swipe | ||
onTouchStart(e) { | ||
this.touchStart = { | ||
x: e.changedTouches[0].clientX, | ||
y: e.changedTouches[0].clientY | ||
}; | ||
}, | ||
onTouchEnd(e) { | ||
const dx = e.changedTouches[0].clientX - this.touchStart.x; | ||
const dy = e.changedTouches[0].clientY - this.touchStart.y; | ||
if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 40) { | ||
if (dx > 0 && this.touchStart.x <= 80) { | ||
this.toggleSidebar(true); | ||
} else { | ||
this.toggleSidebar(false); | ||
} | ||
} | ||
}, | ||
onSWUpdated(e) { | ||
console.log('pwa update: ', e); | ||
this.swUpdateEvent = e; | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style src="prismjs/themes/prism-tomorrow.css"></style> | ||
<style src="./styles/theme.styl" lang="stylus"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<template> | ||
<div class="theme-container"> | ||
<div class="content"> | ||
<h1>404</h1> | ||
<blockquote>{{ getMsg() }}</blockquote> | ||
<router-link to="/">back to the homepage</router-link> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
const msgs = [ | ||
`The page went on flight 404.`, | ||
`How did you come here?`, | ||
`It seems that there is a problem, it is being repaired.`, | ||
`Emmm, the page was hit by a two-way foil.` | ||
] | ||
export default { | ||
methods: { | ||
getMsg () { | ||
return msgs[Math.floor(Math.random() * msgs.length)] | ||
} | ||
} | ||
} | ||
</script> |
Oops, something went wrong.