@kbapp/market-partner-sdk 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +21 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +9 -9
- package/dist/index.umd.js +1 -1
- package/dist/lib/{report-getui.d.ts → report-da-event.d.ts} +3 -3
- package/examples/index.html +3 -3
- package/package.json +8 -1
- package/vite.config.ts +0 -24
package/README.MD
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 开吧商城接入 SDK
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> ⚠️ 重要提示:本 SDK 基于 TypeScript 开发,所有 API 参数均带有明确的必填 / 选填类型标注。使用时请务必开启 TS 类型检查或在 IDE 中查看参数提示,必填项缺失会直接提示错误,选填项可按需传入,请勿忽略类型提示以避免使用异常。
|
|
4
4
|
|
|
5
5
|
## 下载
|
|
6
6
|
|
|
@@ -72,7 +72,7 @@ const onTapRunAction = async () => {
|
|
|
72
72
|
| `runAction` | 执行统一跳转页面标准 |
|
|
73
73
|
| `defineAppShareModel` | 定义页面分享内容 |
|
|
74
74
|
| `openAppSharePanel` | 主动唤起分享面板 |
|
|
75
|
-
| `
|
|
75
|
+
| `reportDAEvent` | 上报数据埋点 |
|
|
76
76
|
| `getAppBaseInfo` | 获取开吧 App 基础信息 |
|
|
77
77
|
| `shareImage` | 分享图片 |
|
|
78
78
|
| `onAppSharePanelShow` | 监听分享面板打开事件 |
|
|
@@ -240,14 +240,15 @@ console.log('是否能使用', canUse)
|
|
|
240
240
|
### getAuthToken
|
|
241
241
|
|
|
242
242
|
> 获取认证令牌
|
|
243
|
+
|
|
243
244
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
244
245
|
|
|
245
246
|
#### 请求参数
|
|
246
247
|
|
|
247
248
|
| 参数 | 类型 | 必填 | 说明 |
|
|
248
|
-
| --------- | ----------------------------- | ---- |
|
|
249
|
-
| `success` | `(token: AuthResult) => void`
|
|
250
|
-
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调
|
|
249
|
+
| --------- | ----------------------------- | ---- | -------- |
|
|
250
|
+
| `success` | `(token: AuthResult) => void` | 否 | 成功回调 |
|
|
251
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
251
252
|
|
|
252
253
|
#### 返回值
|
|
253
254
|
|
|
@@ -279,14 +280,15 @@ if (authResult.code === 0) {
|
|
|
279
280
|
### getAuthTokenWithSilent
|
|
280
281
|
|
|
281
282
|
> 静默获取认证令牌,当用户未登录时不会唤起登录界面
|
|
283
|
+
|
|
282
284
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
283
285
|
|
|
284
286
|
#### 请求参数
|
|
285
287
|
|
|
286
288
|
| 参数 | 类型 | 必填 | 说明 |
|
|
287
|
-
| --------- | ----------------------------- | ---- |
|
|
288
|
-
| `success` | `(token: AuthResult) => void`
|
|
289
|
-
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调
|
|
289
|
+
| --------- | ----------------------------- | ---- | -------- |
|
|
290
|
+
| `success` | `(token: AuthResult) => void` | 否 | 成功回调 |
|
|
291
|
+
| `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
|
|
290
292
|
|
|
291
293
|
#### 返回值
|
|
292
294
|
|
|
@@ -322,6 +324,7 @@ if (authResult.code === 0) {
|
|
|
322
324
|
### runAction
|
|
323
325
|
|
|
324
326
|
> 执行统一跳转页面标准
|
|
327
|
+
|
|
325
328
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
326
329
|
|
|
327
330
|
#### 请求参数
|
|
@@ -355,6 +358,7 @@ runAction({
|
|
|
355
358
|
### defineAppShareModel
|
|
356
359
|
|
|
357
360
|
> 定义 app 点击转发时候的分享卡片内容
|
|
361
|
+
|
|
358
362
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
359
363
|
|
|
360
364
|
#### 请求参数 方式 1
|
|
@@ -433,6 +437,7 @@ await defineAppShareModel({
|
|
|
433
437
|
### openAppSharePanel
|
|
434
438
|
|
|
435
439
|
> 主动唤起分享面板
|
|
440
|
+
|
|
436
441
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
437
442
|
|
|
438
443
|
#### 请求参数
|
|
@@ -469,6 +474,7 @@ openAppSharePanel({
|
|
|
469
474
|
### onAppSharePanelShow
|
|
470
475
|
|
|
471
476
|
> 监听分享面板打开时触发(主动和被动)
|
|
477
|
+
|
|
472
478
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
473
479
|
|
|
474
480
|
#### 请求参数
|
|
@@ -499,6 +505,7 @@ const stopHandle = onAppSharePanelShow(() => {
|
|
|
499
505
|
### shareImage
|
|
500
506
|
|
|
501
507
|
> 分享图片
|
|
508
|
+
|
|
502
509
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
503
510
|
|
|
504
511
|
#### 请求参数
|
|
@@ -528,6 +535,7 @@ shareImage({
|
|
|
528
535
|
### getAppBaseInfo
|
|
529
536
|
|
|
530
537
|
> 获取开吧 App 基础信息
|
|
538
|
+
|
|
531
539
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
532
540
|
|
|
533
541
|
#### 请求参数
|
|
@@ -564,9 +572,10 @@ getAppBaseInfo().then((deviceInfo: AppBaseInfo) => {
|
|
|
564
572
|
})
|
|
565
573
|
```
|
|
566
574
|
|
|
567
|
-
###
|
|
575
|
+
### reportDAEvent
|
|
576
|
+
|
|
577
|
+
> 上报数据埋点
|
|
568
578
|
|
|
569
|
-
> 上报数据埋点到个推
|
|
570
579
|
> @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
|
|
571
580
|
|
|
572
581
|
#### 请求参数
|
|
@@ -588,9 +597,9 @@ Promise<void>
|
|
|
588
597
|
#### 示例代码
|
|
589
598
|
|
|
590
599
|
```js
|
|
591
|
-
import {
|
|
600
|
+
import { reportDAEvent } from '@kbapp/market-partner-sdk'
|
|
592
601
|
|
|
593
|
-
|
|
602
|
+
reportDAEvent({
|
|
594
603
|
eventName: 'event_name',
|
|
595
604
|
eventParams: {
|
|
596
605
|
test_param: 'test_value',
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './core';
|
|
|
2
2
|
export * from './lib/env';
|
|
3
3
|
export * from './lib/bridge-code';
|
|
4
4
|
export * from './lib/get-app-base-info';
|
|
5
|
-
export * from './lib/report-
|
|
5
|
+
export * from './lib/report-da-event';
|
|
6
6
|
export * from './lib/run-action';
|
|
7
7
|
export * from './lib/share-image';
|
|
8
8
|
export * from './lib/share-model';
|
package/dist/index.es.js
CHANGED
|
@@ -161,7 +161,7 @@ function f(e) {
|
|
|
161
161
|
});
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
const
|
|
164
|
+
const D = /(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);
|
|
165
165
|
function d(e, r) {
|
|
166
166
|
return new Promise(async (i, o) => {
|
|
167
167
|
try {
|
|
@@ -202,7 +202,7 @@ function w(e, r) {
|
|
|
202
202
|
errorMsg: `最低版本要求${e.minVersion}`
|
|
203
203
|
})));
|
|
204
204
|
}
|
|
205
|
-
class
|
|
205
|
+
class C {
|
|
206
206
|
}
|
|
207
207
|
const q = b((e) => d(
|
|
208
208
|
e || {},
|
|
@@ -254,7 +254,7 @@ function B(e) {
|
|
|
254
254
|
}))
|
|
255
255
|
);
|
|
256
256
|
}
|
|
257
|
-
const
|
|
257
|
+
const x = (e) => d(
|
|
258
258
|
e,
|
|
259
259
|
w({ minVersion: 80801 }, async () => f({
|
|
260
260
|
name: "OpenActRequest",
|
|
@@ -264,7 +264,7 @@ const G = (e) => d(
|
|
|
264
264
|
}
|
|
265
265
|
}))
|
|
266
266
|
), _ = "SHARE_EVENT_NAME";
|
|
267
|
-
class
|
|
267
|
+
class G {
|
|
268
268
|
}
|
|
269
269
|
function K(e) {
|
|
270
270
|
return d(e, async () => k({
|
|
@@ -312,11 +312,11 @@ function L(e) {
|
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
314
|
export {
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
C as AppBaseInfo,
|
|
316
|
+
G as AppShareModel,
|
|
317
317
|
j as AuthResult,
|
|
318
318
|
l as BridgeCode,
|
|
319
|
-
|
|
319
|
+
D as IS_KB_APP_ENV,
|
|
320
320
|
K as defineAppShareModel,
|
|
321
321
|
q as getAppBaseInfo,
|
|
322
322
|
F as getAuthToken,
|
|
@@ -326,7 +326,7 @@ export {
|
|
|
326
326
|
$ as onAppSharePanelShow,
|
|
327
327
|
W as openAppSharePanel,
|
|
328
328
|
k as registerNativeApiHandler,
|
|
329
|
-
J as
|
|
329
|
+
J as reportDAEvent,
|
|
330
330
|
B as runAction,
|
|
331
|
-
|
|
331
|
+
x as shareImage
|
|
332
332
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a.kbMarket={}))})(this,(function(a){"use strict";const d=class d{constructor(t){this.errorCode=t.errorCode,this.errorMsg=t.errorMsg}};d.UNKNOWN=new d({errorCode:1e3,errorMsg:"未知错误"}),d.UNSUPPORTED_VERSION=new d({errorCode:1001,errorMsg:"当前开吧版本不支持"}),d.TIMEOUT=new d({errorCode:1002,errorMsg:"执行超时"}),d.UNSUPPORTED_BRIDGE_ENV=new d({errorCode:1003,errorMsg:"请在开吧app内执行"});let c=d;const k=()=>{const e=(n,s,r)=>{var u="";typeof s=="function"&&(r=s,s={});var l={data:s===void 0?null:s};if(typeof r=="function"){var v="dscb"+window.dscb++;window[v]=r,l._dscbstub=v}if(l=JSON.stringify(l),window.flutter_inappwebview?window.flutter_inappwebview.callHandler&&(u=window.flutter_inappwebview.callHandler(""+n,l)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(u=prompt("_flutterDsbridge="+n,l)),u instanceof Promise)return u;try{return JSON.parse(u||"{}").data}catch{console.error("callHandle异常,JSON.parse错误")}},t=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,i=(()=>{const n=[],s=setInterval(()=>{t()&&(clearInterval(s),n.forEach(r=>{e.apply(window,r)}),n.length=0)},500);return(...r)=>{n.push(r)}})();var o={default:void 0,callHandler:function(n,s,r){return t()?e(n,s,r):i(n,s,r)},register:function(n,s,r){var u=r?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){o.callHandler("_dsb.dsinit")},0)),typeof s=="object"?u._obs[n]=s:u[n]=s},registerHandler:function(n,s){this.register(n,s,!0)}};return(function(){if(!window._dsf){var n={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:o,_handleMessageFromNative:function(r){var u=JSON.parse(r.data),l={id:r.callbackId,complete:!0},v=this._dsf[r.method],y=this._dsaf[r.method],R=function(E,m){l.data=E.apply(m,u),o.callHandler("_dsb.returnValue",l)},I=function(E,m){u.push(function(z,Q){l.data=z,l.complete=Q!==!1,o.callHandler("_dsb.returnValue",l)}),E.apply(m,u)};if(v)R(v,this._dsf);else if(y)I(y,this._dsaf);else{var g=r.method.split(".");if(g.length<2)return;var V=g.pop(),T=g.join("."),S=this._dsf._obs,A=S[T]||{},h=A[V];if(h&&typeof h=="function"){R(h,A);return}if(S=this._dsaf._obs,A=S[T]||{},h=A[V],h&&typeof h=="function"){I(h,A);return}}}};for(var s in n)window[s]=n[s]}})(),o},N=(e=>/(kb)/i.test(e)?k():{registerHandler(t,i){throw c.UNSUPPORTED_BRIDGE_ENV},callHandler(t,i,o){throw c.UNSUPPORTED_BRIDGE_ENV}})(window?.navigator?.userAgent),P=e=>new Promise((t,i)=>{try{N.registerHandler(e.name,e.handler),e.success?.(),t()}catch(o){e.fail?.(o),i(o)}finally{e.complete?.()}});function f(e){const t=i=>{let o;const n=r=>{(!o||o==="success")&&(o="success",i.success?.(r))},s=r=>{(!o||o==="error")&&(o="error",i.fail?.(r))};i.timeout&&setTimeout(()=>{s(c.TIMEOUT)},i.timeout);try{N.callHandler(i.name,i.params,r=>{let u;try{u=typeof r=="string"?JSON.parse(r.replace(/\n/g,"\\n").replace(/\r/g,"\\r")):r}catch{u=null}n(u)})}catch(r){s(r)}};return new Promise((i,o)=>{t({name:e.name,params:e.params,timeout:e.timeout,success:n=>{e.success?.(n),e.complete?.(),i(n)},fail:n=>{e.fail?.(n),e.complete?.(),o(n)}})})}const M=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);function p(e,t){return new Promise(async(i,o)=>{try{const n=await t();e.success?.(n),i(n)}catch(n){const s=n?.errorCode?n:new c({errorCode:c.UNKNOWN.errorCode,errorMsg:String(n)});e.fail?.(s),o(s)}finally{e.complete?.()}})}function b(e){let t;return function(...i){return t||(t=e(...i),Promise.resolve(t).catch(()=>{t=void 0}),t)}}const H=b(()=>f({name:"OpenActRequest",params:{type:35,data:{}}}));function O(e){return p(e,async()=>(await H()).vcode>=e.minVersion)}function w(e,t){return(...i)=>O({minVersion:e.minVersion}).then(o=>o?t(...i):Promise.reject(new c({errorCode:c.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}class U{}const
|
|
1
|
+
(function(a,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a.kbMarket={}))})(this,(function(a){"use strict";const d=class d{constructor(t){this.errorCode=t.errorCode,this.errorMsg=t.errorMsg}};d.UNKNOWN=new d({errorCode:1e3,errorMsg:"未知错误"}),d.UNSUPPORTED_VERSION=new d({errorCode:1001,errorMsg:"当前开吧版本不支持"}),d.TIMEOUT=new d({errorCode:1002,errorMsg:"执行超时"}),d.UNSUPPORTED_BRIDGE_ENV=new d({errorCode:1003,errorMsg:"请在开吧app内执行"});let c=d;const k=()=>{const e=(n,s,r)=>{var u="";typeof s=="function"&&(r=s,s={});var l={data:s===void 0?null:s};if(typeof r=="function"){var v="dscb"+window.dscb++;window[v]=r,l._dscbstub=v}if(l=JSON.stringify(l),window.flutter_inappwebview?window.flutter_inappwebview.callHandler&&(u=window.flutter_inappwebview.callHandler(""+n,l)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(u=prompt("_flutterDsbridge="+n,l)),u instanceof Promise)return u;try{return JSON.parse(u||"{}").data}catch{console.error("callHandle异常,JSON.parse错误")}},t=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,i=(()=>{const n=[],s=setInterval(()=>{t()&&(clearInterval(s),n.forEach(r=>{e.apply(window,r)}),n.length=0)},500);return(...r)=>{n.push(r)}})();var o={default:void 0,callHandler:function(n,s,r){return t()?e(n,s,r):i(n,s,r)},register:function(n,s,r){var u=r?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){o.callHandler("_dsb.dsinit")},0)),typeof s=="object"?u._obs[n]=s:u[n]=s},registerHandler:function(n,s){this.register(n,s,!0)}};return(function(){if(!window._dsf){var n={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:o,_handleMessageFromNative:function(r){var u=JSON.parse(r.data),l={id:r.callbackId,complete:!0},v=this._dsf[r.method],y=this._dsaf[r.method],R=function(E,m){l.data=E.apply(m,u),o.callHandler("_dsb.returnValue",l)},I=function(E,m){u.push(function(z,Q){l.data=z,l.complete=Q!==!1,o.callHandler("_dsb.returnValue",l)}),E.apply(m,u)};if(v)R(v,this._dsf);else if(y)I(y,this._dsaf);else{var g=r.method.split(".");if(g.length<2)return;var V=g.pop(),T=g.join("."),S=this._dsf._obs,A=S[T]||{},h=A[V];if(h&&typeof h=="function"){R(h,A);return}if(S=this._dsaf._obs,A=S[T]||{},h=A[V],h&&typeof h=="function"){I(h,A);return}}}};for(var s in n)window[s]=n[s]}})(),o},N=(e=>/(kb)/i.test(e)?k():{registerHandler(t,i){throw c.UNSUPPORTED_BRIDGE_ENV},callHandler(t,i,o){throw c.UNSUPPORTED_BRIDGE_ENV}})(window?.navigator?.userAgent),P=e=>new Promise((t,i)=>{try{N.registerHandler(e.name,e.handler),e.success?.(),t()}catch(o){e.fail?.(o),i(o)}finally{e.complete?.()}});function f(e){const t=i=>{let o;const n=r=>{(!o||o==="success")&&(o="success",i.success?.(r))},s=r=>{(!o||o==="error")&&(o="error",i.fail?.(r))};i.timeout&&setTimeout(()=>{s(c.TIMEOUT)},i.timeout);try{N.callHandler(i.name,i.params,r=>{let u;try{u=typeof r=="string"?JSON.parse(r.replace(/\n/g,"\\n").replace(/\r/g,"\\r")):r}catch{u=null}n(u)})}catch(r){s(r)}};return new Promise((i,o)=>{t({name:e.name,params:e.params,timeout:e.timeout,success:n=>{e.success?.(n),e.complete?.(),i(n)},fail:n=>{e.fail?.(n),e.complete?.(),o(n)}})})}const M=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);function p(e,t){return new Promise(async(i,o)=>{try{const n=await t();e.success?.(n),i(n)}catch(n){const s=n?.errorCode?n:new c({errorCode:c.UNKNOWN.errorCode,errorMsg:String(n)});e.fail?.(s),o(s)}finally{e.complete?.()}})}function b(e){let t;return function(...i){return t||(t=e(...i),Promise.resolve(t).catch(()=>{t=void 0}),t)}}const H=b(()=>f({name:"OpenActRequest",params:{type:35,data:{}}}));function O(e){return p(e,async()=>(await H()).vcode>=e.minVersion)}function w(e,t){return(...i)=>O({minVersion:e.minVersion}).then(o=>o?t(...i):Promise.reject(new c({errorCode:c.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}class U{}const D=b(e=>p(e||{},w({minVersion:80801},()=>f({name:"OpenActRequest",params:{type:60001,data:{}}}))));function C(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};const t={};return Object.keys(e).forEach(i=>{const o=e[i];o!==void 0&&(t[i]=o)}),t}function q(e){return p(e,w({minVersion:80801},async()=>f({name:"OpenActRequest",params:{type:60400,data:C({eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType})}})))}function B(e){return p({...e},w({minVersion:80801},async()=>f({name:"OpenActRequest",params:{type:60300,data:e}})))}const J=e=>p(e,w({minVersion:80801},async()=>f({name:"OpenActRequest",params:{type:60500,data:e}}))),_="SHARE_EVENT_NAME";class j{}function K(e){return p(e,async()=>P({name:"CommonShare",handler(t,i){window.dispatchEvent(new Event(_)),"onShareApp"in e&&e.onShareApp?i({type:12,data:e.onShareApp()}):i({type:12,data:e})}}))}function W(e){return p(e,w({minVersion:80801},async()=>(window.dispatchEvent(new Event(_)),f({name:"OpenActRequest",params:{type:60500,data:e}}))))}function G(e){return window.addEventListener(_,e),()=>{window.removeEventListener(_,e)}}class ${}async function F(e){return p(e||{},w({minVersion:80801},async()=>(await f({name:"OpenActRequest",params:{type:60101}})).data||null))}function L(e){return p(e||{},w({minVersion:80801},async()=>(await f({name:"OpenActRequest",params:{type:60100}})).data||null))}a.AppBaseInfo=U,a.AppShareModel=j,a.AuthResult=$,a.BridgeCode=c,a.IS_KB_APP_ENV=M,a.defineAppShareModel=K,a.getAppBaseInfo=D,a.getAuthToken=F,a.getAuthTokenWithSilent=L,a.invokeNativeApi=f,a.isAppVersionSupport=O,a.onAppSharePanelShow=G,a.openAppSharePanel=W,a.registerNativeApiHandler=P,a.reportDAEvent=q,a.runAction=B,a.shareImage=J,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -6,9 +6,9 @@ import { CallbackOptions } from './callback-options';
|
|
|
6
6
|
* @example
|
|
7
7
|
* **示例代码**
|
|
8
8
|
```js
|
|
9
|
-
import {
|
|
9
|
+
import { reportDAEvent } from '@kbapp/market-partner-sdk';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
reportDAEvent({
|
|
12
12
|
eventName: 'event_name',
|
|
13
13
|
eventParams: {
|
|
14
14
|
test_param: 'test_value',
|
|
@@ -19,7 +19,7 @@ reportGetui({
|
|
|
19
19
|
})
|
|
20
20
|
```
|
|
21
21
|
*/
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function reportDAEvent(params: {
|
|
23
23
|
/** 事件名 */
|
|
24
24
|
eventName: string;
|
|
25
25
|
/** 上报值 */
|
package/examples/index.html
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
</body>
|
|
52
52
|
<script type="module">
|
|
53
53
|
import { createApp, ref, reactive } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
|
|
54
|
-
import { getAuthToken, getAuthTokenWithSilent, runAction, defineAppShareModel, openAppSharePanel,
|
|
54
|
+
import { getAuthToken, getAuthTokenWithSilent, runAction, defineAppShareModel, openAppSharePanel, reportDAEvent, getAppBaseInfo, shareImage } from 'https://unpkg.com/@kbapp/market-partner-sdk@latest/dist/index.es.js'
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* 装饰器,用于处理done函数的调用
|
|
@@ -163,12 +163,12 @@
|
|
|
163
163
|
}),
|
|
164
164
|
},
|
|
165
165
|
{
|
|
166
|
-
title: '
|
|
166
|
+
title: 'reportDAEvent',
|
|
167
167
|
subtitle: '上报数据埋点到个推',
|
|
168
168
|
buttonText: '执行',
|
|
169
169
|
desc: `执行结果:上报数据埋点到个推`,
|
|
170
170
|
done: decorateDone(async () => {
|
|
171
|
-
await
|
|
171
|
+
await reportDAEvent({
|
|
172
172
|
eventName: 'text_event_name',
|
|
173
173
|
eventParams: {
|
|
174
174
|
test_param: 'test_value',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kbapp/market-partner-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "开吧商城接入jssdk",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -12,7 +12,14 @@
|
|
|
12
12
|
"browser": "./dist/index.umd.js",
|
|
13
13
|
"author": "along",
|
|
14
14
|
"scripts": {
|
|
15
|
+
"dev": "npm run build && web-dev-server --root-dir ./ --port 3000 --open /examples/index.html --node-resolve --no-cache",
|
|
15
16
|
"build": "rm -rf ./dist && vite build && npx tsc --emitDeclarationOnly",
|
|
16
17
|
"publish": "npm run build && npm publish"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
21
|
+
"@web/dev-server": "^0.4.6",
|
|
22
|
+
"typescript": "^5.9.3",
|
|
23
|
+
"vite": "^7.3.0"
|
|
17
24
|
}
|
|
18
25
|
}
|
package/vite.config.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import react from '@vitejs/plugin-react';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
plugins: [react()],
|
|
6
|
-
build: {
|
|
7
|
-
lib: {
|
|
8
|
-
entry: './src/index.ts',
|
|
9
|
-
name: 'kbMarket',
|
|
10
|
-
fileName: (format) => `index.${format}.js`,
|
|
11
|
-
formats: ['es', 'umd']
|
|
12
|
-
},
|
|
13
|
-
rollupOptions: {
|
|
14
|
-
// 确保外部化处理那些你不想打包进库的依赖
|
|
15
|
-
external: [],
|
|
16
|
-
output: {
|
|
17
|
-
// 为 UMD/iife 构建提供全局变量名称
|
|
18
|
-
globals: {
|
|
19
|
-
// 如果有依赖需要全局变量映射,可以在这里配置
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|