refactor pages/user/index.photos.vue to compositon API
This commit is contained in:
parent
0cf6df8980
commit
09b844035c
1 changed files with 39 additions and 51 deletions
|
@ -17,65 +17,53 @@
|
||||||
</MkContainer>
|
</MkContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
|
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
|
||||||
import { notePage } from '@/filters/note';
|
import { notePage } from '@/filters/note';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import MkContainer from '@/components/ui/container.vue';
|
import MkContainer from '@/components/ui/container.vue';
|
||||||
import ImgWithBlurhash from '@/components/img-with-blurhash.vue';
|
import ImgWithBlurhash from '@/components/img-with-blurhash.vue';
|
||||||
|
import { defaultStore } from '@/store';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps<{
|
||||||
components: {
|
user: Record<string, any>;
|
||||||
MkContainer,
|
}>();
|
||||||
ImgWithBlurhash,
|
|
||||||
},
|
let fetching = $ref(true);
|
||||||
props: {
|
let images = $ref([]);
|
||||||
user: {
|
|
||||||
type: Object,
|
onMounted(() => {
|
||||||
required: true
|
const image = [
|
||||||
},
|
'image/jpeg',
|
||||||
},
|
'image/png',
|
||||||
data() {
|
'image/gif',
|
||||||
return {
|
'image/apng',
|
||||||
fetching: true,
|
'image/vnd.mozilla.apng',
|
||||||
images: [],
|
];
|
||||||
};
|
os.api('users/notes', {
|
||||||
},
|
userId: props.user.id,
|
||||||
mounted() {
|
fileType: image,
|
||||||
const image = [
|
excludeNsfw: defaultStore.state.nsfw !== 'ignore',
|
||||||
'image/jpeg',
|
limit: 10,
|
||||||
'image/png',
|
}).then(notes => {
|
||||||
'image/gif',
|
for (const note of notes) {
|
||||||
'image/apng',
|
for (const file of note.files) {
|
||||||
'image/vnd.mozilla.apng',
|
images.push({
|
||||||
];
|
note,
|
||||||
os.api('users/notes', {
|
file
|
||||||
userId: this.user.id,
|
});
|
||||||
fileType: image,
|
|
||||||
excludeNsfw: this.$store.state.nsfw !== 'ignore',
|
|
||||||
limit: 10,
|
|
||||||
}).then(notes => {
|
|
||||||
for (const note of notes) {
|
|
||||||
for (const file of note.files) {
|
|
||||||
this.images.push({
|
|
||||||
note,
|
|
||||||
file
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.fetching = false;
|
}
|
||||||
});
|
fetching = false;
|
||||||
},
|
});
|
||||||
methods: {
|
|
||||||
thumbnail(image: any): string {
|
|
||||||
return this.$store.state.disableShowingAnimatedImages
|
|
||||||
? getStaticImageUrl(image.thumbnailUrl)
|
|
||||||
: image.thumbnailUrl;
|
|
||||||
},
|
|
||||||
notePage
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function thumbnail(image: any): string {
|
||||||
|
return defaultStore.state.disableShowingAnimatedImages
|
||||||
|
? getStaticImageUrl(image.thumbnailUrl)
|
||||||
|
: image.thumbnailUrl;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in a new issue