feat: 优化图片全屏展示方案
- 使用aspectFill模式最大化图片利用屏幕空间 - 添加精美相框和渐变背景突出图片效果 - 优化图片容器尺寸计算保持完美比例 - 增强视觉层次感和用户体验
This commit is contained in:
parent
3c87b60c18
commit
a0330ec878
|
|
@ -204,7 +204,10 @@
|
|||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: #000;
|
||||
background: linear-gradient(135deg, #2c3e50, #34495e);
|
||||
background-image:
|
||||
radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
|
||||
radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 1000;
|
||||
|
|
@ -274,15 +277,44 @@
|
|||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0rpx;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.8) 100%);
|
||||
}
|
||||
|
||||
.swiper-item::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
left: 20rpx;
|
||||
right: 20rpx;
|
||||
bottom: 160rpx;
|
||||
border-radius: 24rpx;
|
||||
border: 4rpx solid rgba(255, 255, 255, 0.2);
|
||||
box-shadow:
|
||||
0 0 0 1rpx rgba(255, 255, 255, 0.1),
|
||||
inset 0 0 40rpx rgba(255, 255, 255, 0.05),
|
||||
0 20rpx 60rpx rgba(0, 0, 0, 0.3);
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgba(255, 255, 255, 0.02) 0%,
|
||||
rgba(255, 255, 255, 0.05) 50%,
|
||||
rgba(255, 255, 255, 0.02) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.fullscreen-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: calc(100% - 40rpx);
|
||||
height: calc(100% - 180rpx);
|
||||
border-radius: 20rpx;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
margin-top: 20rpx;
|
||||
object-fit: cover;
|
||||
box-shadow: 0 15rpx 50rpx rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
/* 全屏底部 */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { View, Text, Button, Image, Swiper, SwiperItem } from '@tarojs/components'
|
||||
import { useLoad, saveImageToPhotosAlbum, downloadFile, showToast } from '@tarojs/taro'
|
||||
import { saveImageToPhotosAlbum, downloadFile, showToast } from '@tarojs/taro'
|
||||
import { useState } from 'react'
|
||||
import './index.css'
|
||||
import { useSdk } from '../../hooks/index'
|
||||
|
|
@ -34,15 +34,17 @@ export default function Index() {
|
|||
}
|
||||
})
|
||||
|
||||
useLoad(() => {
|
||||
return () => { }
|
||||
})
|
||||
|
||||
const chooseAndGenerateImage = async () => {
|
||||
setState({ step: 'loading', images: [], error: null })
|
||||
|
||||
try {
|
||||
const task_id = await sdk.chooseAndGenerateImage()
|
||||
// 选择图片,选择完成后会自动触发loading状态
|
||||
const task_id = await sdk.chooseAndGenerateImage({
|
||||
onImageSelected: () => {
|
||||
// 选择图片完成后立即显示loading
|
||||
setState({ step: 'loading', images: [], error: null })
|
||||
}
|
||||
})
|
||||
|
||||
// 等待生成完成
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000))
|
||||
const urls = await sdk.getTaskStatus(task_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -146,11 +146,14 @@ export class BowongAISDK {
|
|||
sizeType?: ('original' | 'compressed')[];
|
||||
/** 选择图片的来源,默认为 ['album', 'camera'] */
|
||||
sourceType?: ('album' | 'camera')[];
|
||||
/** 选择图片完成后的回调 */
|
||||
onImageSelected?: () => void;
|
||||
}): Promise<string> {
|
||||
const {
|
||||
count = 1,
|
||||
sizeType = ['original', 'compressed'],
|
||||
sourceType = ['album', 'camera'],
|
||||
onImageSelected,
|
||||
} = options || {};
|
||||
|
||||
try {
|
||||
|
|
@ -161,6 +164,9 @@ export class BowongAISDK {
|
|||
sourceType
|
||||
});
|
||||
|
||||
// 选择图片完成后触发回调
|
||||
onImageSelected?.();
|
||||
|
||||
if (!chooseResult.tempFilePaths || chooseResult.tempFilePaths.length === 0) {
|
||||
throw new Error('未选择图片');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue