2018-02-15 18:33:34 +09:00
|
|
|
<template>
|
2021-04-16 09:41:56 +09:00
|
|
|
<MkContainer :max-height="300">
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #header><Fa :icon="faImage" style="margin-right: 0.5em;"/>{{ $ts.images }}</template>
|
2020-11-25 21:31:34 +09:00
|
|
|
<div class="ujigsodd">
|
|
|
|
<MkLoading v-if="fetching"/>
|
|
|
|
<div class="stream" v-if="!fetching && images.length > 0">
|
|
|
|
<MkA v-for="image in images"
|
|
|
|
class="img"
|
|
|
|
:style="`background-image: url(${thumbnail(image.file)})`"
|
|
|
|
:to="notePage(image.note)"
|
2021-04-16 09:41:56 +09:00
|
|
|
:key="image.id"
|
2020-11-25 21:31:34 +09:00
|
|
|
></MkA>
|
|
|
|
</div>
|
2020-12-26 10:47:36 +09:00
|
|
|
<p class="empty" v-if="!fetching && images.length == 0">{{ $ts.nothing }}</p>
|
2018-02-15 18:33:34 +09:00
|
|
|
</div>
|
2020-11-25 21:31:34 +09:00
|
|
|
</MkContainer>
|
2018-02-15 18:33:34 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { defineComponent } from 'vue';
|
2020-11-25 21:31:34 +09:00
|
|
|
import { faImage } from '@fortawesome/free-solid-svg-icons';
|
2021-03-23 17:30:14 +09:00
|
|
|
import { getStaticImageUrl } from '@client/scripts/get-static-image-url';
|
2020-10-17 20:12:00 +09:00
|
|
|
import notePage from '../../filters/note';
|
2021-03-23 17:30:14 +09:00
|
|
|
import * as os from '@client/os';
|
|
|
|
import MkContainer from '@client/components/ui/container.vue';
|
2018-03-27 16:51:12 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
export default defineComponent({
|
2020-11-25 21:31:34 +09:00
|
|
|
components: {
|
|
|
|
MkContainer,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
user: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
2018-02-15 18:33:34 +09:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
2020-11-25 21:31:34 +09:00
|
|
|
images: [],
|
|
|
|
faImage
|
2018-02-15 18:33:34 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-12-19 06:04:59 +09:00
|
|
|
const image = [
|
|
|
|
'image/jpeg',
|
|
|
|
'image/png',
|
2019-07-04 14:45:28 +09:00
|
|
|
'image/gif',
|
|
|
|
'image/apng',
|
|
|
|
'image/vnd.mozilla.apng',
|
2018-12-19 06:04:59 +09:00
|
|
|
];
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/notes', {
|
2018-03-29 14:48:47 +09:00
|
|
|
userId: this.user.id,
|
2018-12-19 06:04:59 +09:00
|
|
|
fileType: image,
|
2020-12-19 10:55:52 +09:00
|
|
|
excludeNsfw: this.$store.state.nsfw !== 'ignore',
|
2021-04-16 09:41:56 +09:00
|
|
|
limit: 10,
|
2018-04-08 02:30:37 +09:00
|
|
|
}).then(notes => {
|
2018-12-11 20:36:55 +09:00
|
|
|
for (const note of notes) {
|
2019-04-08 16:34:45 +09:00
|
|
|
for (const file of note.files) {
|
2021-04-16 09:41:56 +09:00
|
|
|
this.images.push({
|
|
|
|
note,
|
|
|
|
file
|
|
|
|
});
|
2018-12-11 20:36:55 +09:00
|
|
|
}
|
|
|
|
}
|
2018-02-19 23:37:09 +09:00
|
|
|
this.fetching = false;
|
2018-02-15 18:33:34 +09:00
|
|
|
});
|
2019-02-05 06:22:39 +09:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
thumbnail(image: any): string {
|
2020-12-19 10:55:52 +09:00
|
|
|
return this.$store.state.disableShowingAnimatedImages
|
2019-02-05 06:22:39 +09:00
|
|
|
? getStaticImageUrl(image.thumbnailUrl)
|
|
|
|
: image.thumbnailUrl;
|
|
|
|
},
|
2020-10-17 20:12:00 +09:00
|
|
|
notePage
|
2019-02-05 06:22:39 +09:00
|
|
|
},
|
2018-02-15 18:33:34 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ujigsodd {
|
2020-11-25 21:31:34 +09:00
|
|
|
padding: 8px;
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .stream {
|
2021-04-16 09:41:56 +09:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
|
|
|
grid-gap: 6px;
|
2018-02-15 18:33:34 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .img {
|
2021-04-16 09:41:56 +09:00
|
|
|
height: 128px;
|
2020-01-30 04:37:25 +09:00
|
|
|
background-position: center center;
|
|
|
|
background-size: cover;
|
|
|
|
background-clip: content-box;
|
2020-10-17 20:12:00 +09:00
|
|
|
border-radius: 6px;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
2018-02-15 18:33:34 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .empty {
|
|
|
|
margin: 0;
|
|
|
|
padding: 16px;
|
|
|
|
text-align: center;
|
2018-02-15 18:33:34 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> i {
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-15 18:33:34 +09:00
|
|
|
</style>
|