feat: 优化图片全屏展示方案
- 使用aspectFill模式最大化图片利用屏幕空间 - 添加精美相框和渐变背景突出图片效果 - 优化图片容器尺寸计算保持完美比例 - 增强视觉层次感和用户体验
This commit is contained in:
parent
3c87b60c18
commit
a0330ec878
|
|
@ -204,7 +204,10 @@
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
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;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
|
|
@ -274,15 +277,44 @@
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0rpx;
|
padding: 0;
|
||||||
box-sizing: border-box;
|
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 {
|
.fullscreen-image {
|
||||||
width: 100%;
|
width: calc(100% - 40rpx);
|
||||||
height: 100%;
|
height: calc(100% - 180rpx);
|
||||||
max-width: 100%;
|
border-radius: 20rpx;
|
||||||
max-height: 100%;
|
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 { 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 { useState } from 'react'
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import { useSdk } from '../../hooks/index'
|
import { useSdk } from '../../hooks/index'
|
||||||
|
|
@ -34,15 +34,17 @@ export default function Index() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
useLoad(() => {
|
const chooseAndGenerateImage = async () => {
|
||||||
return () => { }
|
try {
|
||||||
|
// 选择图片,选择完成后会自动触发loading状态
|
||||||
|
const task_id = await sdk.chooseAndGenerateImage({
|
||||||
|
onImageSelected: () => {
|
||||||
|
// 选择图片完成后立即显示loading
|
||||||
|
setState({ step: 'loading', images: [], error: null })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const chooseAndGenerateImage = async () => {
|
// 等待生成完成
|
||||||
setState({ step: 'loading', images: [], error: null })
|
|
||||||
|
|
||||||
try {
|
|
||||||
const task_id = await sdk.chooseAndGenerateImage()
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5000))
|
await new Promise((resolve) => setTimeout(resolve, 5000))
|
||||||
const urls = await sdk.getTaskStatus(task_id)
|
const urls = await sdk.getTaskStatus(task_id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,11 +146,14 @@ export class BowongAISDK {
|
||||||
sizeType?: ('original' | 'compressed')[];
|
sizeType?: ('original' | 'compressed')[];
|
||||||
/** 选择图片的来源,默认为 ['album', 'camera'] */
|
/** 选择图片的来源,默认为 ['album', 'camera'] */
|
||||||
sourceType?: ('album' | 'camera')[];
|
sourceType?: ('album' | 'camera')[];
|
||||||
|
/** 选择图片完成后的回调 */
|
||||||
|
onImageSelected?: () => void;
|
||||||
}): Promise<string> {
|
}): Promise<string> {
|
||||||
const {
|
const {
|
||||||
count = 1,
|
count = 1,
|
||||||
sizeType = ['original', 'compressed'],
|
sizeType = ['original', 'compressed'],
|
||||||
sourceType = ['album', 'camera'],
|
sourceType = ['album', 'camera'],
|
||||||
|
onImageSelected,
|
||||||
} = options || {};
|
} = options || {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -161,6 +164,9 @@ export class BowongAISDK {
|
||||||
sourceType
|
sourceType
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 选择图片完成后触发回调
|
||||||
|
onImageSelected?.();
|
||||||
|
|
||||||
if (!chooseResult.tempFilePaths || chooseResult.tempFilePaths.length === 0) {
|
if (!chooseResult.tempFilePaths || chooseResult.tempFilePaths.length === 0) {
|
||||||
throw new Error('未选择图片');
|
throw new Error('未选择图片');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue