upgrade
This commit is contained in:
parent
eaf48b86c3
commit
703f411ee7
@ -91,14 +91,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data () {
|
||||||
return {
|
return {
|
||||||
socialInfo: false,
|
socialInfo: false,
|
||||||
searchVal: ''
|
searchVal: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
info(type) {
|
info (type) {
|
||||||
if (type === 'qq') {
|
if (type === 'qq') {
|
||||||
this.socialInfo = 'QQ: 373226722'
|
this.socialInfo = 'QQ: 373226722'
|
||||||
} else if (type === 'weixin') {
|
} else if (type === 'weixin') {
|
||||||
@ -111,8 +111,8 @@ export default {
|
|||||||
this.socialInfo = false
|
this.socialInfo = false
|
||||||
}, 3000)
|
}, 3000)
|
||||||
},
|
},
|
||||||
search() {
|
search () {
|
||||||
if (this.searchVal !== '') this.$router.push({ path: 'search?q=' + this.searchVal })
|
if (this.searchVal !== '') { this.$router.push({ path: 'search?q=' + this.searchVal }) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function toArray(arraylike) {
|
function toArray (arraylike) {
|
||||||
return Array.prototype.slice.call(arraylike)
|
return Array.prototype.slice.call(arraylike)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ export default {
|
|||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data () {
|
||||||
return {
|
return {
|
||||||
swiper: null,
|
swiper: null,
|
||||||
swiperWidth: 0,
|
swiperWidth: 0,
|
||||||
@ -107,7 +107,7 @@ export default {
|
|||||||
isOnly: false
|
isOnly: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.box = 'swiper-box-' + Math.random().toFixed(2) * 1000
|
this.box = 'swiper-box-' + Math.random().toFixed(2) * 1000
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
/* 初始化的时候, 拿到所有的 DOM 元素以及相关属性 */
|
/* 初始化的时候, 拿到所有的 DOM 元素以及相关属性 */
|
||||||
@ -130,13 +130,13 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/* 阻止容器的上下滚动, 并且只有在水平方向上面滚动超过 10px 才可以阻止 */
|
/* 阻止容器的上下滚动, 并且只有在水平方向上面滚动超过 10px 才可以阻止 */
|
||||||
fn(e) {
|
fn (e) {
|
||||||
if (this.vLock || Math.abs(this.pos.startX - this.pos.moveX) > 10) {
|
if (this.vLock || Math.abs(this.pos.startX - this.pos.moveX) > 10) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* 滑动到指定的页面 */
|
/* 滑动到指定的页面 */
|
||||||
slideTo(index) {
|
slideTo (index) {
|
||||||
if (!this.moving) {
|
if (!this.moving) {
|
||||||
const currentSlide = Math.round(Math.abs(this.left()) / this.swiperWidth)
|
const currentSlide = Math.round(Math.abs(this.left()) / this.swiperWidth)
|
||||||
/* 如果索引值不合法 或者和目前的值相等 */
|
/* 如果索引值不合法 或者和目前的值相等 */
|
||||||
@ -155,7 +155,7 @@ export default {
|
|||||||
this.translateX(-this.swiperWidth * (index + 1))
|
this.translateX(-this.swiperWidth * (index + 1))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
next() {
|
next () {
|
||||||
if (!this.moving) {
|
if (!this.moving) {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
this.moving = true
|
this.moving = true
|
||||||
@ -163,7 +163,7 @@ export default {
|
|||||||
this.translateX(this.left() - this.swiperWidth)
|
this.translateX(this.left() - this.swiperWidth)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
previous() {
|
previous () {
|
||||||
if (!this.moving) {
|
if (!this.moving) {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
this.moving = true
|
this.moving = true
|
||||||
@ -171,7 +171,7 @@ export default {
|
|||||||
this.translateX(this.left() + this.swiperWidth)
|
this.translateX(this.left() + this.swiperWidth)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initElement() {
|
initElement () {
|
||||||
/* 因为传递过来的是个字符串, 所以要手动加点 */
|
/* 因为传递过来的是个字符串, 所以要手动加点 */
|
||||||
this.swiper = document.querySelector('.' + this.box)
|
this.swiper = document.querySelector('.' + this.box)
|
||||||
this.swiperWidth = this.swiper.clientWidth
|
this.swiperWidth = this.swiper.clientWidth
|
||||||
@ -184,7 +184,7 @@ export default {
|
|||||||
this.isOnly = true
|
this.isOnly = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cloneSlide() {
|
cloneSlide () {
|
||||||
const head = this.slides[0].cloneNode(this.slides[0], true)
|
const head = this.slides[0].cloneNode(this.slides[0], true)
|
||||||
const tail = this.slides[this.slidesNumber - 1].cloneNode(this.slides[this.slidesNumber - 1], true)
|
const tail = this.slides[this.slidesNumber - 1].cloneNode(this.slides[this.slidesNumber - 1], true)
|
||||||
this.swiper.appendChild(head)
|
this.swiper.appendChild(head)
|
||||||
@ -194,7 +194,7 @@ export default {
|
|||||||
this.slidesNumber = this.slides.length
|
this.slidesNumber = this.slides.length
|
||||||
},
|
},
|
||||||
/* 根据用户给定的 defaultSlide 设置 init slide 的值 */
|
/* 根据用户给定的 defaultSlide 设置 init slide 的值 */
|
||||||
setDefaultSlide() {
|
setDefaultSlide () {
|
||||||
/*
|
/*
|
||||||
一切用户给定的值, 都是从 0 - x 开始, 比如用户数据里面有 6个数据
|
一切用户给定的值, 都是从 0 - x 开始, 比如用户数据里面有 6个数据
|
||||||
那么给定的就是 0 - 5
|
那么给定的就是 0 - 5
|
||||||
@ -214,7 +214,7 @@ export default {
|
|||||||
/*
|
/*
|
||||||
## start
|
## start
|
||||||
*/
|
*/
|
||||||
play() {
|
play () {
|
||||||
this.timer = setTimeout(() => {
|
this.timer = setTimeout(() => {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
this.moving = true
|
this.moving = true
|
||||||
@ -223,7 +223,7 @@ export default {
|
|||||||
this.translateX(-(this.swiperWidth + Math.abs(this.left())))
|
this.translateX(-(this.swiperWidth + Math.abs(this.left())))
|
||||||
}, this.interval)
|
}, this.interval)
|
||||||
},
|
},
|
||||||
transitionend() {
|
transitionend () {
|
||||||
this.transitionDuration(0)
|
this.transitionDuration(0)
|
||||||
/*
|
/*
|
||||||
一次滑动结束之后, 通过计算, 实际上我们可以拿到当前处于内部索引的第几个 slide
|
一次滑动结束之后, 通过计算, 实际上我们可以拿到当前处于内部索引的第几个 slide
|
||||||
@ -254,7 +254,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* toushstart handler */
|
/* toushstart handler */
|
||||||
s(e) {
|
s (e) {
|
||||||
if (this.isOnly) {
|
if (this.isOnly) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* toushmove handler */
|
/* toushmove handler */
|
||||||
m(e) {
|
m (e) {
|
||||||
if (this.isOnly) {
|
if (this.isOnly) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* toushend handler */
|
/* toushend handler */
|
||||||
e(e) {
|
e (e) {
|
||||||
if (this.isOnly) {
|
if (this.isOnly) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* 响应用户滚动行为 */
|
/* 响应用户滚动行为 */
|
||||||
recover() {
|
recover () {
|
||||||
this.transitionDuration(this.userDuration)
|
this.transitionDuration(this.userDuration)
|
||||||
const distance = Math.abs(this.left()) % this.swiperWidth
|
const distance = Math.abs(this.left()) % this.swiperWidth
|
||||||
let point = []
|
let point = []
|
||||||
@ -365,13 +365,13 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
translateX(value) {
|
translateX (value) {
|
||||||
this.swiper.style.transform = 'translate3d(' + value + 'px, 0, 0)'
|
this.swiper.style.transform = 'translate3d(' + value + 'px, 0, 0)'
|
||||||
},
|
},
|
||||||
transitionDuration(ms) {
|
transitionDuration (ms) {
|
||||||
this.swiper.style.transitionDuration = ms + 'ms'
|
this.swiper.style.transitionDuration = ms + 'ms'
|
||||||
},
|
},
|
||||||
left() {
|
left () {
|
||||||
return this.swiper.getBoundingClientRect().left
|
return this.swiper.getBoundingClientRect().left
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,13 @@ export default {
|
|||||||
LeftContent,
|
LeftContent,
|
||||||
Footer
|
Footer
|
||||||
},
|
},
|
||||||
data() {
|
data () {
|
||||||
return {
|
return {
|
||||||
showLeftMenuValue: 'block',
|
showLeftMenuValue: 'block',
|
||||||
isPhone: ''
|
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;'
|
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) {
|
if (document.body.clientWidth > 768) {
|
||||||
this.showLeftMenuValue = 'block'
|
this.showLeftMenuValue = 'block'
|
||||||
@ -60,7 +60,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showLeftMenu() {
|
showLeftMenu () {
|
||||||
if (this.showLeftMenuValue !== 'block') {
|
if (this.showLeftMenuValue !== 'block') {
|
||||||
this.showLeftMenuValue = 'block'
|
this.showLeftMenuValue = 'block'
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,6 +50,9 @@ module.exports = {
|
|||||||
type: 'image/x-icon',
|
type: 'image/x-icon',
|
||||||
href: '/favicon.ico'
|
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
|
** You can extend webpack config here
|
||||||
*/
|
*/
|
||||||
extend(config, ctx) {
|
extend (config, ctx) {
|
||||||
// Run ESLint on save
|
// Run ESLint on save
|
||||||
if (ctx.isDev && ctx.isClient) {
|
if (ctx.isDev && ctx.isClient) {
|
||||||
config.module.rules.push({
|
config.module.rules.push({
|
||||||
|
48
package.json
48
package.json
@ -13,34 +13,34 @@
|
|||||||
"precommit": "npm run lint"
|
"precommit": "npm run lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-svg-core": "^1.2.15",
|
"@fortawesome/fontawesome-svg-core": "^1.2.26",
|
||||||
"@fortawesome/free-brands-svg-icons": "^5.7.2",
|
"@fortawesome/free-brands-svg-icons": "^5.12.0",
|
||||||
"@fortawesome/free-regular-svg-icons": "^5.7.2",
|
"@fortawesome/free-regular-svg-icons": "^5.12.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^5.7.2",
|
"@fortawesome/free-solid-svg-icons": "^5.12.0",
|
||||||
"@fortawesome/vue-fontawesome": "^0.1.5",
|
"@fortawesome/vue-fontawesome": "^0.1.8",
|
||||||
"@nuxtjs/axios": "^5.4.0",
|
"@nuxtjs/axios": "^5.8.0",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^6.0.3",
|
||||||
"highlight.js": "^9.15.6",
|
"highlight.js": "^9.17.1",
|
||||||
"koa": "^2.7.0",
|
"koa": "^2.11.0",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"nuxt": "^2.4.5"
|
"nuxt": "^2.10.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxtjs/eslint-config": "^0.0.1",
|
"@nuxtjs/eslint-config": "^2.0.0",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.0.3",
|
||||||
"eslint": "^5.15.0",
|
"eslint": "^6.7.2",
|
||||||
"eslint-config-standard": ">=12.0.0",
|
"eslint-config-standard": ">=14.1.0",
|
||||||
"eslint-loader": "^2.1.2",
|
"eslint-loader": "^3.0.3",
|
||||||
"eslint-plugin-import": ">=2.16.0",
|
"eslint-plugin-import": ">=2.19.1",
|
||||||
"eslint-plugin-jest": "^22.3.0",
|
"eslint-plugin-jest": "^23.1.1",
|
||||||
"eslint-plugin-node": ">=8.0.1",
|
"eslint-plugin-node": ">=10.0.0",
|
||||||
"eslint-plugin-promise": ">=4.0.1",
|
"eslint-plugin-promise": ">=4.2.1",
|
||||||
"eslint-plugin-standard": ">=4.0.0",
|
"eslint-plugin-standard": ">=4.0.1",
|
||||||
"eslint-plugin-vue": "^5.2.2",
|
"eslint-plugin-vue": "^6.0.1",
|
||||||
"nodemon": "^1.18.10",
|
"nodemon": "^2.0.2",
|
||||||
"pug": "^2.0.3",
|
"pug": "^2.0.4",
|
||||||
"pug-plain-loader": "^1.0.0",
|
"pug-plain-loader": "^1.0.0",
|
||||||
"stylus": "^0.54.5",
|
"stylus": "^0.54.7",
|
||||||
"stylus-loader": "^3.0.2"
|
"stylus-loader": "^3.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
async asyncData({ app, params, $axios }) {
|
async asyncData ({ app, params, $axios }) {
|
||||||
let Info = null
|
let Info = null
|
||||||
let Articels = []
|
let Articels = []
|
||||||
const nowPage = params.page ? parseInt(params.page) : 1
|
const nowPage = params.page ? parseInt(params.page) : 1
|
||||||
@ -80,12 +80,12 @@ export default {
|
|||||||
nowPath: params.terms ? '/' + params.terms : ''
|
nowPath: params.terms ? '/' + params.terms : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.$finishLoad()
|
this.$finishLoad()
|
||||||
this.analyseImages()
|
this.analyseImages()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async analyseImages() { // 图片大小分析及处理
|
async analyseImages () { // 图片大小分析及处理
|
||||||
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
||||||
this.imageHeight = articleImgsWidth * 0.5625
|
this.imageHeight = articleImgsWidth * 0.5625
|
||||||
for (const n in this.Articels) {
|
for (const n in this.Articels) {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
async asyncData({ app, params, $axios }) {
|
async asyncData ({ app, params, $axios }) {
|
||||||
let Info = null
|
let Info = null
|
||||||
let Articels = []
|
let Articels = []
|
||||||
const nowPage = params.page ? parseInt(params.page) : 1
|
const nowPage = params.page ? parseInt(params.page) : 1
|
||||||
@ -80,12 +80,12 @@ export default {
|
|||||||
nowPath: params.terms ? '/' + params.terms : ''
|
nowPath: params.terms ? '/' + params.terms : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.$finishLoad()
|
this.$finishLoad()
|
||||||
this.analyseImages()
|
this.analyseImages()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async analyseImages() { // 图片大小分析及处理
|
async analyseImages () { // 图片大小分析及处理
|
||||||
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
||||||
this.imageHeight = articleImgsWidth * 0.5625
|
this.imageHeight = articleImgsWidth * 0.5625
|
||||||
for (const n in this.Articels) {
|
for (const n in this.Articels) {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
async asyncData(inject) {
|
async asyncData (inject) {
|
||||||
const { app, params, $axios } = inject
|
const { app, params, $axios } = inject
|
||||||
let Info = null
|
let Info = null
|
||||||
let Articels = []
|
let Articels = []
|
||||||
@ -81,12 +81,12 @@ export default {
|
|||||||
nowPath: params.terms ? '/' + params.terms : ''
|
nowPath: params.terms ? '/' + params.terms : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.$finishLoad()
|
this.$finishLoad()
|
||||||
this.analyseImages()
|
this.analyseImages()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async analyseImages() { // 图片大小分析及处理
|
async analyseImages () { // 图片大小分析及处理
|
||||||
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
||||||
this.imageHeight = articleImgsWidth * 0.5625
|
this.imageHeight = articleImgsWidth * 0.5625
|
||||||
for (const n in this.Articels) {
|
for (const n in this.Articels) {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
async asyncData({ app, params, $axios }) {
|
async asyncData ({ app, params, $axios }) {
|
||||||
let Info = null
|
let Info = null
|
||||||
let Articels = []
|
let Articels = []
|
||||||
const nowPage = params.page ? parseInt(params.page) : 1
|
const nowPage = params.page ? parseInt(params.page) : 1
|
||||||
@ -80,12 +80,12 @@ export default {
|
|||||||
nowPath: params.terms ? '/' + params.terms : ''
|
nowPath: params.terms ? '/' + params.terms : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.$finishLoad()
|
this.$finishLoad()
|
||||||
this.analyseImages()
|
this.analyseImages()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async analyseImages() { // 图片大小分析及处理
|
async analyseImages () { // 图片大小分析及处理
|
||||||
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
||||||
this.imageHeight = articleImgsWidth * 0.5625
|
this.imageHeight = articleImgsWidth * 0.5625
|
||||||
for (const n in this.Articels) {
|
for (const n in this.Articels) {
|
||||||
|
@ -37,7 +37,7 @@ div
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
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 data = await $axios.$get(`/public/article/details?id=${route.params.id}`)
|
||||||
const result = data.result
|
const result = data.result
|
||||||
result.post_date = app.$moment(result.post_date).utc().format('lll')// 格式化时间
|
result.post_date = app.$moment(result.post_date).utc().format('lll')// 格式化时间
|
||||||
@ -56,12 +56,7 @@ export default {
|
|||||||
tocIds: result.post_toc_ids
|
tocIds: result.post_toc_ids
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
head() {
|
mounted () {
|
||||||
return {
|
|
||||||
title: `${this.Articels.post_title} - 轶哥博客`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$finishLoad()
|
this.$finishLoad()
|
||||||
|
|
||||||
if (this.Articels.post_toc_show) {
|
if (this.Articels.post_toc_show) {
|
||||||
@ -107,7 +102,7 @@ export default {
|
|||||||
const scrollToc = () => {
|
const scrollToc = () => {
|
||||||
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
|
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
|
||||||
const windowWidth = window.innerWidth || document.documentElement.clientWidth
|
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)
|
const tocIdsInx = findInIds(tocIdsTop, scrollTop + 130)
|
||||||
if (tocIdsInx !== -1 && lastIdInx !== tocIdsInx && document.getElementsByClassName('articelRightToc')[0]) {
|
if (tocIdsInx !== -1 && lastIdInx !== tocIdsInx && document.getElementsByClassName('articelRightToc')[0]) {
|
||||||
const tocAList = document.getElementsByClassName('articelRightToc')[0].getElementsByTagName('a')
|
const tocAList = document.getElementsByClassName('articelRightToc')[0].getElementsByTagName('a')
|
||||||
@ -135,7 +130,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
decodeTitle(name) {
|
decodeTitle (name) {
|
||||||
try {
|
try {
|
||||||
return this.urldecode(name)
|
return this.urldecode(name)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -143,11 +138,11 @@ export default {
|
|||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
urldecode(encodedString) {
|
urldecode (encodedString) {
|
||||||
let output = encodedString
|
let output = encodedString
|
||||||
let binVal, thisString
|
let binVal, thisString
|
||||||
const myregexp = /(%[^%]{2})/
|
const myregexp = /(%[^%]{2})/
|
||||||
function utf8to16(str) {
|
function utf8to16 (str) {
|
||||||
let c
|
let c
|
||||||
let char2, char3
|
let char2, char3
|
||||||
|
|
||||||
@ -189,13 +184,13 @@ export default {
|
|||||||
output = utf8to16(output)
|
output = utf8to16(output)
|
||||||
return output
|
return output
|
||||||
},
|
},
|
||||||
articelRightTocClick() {
|
articelRightTocClick () {
|
||||||
const windowWidth = window.innerWidth || document.documentElement.clientWidth
|
const windowWidth = window.innerWidth || document.documentElement.clientWidth
|
||||||
if (windowWidth < 768) {
|
if (windowWidth < 768) {
|
||||||
this.showRightToc = false
|
this.showRightToc = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isOnScreen(element) {
|
isOnScreen (element) {
|
||||||
const ON_SCREEN_HEIGHT = 50
|
const ON_SCREEN_HEIGHT = 50
|
||||||
const ON_SCREEN_WIDTH = 50
|
const ON_SCREEN_WIDTH = 50
|
||||||
|
|
||||||
@ -227,6 +222,11 @@ export default {
|
|||||||
|
|
||||||
return bottomBoundingOnScreen && topBoundingOnScreen && rightBoundingOnScreen && leftBoundingOnScreen
|
return bottomBoundingOnScreen && topBoundingOnScreen && rightBoundingOnScreen && leftBoundingOnScreen
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
head () {
|
||||||
|
return {
|
||||||
|
title: `${this.Articels.post_title} - 轶哥博客`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
async asyncData({ app, params, query, $axios }) {
|
async asyncData ({ app, params, query, $axios }) {
|
||||||
let Info = null
|
let Info = null
|
||||||
let Articels = []
|
let Articels = []
|
||||||
const nowPage = params.page ? parseInt(params.page) : 1
|
const nowPage = params.page ? parseInt(params.page) : 1
|
||||||
@ -80,12 +80,12 @@ export default {
|
|||||||
nowPath: params.terms ? '/' + params.terms : ''
|
nowPath: params.terms ? '/' + params.terms : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.$finishLoad()
|
this.$finishLoad()
|
||||||
this.analyseImages()
|
this.analyseImages()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async analyseImages() { // 图片大小分析及处理
|
async analyseImages () { // 图片大小分析及处理
|
||||||
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
||||||
this.imageHeight = articleImgsWidth * 0.5625
|
this.imageHeight = articleImgsWidth * 0.5625
|
||||||
for (const n in this.Articels) {
|
for (const n in this.Articels) {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
async asyncData({ app, params, $axios }) {
|
async asyncData ({ app, params, $axios }) {
|
||||||
let Info = null
|
let Info = null
|
||||||
let Articels = []
|
let Articels = []
|
||||||
const nowPage = params.page ? parseInt(params.page) : 1
|
const nowPage = params.page ? parseInt(params.page) : 1
|
||||||
@ -80,12 +80,12 @@ export default {
|
|||||||
nowPath: params.terms ? '/' + params.terms : ''
|
nowPath: params.terms ? '/' + params.terms : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.$finishLoad()
|
this.$finishLoad()
|
||||||
this.analyseImages()
|
this.analyseImages()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async analyseImages() { // 图片大小分析及处理
|
async analyseImages () { // 图片大小分析及处理
|
||||||
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
||||||
this.imageHeight = articleImgsWidth * 0.5625
|
this.imageHeight = articleImgsWidth * 0.5625
|
||||||
for (const n in this.Articels) {
|
for (const n in this.Articels) {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
async asyncData({ app, params, $axios }) {
|
async asyncData ({ app, params, $axios }) {
|
||||||
let Info = null
|
let Info = null
|
||||||
let Articels = []
|
let Articels = []
|
||||||
const nowPage = params.page ? parseInt(params.page) : 1
|
const nowPage = params.page ? parseInt(params.page) : 1
|
||||||
@ -80,12 +80,12 @@ export default {
|
|||||||
nowPath: params.terms ? '/' + params.terms : ''
|
nowPath: params.terms ? '/' + params.terms : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.$finishLoad()
|
this.$finishLoad()
|
||||||
this.analyseImages()
|
this.analyseImages()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async analyseImages() { // 图片大小分析及处理
|
async analyseImages () { // 图片大小分析及处理
|
||||||
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
const articleImgsWidth = this.$refs.articleImgs.getBoundingClientRect().width
|
||||||
this.imageHeight = articleImgsWidth * 0.5625
|
this.imageHeight = articleImgsWidth * 0.5625
|
||||||
for (const n in this.Articels) {
|
for (const n in this.Articels) {
|
||||||
|
@ -3,7 +3,7 @@ import '~/layouts/common.styl'
|
|||||||
const $tags = document.getElementById('tags')
|
const $tags = document.getElementById('tags')
|
||||||
const floatTop = $tags.offsetTop + $tags.scrollHeight + 30
|
const floatTop = $tags.offsetTop + $tags.scrollHeight + 30
|
||||||
|
|
||||||
function addEvent(obj, type, fn) {
|
function addEvent (obj, type, fn) {
|
||||||
if (obj.attachEvent) {
|
if (obj.attachEvent) {
|
||||||
obj.attachEvent('on' + type, function () {
|
obj.attachEvent('on' + type, function () {
|
||||||
fn.call(obj)
|
fn.call(obj)
|
||||||
|
@ -8,7 +8,7 @@ const app = new Koa()
|
|||||||
const config = require('../nuxt.config.js')
|
const config = require('../nuxt.config.js')
|
||||||
config.dev = !(app.env === 'production')
|
config.dev = !(app.env === 'production')
|
||||||
|
|
||||||
async function start() {
|
async function start () {
|
||||||
// Instantiate nuxt.js
|
// Instantiate nuxt.js
|
||||||
const nuxt = new Nuxt(config)
|
const nuxt = new Nuxt(config)
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@ export const state = () => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
increment(state) {
|
increment (state) {
|
||||||
state.counter++
|
state.counter++
|
||||||
},
|
},
|
||||||
setLeftDatas(state, data) {
|
setLeftDatas (state, data) {
|
||||||
const NewComments = data[0]
|
const NewComments = data[0]
|
||||||
const HotArticle = data[1]
|
const HotArticle = data[1]
|
||||||
const terms = data[2]
|
const terms = data[2]
|
||||||
@ -41,7 +41,7 @@ export const mutations = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
async nuxtServerInit({ state, commit }, { $axios }) {
|
async nuxtServerInit ({ state, commit }, { $axios }) {
|
||||||
if (state.tags.length === 0) {
|
if (state.tags.length === 0) {
|
||||||
try {
|
try {
|
||||||
const datas = await Promise.all([
|
const datas = await Promise.all([
|
||||||
|
Loading…
Reference in New Issue
Block a user