refactor: 移除不再使用的首页和图片审核演示组件
- 删除首页相关的配置、样式和逻辑文件,简化项目结构 - 移除图片审核演示组件及其样式,减少冗余代码 - 更新app.config.ts,移除原有首页的引用
This commit is contained in:
parent
74efd4b91e
commit
dbcbcc07a4
|
|
@ -4,7 +4,6 @@ export default defineAppConfig({
|
|||
'pages/home/index', // 新的模板卡片首页
|
||||
'pages/history/index', // 历史记录页面
|
||||
'pages/generate/index', // 生成处理页面
|
||||
'pages/index/index', // 保留原有首页,暂时作为模板页面
|
||||
'pages/result/index'
|
||||
],
|
||||
tabBar: {
|
||||
|
|
|
|||
|
|
@ -1,93 +0,0 @@
|
|||
.imageaudit-demo {
|
||||
padding: 20rpx;
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.demo-header {
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
padding: 30rpx 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.demo-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 16rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.demo-subtitle {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.demo-content {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 40rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.audit-history {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.history-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 30rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.history-item {
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.history-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.history-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.history-time {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.history-result {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.history-details {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding-top: 12rpx;
|
||||
border-top: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.history-score,
|
||||
.history-risk {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
import React, { useState } from 'react';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import ImageAudit from '../../components/ImageAudit';
|
||||
import { ImageAuditResult } from '../../hooks/useImageDetectionTaskManager';
|
||||
import './index.css';
|
||||
|
||||
const ImageAuditDemo: React.FC = () => {
|
||||
const [currentImageUrl, setCurrentImageUrl] = useState<string>('');
|
||||
const [auditHistory, setAuditHistory] = useState<Array<{
|
||||
imageUrl: string;
|
||||
result: ImageAuditResult;
|
||||
timestamp: number;
|
||||
}>>([]);
|
||||
|
||||
const handleImageUpload = (imageUrl: string) => {
|
||||
console.log('图片上传成功:', imageUrl);
|
||||
setCurrentImageUrl(imageUrl);
|
||||
Taro.showToast({
|
||||
title: '图片上传成功',
|
||||
icon: 'success'
|
||||
});
|
||||
};
|
||||
|
||||
const handleAuditComplete = (result: ImageAuditResult) => {
|
||||
// 添加到历史记录
|
||||
if (currentImageUrl) {
|
||||
setAuditHistory(prev => [{
|
||||
imageUrl: currentImageUrl,
|
||||
result,
|
||||
timestamp: Date.now()
|
||||
}, ...prev]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAuditError = (error: Error) => {
|
||||
console.error('审核失败:', error);
|
||||
Taro.showToast({
|
||||
title: `审核失败: ${error.message}`,
|
||||
icon: 'error',
|
||||
duration: 3000
|
||||
});
|
||||
};
|
||||
|
||||
const formatTimestamp = (timestamp: number): string => {
|
||||
return new Date(timestamp).toLocaleString('zh-CN');
|
||||
};
|
||||
|
||||
const getResultColor = (conclusion?: string): string => {
|
||||
switch (conclusion) {
|
||||
case 'PASS':
|
||||
return '#52c41a';
|
||||
case 'REJECT':
|
||||
return '#ff4d4f';
|
||||
case 'REVIEW':
|
||||
return '#faad14';
|
||||
default:
|
||||
return '#666';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View className='imageaudit-demo'>
|
||||
<View className='demo-header'>
|
||||
<Text className='demo-title'>图片审核组件演示</Text>
|
||||
<Text className='demo-subtitle'>上传图片进行内容安全审核</Text>
|
||||
</View>
|
||||
|
||||
<View className='demo-content'>
|
||||
<ImageAudit
|
||||
onImageUpload={handleImageUpload}
|
||||
onAuditComplete={handleAuditComplete}
|
||||
onAuditError={handleAuditError}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{auditHistory.length > 0 && (
|
||||
<View className='audit-history'>
|
||||
<Text className='history-title'>审核历史记录</Text>
|
||||
{auditHistory.map((item, index) => (
|
||||
<View key={index} className='history-item'>
|
||||
<View className='history-info'>
|
||||
<Text className='history-time'>
|
||||
{formatTimestamp(item.timestamp)}
|
||||
</Text>
|
||||
<Text
|
||||
className='history-result'
|
||||
style={{ color: getResultColor(item.result?.conclusion) }}
|
||||
>
|
||||
{item.result?.conclusion === 'pass' && '✅ 审核通过'}
|
||||
{item.result?.conclusion === 'reject' && '❌ 审核拒绝'}
|
||||
{item.result?.conclusion === 'review' && '⚠️ 人工复审'}
|
||||
{item.result?.conclusion === 'uncertain' && '❓ 结果不确定'}
|
||||
{!item.result?.conclusion && '❓ 结果未知'}
|
||||
</Text>
|
||||
</View>
|
||||
{item.result?.result && (
|
||||
<View className='history-details'>
|
||||
<Text className='history-score'>
|
||||
安全评分: {Math.round((item.result.result.score || 0) * 100)}
|
||||
</Text>
|
||||
<Text className='history-risk'>
|
||||
风险等级: {item.result.result.riskLevel || '未知'}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageAuditDemo;
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
export default definePageConfig({
|
||||
navigationBarTitleText: 'AI手办生成器',
|
||||
navigationBarBackgroundColor: '#ffffff',
|
||||
navigationBarTextStyle: 'black',
|
||||
backgroundColorTop: '#ffffff',
|
||||
backgroundColorBottom: '#ffffff',
|
||||
backgroundColor: '#ffffff'
|
||||
})
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
.index {
|
||||
font-size: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
min-height: 100vh;
|
||||
min-width: 100vw;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-image: url('../../assets/images/Figure.jpg');
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
position: relative;
|
||||
}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
import { View } from '@tarojs/components'
|
||||
import { useState } from 'react'
|
||||
import { navigateTo } from '@tarojs/taro'
|
||||
import './index.css'
|
||||
import { useSdk, useUploadVideo } from '../../hooks/index'
|
||||
import UploadButton from '../../components/UploadButton'
|
||||
import LoadingOverlay from '../../components/LoadingOverlay'
|
||||
import ErrorOverlay from '../../components/ErrorOverlay'
|
||||
import { createPlatformFactory } from '../../platforms'
|
||||
|
||||
type PageStep = 'upload' | 'loading' | 'error'
|
||||
|
||||
interface AppState {
|
||||
step: PageStep;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export default function Index() {
|
||||
const sdk = useSdk()
|
||||
const [state, setState] = useState<AppState>({
|
||||
step: 'upload',
|
||||
error: null
|
||||
})
|
||||
|
||||
const [videoPath, setVidePath] = useState<string>()
|
||||
|
||||
useUploadVideo((res) => {
|
||||
console.log(res)
|
||||
return {
|
||||
videoPath: videoPath,
|
||||
titleConfig: {
|
||||
title: `视频发布`
|
||||
},
|
||||
success() {
|
||||
console.log("视频发布/挂载成功");
|
||||
},
|
||||
fail() {
|
||||
console.log("视频发布/挂载失败");
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
const chooseAndGenerateImage = async () => {
|
||||
try {
|
||||
// 选择图片,选择完成后会自动触发loading状态
|
||||
const task_id = await sdk.chooseAndGenerateImage({
|
||||
onImageSelected: () => {
|
||||
// 选择图片完成后立即显示loading
|
||||
setState({ step: 'loading', error: null })
|
||||
}
|
||||
})
|
||||
|
||||
// 等待生成完成
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000))
|
||||
const urls = await sdk.getTaskStatus(task_id)
|
||||
|
||||
// 跳转到结果页面
|
||||
navigateTo({
|
||||
url: `/pages/result/index?images=${encodeURIComponent(JSON.stringify(urls))}`
|
||||
})
|
||||
|
||||
// 重置状态
|
||||
setState({ step: 'upload', error: null })
|
||||
} catch (error) {
|
||||
const errorMsg = error instanceof Error ? error.message : '生成失败'
|
||||
setState({ step: 'error', error: errorMsg })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const resetToUpload = () => {
|
||||
setState({ step: 'upload', error: null })
|
||||
}
|
||||
|
||||
const renderCurrentStep = () => {
|
||||
switch (state.step) {
|
||||
case 'upload':
|
||||
return <UploadButton onUpload={chooseAndGenerateImage} />
|
||||
case 'loading':
|
||||
return <LoadingOverlay />
|
||||
case 'error':
|
||||
return <ErrorOverlay onRetry={resetToUpload} />
|
||||
default:
|
||||
return <UploadButton onUpload={chooseAndGenerateImage} />
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<View className='index'>
|
||||
{renderCurrentStep()}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
Loading…
Reference in New Issue