feat: google login
This commit is contained in:
parent
733713f42f
commit
be24e28fc4
|
|
@ -1,6 +1,7 @@
|
||||||
import { useEffect, useRef, useCallback } from 'react';
|
import { useEffect, useRef, useCallback } from 'react';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import { AsyncTaskManager, TaskStatus, TaskConfig } from '../utils/AsyncTaskManager';
|
import { AsyncTaskManager, TaskStatus, TaskConfig } from '../utils/AsyncTaskManager';
|
||||||
|
import { PlatformFactory } from '../platforms/factory';
|
||||||
/**
|
/**
|
||||||
* 平台类型枚举
|
* 平台类型枚举
|
||||||
*/
|
*/
|
||||||
|
|
@ -189,6 +190,36 @@ export function useImageDetectionTaskManager() {
|
||||||
const { imageUrl, platform, options = {} } = params;
|
const { imageUrl, platform, options = {} } = params;
|
||||||
const targetPlatform = platform || currentPlatform.current;
|
const targetPlatform = platform || currentPlatform.current;
|
||||||
|
|
||||||
|
// H5平台跳过审核,直接返回通过结果
|
||||||
|
if (targetPlatform === PlatformType.H5) {
|
||||||
|
const mockTaskId = `h5_mock_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
||||||
|
const h5Result: ImageAuditResult = {
|
||||||
|
taskId: mockTaskId,
|
||||||
|
platform: PlatformType.H5,
|
||||||
|
status: AuditStatus.COMPLETED,
|
||||||
|
conclusion: AuditConclusion.PASS,
|
||||||
|
imageUrl,
|
||||||
|
result: {
|
||||||
|
safe: true,
|
||||||
|
score: 100,
|
||||||
|
riskLevel: 'low',
|
||||||
|
categories: [],
|
||||||
|
suggestion: 'pass',
|
||||||
|
details: 'H5平台跳过审核,自动通过'
|
||||||
|
},
|
||||||
|
processingTime: 0,
|
||||||
|
timestamp: Date.now()
|
||||||
|
};
|
||||||
|
|
||||||
|
// 异步触发回调,模拟真实的审核流程
|
||||||
|
setTimeout(() => {
|
||||||
|
onProgress?.(TaskStatus.SUCCESS);
|
||||||
|
onSuccess?.(h5Result);
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
return mockTaskId;
|
||||||
|
}
|
||||||
|
|
||||||
// 检查缓存
|
// 检查缓存
|
||||||
const cacheKey = `${targetPlatform}_${imageUrl}`;
|
const cacheKey = `${targetPlatform}_${imageUrl}`;
|
||||||
if (options.enableCache && auditCacheRef.current.has(cacheKey)) {
|
if (options.enableCache && auditCacheRef.current.has(cacheKey)) {
|
||||||
|
|
@ -450,7 +481,23 @@ async function preprocessImage(
|
||||||
* 获取当前运行平台
|
* 获取当前运行平台
|
||||||
*/
|
*/
|
||||||
function getCurrentPlatform(): PlatformType {
|
function getCurrentPlatform(): PlatformType {
|
||||||
|
const platform = PlatformFactory.detectPlatform();
|
||||||
|
switch (platform) {
|
||||||
|
case 'bytedance':
|
||||||
return PlatformType.BYTEDANCE;
|
return PlatformType.BYTEDANCE;
|
||||||
|
case 'wechat':
|
||||||
|
return PlatformType.WECHAT;
|
||||||
|
case 'alipay':
|
||||||
|
return PlatformType.ALIPAY;
|
||||||
|
case 'swan':
|
||||||
|
return PlatformType.BAIDU;
|
||||||
|
case 'qq':
|
||||||
|
return PlatformType.QQ;
|
||||||
|
case 'h5':
|
||||||
|
return PlatformType.H5;
|
||||||
|
default:
|
||||||
|
return PlatformType.BYTEDANCE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ export default function Home() {
|
||||||
Taro.hideLoading();
|
Taro.hideLoading();
|
||||||
// 跳转到生成页面
|
// 跳转到生成页面
|
||||||
navigateTo({
|
navigateTo({
|
||||||
url: `/pages/result/index?taskId=${taskId}&templateCode=${template.code}`,
|
url: `/pages/result/index?taskId=${taskId.taskId}&templateCode=${template.code}`,
|
||||||
});
|
});
|
||||||
} catch (businessError) {
|
} catch (businessError) {
|
||||||
// 业务处理失败
|
// 业务处理失败
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ interface ApiResponse<T = any> {
|
||||||
*/
|
*/
|
||||||
export interface ExecuteTemplateParams {
|
export interface ExecuteTemplateParams {
|
||||||
templateCode: string; // 模板代码
|
templateCode: string; // 模板代码
|
||||||
userId: string; // 用户ID
|
|
||||||
imageUrl: string; // 图片URL
|
imageUrl: string; // 图片URL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue