feat: endopints/wechat 中callback改为异步

This commit is contained in:
lxy 2025-11-27 15:30:44 +08:00
parent 7cb2479eab
commit 3aec26e06f
23 changed files with 130 additions and 131 deletions

View File

@ -1,3 +1,2 @@
/// <reference types="wechat-miniprogram" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "article", false, WechatMiniprogram.Component.DataOption>) => React.ReactElement; declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "article", false, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default; export default _default;

View File

@ -5,7 +5,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
tocPosition: "none" | "left" | "right"; tocPosition: "none" | "left" | "right";
highlightBgColor: string; highlightBgColor: string;
onArticlePreview: (content?: string, title?: string) => void; onArticlePreview: (content?: string, title?: string) => void;
origin: import("../../../types/Config").CosOrigin | null; origin: null | EntityDict["extraFile"]["Schema"]["origin"];
scrollId: string; scrollId: string;
height: number | "auto"; height: number | "auto";
activeColor: string | undefined; activeColor: string | undefined;

View File

@ -1,10 +1,9 @@
/// <reference types="react" />
import { GenerateUrlFn } from "../../../types/Article"; import { GenerateUrlFn } from "../../../types/Article";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "article", true, { declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "article", true, {
entityId: string; entityId: string;
articleMenuId: string | undefined; articleMenuId: string | undefined;
generateUrl: GenerateUrlFn; generateUrl: GenerateUrlFn;
empty: import("react").ReactNode; empty: React.ReactNode | undefined;
menuCheck: (isArticle: boolean) => void; menuCheck: (isArticle: boolean) => void;
}>) => React.ReactElement; }>) => React.ReactElement;
export default _default; export default _default;

View File

@ -1,7 +1,7 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "article", true, { declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "article", true, {
articleMenuId: string | undefined; articleMenuId: string | undefined;
onChildEditArticleChange: (data: string) => void; onChildEditArticleChange: (data: string) => void;
show: "preview" | "edit" | "doc"; show: "edit" | "doc" | "preview";
getBreadcrumbItemsByParent: (breadcrumbItems: string[]) => void; getBreadcrumbItemsByParent: (breadcrumbItems: string[]) => void;
breadcrumbItems: string[]; breadcrumbItems: string[];
drawerOpen: boolean; drawerOpen: boolean;

View File

@ -5,7 +5,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
tocPosition: "none" | "left" | "right"; tocPosition: "none" | "left" | "right";
highlightBgColor: string; highlightBgColor: string;
onArticlePreview: (content?: string, title?: string) => void; onArticlePreview: (content?: string, title?: string) => void;
origin: import("../../../types/Config").CosOrigin | null; origin: EntityDict["extraFile"]["Schema"]["origin"] | null;
scrollId: string; scrollId: string;
height: number | "auto"; height: number | "auto";
activeColor: string | undefined; activeColor: string | undefined;

View File

@ -4,6 +4,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
entity: keyof EntityDict; entity: keyof EntityDict;
entityId: string; entityId: string;
autoUpload: boolean; autoUpload: boolean;
origin: import("../../../types/Config").CosOrigin | null; origin: EntityDict["extraFile"]["Schema"]["origin"] | null;
}>) => React.ReactElement; }>) => React.ReactElement;
export default _default; export default _default;

View File

