mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-26 08:45:14 +00:00
refactor(client): use composition api
This commit is contained in:
parent
990fef5993
commit
2a4f2fba09
1 changed files with 21 additions and 41 deletions
|
@ -20,53 +20,33 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { watch } from 'vue';
|
||||||
|
import * as misskey from 'misskey-js';
|
||||||
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
|
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
|
||||||
import ImgWithBlurhash from '@/components/img-with-blurhash.vue';
|
import ImgWithBlurhash from '@/components/img-with-blurhash.vue';
|
||||||
import * as os from '@/os';
|
import { defaultStore } from '@/store';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps<{
|
||||||
components: {
|
image: misskey.entities.DriveFile;
|
||||||
ImgWithBlurhash
|
raw?: boolean;
|
||||||
},
|
}>();
|
||||||
props: {
|
|
||||||
image: {
|
|
||||||
type: Object,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
raw: {
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
hide: true,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
url(): any {
|
|
||||||
let url = this.$store.state.disableShowingAnimatedImages
|
|
||||||
? getStaticImageUrl(this.image.thumbnailUrl)
|
|
||||||
: this.image.thumbnailUrl;
|
|
||||||
|
|
||||||
if (this.raw || this.$store.state.loadRawImages) {
|
let hide = $ref(true);
|
||||||
url = this.image.url;
|
|
||||||
}
|
const url = (props.raw || defaultStore.state.loadRawImages)
|
||||||
|
? props.image.url
|
||||||
|
: defaultStore.state.disableShowingAnimatedImages
|
||||||
|
? getStaticImageUrl(props.image.thumbnailUrl)
|
||||||
|
: props.image.thumbnailUrl;
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
// Plugin:register_note_view_interruptor を使って書き換えられる可能性があるためwatchする
|
// Plugin:register_note_view_interruptor を使って書き換えられる可能性があるためwatchする
|
||||||
this.$watch('image', () => {
|
watch(() => props.image, () => {
|
||||||
this.hide = (this.$store.state.nsfw === 'force') ? true : this.image.isSensitive && (this.$store.state.nsfw !== 'ignore');
|
hide = (defaultStore.state.nsfw === 'force') ? true : props.image.isSensitive && (defaultStore.state.nsfw !== 'ignore');
|
||||||
}, {
|
}, {
|
||||||
deep: true,
|
deep: true,
|
||||||
immediate: true,
|
immediate: true,
|
||||||
});
|
});
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in a new issue