2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2020-10-17 20:12:00 +09:00
|
|
|
<MkContainer :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-30 04:37:25 +09:00
|
|
|
|
2020-07-11 10:13:11 +09:00
|
|
|
<div class="ekmkgxbj">
|
2020-10-17 20:12:00 +09:00
|
|
|
<MkLoading v-if="fetching"/>
|
2020-07-11 10:13:11 +09:00
|
|
|
<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-30 04:37:25 +09:00
|
|
|
</div>
|
2020-07-11 10:13:11 +09:00
|
|
|
</div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkContainer>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-30 04:37:25 +09:00
|
|
|
import { faRssSquare, faCog } from '@fortawesome/free-solid-svg-icons';
|
2020-10-17 20:12:00 +09:00
|
|
|
import MkContainer from '@/components/ui/container.vue';
|
2020-01-30 04:37:25 +09:00
|
|
|
import define from './define';
|
2020-10-17 20:12:00 +09:00
|
|
|
import * as os from '@/os';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
const widget = define({
|
2020-01-30 04:37:25 +09:00
|
|
|
name: 'rss',
|
|
|
|
props: () => ({
|
2020-07-11 10:13:11 +09:00
|
|
|
showHeader: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
url: {
|
|
|
|
type: 'string',
|
|
|
|
default: 'http://feeds.afpbb.com/rss/afpbb/afpbbnews',
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
})
|
2020-10-17 20:12:00 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
extends: widget,
|
2020-01-30 04:37:25 +09:00
|
|
|
components: {
|
|
|
|
MkContainer
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
items: [],
|
|
|
|
fetching: true,
|
|
|
|
clock: null,
|
|
|
|
faRssSquare, faCog
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.fetch();
|
|
|
|
this.clock = setInterval(this.fetch, 60000);
|
2020-10-17 20:12:00 +09:00
|
|
|
this.$watch(() => this.props.url, this.fetch);
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
2020-10-17 20:12:00 +09:00
|
|
|
beforeUnmount() {
|
2020-01-30 04:37:25 +09:00
|
|
|
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;
|
2020-10-27 18:11:41 +09:00
|
|
|
color: var(--fg);
|
2020-01-30 04:37:25 +09:00
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
2021-02-27 11:18:53 +09:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
&:nth-child(even) {
|
|
|
|
background: rgba(#000, 0.05);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|