refactor(client): use setup syntax

This commit is contained in:
syuilo 2022-09-05 18:51:23 +09:00
parent 9132c72545
commit 9db2380c20
3 changed files with 54 additions and 61 deletions

View file

@ -8,12 +8,12 @@
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import { } from 'vue';
export default defineComponent({
});
function focus() {
// TODO
}
</script>
<style lang="scss" scoped>

View file

@ -30,7 +30,7 @@ export default defineComponent({
} else {
if (nextBracketOpen > 0) parsed.push(str.substr(0, nextBracketOpen));
parsed.push({
arg: str.substring(nextBracketOpen + 1, nextBracketClose)
arg: str.substring(nextBracketOpen + 1, nextBracketClose),
});
}
@ -38,5 +38,5 @@ export default defineComponent({
}
return h(this.tag, parsed.map(x => typeof x === 'string' ? (this.textTag ? h(this.textTag, x) : x) : this.$slots[x.arg]()));
}
},
});

View file

@ -4,12 +4,13 @@
<div class="ujigsodd">
<MkLoading v-if="fetching"/>
<div v-if="!fetching && images.length > 0" class="stream">
<MkA v-for="image in images"
:key="image.id"
<MkA
v-for="image in images"
:key="image.note.id + image.file.id"
class="img"
:to="notePage(image.note)"
>
<ImgWithBlurhash :hash="image.blurhash" :src="thumbnail(image.file)" :alt="image.name" :title="image.name"/>
<ImgWithBlurhash :hash="image.file.blurhash" :src="thumbnail(image.file)" :title="image.file.name"/>
</MkA>
</div>
<p v-if="!fetching && images.length == 0" class="empty">{{ $ts.nothing }}</p>
@ -17,32 +18,33 @@
</MkContainer>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import { onMounted } from 'vue';
import * as misskey from 'misskey-js';
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
import { notePage } from '@/filters/note';
import * as os from '@/os';
import MkContainer from '@/components/ui/container.vue';
import ImgWithBlurhash from '@/components/MkImgWithBlurhash.vue';
import { defaultStore } from '@/store';
export default defineComponent({
components: {
MkContainer,
ImgWithBlurhash,
},
props: {
user: {
type: Object,
required: true
},
},
data() {
return {
fetching: true,
images: [],
};
},
mounted() {
const props = defineProps<{
user: misskey.entities.UserDetailed;
}>();
let fetching = $ref(true);
let images = $ref<{
note: misskey.entities.Note;
file: misskey.entities.DriveFile;
}[]>([]);
function thumbnail(image: misskey.entities.DriveFile): string {
return defaultStore.state.disableShowingAnimatedImages
? getStaticImageUrl(image.thumbnailUrl)
: image.thumbnailUrl;
}
onMounted(() => {
const image = [
'image/jpeg',
'image/png',
@ -51,30 +53,21 @@ export default defineComponent({
'image/vnd.mozilla.apng',
];
os.api('users/notes', {
userId: this.user.id,
userId: props.user.id,
fileType: image,
excludeNsfw: this.$store.state.nsfw !== 'ignore',
excludeNsfw: defaultStore.state.nsfw !== 'ignore',
limit: 10,
}).then(notes => {
for (const note of notes) {
for (const file of note.files) {
this.images.push({
images.push({
note,
file
file,
});
}
}
this.fetching = false;
fetching = false;
});
},
methods: {
thumbnail(image: any): string {
return this.$store.state.disableShowingAnimatedImages
? getStaticImageUrl(image.thumbnailUrl)
: image.thumbnailUrl;
},
notePage
},
});
</script>