2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-07-11 01:13:11 +00:00
|
|
|
<mk-container :show-header="props.showHeader">
|
|
|
|
<template #header><fa :icon="faRssSquare"/>RSS</template>
|
|
|
|
<template #func><button class="_button" @click="setting"><fa :icon="faCog"/></button></template>
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-07-11 01:13:11 +00:00
|
|
|
<div class="ekmkgxbj">
|
|
|
|
<mk-loading v-if="fetching"/>
|
|
|
|
<div class="feed" v-else>
|
|
|
|
<a v-for="item in items" :href="item.link" rel="nofollow noopener" target="_blank" :title="item.title">{{ item.title }}</a>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2020-07-11 01:13:11 +00:00
|
|
|
</div>
|
|
|
|
</mk-container>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { faRssSquare, faCog } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import MkContainer from '../components/ui/container.vue';
|
|
|
|
import define from './define';
|
|
|
|
|
|
|
|
export default define({
|
|
|
|
name: 'rss',
|
|
|
|
props: () => ({
|
2020-07-11 01:13:11 +00:00
|
|
|
showHeader: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
url: {
|
|
|
|
type: 'string',
|
|
|
|
default: 'http://feeds.afpbb.com/rss/afpbb/afpbbnews',
|
|
|
|
},
|
2020-01-29 19:37:25 +00:00
|
|
|
})
|
|
|
|
}).extend({
|
|
|
|
components: {
|
|
|
|
MkContainer
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
items: [],
|
|
|
|
fetching: true,
|
|
|
|
clock: null,
|
|
|
|
faRssSquare, faCog
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.fetch();
|
|
|
|
this.clock = setInterval(this.fetch, 60000);
|
2020-07-11 01:13:11 +00:00
|
|
|
this.$watch('props.url', this.fetch);
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
clearInterval(this.clock);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
fetch(`https://api.rss2json.com/v1/api.json?rss_url=${this.props.url}`, {
|
|
|
|
}).then(res => {
|
|
|
|
res.json().then(feed => {
|
|
|
|
this.items = feed.items;
|
|
|
|
this.fetching = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ekmkgxbj {
|
|
|
|
> .feed {
|
|
|
|
padding: 0;
|
|
|
|
font-size: 0.9em;
|
|
|
|
|
|
|
|
> a {
|
|
|
|
display: block;
|
|
|
|
padding: 8px 16px;
|
|
|
|
color: var(--text);
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
&:nth-child(even) {
|
|
|
|
background: rgba(#000, 0.05);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|