Skip to content

Commit 4346152

Browse files
committed
update pagination progress
will update spell error.
1 parent 65ad14f commit 4346152

File tree

6 files changed

+106
-36
lines changed

6 files changed

+106
-36
lines changed

src/App.vue

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<script setup lang="ts">
2-
import { ref } from "vue"
32
import TitleBar from "./components/native/TitleBar.vue"
43
import Dialog from "./components/Dialog.vue"
54
import TopLinks from "./components/TopLinks.vue"
65
6+
import { ref } from "vue"
7+
import { useStorage } from "@vueuse/core"
8+
79
const isOpenModelDialog = ref(false)
10+
const slideDirection = useStorage(
11+
"roco-navigation-transition-direction",
12+
"slideleft"
13+
)
814
</script>
915

1016
<template>
@@ -14,9 +20,11 @@ const isOpenModelDialog = ref(false)
1420
<TopLinks />
1521

1622
<router-view id="context" v-slot="{ Component }">
17-
<keep-alive>
18-
<component :is="Component" :key="$route.fullPath" />
19-
</keep-alive>
23+
<Transition :name="slideDirection" mode="out-in" :appear="true">
24+
<keep-alive :include="['Home', 'About']">
25+
<component :is="Component" :key="$route.fullPath" />
26+
</keep-alive>
27+
</Transition>
2028
</router-view>
2129
</div>
2230
</template>
@@ -32,18 +40,37 @@ html.dark {
3240
}
3341
</style>
3442

43+
<style lang="postcss" scoped>
44+
.slideleft-enter-active,
45+
.slideleft-leave-active,
46+
.slideright-enter-active,
47+
.slideright-leave-active {
48+
@apply transition-all;
49+
}
50+
51+
.slideleft-enter-from,
52+
.slideleft-leave-to {
53+
@apply translate-x-4 opacity-0;
54+
}
55+
.slideright-enter-from,
56+
.slideright-leave-to {
57+
@apply -translate-x-4 opacity-0;
58+
}
59+
</style>
60+
3561
<style scoped lang="postcss">
3662
#app-main {
3763
@apply relative w-[500px] min-h-[600px]
3864
border border-slate-400
3965
bg-slate-50 dark:bg-slate-700
4066
text-slate-700 dark:text-slate-100
41-
transition-all duration-200 ease-in-out;
67+
transition-all duration-200 ease-in-out
68+
overflow-hidden;
4269
4370
font-family: "SourceHanSerifCN";
4471
}
4572
4673
#context {
47-
@apply relative flex w-full h-full flex-col justify-center items-center px-4;
74+
@apply relative flex w-full min-h-[502px] flex-col justify-start items-center px-4;
4875
}
4976
</style>

