2022-07-03 00:40:02 -05:00
|
|
|
<template>
|
|
|
|
<span v-if="!fetching" class="xbhtxfms">
|
|
|
|
<template v-if="display === 'marquee'">
|
2022-12-29 22:37:14 -06:00
|
|
|
<Transition name="change" mode="default">
|
2022-07-03 00:40:02 -05:00
|
|
|
<MarqueeText :key="key" :duration="marqueeDuration" :reverse="marqueeReverse">
|
|
|
|
<span v-for="item in items" class="item">
|
|
|
|
<a class="link" :href="item.link" rel="nofollow noopener" target="_blank" :title="item.title">{{ item.title }}</a><span class="divider"></span>
|
|
|
|
</span>
|
|
|
|
</MarqueeText>
|
2022-12-29 22:37:14 -06:00
|
|
|
</Transition>
|
2022-07-03 00:40:02 -05:00
|
|
|
</template>
|
|
|
|
<template v-else-if="display === 'oneByOne'">
|
|
|
|
<!-- TODO -->
|
|
|
|
</template>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-02-16 08:09:41 -06:00
|
|
|
import { ref } from 'vue';
|
2022-08-30 10:24:33 -05:00
|
|
|
import MarqueeText from '@/components/MkMarquee.vue';
|
2022-07-03 00:40:02 -05:00
|
|
|
import { useInterval } from '@/scripts/use-interval';
|
2022-07-15 03:12:08 -05:00
|
|
|
import { shuffle } from '@/scripts/shuffle';
|
2022-07-03 00:40:02 -05:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
url?: string;
|
2022-07-15 03:12:08 -05:00
|
|
|
shuffle?: boolean;
|
2022-07-03 00:40:02 -05:00
|
|
|
display?: 'marquee' | 'oneByOne';
|
|
|
|
marqueeDuration?: number;
|
|
|
|
marqueeReverse?: boolean;
|
|
|
|
oneByOneInterval?: number;
|
|
|
|
refreshIntervalSec?: number;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const items = ref([]);
|
|
|
|
const fetching = ref(true);
|
|
|
|
let key = $ref(0);
|
|
|
|
|
|
|
|
const tick = () => {
|
2022-12-03 04:42:05 -06:00
|
|
|
window.fetch(`/api/fetch-rss?url=${props.url}`, {}).then(res => {
|
2022-07-03 00:40:02 -05:00
|
|
|
res.json().then(feed => {
|
2022-07-15 03:12:08 -05:00
|
|
|
if (props.shuffle) {
|
|
|
|
shuffle(feed.items);
|
|
|
|
}
|
2022-07-03 00:40:02 -05:00
|
|
|
items.value = feed.items;
|
|
|
|
fetching.value = false;
|
|
|
|
key++;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
useInterval(tick, Math.max(5000, props.refreshIntervalSec * 1000), {
|
|
|
|
immediate: true,
|
|
|
|
afterMounted: true,
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.change-enter-active, .change-leave-active {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
transition: all 1s ease;
|
|
|
|
}
|
|
|
|
.change-enter-from {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(-100%);
|
|
|
|
}
|
|
|
|
.change-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(100%);
|
|
|
|
}
|
|
|
|
|
|
|
|
.xbhtxfms {
|
|
|
|
display: inline-block;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
::v-deep(.item) {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
vertical-align: bottom;
|
|
|
|
margin: 0;
|
|
|
|
|
|
|
|
> .divider {
|
|
|
|
display: inline-block;
|
|
|
|
width: 0.5px;
|
|
|
|
height: var(--height);
|
2022-07-07 03:28:21 -05:00
|
|
|
margin: 0 3em;
|
2022-07-03 00:40:02 -05:00
|
|
|
background: currentColor;
|
2022-07-03 02:36:13 -05:00
|
|
|
opacity: 0.3;
|
2022-07-03 00:40:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|