2022-07-03 08:40:02 +03:00
|
|
|
<template>
|
|
|
|
<span v-if="!fetching" class="xbhtxfms">
|
|
|
|
<template v-if="display === 'marquee'">
|
2022-12-30 06:37:14 +02:00
|
|
|
<Transition name="change" mode="default">
|
2022-07-03 08:40:02 +03: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-30 06:37:14 +02:00
|
|
|
</Transition>
|
2022-07-03 08:40:02 +03:00
|
|
|
</template>
|
|
|
|
<template v-else-if="display === 'oneByOne'">
|
|
|
|
<!-- TODO -->
|
|
|
|
</template>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, defineAsyncComponent, ref, toRef, watch } from 'vue';
|
2022-08-30 18:24:33 +03:00
|
|
|
import MarqueeText from '@/components/MkMarquee.vue';
|
2022-07-03 08:40:02 +03:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { useInterval } from '@/scripts/use-interval';
|
2022-07-15 11:12:08 +03:00
|
|
|
import { shuffle } from '@/scripts/shuffle';
|
2022-07-03 08:40:02 +03:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
url?: string;
|
2022-07-15 11:12:08 +03:00
|
|
|
shuffle?: boolean;
|
2022-07-03 08:40:02 +03: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 12:42:05 +02:00
|
|
|
window.fetch(`/api/fetch-rss?url=${props.url}`, {}).then(res => {
|
2022-07-03 08:40:02 +03:00
|
|
|
res.json().then(feed => {
|
2022-07-15 11:12:08 +03:00
|
|
|
if (props.shuffle) {
|
|
|
|
shuffle(feed.items);
|
|
|
|
}
|
2022-07-03 08:40:02 +03: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 11:28:21 +03:00
|
|
|
margin: 0 3em;
|
2022-07-03 08:40:02 +03:00
|
|
|
background: currentColor;
|
2022-07-03 10:36:13 +03:00
|
|
|
opacity: 0.3;
|
2022-07-03 08:40:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|