enhance: page image component with alt text (#8634)
* refactor to composition API * use existing image component This improves user experience because alt text is displayed correctly. * fix: correct image src * fix: defineProps * fix
This commit is contained in:
		
							parent
							
								
									edfded7fb7
								
							
						
					
					
						commit
						be1d02a7f8
					
				
					 1 changed files with 8 additions and 20 deletions
				
			
		|  | @ -1,34 +1,22 @@ | ||||||
| <template> | <template> | ||||||
| <div class="lzyxtsnt"> | <div class="lzyxtsnt"> | ||||||
| 	<img v-if="image" :src="image.url"/> | 	<ImgWithBlurhash v-if="image" :hash="image.blurhash" :src="image.url" :alt="image.comment" :title="image.comment" :cover="false"/> | ||||||
| </div> | </div> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script lang="ts"> | <script lang="ts" setup> | ||||||
| import { defineComponent, PropType } from 'vue'; | import { defineComponent, PropType } from 'vue'; | ||||||
|  | import ImgWithBlurhash from '@/components/img-with-blurhash.vue'; | ||||||
| import * as os from '@/os'; | import * as os from '@/os'; | ||||||
| import { ImageBlock } from '@/scripts/hpml/block'; | import { ImageBlock } from '@/scripts/hpml/block'; | ||||||
| import { Hpml } from '@/scripts/hpml/evaluator'; | import { Hpml } from '@/scripts/hpml/evaluator'; | ||||||
| 
 | 
 | ||||||
| export default defineComponent({ | const props = defineProps<{ | ||||||
| 	props: { | 	block: PropType<ImageBlock>, | ||||||
| 		block: { | 	hpml: PropType<Hpml>, | ||||||
| 			type: Object as PropType<ImageBlock>, | }>(); | ||||||
| 			required: true |  | ||||||
| 		}, |  | ||||||
| 		hpml: { |  | ||||||
| 			type: Object as PropType<Hpml>, |  | ||||||
| 			required: true |  | ||||||
| 		} |  | ||||||
| 	}, |  | ||||||
| 	setup(props, ctx) { |  | ||||||
| 		const image = props.hpml.page.attachedFiles.find(x => x.id === props.block.fileId); |  | ||||||
| 
 | 
 | ||||||
| 		return { | const image = props.hpml.page.attachedFiles.find(x => x.id === props.block.fileId); | ||||||
| 			image |  | ||||||
| 		}; |  | ||||||
| 	} |  | ||||||
| }); |  | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue