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