-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git commit -m "feat: add demo images section with grid layout and hov…
…er effects"
- Loading branch information
Showing
13 changed files
with
145 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
### 2024-11-11 | ||
- 增加示例部分 | ||
|
||
### 2024-11-01 | ||
- 优化 OpenCV.js 加载完成的判断条件 | ||
- 优化全局样式,使用 scoped 样式 | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<template> | ||
<section class="section"> | ||
<h2>示例</h2> | ||
<div class="demo-images-grid"> | ||
<div | ||
v-for="(image, index) in demoImages" | ||
:key="index" | ||
class="demo-image-item" | ||
@click="() => handleImageClick(image)" | ||
> | ||
<img :src="image.url" :alt="image.description" /> | ||
<span class="demo-image-description">{{ image.description }}</span> | ||
</div> | ||
</div> | ||
</section> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
interface DemoImage { | ||
url: string; | ||
description: string; | ||
} | ||
const demoImages: DemoImage[] = [ | ||
{ | ||
url: new URL('../../assets/demo/example1.jpg', import.meta.url).href, | ||
description: '示例1', | ||
}, | ||
{ | ||
url: new URL('../../assets/demo/example2.jpg', import.meta.url).href, | ||
description: '示例2', | ||
}, | ||
{ | ||
url: new URL('../../assets/demo/example3.jpg', import.meta.url).href, | ||
description: '示例3', | ||
}, | ||
]; | ||
const emit = defineEmits<{ | ||
(e: 'selectDemo', img: HTMLImageElement): void; | ||
}>(); | ||
const handleImageClick = (demoImage: DemoImage) => { | ||
const img = new Image(); | ||
img.src = demoImage.url; | ||
img.onload = () => { | ||
emit('selectDemo', img); | ||
}; | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.demo-images-grid { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); | ||
gap: 1rem; | ||
} | ||
.demo-image-item { | ||
cursor: pointer; | ||
transition: transform 0.2s; | ||
text-align: center; | ||
} | ||
.demo-image-item:hover { | ||
transform: scale(1.05); | ||
} | ||
.demo-image-item img { | ||
width: 100%; | ||
height: 150px; | ||
object-fit: cover; | ||
border-radius: 4px; | ||
} | ||
.demo-image-description { | ||
display: block; | ||
margin-top: 0.5rem; | ||
font-size: 0.9rem; | ||
color: #666; | ||
} | ||
</style> |
Oops, something went wrong.