2020-01-10 20:00:42 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2020-05-30 05:53:50 +00:00
|
|
|
<div v-if="show" class="card card-body p-0 border mt-4 mb-3 shadow-none">
|
2020-05-29 05:33:06 +00:00
|
|
|
<div id="storyContainer" :class="[list == true ? 'mt-1 mr-3 mb-0 ml-1':'mx-3 mt-3 mb-0 pb-0']"></div>
|
2020-01-10 20:00:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style type="text/css" scoped>
|
|
|
|
#storyContainer > .story {
|
|
|
|
margin-right: 3rem;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
import 'zuck.js/dist/zuck.css';
|
|
|
|
import 'zuck.js/dist/skins/snapgram.css';
|
|
|
|
let Zuck = require('zuck.js');
|
|
|
|
|
|
|
|
export default {
|
2020-04-09 04:03:46 +00:00
|
|
|
props: ['list'],
|
2020-01-10 20:00:42 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-05-30 05:53:50 +00:00
|
|
|
show: false,
|
2020-01-10 20:00:42 +00:00
|
|
|
stories: {},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.fetchStories();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetchStories() {
|
2020-02-05 04:04:58 +00:00
|
|
|
axios.get('/api/stories/v0/recent')
|
2020-01-10 20:00:42 +00:00
|
|
|
.then(res => {
|
|
|
|
let data = res.data;
|
2020-05-30 05:53:50 +00:00
|
|
|
if(!res.data.length) {
|
|
|
|
this.show = false;
|
|
|
|
return;
|
|
|
|
}
|
2020-01-10 20:00:42 +00:00
|
|
|
let stories = new Zuck('storyContainer', {
|
2020-04-09 04:03:46 +00:00
|
|
|
list: this.list == true ? true : false,
|
2020-01-10 20:00:42 +00:00
|
|
|
stories: data,
|
|
|
|
localStorage: true,
|
|
|
|
callbacks: {
|
|
|
|
onOpen (storyId, callback) {
|
|
|
|
document.body.style.overflow = "hidden";
|
|
|
|
callback()
|
|
|
|
},
|
|
|
|
|
|
|
|
onEnd (storyId, callback) {
|
|
|
|
axios.post('/i/stories/viewed', {
|
|
|
|
id: storyId
|
|
|
|
});
|
|
|
|
callback();
|
|
|
|
},
|
|
|
|
|
|
|
|
onClose (storyId, callback) {
|
|
|
|
document.body.style.overflow = "auto";
|
|
|
|
callback();
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
data.forEach(d => {
|
2020-02-05 04:04:58 +00:00
|
|
|
let url = '/api/stories/v0/fetch/' + d.pid;
|
2020-01-10 20:00:42 +00:00
|
|
|
axios.get(url)
|
|
|
|
.then(res => {
|
|
|
|
res.data.forEach(item => {
|
|
|
|
let img = new Image();
|
|
|
|
img.src = item.src;
|
|
|
|
stories.addItem(d.id, item);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-05-30 05:53:50 +00:00
|
|
|
this.show = true;
|
2020-01-10 20:00:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
#storyContainer .story {
|
|
|
|
margin-right: 2rem;
|
|
|
|
width: 100%;
|
2020-05-29 05:33:06 +00:00
|
|
|
max-width: 60px;
|
2020-01-10 20:00:42 +00:00
|
|
|
}
|
|
|
|
.stories.carousel .story > .item-link > .item-preview {
|
2020-05-29 05:33:06 +00:00
|
|
|
height: 60px;
|
2020-01-10 20:00:42 +00:00
|
|
|
}
|
|
|
|
#zuck-modal.with-effects {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
.stories.carousel .story > .item-link > .info .name {
|
2020-05-29 05:33:06 +00:00
|
|
|
font-weight: 500;
|
|
|
|
font-size: 11px;
|
2020-01-10 20:00:42 +00:00
|
|
|
}
|
|
|
|
.stories.carousel .story > .item-link > .info {
|
|
|
|
}
|
|
|
|
</style>
|