refactor: fix type error

This commit is contained in:
yukineko 2024-01-05 01:23:53 +09:00
parent 61f63f368d
commit 310e68c0e3
No known key found for this signature in database
GPG Key ID: E5BACB72109B7B90
2 changed files with 16 additions and 11 deletions

View File

@ -49,7 +49,7 @@ type MfmEvents = {
}; };
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
export default function(props: MfmProps, context: SetupContext<MfmEvents>) { export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEvents>['emit'] }) {
const isNote = props.isNote ?? true; const isNote = props.isNote ?? true;
const shouldNyaize = props.nyaize ? props.nyaize === 'respect' ? props.author?.isCat : false : false; const shouldNyaize = props.nyaize ? props.nyaize === 'respect' ? props.author?.isCat : false : false;
@ -292,7 +292,7 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
const clickEv = typeof token.props.args.ev === 'string' ? token.props.args.ev : ''; const clickEv = typeof token.props.args.ev === 'string' ? token.props.args.ev : '';
context.emit('clickEv', clickEv); emit('clickEv', clickEv);
} }, genEl(token.children, scale)); } }, genEl(token.children, scale));
} }
} }

View File

@ -63,27 +63,32 @@ onMounted(() => {
watch([parentStickyTop, parentStickyBottom], calc); watch([parentStickyTop, parentStickyBottom], calc);
watch(childStickyTop, () => { watch(childStickyTop, () => {
if (bodyEl.value == null) return;
bodyEl.value.style.setProperty('--stickyTop', `${childStickyTop.value}px`); bodyEl.value.style.setProperty('--stickyTop', `${childStickyTop.value}px`);
}, { }, {
immediate: true, immediate: true,
}); });
watch(childStickyBottom, () => { watch(childStickyBottom, () => {
if (bodyEl.value == null) return;
bodyEl.value.style.setProperty('--stickyBottom', `${childStickyBottom.value}px`); bodyEl.value.style.setProperty('--stickyBottom', `${childStickyBottom.value}px`);
}, { }, {
immediate: true, immediate: true,
}); });
headerEl.value.style.position = 'sticky'; if (headerEl.value != null) {
headerEl.value.style.top = 'var(--stickyTop, 0)'; headerEl.value.style.position = 'sticky';
headerEl.value.style.zIndex = '1000'; headerEl.value.style.top = 'var(--stickyTop, 0)';
headerEl.value.style.zIndex = '1000';
observer.observe(headerEl.value);
}
footerEl.value.style.position = 'sticky'; if (footerEl.value != null) {
footerEl.value.style.bottom = 'var(--stickyBottom, 0)'; footerEl.value.style.position = 'sticky';
footerEl.value.style.zIndex = '1000'; footerEl.value.style.bottom = 'var(--stickyBottom, 0)';
footerEl.value.style.zIndex = '1000';
observer.observe(headerEl.value); observer.observe(footerEl.value);
observer.observe(footerEl.value); }
}); });
onUnmounted(() => { onUnmounted(() => {