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']
}
};

3
.gitignore vendored
View File

@ -1 +1,2 @@
node_modules/
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
}
@ -88,7 +88,7 @@ export default {
display: inline-block;
text-align: center;
cursor: pointer;
i
i
font-size 1.6rem
color $accentColor
.back-to-ceiling:hover {

View File

@ -25,14 +25,14 @@
<slot
name="sidebar-bottom"
slot="bottom"/>
</Sidebar>
</Sidebar>
<Password v-if="!isHasPageKey" :isPage="true"></Password>
<div v-else>
<slot></slot>
<Valine :isComment="isComment"></Valine>
</div>
<BackToTop></BackToTop>
</div>
</transition>
@ -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
)
},
@ -127,7 +127,7 @@ export default {
hasKey () {
const keyPage = this.$themeConfig.keyPage
if (!keyPage) {
this.isHasKey = true
this.isHasKey = true
return
}
@ -137,7 +137,7 @@ export default {
hasPageKey () {
const pageKeys = this.$frontmatter.keys
if (!pageKeys) {
this.isHasPageKey = true
this.isHasPageKey = true
return
}

View File

@ -1,10 +1,10 @@
<template>
<div class="home" :class="recoShow?'reco-show': 'reco-hide'">
<div class="hero">
<img
v-if="data.isShowHeroImage !== false"
:style="heroImageStyle"
:src="data.heroImage ? $withBase(data.heroImage) : require('../images/icon_vuepress_reco.png')"
<img
v-if="data.isShowHeroImage !== false"
:style="heroImageStyle"
:src="data.heroImage ? $withBase(data.heroImage) : require('../images/icon_vuepress_reco.png')"
alt="hero">
<h1 v-if="data.isShowTitleInHome !== false">{{ data.heroText || $title || '午后南杂' }}</h1>
@ -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">
@ -181,7 +181,7 @@ export default {
margin-left 1rem
> i {
margin-right .5rem
}
}
}
}

View File

@ -9,13 +9,13 @@
<div class="home-blog-wrapper">
<!-- 博客列表 -->
<note-abstract
<note-abstract
class="blog-list"
:data="posts"
:isHome="true"
:currentPage="1"></note-abstract>
<div class="info-wrapper">
<img class="personal-img" :src="$frontmatter.faceImage ? $withBase($frontmatter.faceImage) : require('../images/home-head.png')" alt="hero">
<img class="personal-img" :src="$frontmatter.faceImage ? $withBase($frontmatter.faceImage) : require('../images/home-head.png')" alt="hero">
<h3 class="name" v-if="$themeConfig.author || $site.title">{{ $themeConfig.author || $site.title }}</h3>
<div class="num">
<div>
@ -40,13 +40,13 @@
<hr>
<h4><i class="iconfont reco-tag"></i> 标签</h4>
<div class="tags">
<span
v-for="(item, index) in tags"
<span
v-for="(item, index) in tags"
:key="index"
:style="{ 'backgroundColor': item.color }"
@click="getPagesByTags(item.name)">{{item.name}}</span>
</div>
</div>
</div>
</div>
<Content class="home-center" custom/>
@ -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">
@ -218,7 +217,7 @@ export default {
.info-wrapper {
transition all .3s
margin-left 15px;
width 380px;
width 380px;
height auto;
box-shadow 0 2px 10px rgba(0,0,0,0.2);
box-sizing border-box
@ -262,7 +261,7 @@ export default {
.category-item {
padding: .4rem .8rem;
border: 1px solid #999;
transition: all .5s
transition: all .5s
&:first-child {
border-top-right-radius: .25rem;
border-top-left-radius: .25rem;
@ -302,15 +301,15 @@ export default {
color: #fff;
font-size: 13px;
box-shadow 0 1px 4px 0 rgba(0,0,0,0.2)
transition: all .5s
transition: all .5s
&:hover {
transform scale(1.04)
}
}
&.active {
transform scale(1.2)
}
}
}
}
}
}
}
}
@ -323,7 +322,7 @@ export default {
margin-left 1rem
> i {
margin-right .5rem
}
}
}
}
}

View File

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

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,51 +68,51 @@ export default {
return { text, link }
})
}
return [...this.userNav, languageDropdown]
return [...userNav, languageDropdown]
}
// blogConfig
const blogConfig = this.$themeConfig.blogConfig || {},
isHasCategory = this.userNav.some(item => {
if (blogConfig.category) {
return item.text === (blogConfig.category.text || '分类')
} else {
return true
}
}),
isHasTag = this.userNav.some(item => {
if (blogConfig.tag) {
return item.text === (blogConfig.tag.text || '标签')
} else {
return true
}
})
const blogConfig = this.$themeConfig.blogConfig || {}
const isHasCategory = userNav.some(item => {
if (blogConfig.category) {
return item.text === (blogConfig.category.text || '分类')
} else {
return true
}
})
const isHasTag = userNav.some(item => {
if (blogConfig.tag) {
return item.text === (blogConfig.tag.text || '标签')
} else {
return true
}
})
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