@ -18,6 +18,10 @@ export default OakComponent({
entity: 1, entity: 1,
entityId: 1, entityId: 1,
sort: 1, sort: 1,
fileType: 1,
isBridge: 1,
uploadState: 1,
size: 1,
applicationId: 1, applicationId: 1,
}, },
features: ['extraFile'], features: ['extraFile'],

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { EntityDict } from '../../../oak-app-domain'; import { EntityDict } from '../../../oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { ReactComponentProps } from 'oak-frontend-base/lib/types/Page'; import { ReactComponentProps } from 'oak-frontend-base/lib/types/Page';
@ -9,31 +8,14 @@ type AfterCommit = (() => void) | undefined;
type BeforeCommit = (() => boolean | undefined | Promise<boolean | undefined>) | undefined; type BeforeCommit = (() => boolean | undefined | Promise<boolean | undefined>) | undefined;
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, { declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
entity: keyof ED2; entity: keyof ED2;
action?: string | undefined; action?: string;
size?: ButtonProps['size'] | AmButtonProps['size']; size?: ButtonProps["size"] | AmButtonProps["size"];
block?: boolean | undefined; block?: boolean;
type?: ButtonProps['type'] | AmButtonProps['type']; type?: ButtonProps["type"] | AmButtonProps["type"];
executeText?: string | undefined; executeText?: string;
buttonProps?: (ButtonProps & { buttonProps?: ButtonProps & AmButtonProps;
color?: "default" | "success" | "primary" | "warning" | "danger" | undefined;
fill?: "none" | "solid" | "outline" | undefined;
size?: "small" | "middle" | "large" | "mini" | undefined;
block?: boolean | undefined;
loading?: boolean | "auto" | undefined;
loadingText?: string | undefined;
loadingIcon?: import("react").ReactNode;
disabled?: boolean | undefined;
onClick?: ((event: import("react").MouseEvent<HTMLButtonElement, MouseEvent>) => unknown) | undefined;
type?: "button" | "reset" | "submit" | undefined;
shape?: "default" | "rounded" | "rectangular" | undefined;
children?: import("react").ReactNode;
} & Pick<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, "id" | "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
className?: string | undefined;
style?: (import("react").CSSProperties & Partial<Record<"--text-color" | "--background-color" | "--border-radius" | "--border-width" | "--border-style" | "--border-color", string>>) | undefined;
tabIndex?: number | undefined;
} & import("react").AriaAttributes) | undefined;
afterCommit?: AfterCommit; afterCommit?: AfterCommit;
beforeCommit?: BeforeCommit; beforeCommit?: BeforeCommit;
messageProps?: boolean | MessageProps | undefined; messageProps?: MessageProps | boolean;
}>) => React.ReactElement; }>) => React.ReactElement;
export default _default; export default _default;

View File

@ -20,7 +20,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
extension: string[]; extension: string[];
selectCount: number; selectCount: number;
sourceType: SourceType[]; sourceType: SourceType[];
mediaType: ('image' | 'video')[]; mediaType: ("image" | "video")[];
mode: ImageMode; mode: ImageMode;
size: number; size: number;
showUploadList: boolean; showUploadList: boolean;
@ -52,7 +52,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
aspect: number; aspect: number;
minZoom: number; minZoom: number;
maxZoom: number; maxZoom: number;
cropShape: 'rect' | 'round'; cropShape: "rect" | "round";
cropperProps: object; cropperProps: object;
modalTitle: string; modalTitle: string;
modalWidth: string; modalWidth: string;
@ -67,7 +67,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
minHeight: number; minHeight: number;
compressWidth: number; compressWidth: number;
compressHeight: number; compressHeight: number;
resize: 'contain' | 'cover' | 'none'; resize: "contain" | "cover" | "none";
compressQuality: number; compressQuality: number;
mimeType: string; mimeType: string;
convertTypes: string[]; convertTypes: string[];

View File

