From 2cff8db4bf0b998207a646b87a440aeddd4d9600 Mon Sep 17 00:00:00 2001 From: imeepos Date: Tue, 2 Sep 2025 17:40:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B9=B3=E5=8F=B0=E9=80=82=E9=85=8D?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=92=8C=E4=BB=A3=E7=A0=81=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新小程序配置支持微信平台(appid: wxb51f0b0c3aad7cdf) - 新增微信小程序平台适配模块(weapp.ts) - 优化广告组件跨平台兼容性处理 - 移除不必要的React.memo优化 - 简化广告加载逻辑,提高稳定性 - 修复代码规范问题(import顺序、unused变量) --- .env.development | 5 +- .env.production | 4 +- .env.test | 4 +- project.config.json | 40 +++- project.private.config.json | 7 + src/components/DownloadSection/index.tsx | 11 +- src/components/ErrorOverlay/index.tsx | 15 +- src/components/LoadingOverlay/index.tsx | 17 +- src/components/UploadButton/index.tsx | 9 +- src/hooks/useAd.ts | 15 +- src/pages/index/index.tsx | 4 - src/pages/result/index.tsx | 34 +--- src/platforms/core.ts | 1 + src/platforms/factory.ts | 13 +- src/platforms/tt.ts | 58 +++--- src/platforms/weapp.ts | 241 +++++++++++++++++++++++ src/sdk/index.ts | 3 +- 17 files changed, 371 insertions(+), 110 deletions(-) create mode 100644 project.private.config.json create mode 100644 src/platforms/weapp.ts diff --git a/.env.development b/.env.development index 0dc3e7b..052b7eb 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,2 @@ -# 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config -# TARO_APP_ID="开发环境下的小程序 AppID" -TARO_APP_ID=ttbfd9c96420ec8f8201 \ No newline at end of file +# TARO_APP_ID=ttbfd9c96420ec8f8201 +TARO_APP_ID=wxb51f0b0c3aad7cdf \ No newline at end of file diff --git a/.env.production b/.env.production index 0202ec0..052b7eb 100644 --- a/.env.production +++ b/.env.production @@ -1,2 +1,2 @@ -# TARO_APP_ID="生产环境下的小程序 AppID" -TARO_APP_ID=ttbfd9c96420ec8f8201 \ No newline at end of file +# TARO_APP_ID=ttbfd9c96420ec8f8201 +TARO_APP_ID=wxb51f0b0c3aad7cdf \ No newline at end of file diff --git a/.env.test b/.env.test index 8ee227d..052b7eb 100644 --- a/.env.test +++ b/.env.test @@ -1,2 +1,2 @@ -# TARO_APP_ID="测试环境下的小程序 AppID" -TARO_APP_ID=ttbfd9c96420ec8f8201 \ No newline at end of file +# TARO_APP_ID=ttbfd9c96420ec8f8201 +TARO_APP_ID=wxb51f0b0c3aad7cdf \ No newline at end of file diff --git a/project.config.json b/project.config.json index 1e7518d..095a2f9 100644 --- a/project.config.json +++ b/project.config.json @@ -1 +1,39 @@ -{"miniprogramRoot":"./dist","projectname":"bw-mini-app","description":"图生图 风格转换 ","appid":"ttbfd9c96420ec8f8201","setting":{"urlCheck":true,"es6":true,"enhance":false,"compileHotReLoad":false,"postcss":false,"minified":false},"compileType":"miniprogram"} \ No newline at end of file +{ + "miniprogramRoot": "dist/", + "projectname": "bw-mini-app", + "description": "图生图 风格转换 ", + "appid": "wxb51f0b0c3aad7cdf", + "setting": { + "urlCheck": true, + "es6": true, + "enhance": true, + "compileHotReLoad": false, + "postcss": false, + "minified": true, + "compileWorklet": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "minifyWXML": true, + "localPlugins": false, + "disableUseStrict": false, + "useCompilerPlugins": false, + "condition": false, + "swc": false, + "disableSWC": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "compileType": "miniprogram", + "simulatorPluginLibVersion": {}, + "packOptions": { + "ignore": [], + "include": [] + }, + "editorSetting": {} +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..3383277 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,7 @@ +{ + "setting": { + "urlCheck": true, + "bigPackageSizeSupport": false, + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/src/components/DownloadSection/index.tsx b/src/components/DownloadSection/index.tsx index 66774d9..55cc919 100644 --- a/src/components/DownloadSection/index.tsx +++ b/src/components/DownloadSection/index.tsx @@ -1,5 +1,4 @@ import { View, Text } from '@tarojs/components' -import { memo } from 'react' import './index.css' interface DownloadSectionProps { @@ -8,9 +7,9 @@ interface DownloadSectionProps { loading: boolean } -const DownloadSection: React.FC = memo(({ onDownload, onRegenerate, loading }) => { +const DownloadSection: React.FC = ({ onDownload, onRegenerate, loading }) => { return ( - + = memo(({ onDownload, onRe {loading ? '广告加载中...' : '📱 看广告下载到相册'} {onRegenerate && ( - + 🎨 再来一张 )} - 观看完整广告即可免费下载所有图片 + 观看完整广告即可免费下载所有图片 ) -}) +} export default DownloadSection \ No newline at end of file diff --git a/src/components/ErrorOverlay/index.tsx b/src/components/ErrorOverlay/index.tsx index 0d0732b..9a38b32 100644 --- a/src/components/ErrorOverlay/index.tsx +++ b/src/components/ErrorOverlay/index.tsx @@ -1,21 +1,20 @@ import { View, Text } from '@tarojs/components' -import { memo } from 'react' import './index.css' interface ErrorOverlayProps { onRetry: () => void } -const ErrorOverlay: React.FC = memo(({ onRetry }) => { +const ErrorOverlay: React.FC = ({ onRetry }) => { return ( - - - ⚠️ - 生成失败 - 点击任意处重新开始 + + + ⚠️ + 生成失败 + 点击任意处重新开始 ) -}) +} export default ErrorOverlay \ No newline at end of file diff --git a/src/components/LoadingOverlay/index.tsx b/src/components/LoadingOverlay/index.tsx index a2f8128..aec5c00 100644 --- a/src/components/LoadingOverlay/index.tsx +++ b/src/components/LoadingOverlay/index.tsx @@ -1,19 +1,18 @@ import { View, Text } from '@tarojs/components' -import { memo } from 'react' import './index.css' -const LoadingOverlay: React.FC = memo(() => { +const LoadingOverlay: React.FC = () => { return ( - - - - - AI正在生成中... - 请耐心等待,正在为您精心制作 + + + + + AI正在生成中... + 请耐心等待,正在为您精心制作 ) -}) +} export default LoadingOverlay \ No newline at end of file diff --git a/src/components/UploadButton/index.tsx b/src/components/UploadButton/index.tsx index d19f445..03c1ec9 100644 --- a/src/components/UploadButton/index.tsx +++ b/src/components/UploadButton/index.tsx @@ -1,19 +1,18 @@ import { View, Button } from '@tarojs/components' -import { memo } from 'react' import './index.css' interface UploadButtonProps { onUpload: () => void } -const UploadButton: React.FC = memo(({ onUpload }) => { +const UploadButton: React.FC = ({ onUpload }) => { return ( - - ) -}) +} export default UploadButton \ No newline at end of file diff --git a/src/hooks/useAd.ts b/src/hooks/useAd.ts index 792910c..da7ea1a 100644 --- a/src/hooks/useAd.ts +++ b/src/hooks/useAd.ts @@ -1,5 +1,5 @@ +import { useState, useCallback, useRef, useEffect } from 'react'; import { createPlatformFactory, RewardedVideoAd, RewardedVideoCloseCb, RewardedVideoErrorCb } from "../platforms"; -import { useState, useCallback, useRef, useEffect, useMemo } from 'react'; // 广告奖励回调函数类型 type AdRewardCallback = () => void; @@ -20,16 +20,11 @@ interface UseAdOptions { export function useAd(options?: UseAdOptions): UseAdReturn { const [loading, setLoading] = useState(true); const adRef = useRef(null); - - // 使用 useMemo 稳定 options 引用,避免重复初始化 - const stableOptions = useMemo(() => options, [options?.onReward, options?.onClose]); useEffect(() => { // 创建平台广告实例 const factory = createPlatformFactory() - adRef.current = factory.createRewardedVideoAd({ - adUnitId: 'gncb4kr2b6kwp0uacr' - }); + adRef.current = factory.createRewardedVideoAd(); const ad = adRef.current!; // 广告关闭回调处理 @@ -45,7 +40,7 @@ export function useAd(options?: UseAdOptions): UseAdReturn { console.log('用户观看完整广告,给予奖励'); // 执行奖励回调 - stableOptions?.onReward?.(); + options?.onReward?.(); // 可以在这里处理以下业务: // 1. 发放奖励(积分、道具等) @@ -64,7 +59,7 @@ export function useAd(options?: UseAdOptions): UseAdReturn { } // 执行关闭回调,传入是否完整观看 - stableOptions?.onClose?.(isEnded); + options?.onClose?.(isEnded); } // 广告加载错误回调处理 const onError: RewardedVideoErrorCb = (res) => { @@ -91,7 +86,7 @@ export function useAd(options?: UseAdOptions): UseAdReturn { adRef.current.destroy(); } }; - }, [stableOptions]); + }, [options]); // 显示广告方法 const showAd = useCallback(() => { diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index eeebb47..801d76b 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -6,7 +6,6 @@ import { useSdk } 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' @@ -24,9 +23,6 @@ export default function Index() { const chooseAndGenerateImage = async () => { try { - const platformFactory = createPlatformFactory() - await platformFactory.createUserInfo().checkSession().catch(e => console.error(e)) - // 选择图片,选择完成后会自动触发loading状态 const task_id = await sdk.chooseAndGenerateImage({ onImageSelected: () => { diff --git a/src/pages/result/index.tsx b/src/pages/result/index.tsx index 160acb4..d9440e1 100644 --- a/src/pages/result/index.tsx +++ b/src/pages/result/index.tsx @@ -1,31 +1,17 @@ import { View, Image } from '@tarojs/components' -import { memo, useEffect, useState } from 'react' +import { useEffect, useState } from 'react' import { saveImageToPhotosAlbum, downloadFile, showToast, navigateBack, getCurrentInstance } from '@tarojs/taro' -import { useAd } from '../../hooks/useAd' import DownloadSection from '../../components/DownloadSection' import './index.css' -const ResultPage: React.FC = memo(() => { +const ResultPage: React.FC = () => { const [images, setImages] = useState([]) - - // 广告激励下载功能 - const { loading: adLoading } = useAd({ - onReward: () => { - // 观看完整广告后下载图片 - handleDownloadImages() - }, - onClose: (isEnded) => { - if (!isEnded) { - console.log('需要观看完整广告才能下载') - } - } - }) useEffect(() => { // 获取页面参数 const instance = getCurrentInstance() const params = instance?.router?.params - + if (params?.images) { try { const imageList = JSON.parse(decodeURIComponent(params.images)) @@ -50,7 +36,7 @@ const ResultPage: React.FC = memo(() => { // 下载图片到本地相册 const handleDownloadImages = async () => { if (!images.length) return - + try { showToast({ title: '开始下载...', icon: 'loading' }) @@ -87,9 +73,9 @@ const ResultPage: React.FC = memo(() => { } return ( - + { backgroundRepeat: 'no-repeat' }} > - - + + - + ) -}) +} export default ResultPage \ No newline at end of file diff --git a/src/platforms/core.ts b/src/platforms/core.ts index bc62f67..a2d01e1 100644 --- a/src/platforms/core.ts +++ b/src/platforms/core.ts @@ -52,6 +52,7 @@ export interface RewardedVideoAdOptions { * 定义了跨平台激励视频广告的统一接口 */ export abstract class RewardedVideoAd { + abstract canUse(): boolean; /** * 手动加载广告素材 * 当广告素材加载出现错误时,可以通过此方法手动重新加载 diff --git a/src/platforms/factory.ts b/src/platforms/factory.ts index 1c1c307..91e7ea8 100644 --- a/src/platforms/factory.ts +++ b/src/platforms/factory.ts @@ -1,5 +1,6 @@ import { RewardedVideoAdTT, UserInfoTT } from "./tt"; -import { RewardedVideoAd, RewardedVideoAdOptions, UserInfo } from "./core"; +import { RewardedVideoAd, UserInfo } from "./core"; +import { RewardedVideoAdWeApp, UserInfoWeApp } from "./weapp"; /** * 小程序平台全局对象类型声明 @@ -37,12 +38,14 @@ export class PlatformFactory { * @returns RewardedVideoAd 广告实例 * @throws Error 当平台不支持时抛出错误 */ - createRewardedVideoAd(options?: RewardedVideoAdOptions): RewardedVideoAd { + createRewardedVideoAd(): RewardedVideoAd { switch (this.platform) { case 'tt': - return new RewardedVideoAdTT(options); + return new RewardedVideoAdTT({ + adUnitId: 'gncb4kr2b6kwp0uacr' + }); case 'weapp': - throw new Error(`微信小程序平台暂未实现`); + throw new RewardedVideoAdWeApp(); case 'alipay': throw new Error(`支付宝小程序平台暂未实现`); case 'swan': @@ -60,7 +63,7 @@ export class PlatformFactory { case 'tt': return new UserInfoTT(); case 'weapp': - throw new Error(`微信小程序平台暂未实现`); + throw new UserInfoWeApp(); case 'alipay': throw new Error(`支付宝小程序平台暂未实现`); case 'swan': diff --git a/src/platforms/tt.ts b/src/platforms/tt.ts index 624f254..8c287c4 100644 --- a/src/platforms/tt.ts +++ b/src/platforms/tt.ts @@ -5,7 +5,6 @@ import { RewardedVideoLoadCb, RewardedVideoAdOptions, UserInfo, - IUserInfo, IUserProfile, ICheckSession } from "./core"; @@ -18,27 +17,19 @@ declare const tt: { [key: string]: any; }; -/** - * 字节跳动平台激励视频广告配置接口 - */ -interface TTRewardedVideoAdOptions { - /** 广告位 ID */ - adUnitId: string; - /** 是否启用多场景化 */ - multiton?: boolean; - /** 用户 ID */ - userId?: string; -} - /** * 字节跳动平台激励视频广告实现类 * 封装字节跳动小程序的激励视频广告 API */ export class RewardedVideoAdTT extends RewardedVideoAd { private readonly ad: any; - private readonly options: TTRewardedVideoAdOptions; + private readonly options: RewardedVideoAdOptions; private _isReady: boolean = false; + canUse(): boolean { + return this.options?.adUnitId ? true : false; + } + /** * 构造函数 * @param options 广告配置选项 @@ -51,29 +42,27 @@ export class RewardedVideoAdTT extends RewardedVideoAd { adUnitId: options?.adUnitId || '', }; - if (!this.options.adUnitId) { - throw new Error('广告位 ID (adUnitId) 不能为空'); - } - // 检查字节跳动环境 if (typeof tt === 'undefined') { throw new Error('当前环境不支持字节跳动小程序 API'); } // 创建激励视频广告实例 - this.ad = tt.createRewardedVideoAd({ - adUnitId: this.options.adUnitId, - }); + if (this.options.adUnitId) { + this.ad = tt.createRewardedVideoAd({ + adUnitId: this.options.adUnitId, + }); - // 监听广告加载成功事件 - this.ad.onLoad(() => { - this._isReady = true; - }); + // 监听广告加载成功事件 + this.ad.onLoad(() => { + this._isReady = true; + }); - // 监听广告加载错误事件 - this.ad.onError(() => { - this._isReady = false; - }); + // 监听广告加载错误事件 + this.ad.onError(() => { + this._isReady = false; + }); + } } /** @@ -81,6 +70,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @returns Promise 加载完成的 Promise */ async load(): Promise { + if(!this.ad) return; try { await this.ad.load(); this._isReady = true; @@ -95,6 +85,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @returns Promise 展示完成的 Promise */ async show(): Promise { + if(!this.ad) return; if (!this._isReady) { throw new Error('广告尚未加载完成,请先调用 load() 方法或等待广告加载完成'); } @@ -106,6 +97,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @returns Promise 销毁完成的 Promise */ async destroy(): Promise { + if(!this.ad) return; this._isReady = false; if (this.ad.destroy) { return this.ad.destroy(); @@ -122,6 +114,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @param cb 关闭事件回调函数 */ onClose(cb: RewardedVideoCloseCb): void { + if(!this.ad) return; this.ad.onClose(cb); } @@ -130,6 +123,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @param cb 需要移除的关闭事件回调函数 */ offClose(cb: RewardedVideoCloseCb): void { + if(!this.ad) return; this.ad.offClose(cb); } @@ -138,6 +132,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @param cb 错误事件回调函数 */ onError(cb: RewardedVideoErrorCb): void { + if(!this.ad) return; this.ad.onError(cb); } @@ -146,6 +141,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @param cb 需要移除的错误事件回调函数 */ offError(cb: RewardedVideoErrorCb): void { + if(!this.ad) return; this.ad.offError(cb); } @@ -154,6 +150,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @param cb 加载成功事件回调函数 */ onLoad(cb: RewardedVideoLoadCb): void { + if(!this.ad) return; this.ad.onLoad(cb); } @@ -162,6 +159,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * @param cb 需要移除的加载成功事件回调函数 */ offLoad(cb: RewardedVideoLoadCb): void { + if(!this.ad) return; this.ad.offLoad(cb); } @@ -186,7 +184,7 @@ export class RewardedVideoAdTT extends RewardedVideoAd { * 获取广告配置选项 * @returns TTRewardedVideoAdOptions 当前配置 */ - getOptions(): TTRewardedVideoAdOptions { + getOptions(): RewardedVideoAdOptions { return { ...this.options }; } diff --git a/src/platforms/weapp.ts b/src/platforms/weapp.ts new file mode 100644 index 0000000..21f3db7 --- /dev/null +++ b/src/platforms/weapp.ts @@ -0,0 +1,241 @@ +import { + RewardedVideoAd, + RewardedVideoCloseCb, + RewardedVideoErrorCb, + RewardedVideoLoadCb, + RewardedVideoAdOptions, + UserInfo, + IUserProfile, + ICheckSession +} from "./core"; + +/** + * 字节跳动小程序全局对象类型声明 + */ +declare const wx: { + createRewardedVideoAd: (options: any) => any; + [key: string]: any; +}; + +/** + * 字节跳动平台激励视频广告实现类 + * 封装字节跳动小程序的激励视频广告 API + */ +export class RewardedVideoAdWeApp extends RewardedVideoAd { + private readonly ad: any; + private readonly options: RewardedVideoAdOptions; + private _isReady: boolean = false; + canUse(): boolean { + return this.options?.adUnitId ? true : false; + } + /** + * 构造函数 + * @param options 广告配置选项 + */ + constructor(options?: RewardedVideoAdOptions) { + super(); + + // 设置默认配置 + this.options = { + adUnitId: options?.adUnitId || '', + }; + + // 检查字节跳动环境 + if (typeof wx === 'undefined') { + throw new Error('当前环境不支持字节跳动小程序 API'); + } + + // 创建激励视频广告实例 + if (this.options.adUnitId) { + this.ad = wx.createRewardedVideoAd({ + adUnitId: this.options.adUnitId, + }); + + // 监听广告加载成功事件 + this.ad.onLoad(() => { + this._isReady = true; + }); + + // 监听广告加载错误事件 + this.ad.onError(() => { + this._isReady = false; + }); + } + + } + + /** + * 手动加载广告素材 + * @returns Promise 加载完成的 Promise + */ + async load(): Promise { + if (!this.ad) return; + try { + await this.ad.load(); + this._isReady = true; + } catch (error) { + this._isReady = false; + throw error; + } + } + + /** + * 展示激励视频广告 + * @returns Promise 展示完成的 Promise + */ + async show(): Promise { + if (!this.ad) return; + if (!this._isReady) { + throw new Error('广告尚未加载完成,请先调用 load() 方法或等待广告加载完成'); + } + return this.ad.show(); + } + + /** + * 销毁激励视频广告实例 + * @returns Promise 销毁完成的 Promise + */ + async destroy(): Promise { + if (!this.ad) return; + this._isReady = false; + if (this.ad.destroy) { + return this.ad.destroy(); + } + // 兼容性处理:某些版本可能使用 destory (拼写错误) + if (this.ad.destory) { + return this.ad.destory(); + } + return Promise.resolve(); + } + + /** + * 绑定广告关闭事件监听器 + * @param cb 关闭事件回调函数 + */ + onClose(cb: RewardedVideoCloseCb): void { + if (!this.ad) return; + this.ad.onClose(cb); + } + + /** + * 解除绑定广告关闭事件监听器 + * @param cb 需要移除的关闭事件回调函数 + */ + offClose(cb: RewardedVideoCloseCb): void { + if (!this.ad) return; + this.ad.offClose(cb); + } + + /** + * 绑定广告错误事件监听器 + * @param cb 错误事件回调函数 + */ + onError(cb: RewardedVideoErrorCb): void { + if (!this.ad) return; + this.ad.onError(cb); + } + + /** + * 解除绑定广告错误事件监听器 + * @param cb 需要移除的错误事件回调函数 + */ + offError(cb: RewardedVideoErrorCb): void { + if (!this.ad) return; + this.ad.offError(cb); + } + + /** + * 绑定广告加载成功事件监听器 + * @param cb 加载成功事件回调函数 + */ + onLoad(cb: RewardedVideoLoadCb): void { + if (!this.ad) return; + this.ad.onLoad(cb); + } + + /** + * 解除绑定广告加载成功事件监听器 + * @param cb 需要移除的加载成功事件回调函数 + */ + offLoad(cb: RewardedVideoLoadCb): void { + if (!this.ad) return; + this.ad.offLoad(cb); + } + + /** + * 获取广告是否准备就绪 + * @returns boolean 广告是否可以播放 + */ + isReady(): boolean { + return this._isReady; + } + + /** + * 预加载广告 + * 在合适的时机预先加载广告,提高用户体验 + * @returns Promise 预加载完成的 Promise + */ + async preload(): Promise { + return this.load(); + } + + /** + * 获取广告配置选项 + * @returns TTRewardedVideoAdOptions 当前配置 + */ + getOptions(): RewardedVideoAdOptions { + return { ...this.options }; + } + + /** + * 获取原生广告实例 + * 用于访问平台特有的方法和属性 + * @returns any 原生广告实例 + */ + getNativeAd(): any { + return this.ad; + } +} + +export class UserInfoWeApp extends UserInfo { + getUserProfile(): Promise { + return new Promise((resolve, reject) => { + wx.getUserProfile({ + success: (res: any) => { + console.log({ res }) + resolve(res) + }, + fail: (res: any) => { + console.log({ res }) + reject(res) + } + }) + }) + } + + login(): Promise { + return new Promise((resolve, reject) => { + wx.login({ + success: (res: any) => { + resolve(res) + }, + fail: (res: any) => { + reject(res) + } + }) + }) + } + + checkSession(): Promise { + return new Promise((resolve, reject) => { + wx.checkSession({ + success: (res: any) => { + resolve(res) + }, + fail: (res: any) => { + reject(res) + } + }) + }) + } +} \ No newline at end of file diff --git a/src/sdk/index.ts b/src/sdk/index.ts index a6f66d5..e8142b5 100644 --- a/src/sdk/index.ts +++ b/src/sdk/index.ts @@ -164,6 +164,8 @@ export class BowongAISDK { sourceType }); + console.log({chooseResult}) + // 选择图片完成后触发回调 onImageSelected?.(); @@ -311,7 +313,6 @@ export class BowongAISDK { } const result = response.data as ApiResponse; - console.log({ result }) if (!result.status) { throw new Error(result.msg || '查询任务状态失败'); }