This commit is contained in:
yi-ge 2019-12-13 11:46:15 +08:00
parent eaf48b86c3
commit 703f411ee7
17 changed files with 2662 additions and 2030 deletions

View File

@ -91,14 +91,14 @@
<script>
export default {
data() {
data () {
return {
socialInfo: false,
searchVal: ''
}
},
methods: {
info(type) {
info (type) {
if (type === 'qq') {
this.socialInfo = 'QQ: 373226722'
} else if (type === 'weixin') {
@ -111,8 +111,8 @@ export default {
this.socialInfo = false
}, 3000)
},
search() {
if (this.searchVal !== '') this.$router.push({ path: 'search?q=' + this.searchVal })
search () {
if (this.searchVal !== '') { this.$router.push({ path: 'search?q=' + this.searchVal }) }
}
}
}

View File

@ -41,7 +41,7 @@
</template>
<script>
function toArray(arraylike) {
function toArray (arraylike) {
return Array.prototype.slice.call(arraylike)
}
@ -82,7 +82,7 @@ export default {
default: false
}
},
data() {
data () {
return {
swiper: null,
swiperWidth: 0,
@ -107,7 +107,7 @@ export default {
isOnly: false
}
},
mounted() {
mounted () {
this.box = 'swiper-box-' + Math.random().toFixed(2) * 1000
setTimeout(() => {
/* 初始化的时候, 拿到所有的 DOM 元素以及相关属性 */
@ -130,13 +130,13 @@ export default {
},
methods: {
/* 阻止容器的上下滚动, 并且只有在水平方向上面滚动超过 10px 才可以阻止 */
fn(e) {
fn (e) {
if (this.vLock || Math.abs(this.pos.startX - this.pos.moveX) > 10) {
e.preventDefault()
}
},
/* 滑动到指定的页面 */
slideTo(index) {
slideTo (index) {
if (!this.moving) {
const currentSlide = Math.round(Math.abs(this.left()) / this.swiperWidth)
/* 如果索引值不合法 或者和目前的值相等 */
@ -155,7 +155,7 @@ export default {
this.translateX(-this.swiperWidth * (index + 1))
}
},
next() {
next () {
if (!this.moving) {
clearTimeout(this.timer)
this.moving = true
@ -163,7 +163,7 @@ export default {
this.translateX(this.left() - this.swiperWidth)
}
},
previous() {
previous () {
if (!this.moving) {
clearTimeout(this.timer)
this.moving = true
@ -171,7 +171,7 @@ export default {
this.translateX(this.left() + this.swiperWidth)
}
},
initElement() {
initElement () {
/* 因为传递过来的是个字符串, 所以要手动加点 */
this.swiper = document.querySelector('.' + this.box)
this.swiperWidth = this.swiper.clientWidth
@ -184,7 +184,7 @@ export default {
this.isOnly = true
}
},
cloneSlide() {
cloneSlide () {
const head = this.slides[0].cloneNode(this.slides[0], true)
const tail = this.slides[this.slidesNumber - 1].cloneNode(this.slides[this.slidesNumber - 1], true)
this.swiper.appendChild(head)
@ -194,7 +194,7 @@ export default {
this.slidesNumber = this.slides.length
},
/* 根据用户给定的 defaultSlide 设置 init slide 的值 */
setDefaultSlide() {
setDefaultSlide () {
/*
一切用户给定的值, 都是从 0 - x 开始, 比如用户数据里面有 6个数据
那么给定的就是 0 - 5
@ -214,7 +214,7 @@ export default {
/*
## start
*/
play() {
play () {
this.timer = setTimeout(() => {
clearTimeout(this.timer)
this.moving = true
@ -223,7 +223,7 @@ export default {
this.translateX(-(this.swiperWidth + Math.abs(this.left())))
}, this.interval)
},
transitionend() {
transitionend () {
this.transitionDuration(0)
/*
一次滑动结束之后, 通过计算, 实际上我们可以拿到当前处于内部索引的第几个 slide
@ -254,7 +254,7 @@ export default {
}
},
/* toushstart handler */
s(e) {
s (e) {
if (this.isOnly) {
return
}
@ -278,7 +278,7 @@ export default {
}
},
/* toushmove handler */
m(e) {
m (e) {
if (this.isOnly) {
return
}
@ -294,7 +294,7 @@ export default {
}
},
/* toushend handler */
e(e) {
e (e) {
if (this.isOnly) {
return
}
@ -314,7 +314,7 @@ export default {
}
},
/* 响应用户滚动行为 */
recover() {
recover () {
this.transitionDuration(this.userDuration)
const distance = Math.abs(this.left()) % this.swiperWidth
let point = []
@ -365,13 +365,13 @@ export default {
}
}
},
translateX(value) {
translateX (value) {
this.swiper.style.transform = 'translate3d(' + value + 'px, 0, 0)'
},
transitionDuration(ms) {
transitionDuration (ms) {
this.swiper.style.transitionDuration = ms + 'ms'
},
left() {
left () {
return this.swiper.getBoundingClientRect().left
}
}

View File

@ -33,13 +33,13 @@ export default {
LeftContent,
Footer
},
data() {
data () {
return {
showLeftMenuValue: 'block',
isPhone: ''
}
},
mounted() {
mounted () {
const phoneStyle = 'height: 100%; position: fixed; top: 70px; background-color: #fff; z-index:9999; overflow: scroll; overflow-x: hidden; -webkit-overflow-scrolling: touch;'
if (document.body.clientWidth > 768) {
this.showLeftMenuValue = 'block'
@ -60,7 +60,7 @@ export default {
}
},
methods: {
showLeftMenu() {
showLeftMenu () {
if (this.showLeftMenuValue !== 'block') {
this.showLeftMenuValue = 'block'
} else {

View File

@ -50,6 +50,9 @@ module.exports = {
type: 'image/x-icon',
href: '/favicon.ico'
}
],
script: [
{ src: 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', async: true, 'data-ad-client': 'ca-pub-2143583075951360' }
]
},
@ -103,7 +106,7 @@ module.exports = {
/*
** You can extend webpack config here
*/
extend(config, ctx) {
extend (config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({

View File

@ -13,34 +13,34 @@
"precommit": "npm run lint"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.15",
"@fortawesome/free-brands-svg-icons": "^5.7.2",
"@fortawesome/free-regular-svg-icons": "^5.7.2",
"@fortawesome/free-solid-svg-icons": "^5.7.2",
"@fortawesome/vue-fontawesome": "^0.1.5",
"@nuxtjs/axios": "^5.4.0",
"cross-env": "^5.2.0",
"highlight.js": "^9.15.6",
"koa": "^2.7.0",
"@fortawesome/fontawesome-svg-core": "^1.2.26",
"@fortawesome/free-brands-svg-icons": "^5.12.0",
"@fortawesome/free-regular-svg-icons": "^5.12.0",
"@fortawesome/free-solid-svg-icons": "^5.12.0",
"@fortawesome/vue-fontawesome": "^0.1.8",
"@nuxtjs/axios": "^5.8.0",
"cross-env": "^6.0.3",
"highlight.js": "^9.17.1",
"koa": "^2.11.0",
"moment": "^2.24.0",
"nuxt": "^2.4.5"
"nuxt": "^2.10.2"
},
"devDependencies": {
"@nuxtjs/eslint-config": "^0.0.1",
"babel-eslint": "^10.0.1",
"eslint": "^5.15.0",
"eslint-config-standard": ">=12.0.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-import": ">=2.16.0",
"eslint-plugin-jest": "^22.3.0",
"eslint-plugin-node": ">=8.0.1",
"eslint-plugin-promise": ">=4.0.1",
"eslint-plugin-standard": ">=4.0.0",
"eslint-plugin-vue": "^5.2.2",
"nodemon": "^1.18.10",
"pug": "^2.0.3",
"@nuxtjs/eslint-config": "^2.0.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.7.2",
"eslint-config-standard": ">=14.1.0",
"eslint-loader": "^3.0.3",
"eslint-plugin-import": ">=2.19.1",
"eslint-plugin-jest": "^23.1.1",
"eslint-plugin-node": ">=10.0.0",
"eslint-plugin-promise": ">=4.2.1",
"eslint-plugin-standard": ">=4.0.1",
"eslint-plugin-vue": "^6.0.1",
"nodemon": "^2.0.2",
"pug": "^2.0.4",
"pug-plain-loader": "^1.0.0",
"stylus": "^0.54.5",
"stylus": "^0.54.7",
"stylus-loader": "^3.0.2"
}
}

View File

@ -39,7 +39,7 @@
<script>
export default {
async asyncData({ app, params, $axios }) {
async asyncData ({ app, params, $axios }) {
let Info = null
let Articels = []
const nowPage = params.page ? parseInt(params.page) : 1
@ -80,12 +80,12 @@ export default {
nowPath: params.terms ? '/' + params.terms : ''
}
},
mounted() {
mounted () {
this.$finishLoad()
this.analyseImages()
},
methods: {
async analyseImages() { //
async analyseImages () { //
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
this.imageHeight = articleImgsWidth * 0.5625
for (const n in this.Articels) {

View File

@ -39,7 +39,7 @@
<script>
export default {
async asyncData({ app, params, $axios }) {
async asyncData ({ app, params, $axios }) {
let Info = null
let Articels = []
const nowPage = params.page ? parseInt(params.page) : 1
@ -80,12 +80,12 @@ export default {
nowPath: params.terms ? '/' + params.terms : ''
}
},
mounted() {
mounted () {
this.$finishLoad()
this.analyseImages()
},
methods: {
async analyseImages() { //
async analyseImages () { //
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
this.imageHeight = articleImgsWidth * 0.5625
for (const n in this.Articels) {

View File

@ -39,7 +39,7 @@
<script>
export default {
async asyncData(inject) {
async asyncData (inject) {
const { app, params, $axios } = inject
let Info = null
let Articels = []
@ -81,12 +81,12 @@ export default {
nowPath: params.terms ? '/' + params.terms : ''
}
},
mounted() {
mounted () {
this.$finishLoad()
this.analyseImages()
},
methods: {
async analyseImages() { //
async analyseImages () { //
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
this.imageHeight = articleImgsWidth * 0.5625
for (const n in this.Articels) {

View File

@ -39,7 +39,7 @@
<script>
export default {
async asyncData({ app, params, $axios }) {
async asyncData ({ app, params, $axios }) {
let Info = null
let Articels = []
const nowPage = params.page ? parseInt(params.page) : 1
@ -80,12 +80,12 @@ export default {
nowPath: params.terms ? '/' + params.terms : ''
}
},
mounted() {
mounted () {
this.$finishLoad()
this.analyseImages()
},
methods: {
async analyseImages() { //
async analyseImages () { //
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
this.imageHeight = articleImgsWidth * 0.5625
for (const n in this.Articels) {

View File

@ -37,7 +37,7 @@ div
<script>
export default {
async asyncData({ route, app, $axios }) {
async asyncData ({ route, app, $axios }) {
const data = await $axios.$get(`/public/article/details?id=${route.params.id}`)
const result = data.result
result.post_date = app.$moment(result.post_date).utc().format('lll')//
@ -56,12 +56,7 @@ export default {
tocIds: result.post_toc_ids
}
},
head() {
return {
title: `${this.Articels.post_title} - 轶哥博客`
}
},
mounted() {
mounted () {
this.$finishLoad()
if (this.Articels.post_toc_show) {
@ -107,7 +102,7 @@ export default {
const scrollToc = () => {
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
const windowWidth = window.innerWidth || document.documentElement.clientWidth
if (windowWidth < 768) scrollTop = scrollTop * 2.7 + 175
if (windowWidth < 768) { scrollTop = scrollTop * 2.7 + 175 }
const tocIdsInx = findInIds(tocIdsTop, scrollTop + 130)
if (tocIdsInx !== -1 && lastIdInx !== tocIdsInx && document.getElementsByClassName('articelRightToc')[0]) {
const tocAList = document.getElementsByClassName('articelRightToc')[0].getElementsByTagName('a')
@ -135,7 +130,7 @@ export default {
}
},
methods: {
decodeTitle(name) {
decodeTitle (name) {
try {
return this.urldecode(name)
} catch (err) {
@ -143,11 +138,11 @@ export default {
return name
}
},
urldecode(encodedString) {
urldecode (encodedString) {
let output = encodedString
let binVal, thisString
const myregexp = /(%[^%]{2})/
function utf8to16(str) {
function utf8to16 (str) {
let c
let char2, char3
@ -189,13 +184,13 @@ export default {
output = utf8to16(output)
return output
},
articelRightTocClick() {
articelRightTocClick () {
const windowWidth = window.innerWidth || document.documentElement.clientWidth
if (windowWidth < 768) {
this.showRightToc = false
}
},
isOnScreen(element) {
isOnScreen (element) {
const ON_SCREEN_HEIGHT = 50
const ON_SCREEN_WIDTH = 50
@ -227,6 +222,11 @@ export default {
return bottomBoundingOnScreen && topBoundingOnScreen && rightBoundingOnScreen && leftBoundingOnScreen
}
},
head () {
return {
title: `${this.Articels.post_title} - 轶哥博客`
}
}
}
</script>

View File

@ -39,7 +39,7 @@
<script>
export default {
async asyncData({ app, params, query, $axios }) {
async asyncData ({ app, params, query, $axios }) {
let Info = null
let Articels = []
const nowPage = params.page ? parseInt(params.page) : 1
@ -80,12 +80,12 @@ export default {
nowPath: params.terms ? '/' + params.terms : ''
}
},
mounted() {
mounted () {
this.$finishLoad()
this.analyseImages()
},
methods: {
async analyseImages() { //
async analyseImages () { //
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
this.imageHeight = articleImgsWidth * 0.5625
for (const n in this.Articels) {

View File

@ -39,7 +39,7 @@
<script>
export default {
async asyncData({ app, params, $axios }) {
async asyncData ({ app, params, $axios }) {
let Info = null
let Articels = []
const nowPage = params.page ? parseInt(params.page) : 1
@ -80,12 +80,12 @@ export default {
nowPath: params.terms ? '/' + params.terms : ''
}
},
mounted() {
mounted () {
this.$finishLoad()
this.analyseImages()
},
methods: {
async analyseImages() { //
async analyseImages () { //
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
this.imageHeight = articleImgsWidth * 0.5625
for (const n in this.Articels) {

View File

@ -39,7 +39,7 @@
<script>
export default {
async asyncData({ app, params, $axios }) {
async asyncData ({ app, params, $axios }) {
let Info = null
let Articels = []
const nowPage = params.page ? parseInt(params.page) : 1
@ -80,12 +80,12 @@ export default {
nowPath: params.terms ? '/' + params.terms : ''
}
},
mounted() {
mounted () {
this.$finishLoad()
this.analyseImages()
},
methods: {
async analyseImages() { //
async analyseImages () { //
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
this.imageHeight = articleImgsWidth * 0.5625
for (const n in this.Articels) {

View File

@ -3,7 +3,7 @@ import '~/layouts/common.styl'
const $tags = document.getElementById('tags')
const floatTop = $tags.offsetTop + $tags.scrollHeight + 30
function addEvent(obj, type, fn) {
function addEvent (obj, type, fn) {
if (obj.attachEvent) {
obj.attachEvent('on' + type, function () {
fn.call(obj)

View File

@ -8,7 +8,7 @@ const app = new Koa()
const config = require('../nuxt.config.js')
config.dev = !(app.env === 'production')
async function start() {
async function start () {
// Instantiate nuxt.js
const nuxt = new Nuxt(config)

View File

@ -7,10 +7,10 @@ export const state = () => ({
})
export const mutations = {
increment(state) {
increment (state) {
state.counter++
},
setLeftDatas(state, data) {
setLeftDatas (state, data) {
const NewComments = data[0]
const HotArticle = data[1]
const terms = data[2]
@ -41,7 +41,7 @@ export const mutations = {
}
export const actions = {
async nuxtServerInit({ state, commit }, { $axios }) {
async nuxtServerInit ({ state, commit }, { $axios }) {
if (state.tags.length === 0) {
try {
const datas = await Promise.all([

4509
yarn.lock

File diff suppressed because it is too large Load Diff