add: eslint rules and editorconfig

This commit is contained in:
reco_luan 2019-09-20 13:54:13 +08:00
parent 511b1f75a7
commit b1d4154ec3
29 changed files with 2114 additions and 338 deletions

14
.editorconfig Executable file
View File

@ -0,0 +1,14 @@
# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false

3
.eslintignore Executable file
View File

@ -0,0 +1,3 @@
styles/
images/
node_modules/

205
.eslintrc.js Executable file
View File

@ -0,0 +1,205 @@
module.exports = {
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:vue/essential"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"parser": "babel-eslint",
"ecmaVersion": 2018,
"sourceType": "module",
"allowImportExportEverywhere": true
},
"plugins": [
"vue"
],
rules: {
"vue/max-attributes-per-line": [2, {
"singleline": 10,
"multiline": {
"max": 1,
"allowFirstLine": false
}
}],
"vue/name-property-casing": ["error", "PascalCase"],
"vue/html-self-closing": 0,
"vue/attributes-order": 0,
'accessor-pairs': 2,
'arrow-spacing': [2, {
'before': true,
'after': true
}],
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {
'allowSingleLine': true
}],
'camelcase': [0, {
'properties': 'always'
}],
'comma-dangle': [2, 'never'],
'comma-spacing': [2, {
'before': false,
'after': true
}],
'comma-style': [2, 'last'],
'constructor-super': 2,
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 0,
'eqeqeq': 0,
'generator-star-spacing': [2, {
'before': true,
'after': true
}],
'handle-callback-err': [2, '^(err|error)$'],
'indent': ["error", 2, {
"SwitchCase": 1
}],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [2, {
'beforeColon': false,
'afterColon': true
}],
'keyword-spacing': [2, {
'before': true,
'after': true
}],
'new-cap': [2, {
'newIsCap': true,
'capIsNew': false
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
}],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [2, {
'max': 1
}],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [2, {
'defaultAssignment': false
}],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [2, {
'vars': 'all',
'args': 'none'
}],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [2, {
'initialized': 'never'
}],
'operator-linebreak': [2, 'after', {
'overrides': {
'?': 'before',
':': 'before'
}
}],
'padded-blocks': [2, 'never'],
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'always'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, {
'words': true,
'nonwords': false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
'yoda': [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [2, 'always', {
objectsInObjects: false
}],
'array-bracket-spacing': [2, 'never']
}
};

1
.gitignore vendored
View File

@ -1 +1,2 @@
node_modules/
yarn.lock

View File

