Explorar o código

feat: 修改参数名称

huangzhichao hai 1 ano
pai
achega
8722544952

+ 2 - 2
src/pages/index/index.tsx

@@ -9,7 +9,7 @@ const Index: React.FC = () => {
   useLoad(() => {
   })
 
-  function openEmbeddedMiniProgram(appId, path) {
+  function onEmitOpenMiniProgram(appId, path) {
     Taro.openEmbeddedMiniProgram({
       appId,
       path,
@@ -19,7 +19,7 @@ const Index: React.FC = () => {
 
   return (
     <View className='index'>
-      <custom props={{ openEmbeddedMiniProgram, adpId: 'uh2321awe1', width:250 }}/>
+      <custom props={{ onEmitOpenMiniProgram, adpId: 'uh2321awe1', width:250 }}/>
     </View>
   )
 }

+ 6 - 5
src/plugin/components/custom/index.tsx

@@ -19,7 +19,7 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
   let {
     adpId,
     width,
-    openEmbeddedMiniProgram,
+    onEmitOpenMiniProgram,
     onError,
     onLoad,
     onClose
@@ -37,7 +37,7 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
   function init() {
     if (
         typeof adpId !== 'string' ||
-        typeof openEmbeddedMiniProgram !== 'function'
+        typeof onEmitOpenMiniProgram !== 'function'
       ) {
       catchError('参数错误', 1031)
       return
@@ -107,7 +107,7 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
     const orgPath = `path=${encodeURIComponent(landingPageAddress)}&${query}`
     const path = AES.encrypt(orgPath, 'wx5ef216d1caf4a0eaylq').toString()
 
-    openEmbeddedMiniProgram(
+    onEmitOpenMiniProgram(
       'wx5ef216d1caf4a0ea',
       `/pages/ad-launch-page/index?q=${path}`
     )
@@ -194,10 +194,11 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
   }
 
   function catchError(message, code) {
-    onError({ message, code })
+    onError(code)
     setShow(false)
     adActionReport(reportBusinessType.adError, 'adError', {
-      errorCode: code
+      errorCode: code,
+      message
     })
   }
 

+ 2 - 2
src/plugin/share/index.ts

@@ -6,7 +6,7 @@ export function wrapProps(props: PropsWithChildren<CustomPropsType>) {
   let {
     adpId,
     width,
-    openEmbeddedMiniProgram = noop,
+    onEmitOpenMiniProgram = noop,
     onError = noop,
     onLoad = noop,
     onClose = noop
@@ -15,7 +15,7 @@ export function wrapProps(props: PropsWithChildren<CustomPropsType>) {
   return {
     adpId,
     width,
-    openEmbeddedMiniProgram,
+    onEmitOpenMiniProgram,
     onError,
     onLoad,
     onClose

+ 2 - 2
types/global.d.ts

@@ -36,8 +36,8 @@ declare namespace Taro {
 type CustomPropsType = {
   adpId: number
   width?: number
-  openEmbeddedMiniProgram(appId: string, path: string): void
-  onError?(params: { message: string, code: number}): void
+  onEmitOpenMiniProgram(appId: string, path: string): void
+  onError?(code: number): void
   onLoad?(): void
   onClose?(): void
 }