@ -67,7 +67,7 @@ export default {
cursor: pointer;
&.active
color $accentColor
&:hover
&:hover
color $accentColor
@media (max-width: $MQMobile)

View File

@ -1,27 +1,27 @@
<template>
<div class="pagation" v-show="show">
<div class="pagation-list">
<span class="jump" v-show="currentPage>1" @click="goPrev" unselectable="on">Prev</span>
<span v-show="efont" class="jump" @click="jumpPage(1)">1</span>
<span class="ellipsis" v-show="efont">...</span>
<span class="jump" v-for="num in indexs" :key="num" :class="{bgprimary:currentPage==num}" @click="jumpPage(num)">{{num}}</span>
<span class="ellipsis" v-show="efont&&currentPage<pages-4">...</span>
<div class="pagation" v-show="show">
<div class="pagation-list">
<span class="jump" v-show="currentPage>1" @click="goPrev" unselectable="on">Prev</span>
<span v-show="efont" class="jump" @click="jumpPage(1)">1</span>
<span class="ellipsis" v-show="efont">...</span>
<span class="jump" v-for="num in indexs" :key="num" :class="{bgprimary:currentPage==num}" @click="jumpPage(num)">{{num}}</span>
<span class="ellipsis" v-show="efont&&currentPage<pages-4">...</span>
<span v-show="efont&&currentPage<pages-4" class="jump" @click="jumpPage(pages)">{{pages}}</span>
<span class="jump" v-show="currentPage < pages" @click="goNext">Next</span>
<span class="jumppoint">跳转到</span>
<span class="jumpinp"><input type="text" v-model="changePage"></span>
<span class="jump gobtn" @click="jumpPage(changePage)">GO</span>
</div>
</div>
<span class="jump" v-show="currentPage < pages" @click="goNext">Next</span>
<span class="jumppoint">跳转到</span>
<span class="jumpinp"><input type="text" v-model="changePage"></span>
<span class="jump gobtn" @click="jumpPage(changePage)">GO</span>
</div>
</div>
</template>
<script>
export default {
data () {
return {
changePage:'', //
}
},
changePage: '' //
}
},
props: {
total: {
type: Number,
@ -36,42 +36,42 @@ export default {
default: 1
}
},
computed:{
pages () {
return Math.ceil(this.total / this.perPage)
},
show:function(){
return this.pages && this.pages !=1
},
efont: function() {
if (this.pages <= 7) return false;
return this.currentPage > 5
},
indexs: function() {
var left = 1,
right = this.pages,
ar = [];
if (this.pages >= 7) {
if (this.currentPage > 5 && this.currentPage < this.pages - 4) {
left = Number(this.currentPage) - 3;
right = Number(this.currentPage) + 3;
} else {
if (this.currentPage <= 5) {
left = 1;
right = 7;
} else {
right = this.pages;
computed: {
pages () {
return Math.ceil(this.total / this.perPage)
},
show: function () {
return this.pages && this.pages != 1
},
efont: function () {
if (this.pages <= 7) return false
return this.currentPage > 5
},
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
} else {
if (this.currentPage <= 5) {
left = 1
right = 7
} else {
right = this.pages
left = this.pages - 6;
}
}
}
while (left <= right) {
ar.push(left);
left++;
}
return ar;
},
left = this.pages - 6
}
}
}
while (left <= right) {
ar.push(left)
left++
}
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,22 +100,22 @@ export default {
emit (id) {
this.$emit('getCurrentPage', id)
}
},
};
}
}
</script>
<style lang="stylus" scoped>
.pagation
font-weight: 700;
text-align: center;
color: #888;
margin: 20px auto 0;
background: #f2f2f2;
font-weight: 700;
text-align: center;
color: #888;
margin: 20px auto 0;
background: #f2f2f2;
.pagation-list
font-size: 0;
background: #fff;
line-height: 50px;
font-size: 0;
background: #fff;
line-height: 50px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
@ -125,31 +125,31 @@ export default {
span
font-size: 14px;
&.jump
border: 1px solid #ccc;
padding: 5px 8px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
cursor: pointer;
border: 1px solid #ccc;
padding: 5px 8px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
cursor: pointer;
margin-left: 5px;
&.jumpinp
input
width: 55px;
height: 26px;
font-size: 13px;
border: 1px solid #ccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
width: 55px;
height: 26px;
font-size: 13px;
border: 1px solid #ccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
text-align: center;
outline none
&.bgprimary
cursor: default;
color: #fff;
background: $accentColor;
border-color: $accentColor;
cursor: default;
color: #fff;
background: $accentColor;
border-color: $accentColor;
&.ellipsis
padding: 0px 8px;
padding: 0px 8px;
&.jumppoint
margin-left: 30px;
</style>

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`
)
}
},
@ -156,7 +150,7 @@ export default {
const keys = this.$frontmatter.keys
if (!keys) {
this.isHasKey = true
this.isHasKey = true
return
}
@ -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
)
}
}
@ -236,7 +230,7 @@ function flatten (items, res) {
#time-line {
margin-top 0
padding-top 0
}
}
.page-title
max-width: 740px;
margin: 0 auto;
@ -265,7 +259,7 @@ function flatten (items, res) {
}
&.reco-show.page {
load-end(0.08s)
}
}
.page-nav
@extend $wrapper
@ -280,10 +274,9 @@ function flatten (items, res) {
.next
float right
@media (max-width: $MQMobile)
.page-title
padding: 0 1rem;
padding: 0 1rem;
.page-edit
.edit-link
margin-bottom .5rem

View File

@ -29,7 +29,9 @@ export default {
props: {
pageInfo: {
type: Object,
default: {}
default () {
return {}
}
},
currentTag: {
type: String,
@ -49,7 +51,7 @@ export default {
}
}
},
methods: {
goTags (tag) {
const base = this.$site.base
@ -66,7 +68,7 @@ export default {
line-height 1.5rem
&:not(:last-child)
margin-right 1rem
span
span
margin-left .5rem
.tags
.tag-item
@ -74,7 +76,7 @@ export default {
font-family Ubuntu, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif
&.active
color $accentColor
&:hover
&:hover
color $accentColor
@media (max-width: $MQMobile)

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: ''
@ -63,14 +63,14 @@ export default {
if (!isHasKey) {
this.warningText = 'Key Error'
return
}
}
const passwordBtn = this.$refs.passwordBtn
const width = document.getElementById('box').getClientRects()[0].width
passwordBtn.style.width = `${width - 2}px`
passwordBtn.style.opacity = 1
setTimeout(() => {
window.location.reload();
window.location.reload()
}, 800)
},
isHasKey () {
@ -221,7 +221,7 @@ export default {
margin-left 1rem
> i {
margin-right .5rem
}
}
}
}
@media (max-width: $MQMobile) {

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

@ -33,7 +33,7 @@ export default {
props: [
'items',
'depth', // depth of current sidebar links
'depth', // depth of current sidebar links
'sidebarDepth' // depth of headers to be extracted
],

View File

@ -14,55 +14,54 @@
<script>
export default {
name: 'ThemeOptions',
name: 'ThemeOptions',
data() {
return {
darkTheme: 'false',
reco: {}
};
},
data () {
return {
darkTheme: 'false',
reco: {}
}
},
computed: {
themePicker () {
return this.$themeConfig.themePicker || {
red: '#f26d6d',
blue: '#2196f3',
green: '#3eaf7c',
orange: '#fb9b5f'
}
}
},
computed: {
themePicker () {
return this.$themeConfig.themePicker || {
red: '#f26d6d',
blue: '#2196f3',
green: '#3eaf7c',
orange: '#fb9b5f'
}
}
},
mounted() {
const theme = localStorage.getItem('reco-theme')
if (theme) this.setTheme(theme)
},
mounted () {
const theme = localStorage.getItem('reco-theme')
if (theme) this.setTheme(theme)
},
methods: {
setTheme(theme, moveClass = true) {
methods: {
setTheme (theme, moveClass = true) {
const classes = document.body.classList
const themes = Object.keys(this.themePicker).map(colorTheme => `reco-theme-${colorTheme}`)
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)
return
}
if (!theme) {
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);
} else {
localStorage.removeItem('reco-theme')
classes.remove(`reco-theme-${theme}`);
}
}
},
};
if (moveClass) {
classes.add(`reco-theme-${theme}`)
localStorage.setItem('reco-theme', theme)
} else {
localStorage.removeItem('reco-theme')
classes.remove(`reco-theme-${theme}`)
}
}
}
}
</script>
<style lang="stylus">
@ -87,7 +86,7 @@ export default {
&.{key}-theme {
background-color: value;
}
}
}
}
}
}

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',
name: 'UserSettings',
directives: {
'click-outside': ClickOutside,
},
directives: {
'click-outside': ClickOutside
},
components: {
ThemeOptions
},
components: {
ThemeOptions
},
data() {
return {
showMenu: false,
};
},
data () {
return {
showMenu: false
}
},
methods: {
hideMenu() {
this.showMenu = false;
},
},
};
methods: {
hideMenu () {
this.showMenu = false
}
}
}
</script>
<style lang="stylus">

View File

@ -56,15 +56,14 @@ export default {
this.pages = pages.length == 0 ? [] : pages
for (let i = 0, length = pages.length; i < length; i++) {
const page = pages[i]
const pageDateYear = this.dateFormat(page.frontmatter.date, 'year')
const pageDateYear = this.dateFormat(page.frontmatter.date, 'year')
if (this.formatPages[pageDateYear]) this.formatPages[pageDateYear].push(page)
else {
this.formatPages[pageDateYear] = [page]
}
}
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) {
@ -135,7 +134,7 @@ export default {
height: 8px;
background: #ddd;
border-radius: 50%;
}
}
}
.year {
margin: 80px 0 0px;
@ -157,7 +156,7 @@ export default {
&::before {
background $accentColor
}
}
}
.title {
color $accentColor
}
@ -179,7 +178,7 @@ export default {
border-radius: 50%;
border: 1px solid #fff;
z-index 2
}
}
}
.title {
line-height 30px

View File

@ -6,33 +6,32 @@
<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
window.AV = AV
}
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>
@ -81,5 +79,5 @@ export default {
padding-left: 16.4rem;
@media (max-width: $MQMobile)
.valine-wrapper
padding-left: 0;
padding-left: 0;
</style>

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

@ -4,10 +4,10 @@
<Common :sidebar="false" :isComment="false">
<!-- 分类集合 -->
<ul class="category-wrapper">
<li
<li
class="category-item"
:class="title.trim() == item.name ? 'active': ''"
v-for="(item, index) in this.$categories.list"
v-for="(item, index) in this.$categories.list"
:key="index">
<router-link :to="item.path">
<span class="category-name">{{ item.name }}</span>
@ -17,14 +17,14 @@
</ul>
<!-- 博客列表 -->
<note-abstract
<note-abstract
class="list"
:data="posts"
:currentPage="currentPage"
@currentTag="getCurrentTag"></note-abstract>
<!-- 分页 -->
<pagation
<pagation
class="pagation"
:total="posts.length"
:currentPage="currentPage"
@ -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)
})
@ -94,7 +94,7 @@ export default {
.categories-wrapper
max-width: 740px;
margin: 0 auto;
padding: 4.6rem 2.5rem 0;
padding: 4.6rem 2.5rem 0;
.category-wrapper {
list-style none
padding-left 0
@ -151,7 +151,7 @@ export default {
.pagation {
load-end(0.24s)
}
}
}
@media (max-width: $MQMobile)
.categories-wrapper

View File

@ -2,21 +2,21 @@
<div class="tags-wrapper" :class="recoShow?'reco-show': 'reco-hide'">
<Common :sidebar="false" :isComment="false"></Common>
<div class="tags">
<span
v-for="(item, index) in tags"
<span
v-for="(item, index) in tags"
:key="index"
:class="{'active': item.name == currentTag}"
:style="{ 'backgroundColor': item.color }"
@click="getPagesByTags(item.name)">{{item.name}}</span>
</div>
<note-abstract
<note-abstract
class="list"
:data="posts"
:currentPage="currentPage"
:currentTag="currentTag"
@currentTag="getCurrentTag"></note-abstract>
<pagation
<pagation
class="pagation"
:total="posts.length"
:currentPage="currentPage"
@ -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,9 +82,7 @@ export default {
//
getPagesByTags (currentTag) {
this.currentTag = currentTag
let posts = []
if (currentTag !== '全部') {
@ -98,8 +96,8 @@ export default {
// reverse()
this.posts = posts.length == 0 ? [] : posts
this.getCurrentPage(1);
this.getCurrentPage(1)
},
getCurrentTag (tag) {
@ -127,7 +125,7 @@ export default {
.tags-wrapper
max-width: 740px;
margin: 0 auto;
padding: 4.6rem 2.5rem 0;
padding: 4.6rem 2.5rem 0;
.tags
margin 30px 0
span
@ -161,7 +159,7 @@ export default {
.pagation {
load-end(0.24s)
}
}
}
@media (max-width: $MQMobile)
.tags-wrapper

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"
}
}
}