1
0
mirror of https://github.com/robonen/lorem-blog.git synced 2026-03-20 10:54:38 +00:00

feat(blog): implement BlogHeader and BlogList components, add post fetching and filtering logic

This commit is contained in:
2025-06-15 15:40:54 +07:00
parent 8e408ead25
commit 35104cdbc8
7 changed files with 425 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
import { type MaybeRefOrGetter, onScopeDispose, toValue, watchEffect } from 'vue';
export function useBodyScrollLock(isLocked: MaybeRefOrGetter<boolean>) {
let originalOverflow: string | null = null;
const lock = () => {
if (originalOverflow === null)
originalOverflow = document.body.style.overflow || '';
document.body.style.overflow = 'hidden';
};
const unlock = () => {
if (originalOverflow !== null) {
document.body.style.overflow = originalOverflow;
originalOverflow = null;
}
};
watchEffect(() => {
if (toValue(isLocked))
lock();
else
unlock();
});
onScopeDispose(() => {
unlock();
});
return {
lock,
unlock,
};
}