src/components/FeatureFilter.vue

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -163,28 +163,9 @@ watch(checkedOption, (value) => {
163163
@apply border-green-400 dark:border-green-500
164164
bg-green-200 dark:bg-green-700
165165
transform transition-all;
166-
animation: jump 0.2s ease-in-out forwards;
167166
}
168167
.feature-item:has(.checked.feature-text) .feature-icon,
169168
.feature-item:has(.checked.feature-text) .feature-text {
170169
@apply bg-green-200 dark:bg-green-700;
171170
}
172-
173-
@keyframes jump {
174-
0% {
175-
@apply -translate-y-px;
176-
}
177-
25% {
178-
@apply translate-y-px;
179-
}
180-
50% {
181-
@apply -translate-y-px;
182-
}
183-
75% {
184-
@apply -translate-y-0.5;
185-
}
186-
100% {
187-
@apply translate-y-0;
188-
}
189-
}
190171
</style>

src/components/native/Paganation.vue

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts" setup>
22
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/vue/20/solid"
33
import { useThrottleFn } from "@vueuse/core"
4-
import { ref, toRefs } from "vue"
4+
import { Ref, ref, toRefs } from "vue"
55
66
const $props = withDefaults(
77
defineProps<{
@@ -32,6 +32,7 @@ const $props = withDefaults(
3232
const { page, total, canJump, hasNext, hasPrev } = toRefs($props)
3333
const { pageUpdateFn } = $props
3434
const innerPage = ref(page.value)
35+
const bar: Ref<HTMLElement | null> = ref(null)
3536
3637
function getDisabledClass(bool: boolean) {
3738
return bool ? "disabled" : null
@@ -46,14 +47,19 @@ function submitPageChange(change?: "plus" | "minus") {
4647
}
4748
const throttleSubmitPageChange = useThrottleFn((change?: "plus" | "minus") => {
4849
submitPageChange(change)
50+
bar.value!.classList.remove("active")
4951
}, 800)
52+
const throttleSubmitPageChangeWithProgress = (change?: "plus" | "minus") => {
53+
bar.value!.classList.add("active")
54+
throttleSubmitPageChange(change)
55+
}
5056
</script>
5157

5258
<template>
5359
<div class="paganation">
5460
<span
5561
:class="['prev', 'operation', getDisabledClass(!hasPrev)]"
56-
@click="throttleSubmitPageChange('minus')"
62+
@click="throttleSubmitPageChangeWithProgress('minus')"
5763
>
5864
<ChevronLeftIcon class="icon" />
5965
</span>
@@ -63,24 +69,25 @@ const throttleSubmitPageChange = useThrottleFn((change?: "plus" | "minus") => {
6369
v-if="canJump && total && pageSize"
6470
type="number"
6571
:min="1"
66-
@keyup.enter="throttleSubmitPageChange()"
72+
@keyup.enter="throttleSubmitPageChangeWithProgress()"
6773
/>
6874
<span v-else class="page">{{ page }}</span>
6975
<span
7076
:class="['next', 'operation', getDisabledClass(!hasNext)]"
71-
@click="throttleSubmitPageChange('plus')"
77+
@click="throttleSubmitPageChangeWithProgress('plus')"
7278
>
7379
<ChevronRightIcon class="icon" />
7480
</span>
7581
<span v-if="canJump && total && pageSize" class="append-text"
7682
>共 {{ Math.round(total / pageSize) }} 页</span
7783
>
84+
<span class="progress-bar" ref="bar"></span>
7885
</div>
7986
</template>
8087

8188
<style lang="postcss" scoped>
8289
.paganation {
83-
@apply inline-flex justify-center items-center flex-wrap mt-4;
90+
@apply relative inline-flex justify-center items-center flex-wrap mt-4;
8491
}
8592
.operation {
8693
@apply inline-flex justify-center items-center px-0.5
@@ -115,4 +122,26 @@ const throttleSubmitPageChange = useThrottleFn((change?: "plus" | "minus") => {
115122
@apply inline-block mx-3
116123
text-sm font-semibold select-none;
117124
}
125+
126+
.progress-bar {
127+
@apply absolute w-full max-w-[128px] h-0.5 bottom-0 left-0
128+
bg-green-400 translate-y-2;
129+
}
130+
.progress-bar.active {
131+
animation: linearProgress 0.5s linear forwards;
132+
}
133+
</style>
134+
135+
<style lang="postcss">
136+
@keyframes linearProgress {
137+
0% {
138+
@apply bg-slate-400 w-0;
139+
}
140+
50% {
141+
@apply w-1/2;
142+
}
143+
100% {
144+
@apply bg-green-400 w-full;
145+
}
146+
}
118147
</style>

src/router.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import type { RouteRecordRaw } from "vue-router"
44
const routes: Array<RouteRecordRaw> = [
55
{
66
path: "/",
7+
name: "Home",
78
component: () => import("./views/Home.vue"),
89
},
910
{
1011
path: "/about",
12+
name: "About",
1113
component: () => import("./views/About.vue"),
1214
},
1315
]

src/views/About.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
<script lang="ts" setup>
2-
// import { ref } from "vue"
2+
import { onActivated } from "vue"
33
import { useStorage } from "@vueuse/core"
44
55
const isFullRound = useStorage("roco-avatar-rounded", false)
6+
const slideDirection = useStorage(
7+
"roco-navigation-transition-direction",
8+
"slideleft"
9+
)
610
711
function toggleAvatarRounded() {
812
isFullRound.value = !isFullRound.value
913
}
14+
15+
onActivated(() => {
16+
slideDirection.value = "slideleft"
17+
})
1018
</script>
1119

1220
<template>
13-
<div id="about">
21+
<div>
1422
<div class="avatar-container">
1523
<img
1624
src="https://avatars.githubusercontent.com/u/73767966?v=4"
@@ -25,6 +33,20 @@ function toggleAvatarRounded() {
2533
<a draggable="false" target="_blank" href="https://github.com/NeserCode"
2634
>NeserCode</a
2735
>
36+
#
37+
<a
38+
draggable="false"
39+
target="_blank"
40+
href="https://github.com/NeserCode-Studio"
41+
>NCS</a
42+
>
43+
·
44+
<a
45+
draggable="false"
46+
target="_blank"
47+
href="https://afdian.net/a/nesercode"
48+
>支持一下!</a
49+
>
2850
</span>
2951
</div>
3052
<span class="mt-8 font-black">致谢</span>
@@ -98,7 +120,7 @@ img {
98120
}
99121
100122
.avatar-container {
101-
@apply w-full flex flex-col justify-center items-center mt-8;
123+
@apply w-full flex flex-col justify-center items-center mt-4;
102124
}
103125
104126
.avatar {
@@ -111,7 +133,7 @@ img {
111133
112134
.author {
113135
@apply inline-block py-0.5 mt-4
114-
text-xs select-none;
136+
text-xs text-center select-none;
115137
}
116138
117139
.api-provide,

src/views/Home.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts" setup>
2-
import { ref, computed, provide } from "vue"
2+
import { ref, computed, provide, onActivated } from "vue"
3+
import { useStorage } from "@vueuse/core"
34
import SearchFilter from "../components/SearchFilter.vue"
45
import FeatureFilter from "../components/FeatureFilter.vue"
56
import SpiritList from "../components/SpiritList.vue"
@@ -9,6 +10,14 @@ import {
910
UpdateFeatureFunctionalKey,
1011
UpdateSearchFunctionalKey,
1112
} from "../tokens"
13+
const slideDirection = useStorage(
14+
"roco-navigation-transition-direction",
15+
"slideleft"
16+
)
17+
18+
onActivated(() => {
19+
slideDirection.value = "slideright"
20+
})
1221
1322
const selectedFeature = ref("")
1423
const inputSearch = ref("")
@@ -60,7 +69,7 @@ function pageUpdateFn(page: number) {
6069
</script>
6170

6271
<template>
63-
<div id="home">
72+
<div>
6473
<div class="filters">
6574
<SearchFilter />
6675
<FeatureFilter />

0 commit comments

Comments
 (0)