@ -12,6 +12,7 @@ export default OakComponent({
objectId: 1, objectId: 1,
filename: 1, filename: 1,
extra1: 1, extra1: 1,
extra2: 1,
extension: 1, extension: 1,
type: 1, type: 1,
entity: 1, entity: 1,
@ -20,6 +21,8 @@ export default OakComponent({
sort: 1, sort: 1,
isBridge: 1, isBridge: 1,
uploadState: 1, uploadState: 1,
size: 1,
applicationId: 1,
}, },
data: { data: {
// 根据 size 不同,计算的图片显示大小不同 // 根据 size 不同,计算的图片显示大小不同
@ -47,19 +50,19 @@ export default OakComponent({
bucket: '', bucket: '',
autoUpload: false, autoUpload: false,
maxNumber: 20, maxNumber: 20,
extension: [], extension: [], //小程序独有 chooseMessageFile
selectCount: 1, selectCount: 1, // 每次打开图片时,可选中的数量 小程序独有
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'], // 小程序独有 chooseMedia
mediaType: ['image'], mediaType: ['image'], // 小程序独有 chooseMedia
mode: 'aspectFit', mode: 'aspectFit', // 图片显示模式
size: 3, size: 3, // 每行可显示的个数 小程序独有
showUploadList: true, showUploadList: true, //web独有
showUploadProgress: false, showUploadProgress: false, // web独有
accept: 'image/*', accept: 'image/*', // web独有
disablePreview: false, disablePreview: false, // 图片是否可预览
disableDelete: false, disableDelete: false, // 图片是否可删除
disableAdd: false, disableAdd: false, // 上传按钮隐藏
disableDownload: false, disableDownload: false, // 下载按钮隐藏
type: 'image', type: 'image',
origin: null, origin: null,
tag1: '', tag1: '',
@ -67,40 +70,40 @@ export default OakComponent({
entity: '', entity: '',
entityId: '', entityId: '',
theme: 'image', theme: 'image',
enableCrop: false, enableCrop: false, //启用裁剪
enableCompross: false, enableCompross: false, //启用压缩
//图片裁剪 //图片裁剪
cropQuality: 1, cropQuality: 1, //图片裁剪质量范围0 ~ 1
showRest: false, showRest: false, //显示重置按钮,重置缩放及旋转
showGrid: false, showGrid: false, //显示裁切区域网格(九宫格)
fillColor: 'white', fillColor: 'white', //裁切图像填充色
rotationSlider: false, rotationSlider: false, //图片旋转控制
aspectSlider: false, aspectSlider: false, //裁切比率控制
zoomSlider: true, zoomSlider: true, //图片缩放控制
resetText: '重置', resetText: '重置', //重置按钮文字
aspect: 1 / 1, aspect: 1 / 1, //裁切区域宽高比width / height
minZoom: 1, minZoom: 1, //最小缩放倍数
maxZoom: 3, maxZoom: 3, //最大缩放倍数
cropShape: 'rect', cropShape: 'rect', //裁切区域形状,'rect' 或 'round'
cropperProps: {}, cropperProps: {}, //recat-easy-crop的props
modalTitle: '编辑图片', modalTitle: '编辑图片', //弹窗标题
modalWidth: '40vw', modalWidth: '40vw', //弹窗宽度
modalOk: '确定', modalOk: '确定', //确定按钮文字
modalCancel: '取消', modalCancel: '取消', //取消按钮的文字
//图片压缩 //图片压缩
strict: true, strict: true, //当压缩后的图片尺寸大于原图尺寸时输出原图
checkOrientation: true, checkOrientation: true, //读取图像的Exif方向值并自动旋转或翻转图像仅限 JPEG 图像)
retainExif: false, retainExif: false, //压缩后保留图片的Exif信息
maxWidth: Infinity, maxWidth: Infinity, //输出图片的最大宽度值需大于0
maxHeight: Infinity, maxHeight: Infinity, //输出图片的最大高度值需大于0
minWidth: 0, minWidth: 0, //输出图片的最小宽度值需大于0且不应大于maxWidth
minHeight: 0, minHeight: 0, //输出图片的最小高度。值需大于0且不应大于maxHeight
compressWidth: undefined, compressWidth: undefined, //输出图像的宽度。如果未指定则将使用原始图像的宽度若设置了height则宽度将根据自然纵横比自动计算。
compressHeight: undefined, compressHeight: undefined, //输出图像的高度。如果未指定则将使用原始图像的高度若设置了width则高度将根据自然纵横比自动计算。
resize: 'none', resize: 'none', //仅在同时指定了width和height时生效
compressQuality: 0.8, compressQuality: 0.8, //输出图像的质量。范围0 ~ 1
mimeType: 'auto', mimeType: 'auto', //输出图片的 MIME 类型。默认情况下,将使用源图片文件的原始 MIME 类型。
convertTypes: ['image/png'], convertTypes: ['image/png'], //文件类型包含在其中且文件大小超过该convertSize值的文件将被转换为 JPEG。
convertSize: Infinity, //文件类型包含在convertTypes中且文件大小超过此值的文件将转换为 JPEGInfinity表示禁用该功能 convertSize: Infinity, //文件类型包含在convertTypes中且文件大小超过此值的文件将转换为 JPEGInfinity表示禁用该功能
}, },
features: ['extraFile'], features: ['extraFile'],

View File

@ -13,6 +13,7 @@ export default OakComponent({
objectId: 1, objectId: 1,
filename: 1, filename: 1,
extra1: 1, extra1: 1,
extra2: 1,
extension: 1, extension: 1,
type: 1, type: 1,
entity: 1, entity: 1,
@ -20,6 +21,9 @@ export default OakComponent({
fileType: 1, fileType: 1,
sort: 1, sort: 1,
isBridge: 1, isBridge: 1,
uploadState: 1,
size: 1,
applicationId: 1,
}, },
features: ['extraFile'], features: ['extraFile'],
filters: [ filters: [
@ -55,9 +59,9 @@ export default OakComponent({
data: { data: {
isModalOpen: false, isModalOpen: false,
isModalOpen1: false, isModalOpen1: false,
renderImgs: [], renderImgs: [], // 读取的原文图片在modal使用
methodsType: '', methodsType: '',
bridgeUrl: '', bridgeUrl: '', // 通过桥接方式获得的url
selectedId: -1, selectedId: -1,
}, },
properties: { properties: {

View File

@ -11,6 +11,6 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
tag2: string; tag2: string;
entity: keyof ED2; entity: keyof ED2;
entityId: string; entityId: string;
style?: string | undefined; style?: string;
}>) => React.ReactElement; }>) => React.ReactElement;
export default _default; export default _default;

View File

@ -11,6 +11,7 @@ export default OakComponent({
objectId: 1, objectId: 1,
filename: 1, filename: 1,
extra1: 1, extra1: 1,
extra2: 1,
extension: 1, extension: 1,
type: 1, type: 1,
entity: 1, entity: 1,
@ -19,6 +20,8 @@ export default OakComponent({
sort: 1, sort: 1,
isBridge: 1, isBridge: 1,
uploadState: 1, uploadState: 1,
size: 1,
applicationId: 1,
}, },
features: ['extraFile'], features: ['extraFile'],
formData({ data, features }) { formData({ data, features }) {
@ -67,10 +70,10 @@ export default OakComponent({
}, },
], ],
properties: { properties: {
mode: 'aspectFit', mode: 'aspectFit', // 图片显示模式
size: 3, size: 3, // 每行可显示的个数 小程序独有
disablePreview: false, disablePreview: false, // 图片是否可预览
disableDownload: false, disableDownload: false, // 下载按钮隐藏
tag1: '', tag1: '',
tag2: '', tag2: '',
entity: '', entity: '',

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { EntityDict } from '../../../oak-app-domain'; import { EntityDict } from '../../../oak-app-domain';
import { FileState } from '../../../features/extraFile'; import { FileState } from '../../../features/extraFile';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
@ -21,7 +20,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
extension: string[]; extension: string[];
selectCount: number; selectCount: number;
sourceType: SourceType[]; sourceType: SourceType[];
mediaType: ('image' | 'video')[]; mediaType: ("image" | "video")[];
mode: ImageMode; mode: ImageMode;
size: number; size: number;
showUploadList: boolean; showUploadList: boolean;
@ -40,8 +39,8 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
entityId: string; entityId: string;
theme: Theme; theme: Theme;
children?: React.ReactNode; children?: React.ReactNode;
style?: import("react").CSSProperties | undefined; style?: React.CSSProperties;
className?: string | undefined; className?: string;
beforeUpload: (file: File) => Promise<string>; beforeUpload: (file: File) => Promise<string>;
}>) => React.ReactElement; }>) => React.ReactElement;
export default _default; export default _default;

View File

@ -13,6 +13,7 @@ export default OakComponent({
objectId: 1, objectId: 1,
filename: 1, filename: 1,
extra1: 1, extra1: 1,
extra2: 1,
extension: 1, extension: 1,
type: 1, type: 1,
entity: 1, entity: 1,
@ -50,19 +51,19 @@ export default OakComponent({
bucket: '', bucket: '',
autoUpload: false, autoUpload: false,
maxNumber: 20, maxNumber: 20,
extension: [], extension: [], //小程序独有 chooseMessageFile
selectCount: 1, selectCount: 1, // 每次打开图片时,可选中的数量 小程序独有
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'], // 小程序独有 chooseMedia
mediaType: ['image'], mediaType: ['image'], // 小程序独有 chooseMedia
mode: 'aspectFit', mode: 'aspectFit', // 图片显示模式
size: 3, size: 3, // 每行可显示的个数 小程序独有
showUploadList: true, showUploadList: true, //web独有
showUploadProgress: false, showUploadProgress: false, // web独有
accept: 'image/*', accept: 'image/*', // web独有
disablePreview: false, disablePreview: false, // 图片是否可预览
disableDelete: false, disableDelete: false, // 图片是否可删除
disableAdd: false, disableAdd: false, // 上传按钮隐藏
disableDownload: false, disableDownload: false, // 下载按钮隐藏
type: 'image', type: 'image',
origin: null, origin: null,
tag1: '', tag1: '',
@ -147,7 +148,7 @@ export default OakComponent({
type, type,
tag1, tag1,
tag2, tag2,
objectId: generateNewId(), objectId: generateNewId(), // 这个域用来标识唯一性
entity, entity,
filename, filename,
size, size,

View File

@ -8,23 +8,23 @@ export interface UploadHandle {
} }
declare const _default: React.ForwardRefExoticComponent<WebComponentProps<EntityDict, "extraFile", true, { declare const _default: React.ForwardRefExoticComponent<WebComponentProps<EntityDict, "extraFile", true, {
files: EnhancedExtraFile[]; files: EnhancedExtraFile[];
accept?: string | undefined; accept?: string;
maxNumber?: number | undefined; maxNumber?: number;
multiple?: boolean | undefined; multiple?: boolean;
draggable?: boolean | undefined; draggable?: boolean;
theme?: Theme | undefined; theme?: Theme;
beforeUpload?: ((file: File) => Promise<boolean> | boolean) | undefined; beforeUpload?: (file: File) => Promise<boolean> | boolean;
style?: React.CSSProperties | undefined; style?: React.CSSProperties;
className?: string | undefined; className?: string;
directory?: boolean | undefined; directory?: boolean;
onPreview?: ((file: UploadFile<any>) => void) | undefined; onPreview?: (file: UploadFile<any>) => void;
onDownload?: ((file: UploadFile<any>) => void) | undefined; onDownload?: (file: UploadFile<any>) => void;
showUploadList?: boolean | undefined; showUploadList?: boolean;
children?: JSX.Element | undefined; children?: JSX.Element;
disableInsert?: boolean | undefined; disableInsert?: boolean;
disableDownload?: boolean | undefined; disableDownload?: boolean;
disableDelete?: boolean | undefined; disableDelete?: boolean;
disablePreview?: boolean | undefined; disablePreview?: boolean;
}, { }, {
onRemove: (file: UploadFile) => void; onRemove: (file: UploadFile) => void;
addFileByWeb: (file: UploadFile) => void; addFileByWeb: (file: UploadFile) => void;

View File

@ -2,6 +2,6 @@ import { Endpoint } from 'oak-domain/lib/types/Endpoint';
import { EntityDict } from '../oak-app-domain'; import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt'; import { BRC } from '../types/RuntimeCxt';
import { WechatPublicEventData } from 'oak-external-sdk/lib/types/Wechat'; import { WechatPublicEventData } from 'oak-external-sdk/lib/types/Wechat';
export declare function registerWeChatPublicEventCallback(appId: string, callback: (data: WechatPublicEventData, context: BRC<EntityDict>) => void): void; export declare function registerWeChatPublicEventCallback(appId: string, callback: (data: WechatPublicEventData, context: BRC<EntityDict>) => Promise<void>): void;
declare const endpoints: Record<string, Endpoint<EntityDict, BRC<EntityDict>>>; declare const endpoints: Record<string, Endpoint<EntityDict, BRC<EntityDict>>>;
export default endpoints; export default endpoints;

View File

@ -484,7 +484,7 @@ async function onWeChatPublicEvent(data, context) {
let evt; let evt;
// 如果有应用注入的事件回调则处理之,不依赖其返回 // 如果有应用注入的事件回调则处理之,不依赖其返回
if (CALLBACK[appId]) { if (CALLBACK[appId]) {
CALLBACK[appId](data, context); await CALLBACK[appId](data, context);
} }
// 接收事件推送 // 接收事件推送
if (MsgType === 'event') { if (MsgType === 'event') {

View File

@ -84,6 +84,9 @@ const triggers = [
objectId: 1, objectId: 1,
bucket: 1, bucket: 1,
extension: 1, extension: 1,
entity: 1,
entityId: 1,
extra2: 1,
applicationId: 1, applicationId: 1,
application: applicationProjection application: applicationProjection
}, },

View File

@ -2,6 +2,6 @@ import { Endpoint } from 'oak-domain/lib/types/Endpoint';
import { EntityDict } from '../oak-app-domain'; import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt'; import { BRC } from '../types/RuntimeCxt';
import { WechatPublicEventData } from 'oak-external-sdk/lib/types/Wechat'; import { WechatPublicEventData } from 'oak-external-sdk/lib/types/Wechat';
export declare function registerWeChatPublicEventCallback(appId: string, callback: (data: WechatPublicEventData, context: BRC<EntityDict>) => void): void; export declare function registerWeChatPublicEventCallback(appId: string, callback: (data: WechatPublicEventData, context: BRC<EntityDict>) => Promise<void>): void;
declare const endpoints: Record<string, Endpoint<EntityDict, BRC<EntityDict>>>; declare const endpoints: Record<string, Endpoint<EntityDict, BRC<EntityDict>>>;
export default endpoints; export default endpoints;

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.registerWeChatPublicEventCallback = void 0; exports.registerWeChatPublicEventCallback = registerWeChatPublicEventCallback;
const tslib_1 = require("tslib"); const tslib_1 = require("tslib");
const assert_1 = require("oak-domain/lib/utils/assert"); const assert_1 = require("oak-domain/lib/utils/assert");
const url_1 = tslib_1.__importDefault(require("url")); const url_1 = tslib_1.__importDefault(require("url"));
@ -30,7 +30,6 @@ function registerWeChatPublicEventCallback(appId, callback) {
(0, assert_1.assert)(!CALLBACK.hasOwnProperty(appId)); (0, assert_1.assert)(!CALLBACK.hasOwnProperty(appId));
CALLBACK[appId] = callback; CALLBACK[appId] = callback;
} }
exports.registerWeChatPublicEventCallback = registerWeChatPublicEventCallback;
/** /**
* 用户取关事件注意要容wechatUser不存在的情况 * 用户取关事件注意要容wechatUser不存在的情况
* @param openId * @param openId
@ -489,7 +488,7 @@ async function onWeChatPublicEvent(data, context) {
let evt; let evt;
// 如果有应用注入的事件回调则处理之,不依赖其返回 // 如果有应用注入的事件回调则处理之,不依赖其返回
if (CALLBACK[appId]) { if (CALLBACK[appId]) {
CALLBACK[appId](data, context); await CALLBACK[appId](data, context);
} }
// 接收事件推送 // 接收事件推送
if (MsgType === 'event') { if (MsgType === 'event') {

View File

@ -87,6 +87,9 @@ const triggers = [
objectId: 1, objectId: 1,
bucket: 1, bucket: 1,
extension: 1, extension: 1,
entity: 1,
entityId: 1,
extra2: 1,
applicationId: 1, applicationId: 1,
application: Projection_1.applicationProjection application: Projection_1.applicationProjection
}, },

View File

@ -40,12 +40,12 @@ function assertFromWeChat(query: VerifyQuery, config: WechatPublicConfig | Wecha
const CALLBACK: Record< const CALLBACK: Record<
string, string,
(data: WechatPublicEventData, context: BRC<EntityDict>) => void (data: WechatPublicEventData, context: BRC<EntityDict>) => Promise<void>
> = {}; > = {};
export function registerWeChatPublicEventCallback( export function registerWeChatPublicEventCallback(
appId: string, appId: string,
callback: (data: WechatPublicEventData, context: BRC<EntityDict>) => void callback: (data: WechatPublicEventData, context: BRC<EntityDict>) => Promise<void>
) { ) {
assert(!CALLBACK.hasOwnProperty(appId)); assert(!CALLBACK.hasOwnProperty(appId));
@ -631,7 +631,7 @@ async function onWeChatPublicEvent(data: WechatPublicEventData, context: BRC<Ent
// 如果有应用注入的事件回调则处理之,不依赖其返回 // 如果有应用注入的事件回调则处理之,不依赖其返回
if (CALLBACK[appId]) { if (CALLBACK[appId]) {
CALLBACK[appId](data, context); await CALLBACK[appId](data, context);
} }