@ -20,7 +20,7 @@ export default {
},
customStyle: {
type: Object,
default: function() {
default: function () {
return {
right: '1rem',
bottom: '6rem',
@ -37,27 +37,27 @@ export default {
default: 'fade'
}
},
data() {
data () {
return {
visible: false,
interval: null,
isMoving: false
}
},
mounted() {
mounted () {
window.addEventListener('scroll', this.handleScroll)
},
beforeDestroy() {
beforeDestroy () {
window.removeEventListener('scroll', this.handleScroll)
if (this.interval) {
clearInterval(this.interval)
}
},
methods: {
handleScroll() {
handleScroll () {
this.visible = window.pageYOffset > this.visibilityHeight
},
backToTop() {
backToTop () {
if (this.isMoving) return
const start = window.pageYOffset
let i = 0
@ -74,7 +74,7 @@ export default {
i++
}, 16.7)
},
easeInOutQuad(t, b, c, d) {
easeInOutQuad (t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t + b
return -c / 2 * (--t * (t - 2) - 1) + b
}

View File

@ -46,8 +46,8 @@ import { resolveSidebarItems } from '../util'
import Password from '@theme/components/Password'
import Loading from '@theme/components/Loading'
import Valine from '@theme/components/Valine/'
import BackToTop from "@theme/components/BackToTop"
import { setTimeout } from 'timers';
import BackToTop from '@theme/components/BackToTop'
import { setTimeout } from 'timers'
export default {
components: { Sidebar, Navbar, Password, Valine, BackToTop, Loading },
@ -68,26 +68,26 @@ export default {
const { themeConfig } = this.$site
const { frontmatter } = this.$page
if (
frontmatter.navbar === false
|| themeConfig.navbar === false) {
frontmatter.navbar === false ||
themeConfig.navbar === false) {
return false
}
return (
this.$title
|| themeConfig.logo
|| themeConfig.repo
|| themeConfig.nav
|| this.$themeLocaleConfig.nav
this.$title ||
themeConfig.logo ||
themeConfig.repo ||
themeConfig.nav ||
this.$themeLocaleConfig.nav
)
},
shouldShowSidebar () {
const { frontmatter } = this.$page
return (
this.sidebar !== false
&& !frontmatter.home
&& frontmatter.sidebar !== false
&& this.sidebarItems.length
this.sidebar !== false &&
!frontmatter.home &&
frontmatter.sidebar !== false &&
this.sidebarItems.length
)
},

View File

@ -59,7 +59,7 @@
</template>
<script>
import NavLink from "@theme/components/NavLink/";
import NavLink from '@theme/components/NavLink/'
import AccessNumber from '@theme/components/Valine/AccessNumber'
export default {
@ -73,15 +73,15 @@ export default {
year () {
return new Date().getFullYear()
},
data() {
return this.$frontmatter;
data () {
return this.$frontmatter
},
actionLink() {
actionLink () {
return {
link: this.data.actionLink,
text: this.data.actionText
};
}
},
heroImageStyle () {
@ -94,7 +94,7 @@ export default {
mounted () {
this.recoShow = true
}
};
}
</script>
<style lang="stylus">

View File

@ -77,18 +77,17 @@
</template>
<script>
import NavLink from "@theme/components/NavLink/";
import AccessNumber from '@theme/components/Valine/AccessNumber'
import NoteAbstract from '@theme/components/NoteAbstract.vue'
import mixin from '@theme/mixins/index.js'
export default {
mixins: [mixin],
components: { NavLink, AccessNumber, NoteAbstract },
components: { AccessNumber, NoteAbstract },
data () {
return {
recoShow: false,
tags: [],
tags: []
}
},
computed: {
@ -116,15 +115,15 @@ export default {
year () {
return new Date().getFullYear()
},
data() {
return this.$frontmatter;
data () {
return this.$frontmatter
},
actionLink() {
actionLink () {
return {
link: this.data.actionLink,
text: this.data.actionText
};
}
},
heroImageStyle () {
@ -145,7 +144,7 @@ export default {
},
created () {
if (this.$tags.list.length > 0) {
let tags = this.$tags.list
const tags = this.$tags.list
tags.map(item => {
const color = this._tagColor()
item.color = color
@ -175,9 +174,9 @@ export default {
//
_getTimeNum (data) {
return parseInt(new Date(data.frontmatter.date).getTime())
},
}
};
}
}
</script>
<style lang="stylus">

View File

@ -13,7 +13,7 @@
import mixin from '@theme/mixins/index.js'
export default {
mixins: [mixin]
};
}
</script>
<style lang="stylus" scoped>
#loader-wrapper{

View File

@ -43,7 +43,7 @@ export default {
},
nav () {
const { locales } = this.$site
const { $site: { locales }, userNav } = this
if (locales && Object.keys(locales).length > 1) {
const currentLink = this.$page.path
const routes = this.$router.options.routes
@ -68,19 +68,19 @@ export default {
return { text, link }
})
}
return [...this.userNav, languageDropdown]
return [...userNav, languageDropdown]
}
// blogConfig
const blogConfig = this.$themeConfig.blogConfig || {},
isHasCategory = this.userNav.some(item => {
const blogConfig = this.$themeConfig.blogConfig || {}
const isHasCategory = userNav.some(item => {
if (blogConfig.category) {
return item.text === (blogConfig.category.text || '分类')
} else {
return true
}
}),
isHasTag = this.userNav.some(item => {
})
const isHasTag = userNav.some(item => {
if (blogConfig.tag) {
return item.text === (blogConfig.tag.text || '标签')
} else {
@ -88,31 +88,31 @@ export default {
}
})
if (!isHasCategory && blogConfig.hasOwnProperty('category')) {
if (!isHasCategory && Object.hasOwnProperty.call(blogConfig, 'category')) {
const category = blogConfig.category
const $categories = this.$categories
this.userNav.splice( parseInt(category.location || 2) - 1, 0, {
userNav.splice(parseInt(category.location || 2) - 1, 0, {
items: $categories.list.map(item => {
item.link = item.path
item.text = item.name
return item
}),
text: category.text || '分类',
type: "links",
icon: "reco-category"
type: 'links',
icon: 'reco-category'
})
}
if (!isHasTag && blogConfig.hasOwnProperty('tag')) {
if (!isHasTag && Object.hasOwnProperty.call(blogConfig, 'tag')) {
const tag = blogConfig.tag
this.userNav.splice(parseInt(tag.location || 3) - 1, 0, {
userNav.splice(parseInt(tag.location || 3) - 1, 0, {
link: '/tag/',
text: tag.text || '标签',
type: "links",
icon: "reco-tag"
type: 'links',
icon: 'reco-tag'
})
}
return this.userNav
return userNav
},
userLinks () {
@ -130,6 +130,7 @@ export default {
? repo
: `https://github.com/${repo}`
}
return ''
},
repoLabel () {

View File

@ -59,8 +59,8 @@ export default {
if (document.documentElement.clientWidth < MOBILE_DESKTOP_BREAKPOINT) {
this.linksWrapMaxWidth = null
} else {
this.linksWrapMaxWidth = this.$el.offsetWidth - NAVBAR_VERTICAL_PADDING
- (this.$refs.siteName && this.$refs.siteName.offsetWidth || 0)
this.linksWrapMaxWidth = this.$el.offsetWidth - NAVBAR_VERTICAL_PADDING -
(this.$refs.siteName && this.$refs.siteName.offsetWidth || 0)
}
}
handleLinksWrapWidth()

View File

@ -19,7 +19,7 @@
export default {
data () {
return {
changePage:'', //
changePage: '' //
}
},
props: {
@ -36,42 +36,42 @@ export default {
default: 1
}
},
computed:{
computed: {
pages () {
return Math.ceil(this.total / this.perPage)
},
show:function(){
return this.pages && this.pages !=1
show: function () {
return this.pages && this.pages != 1
},
efont: function() {
if (this.pages <= 7) return false;
efont: function () {
if (this.pages <= 7) return false
return this.currentPage > 5
},
indexs: function() {
var left = 1,
right = this.pages,
ar = [];
indexs: function () {
var left = 1
var right = this.pages
var ar = []
if (this.pages >= 7) {
if (this.currentPage > 5 && this.currentPage < this.pages - 4) {
left = Number(this.currentPage) - 3;
right = Number(this.currentPage) + 3;
left = Number(this.currentPage) - 3
right = Number(this.currentPage) + 3
} else {
if (this.currentPage <= 5) {
left = 1;
right = 7;
left = 1
right = 7
} else {
right = this.pages;
right = this.pages
left = this.pages - 6;
left = this.pages - 6
}
}
}
while (left <= right) {
ar.push(left);
left++;
ar.push(left)
left++
}
return ar
}
return ar;
},
},
methods: {
goPrev () {
@ -86,8 +86,8 @@ export default {
this.emit(++currentPage)
}
},
jumpPage: function(id) {
if(id == ''){
jumpPage: function (id) {
if (id == '') {
alert(`请输入页码!`)
return
}
@ -100,8 +100,8 @@ export default {
emit (id) {
this.$emit('getCurrentPage', id)
}
},
};
}
}
</script>
<style lang="stylus" scoped>

View File

@ -75,7 +75,7 @@ import { resolvePage, outboundRE, endingSlashRE } from '../util'
import TimeLine from '@theme/components/TimeLine'
export default {
components: { PageInfo, TimeLine},
components: { PageInfo, TimeLine },
props: ['sidebarItems'],
@ -92,7 +92,6 @@ export default {
lastUpdated () {
return this.$page.lastUpdated
},
lastUpdatedText () {
if (typeof this.$themeLocaleConfig.lastUpdated === 'string') {
return this.$themeLocaleConfig.lastUpdated
@ -102,7 +101,6 @@ export default {
}
return 'Last Updated'
},
prev () {
const prev = this.$frontmatter.prev
if (prev === false) {
@ -113,7 +111,6 @@ export default {
return resolvePrev(this.$page, this.sidebarItems)
}
},
next () {
const next = this.$frontmatter.next
if (next === false) {
@ -124,10 +121,9 @@ export default {
return resolveNext(this.$page, this.sidebarItems)
}
},
editLink () {
if (this.$frontmatter.editLink === false) {
return
return false
}
const {
repo,
@ -140,13 +136,11 @@ export default {
if (docsRepo && editLinks && this.$page.relativePath) {
return this.createEditLink(repo, docsRepo, docsDir, docsBranch, this.$page.relativePath)
}
return ''
},
editLinkText () {
return (
this.$themeLocaleConfig.editLinkText
|| this.$themeConfig.editLinkText
|| `Edit this page`
this.$themeLocaleConfig.editLinkText || this.$themeConfig.editLinkText || `Edit this page`
)
}
},
@ -171,12 +165,12 @@ export default {
? docsRepo
: repo
return (
base.replace(endingSlashRE, '')
+ `/src`
+ `/${docsBranch}/`
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
+ path
+ `?mode=edit&spa=0&at=${docsBranch}&fileviewer=file-view-default`
base.replace(endingSlashRE, '') +
`/src` +
`/${docsBranch}/` +
(docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '') +
path +
`?mode=edit&spa=0&at=${docsBranch}&fileviewer=file-view-default`
)
}
@ -184,11 +178,11 @@ export default {
? docsRepo
: `https://github.com/${docsRepo}`
return (
base.replace(endingSlashRE, '')
+ `/edit`
+ `/${docsBranch}/`
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
+ path
base.replace(endingSlashRE, '') +
`/edit` +
`/${docsBranch}/` +
(docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '') +
path
)
}
}
@ -280,7 +274,6 @@ function flatten (items, res) {
.next
float right
@media (max-width: $MQMobile)
.page-title
padding: 0 1rem;

View File

@ -29,7 +29,9 @@ export default {
props: {
pageInfo: {
type: Object,
default: {}
default () {
return {}
}
},
currentTag: {
type: String,

View File

@ -35,7 +35,7 @@
import Background from '@theme/components/Background'
export default {
components: {Background},
components: { Background },
props: {
isPage: {
type: Boolean,
@ -43,7 +43,7 @@ export default {
}
},
name: 'Password',
data() {
data () {
return {
warningText: 'Konck! Knock!',
key: ''
@ -70,7 +70,7 @@ export default {
passwordBtn.style.width = `${width - 2}px`
passwordBtn.style.opacity = 1
setTimeout(() => {
window.location.reload();
window.location.reload()
}, 800)
},
isHasKey () {

View File

@ -8,19 +8,19 @@
import screenfull from 'screenfull'
export default {
name: 'Screenfull',
data() {
data () {
return {
isFullscreen: false
}
},
mounted() {
mounted () {
this.init()
},
beforeDestroy() {
beforeDestroy () {
this.destroy()
},
methods: {
click() {
click () {
if (!screenfull.enabled) {
this.$message({
message: 'you browser can not work',
@ -30,15 +30,15 @@ export default {
}
screenfull.toggle()
},
change() {
change () {
this.isFullscreen = screenfull.isFullscreen
},
init() {
init () {
if (screenfull.enabled) {
screenfull.on('change', this.change)
}
},
destroy() {
destroy () {
if (screenfull.enabled) {
screenfull.off('change', this.change)
}

View File

@ -30,15 +30,15 @@ export default {
: selfActive
const link = renderLink(h, item.path, item.title || item.path, active)
const configDepth = $page.frontmatter.sidebarDepth
|| sidebarDepth
|| $themeLocaleConfig.sidebarDepth
|| $themeConfig.sidebarDepth
const configDepth = $page.frontmatter.sidebarDepth ||
sidebarDepth ||
$themeLocaleConfig.sidebarDepth ||
$themeConfig.sidebarDepth
const maxDepth = configDepth == null ? 1 : configDepth
const displayAllHeaders = $themeLocaleConfig.displayAllHeaders
|| $themeConfig.displayAllHeaders
const displayAllHeaders = $themeLocaleConfig.displayAllHeaders ||
$themeConfig.displayAllHeaders
if (item.type === 'auto') {
return [link, renderChildren(h, item.children, item.basePath, $route, maxDepth)]

View File

@ -16,11 +16,11 @@
export default {
name: 'ThemeOptions',
data() {
data () {
return {
darkTheme: 'false',
reco: {}
};
}
},
computed: {
@ -34,35 +34,34 @@ export default {
}
},
mounted() {
mounted () {
const theme = localStorage.getItem('reco-theme')
if (theme) this.setTheme(theme)
},
methods: {
setTheme(theme, moveClass = true) {
const classes = document.body.classList;
const themes = Object.keys(this.themePicker).map(colorTheme => `reco-theme-${colorTheme}`);
setTheme (theme, moveClass = true) {
const classes = document.body.classList
const themes = Object.keys(this.themePicker).map(colorTheme => `reco-theme-${colorTheme}`)
if (!theme) {
if (moveClass) localStorage.removeItem('reco-theme');
classes.remove(...themes);
if (moveClass) localStorage.removeItem('reco-theme')
classes.remove(...themes)
return
}
classes.remove(...themes.filter(t => t !== `reco-theme-${theme}`));
classes.remove(...themes.filter(t => t !== `reco-theme-${theme}`))
if (moveClass) {
classes.add(`reco-theme-${theme}`);
localStorage.setItem('reco-theme', theme);
classes.add(`reco-theme-${theme}`)
localStorage.setItem('reco-theme', theme)
} else {
localStorage.removeItem('reco-theme')
classes.remove(`reco-theme-${theme}`);
classes.remove(`reco-theme-${theme}`)
}
}
},
};
}
}
</script>
<style lang="stylus">

View File

@ -12,32 +12,32 @@
</template>
<script>
import ClickOutside from 'vue-click-outside';
import ThemeOptions from './ThemeOptions.vue';
import ClickOutside from 'vue-click-outside'
import ThemeOptions from './ThemeOptions.vue'
export default {
name: 'UserSettings',
directives: {
'click-outside': ClickOutside,
'click-outside': ClickOutside
},
components: {
ThemeOptions
},
data() {
data () {
return {
showMenu: false,
};
showMenu: false
}
},
methods: {
hideMenu() {
this.showMenu = false;
},
},
};
hideMenu () {
this.showMenu = false
}
}
}
</script>
<style lang="stylus">

View File

@ -63,8 +63,7 @@ export default {
}
}
for(let key in this.formatPages) {
for (const key in this.formatPages) {
this.formatPagesArr.unshift({
year: key,
data: this.formatPages[key].sort((a, b) => {
@ -73,9 +72,9 @@ export default {
})
}
},
renderTime(date) {
var dateee = new Date(date).toJSON();
return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '').replace(/-/g,'/')
renderTime (date) {
var dateee = new Date(date).toJSON()
return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '').replace(/-/g, '/')
},
//
dateFormat (date, type) {
@ -90,7 +89,7 @@ export default {
},
//
go (url) {
this.$router.push({path: url})
this.$router.push({ path: url })
},
//
_getTimeNum (date) {

View File

@ -6,24 +6,23 @@
<script>
export default {
props: ['isComment'],
computed: {
//
isShowComment () {
const frontmatter = this.$frontmatter
return this.isComment == false || frontmatter.isComment == false || frontmatter.home == true ? false : true
return !(this.isComment == false || frontmatter.isComment == false || frontmatter.home == true)
}
},
mounted: function(){
mounted: function () {
this.createValine()
},
methods: {
createValine () {
const valineConfig = this.$themeConfig.valineConfig
if (valineConfig) {
const Valine = require('valine');
const Valine = require('valine')
const AV = require('leancloud-storage')
if (typeof window !== 'undefined') {
this.window = window
@ -31,8 +30,8 @@ export default {
}
new Valine({
el: '#valine' ,
appId: valineConfig.appId,// your appId
el: '#valine',
appId: valineConfig.appId, // your appId
appKey: valineConfig.appKey, // your appKey
placeholder: valineConfig.placeholder || 'just go go',
notify: valineConfig.notify || false,
@ -41,23 +40,22 @@ export default {
visitor: valineConfig.visitor || true,
recordIP: valineConfig.recordIP || false,
path: window.location.pathname
});
})
}
}
},
watch: {
'$route' (to, from) {
if(to.path !== from.path){
if (to.path !== from.path) {
//
// this.$router.go(0)
setTimeout(() => {
this.createValine()
}, 300)
}
}
},
};
}
}
</script>
<style lang="stylus" scoped>

View File

@ -6,8 +6,8 @@ module.exports = (options, ctx) => ({
const { themeConfig, siteConfig } = ctx
// resolve algolia
const isAlgoliaSearch = (
themeConfig.algolia
|| Object.keys(siteConfig.locales && themeConfig.locales || {})
themeConfig.algolia ||
Object.keys(siteConfig.locales && themeConfig.locales || {})
.some(base => themeConfig.locales[base].algolia)
)
return {

View File

@ -24,7 +24,7 @@ export default {
},
mounted () {
if (this.noFoundPageByTencent) {
let dom = document.createElement('script')
const dom = document.createElement('script')
dom.setAttribute('homePageName', '回到首页')
dom.setAttribute('homePageUrl', '/')
dom.setAttribute('src', '//qzonestyle.gtimg.cn/qzone/hybrid/app/404/search_children.js')

View File

@ -52,7 +52,7 @@ export default {
computed: {
//
posts () {
let posts = this.$category.posts
const posts = this.$category.posts
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})

View File

@ -62,7 +62,7 @@ export default {
created () {
if (this.$tags.list.length > 0) {
let tags = this.$tags.list
const tags = this.$tags.list
tags.map(item => {
const color = this._tagColor()
item.color = color
@ -82,10 +82,8 @@ export default {
//
getPagesByTags (currentTag) {
this.currentTag = currentTag
let posts = []
if (currentTag !== '全部') {
posts = this.$tags.map[currentTag].posts
@ -99,7 +97,7 @@ export default {
// reverse()
this.posts = posts.length == 0 ? [] : posts
this.getCurrentPage(1);
this.getCurrentPage(1)
},
getCurrentTag (tag) {

1557
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,9 @@
"description": "this is a vuepress theme",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"eslint-ext": "eslint --ext .js,.vue ./",
"eslint-fix": "eslint --fix --ext .js,.vue ./"
},
"repository": {
"type": "git",
@ -24,10 +26,15 @@
"_from": "vuepress-theme-reco@0.2.1",
"_resolved": "http://registry.npm.taobao.org/vuepress-theme-reco/download/vuepress-theme-reco-0.2.1.tgz",
"dependencies": {
"leancloud-storage": "3.13.2",
"valine": "1.3.6",
"@vuepress/plugin-blog": "1.0.0-alpha.49",
"vue-click-outside": "1.0.7",
"screenfull": "4.2.1"
"leancloud-storage": "3.13.2",
"screenfull": "4.2.1",
"valine": "1.3.6",
"vue-click-outside": "1.0.7"
},
"devDependencies": {
"babel-eslint": "^10.0.3",
"eslint": "^6.4.0",
"eslint-plugin-vue": "^5.2.3"
}
}