Skip to content

Commit 6496869

Browse files
author
reco_luan
committed
feat(vuepress-plugin-pagation): set page size by plugin option
ISSUES CLOSED: #207
1 parent f3476f3 commit 6496869

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

packages/@vuepress-reco/vuepress-plugin-pagation/bin/Pagation.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export default {
7676
},
7777
data () {
7878
return {
79-
changePage: '' // 跳转页
79+
changePage: '', // 跳转页
80+
/* eslint-disable no-undef */
81+
pageSize: PERPAGE
8082
}
8183
},
8284
props: {
@@ -86,7 +88,7 @@ export default {
8688
},
8789
perPage: {
8890
type: Number,
89-
default: 2
91+
default: 10
9092
},
9193
currentPage: {
9294
type: Number,
@@ -95,7 +97,8 @@ export default {
9597
},
9698
computed: {
9799
pages () {
98-
return Math.ceil(this.total / this.perPage)
100+
const pageSize = this.pageSize || this.perPage
101+
return Math.ceil(this.total / pageSize)
99102
},
100103
show: function () {
101104
return this.pages && this.pages != 1

packages/@vuepress-reco/vuepress-plugin-pagation/bin/Pagation.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ import pagationLocales from './locales'
4747
export default {
4848
data () {
4949
return {
50-
changePage: '' // 跳转页
50+
changePage: '', // 跳转页
51+
/* eslint-disable no-undef */
52+
pageSize: PERPAGE
5153
}
5254
},
5355
props: {
@@ -66,7 +68,8 @@ export default {
6668
},
6769
computed: {
6870
pages () {
69-
return Math.ceil(this.total / this.perPage)
71+
const pageSize = this.pageSize || this.perPage
72+
return Math.ceil(this.total / pageSize)
7073
},
7174
show: function () {
7275
return this.pages && this.pages != 1
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
const { path } = require('@vuepress/shared-utils')
22

33
module.exports = (options, context) => ({
4+
define () {
5+
const { perPage } = options || {}
6+
return {
7+
PERPAGE: perPage
8+
}
9+
},
410
name: '@vuepress-reco/vuepress-plugin-pagation',
511
enhanceAppFiles: [
612
path.resolve(__dirname, './bin/enhanceAppFile.js')
713
]
8-
})
14+
})

0 commit comments

Comments
 (0)