Skip to content

Commit 8b0384e

Browse files
committed
feat(Pagination): 完善分页组件
1 parent c77e7c5 commit 8b0384e

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

packages/components/pagination/lib/Pagination.scss

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@
2121
& > * {
2222
margin-left: 6px;
2323
}
24-
.v3-pagination__pages-prev,
25-
.v3-pagination__pages-next,
26-
.v3-pagination__pages-item {
24+
& > :first-child {
25+
margin-left: 12px;
26+
}
27+
& > * {
2728
display: flex;
2829
justify-content: center;
2930
align-items: center;
3031
height: 30px;
3132
border: 1px solid transparent;
33+
border-radius: $border-radius-width-small;
3234
cursor: pointer;
3335
user-select: none;
3436
&:hover {
35-
color: $success-color;
37+
color: $primary-color;
3638
}
3739
&.is-active {
38-
border-color: $success-color;
39-
color: $success-color;
40+
border-color: $primary-color;
41+
color: $primary-color;
4042
}
4143
}
4244
.v3-pagination__pages-prev,

packages/components/pagination/lib/Pagination.vue

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,29 @@
1212
/>
1313
</div>
1414
<div class="v3-pagination__pages">
15-
<div class="v3-pagination__pages-prev">
15+
<div class="v3-pagination__pages-prev" @click="handlePrevPage">
1616
<V3Icon :type="'Left'" />
1717
</div>
18-
<div class="v3-pagination__pages-item">1</div>
19-
<div class="v3-pagination__pages-item">2</div>
20-
<div class="v3-pagination__pages-item">3</div>
21-
<div class="v3-pagination__pages-item">4</div>
22-
<div class="v3-pagination__pages-item">5</div>
23-
<div class="v3-pagination__pages-next">
18+
<div class="v3-pagination__pages-first"></div>
19+
<div
20+
class="v3-pagination__pages-fast-backward"
21+
@mouseenter="isHoverFastBackward = true"
22+
@mouseleave="isHoverFastBackward = false"
23+
>
24+
<V3Icon v-if="!isHoverFastBackward" :type="'More'" />
25+
<V3Icon v-else :type="'DoubleLeft'" />
26+
</div>
27+
<div class="v3-pagination__pages-item" @click="handleTogglePage">1</div>
28+
<div
29+
class="v3-pagination__pages-fast-forward"
30+
@mouseenter="isHoverFastForward = true"
31+
@mouseleave="isHoverFastForward = false"
32+
>
33+
<V3Icon v-if="!isHoverFastForward" :type="'More'" />
34+
<V3Icon v-else :type="'DoubleRight'" />
35+
</div>
36+
<div class="v3-pagination__pages-last"></div>
37+
<div class="v3-pagination__pages-next" @click="handleNextPage">
2438
<V3Icon :type="'Right'" />
2539
</div>
2640
</div>
@@ -38,7 +52,7 @@
3852
</div>
3953
</template>
4054
<script lang="ts" setup>
41-
import { ref } from 'vue';
55+
import { computed, ref } from 'vue';
4256
4357
import { V3Icon, V3Input, V3Select } from '@components/main';
4458
import { isNumber } from 'lodash-es';
@@ -83,14 +97,28 @@ const props = withDefaults(defineProps<IPaginationProps>(), {
8397
* 跳至第n页
8498
*/
8599
const customPage = ref();
86-
function handleInput(v: string) {
87-
customPage.value = Number.parseInt(v.replace(/[^0-9]/g, '')) || '';
100+
function handleInput(e: InputEvent) {
101+
const target = e.target as HTMLInputElement;
102+
let value = target.value;
103+
let valueToNumber = Number.parseInt(value.replace(/[^0-9]/g, ''));
104+
customPage.value = !isNaN(valueToNumber) ? `${valueToNumber}` : undefined;
88105
}
106+
const computedCustomPage = computed(() => {
107+
return Number.parseInt(customPage.value);
108+
});
89109
90110
/**
91111
* n条/页
92112
*/
93113
const customPageSize = ref(10);
114+
115+
const isHoverFastForward = ref(false);
116+
117+
const isHoverFastBackward = ref(false);
118+
119+
function handlePrevPage() {}
120+
function handleTogglePage() {}
121+
function handleNextPage() {}
94122
</script>
95123
<style lang="scss">
96124
@import './Pagination.scss';

0 commit comments

Comments
 (0)