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;
export default _default;

View File

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

View File

@ -1,10 +1,9 @@
/// <reference types="react" />
import { GenerateUrlFn } from "../../../types/Article";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "article", true, {
entityId: string;
articleMenuId: string | undefined;
generateUrl: GenerateUrlFn;
empty: import("react").ReactNode;
empty: React.ReactNode | undefined;
menuCheck: (isArticle: boolean) => void;
}>) => React.ReactElement;
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, {
articleMenuId: string | undefined;
onChildEditArticleChange: (data: string) => void;
show: "preview" | "edit" | "doc";
show: "edit" | "doc" | "preview";
getBreadcrumbItemsByParent: (breadcrumbItems: string[]) => void;
breadcrumbItems: string[];
drawerOpen: boolean;

View File

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

View File

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

View File

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

View File

@ -1,4 +1,3 @@
/// <reference types="react" />
import { EntityDict } from '../../../oak-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
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;
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
entity: keyof ED2;
action?: string | undefined;
size?: ButtonProps['size'] | AmButtonProps['size'];
block?: boolean | undefined;
type?: ButtonProps['type'] | AmButtonProps['type'];
executeText?: string | undefined;
buttonProps?: (ButtonProps & {
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;
action?: string;
size?: ButtonProps["size"] | AmButtonProps["size"];
block?: boolean;
type?: ButtonProps["type"] | AmButtonProps["type"];
executeText?: string;
buttonProps?: ButtonProps & AmButtonProps;
afterCommit?: AfterCommit;
beforeCommit?: BeforeCommit;
messageProps?: boolean | MessageProps | undefined;
messageProps?: MessageProps | boolean;
}>) => React.ReactElement;
export default _default;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,6 @@ import { Endpoint } from 'oak-domain/lib/types/Endpoint';
import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
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>>>;
export default endpoints;

View File

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

View File

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

View File

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