diff --git a/es/aspects/AspectDict.d.ts b/es/aspects/AspectDict.d.ts index 619960621..61eb14ba7 100644 --- a/es/aspects/AspectDict.d.ts +++ b/es/aspects/AspectDict.d.ts @@ -292,11 +292,13 @@ export type AspectDict = { * 创建微信登录会话(用于扫码登录场景) * @param type 登录类型(login-登录,bind-绑定) * @param interval 会话有效期(毫秒) + * @param router 扫码目标路由 * @returns 返回登录会话 ID */ createWechatLogin: (params: { type: EntityDict['wechatLogin']['Schema']['type']; interval: number; + router: EntityDict['wechatLogin']['Schema']['router']; }, context: BackendRuntimeContext) => Promise; /** * 解绑微信用户 diff --git a/es/aspects/template.d.ts b/es/aspects/template.d.ts index ddac06395..d3bbe7f7f 100644 --- a/es/aspects/template.d.ts +++ b/es/aspects/template.d.ts @@ -19,6 +19,6 @@ export declare function syncWechatTemplate(params: { example: string; keywordEnumValueList: { keywordCode: string; - enumValueList: Array; + enumValueList: string[]; }[]; }[]>; diff --git a/es/aspects/token.js b/es/aspects/token.js index e97e051d1..95625e9a1 100644 --- a/es/aspects/token.js +++ b/es/aspects/token.js @@ -1652,7 +1652,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { wechatMp: 'mp', native: 'native', }; - const createWechatUserAndReturnTokenId = async (user, wechatLoginId) => { + const createWechatUserAndReturnTokenId = async (user) => { const wechatUserCreateData = { id: await generateNewIdAsync(), unionId, @@ -1661,13 +1661,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { applicationId: application.id, ...wechatUserData, }; - let tokenValue; - if (wechatLoginId) { - tokenValue = await setUpTokenAndUser(env, context, 'wechatLogin', wechatLoginId, undefined, user); - } - else { - tokenValue = await setUpTokenAndUser(env, context, 'wechatUser', undefined, wechatUserCreateData, user); - } + const tokenValue = await setUpTokenAndUser(env, context, 'wechatUser', undefined, wechatUserCreateData, user); return { tokenValue, wechatUserId: wechatUserCreateData.id }; }; // 扫码者 @@ -1770,12 +1764,12 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { }, }, { dontCollect: true }); const tokenValue = await setUpTokenAndUser(env, context, 'wechatUser', wechatUser.id, undefined, wechatLoginData.user); - await updateWechatLogin({ successed: true }); + await updateWechatLogin({ successed: true, wechatUserId: wechatUser.id }); return tokenValue; } else { - const { tokenValue } = await createWechatUserAndReturnTokenId(wechatLoginData.user); - await updateWechatLogin({ successed: true }); + const { tokenValue, wechatUserId } = await createWechatUserAndReturnTokenId(wechatLoginData.user); + await updateWechatLogin({ successed: true, wechatUserId }); return tokenValue; } } @@ -1829,6 +1823,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { await updateWechatLogin({ userId: wechatUser.userId, successed: true, + wechatUserId: wechatUser.id, }); return tokenValue; } @@ -1844,7 +1839,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { action: 'create', data: userData, }, {}); - const { tokenValue, wechatUserId } = await createWechatUserAndReturnTokenId(userData, wechatLoginId); + const { tokenValue, wechatUserId } = await createWechatUserAndReturnTokenId(userData); await updateWechatLogin({ userId, wechatUserId, successed: true }); return tokenValue; } @@ -1947,7 +1942,8 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { } } // 到这里都是要同时创建wechatUser和user对象了 - return (await createWechatUserAndReturnTokenId()).tokenValue; + const { tokenValue } = await createWechatUserAndReturnTokenId(); + return tokenValue; } /** * 微信App授权登录 @@ -1976,19 +1972,6 @@ export async function loginWechat({ code, env, wechatLoginId, }, context) { if (tokenInfo.entity === 'wechatUser') { await tryRefreshWechatPublicUserInfo(tokenInfo.entityId, context); } - else if (tokenInfo.entity === 'wechatLogin') { - const [wechatLogin] = await context.select('wechatLogin', { - data: { - id: 1, - wechatUserId: 1, - }, - filter: { - id: tokenInfo.entityId, - }, - }, {}); - assert(wechatLogin?.wechatUserId); - await tryRefreshWechatPublicUserInfo(wechatLogin.wechatUserId, context); - } closeRootMode(); return tokenValue; } @@ -2579,8 +2562,8 @@ export async function refreshToken(params, context) { // 只有server模式去刷新token // 'development' | 'production' | 'staging' const intervals = { - development: 7200 * 1000, // 2小时 - staging: 600 * 1000, // 十分钟 + development: 7200 * 1000, + staging: 600 * 1000, production: 600 * 1000, // 十分钟 }; let applicationId = token.applicationId; diff --git a/es/aspects/wechatLogin.d.ts b/es/aspects/wechatLogin.d.ts index 9c13e80d8..c6bd46f98 100644 --- a/es/aspects/wechatLogin.d.ts +++ b/es/aspects/wechatLogin.d.ts @@ -3,4 +3,5 @@ import { BRC } from '../types/RuntimeCxt'; export declare function createWechatLogin(params: { type: EntityDict['wechatLogin']['Schema']['type']; interval: number; + router: EntityDict['wechatLogin']['Schema']['router']; }, context: BRC): Promise; diff --git a/es/aspects/wechatLogin.js b/es/aspects/wechatLogin.js index 27f993f0c..f953a0277 100644 --- a/es/aspects/wechatLogin.js +++ b/es/aspects/wechatLogin.js @@ -1,11 +1,26 @@ import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; export async function createWechatLogin(params, context) { - const { type, interval } = params; + const { type, interval, router } = params; let userId; if (type === 'bind') { userId = context.getCurrentUserId(); } const id = await generateNewIdAsync(); + let _router = router; + // router为空则默认为/wechatLogin/confirm + if (!router) { + _router = { + pathname: '/wechatLogin/confirm', + props: { + oakId: id, + }, + }; + } + else { + _router.props = { + oakId: id, + }; + } const createData = { id, type, @@ -13,11 +28,10 @@ export async function createWechatLogin(params, context) { expired: false, qrCodeType: 'wechatPublic', successed: false, + router: _router, }; if (userId) { - Object.assign(createData, { - userId, - }); + createData.userId = userId; } if (type === 'login') { const closeRoot = context.openRootMode(); diff --git a/es/components/address/list/index.d.ts b/es/components/address/list/index.d.ts index ff8c6a49c..eb7c9c471 100644 --- a/es/components/address/list/index.d.ts +++ b/es/components/address/list/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/address/upsert/index.d.ts b/es/components/address/upsert/index.d.ts index 04a2aeb0b..543b66d91 100644 --- a/es/components/address/upsert/index.d.ts +++ b/es/components/address/upsert/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/amap/location/PositionPicker.d.ts b/es/components/amap/location/PositionPicker.d.ts index 079e9fc08..95455897b 100644 --- a/es/components/amap/location/PositionPicker.d.ts +++ b/es/components/amap/location/PositionPicker.d.ts @@ -1,3 +1,4 @@ +/// import React from 'react'; export type PositionProps = { loadUI: boolean; diff --git a/es/components/amap/location/index.d.ts b/es/components/amap/location/index.d.ts index 5c543de6b..67f2a992f 100644 --- a/es/components/amap/location/index.d.ts +++ b/es/components/amap/location/index.d.ts @@ -1,3 +1,4 @@ +/// import React from 'react'; import { ModalProps } from 'antd'; import { GeolocationProps } from '@uiw/react-amap'; diff --git a/es/components/amap/map/index.d.ts b/es/components/amap/map/index.d.ts index ed3e63766..288bdd24a 100644 --- a/es/components/amap/map/index.d.ts +++ b/es/components/amap/map/index.d.ts @@ -1,3 +1,4 @@ +/// import React from 'react'; import { MapProps, APILoaderConfig } from '@uiw/react-amap'; import './index.less'; diff --git a/es/components/application/cos/web.pc.d.ts b/es/components/application/cos/web.pc.d.ts index 4dfb1dbf1..d5290a98f 100644 --- a/es/components/application/cos/web.pc.d.ts +++ b/es/components/application/cos/web.pc.d.ts @@ -2,7 +2,7 @@ import React from 'react'; import { WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../../oak-app-domain'; declare const Cos: (props: WebComponentProps declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/application/detailForPlatform/index.d.ts b/es/components/application/detailForPlatform/index.d.ts index 6b6e8e37f..f1528b757 100644 --- a/es/components/application/detailForPlatform/index.d.ts +++ b/es/components/application/detailForPlatform/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/application/upsert/index.d.ts b/es/components/application/upsert/index.d.ts index 2ca3cf7d3..f0ad771b5 100644 --- a/es/components/application/upsert/index.d.ts +++ b/es/components/application/upsert/index.d.ts @@ -1,3 +1,4 @@ +/// import { EntityDict } from '../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/article/cell/index.d.ts b/es/components/article/cell/index.d.ts index cbb0af164..7e54e8a64 100644 --- a/es/components/article/cell/index.d.ts +++ b/es/components/article/cell/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/article/editor/index.d.ts b/es/components/article/editor/index.d.ts index 3f111fef0..f9bf5091f 100644 --- a/es/components/article/editor/index.d.ts +++ b/es/components/article/editor/index.d.ts @@ -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: null | EntityDict["extraFile"]["Schema"]["origin"]; + origin: import("../../../types/Config").CosOrigin | null; scrollId: string; height: number | "auto"; activeColor: string | undefined; diff --git a/es/components/article/list/index.d.ts b/es/components/article/list/index.d.ts index c63d888b1..8550d91d3 100644 --- a/es/components/article/list/index.d.ts +++ b/es/components/article/list/index.d.ts @@ -1,9 +1,10 @@ +/// import { GenerateUrlFn } from "../../../types/Article"; declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; }>) => React.ReactElement; export default _default; diff --git a/es/components/article/treeList/index.d.ts b/es/components/article/treeList/index.d.ts index 531bb39b4..6f4290f52 100644 --- a/es/components/article/treeList/index.d.ts +++ b/es/components/article/treeList/index.d.ts @@ -1,7 +1,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; - show: "edit" | "doc" | "preview"; + show: "preview" | "doc" | "edit"; getBreadcrumbItemsByParent: (breadcrumbItems: string[]) => void; breadcrumbItems: string[]; drawerOpen: boolean; diff --git a/es/components/article/upsert/index.d.ts b/es/components/article/upsert/index.d.ts index 72e4a84c3..f9bf5091f 100644 --- a/es/components/article/upsert/index.d.ts +++ b/es/components/article/upsert/index.d.ts @@ -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: EntityDict["extraFile"]["Schema"]["origin"] | null; + origin: import("../../../types/Config").CosOrigin | null; scrollId: string; height: number | "auto"; activeColor: string | undefined; diff --git a/es/components/articleMenu/container/index.d.ts b/es/components/articleMenu/container/index.d.ts index eda38eb91..4045e76de 100644 --- a/es/components/articleMenu/container/index.d.ts +++ b/es/components/articleMenu/container/index.d.ts @@ -1,12 +1,13 @@ +/// import { EntityDict } from "../../../oak-app-domain"; import { GenerateUrlFn } from "../../../types/Article"; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/articleMenu/list/index.d.ts b/es/components/articleMenu/list/index.d.ts index 7ba5ef00b..a1f227ab2 100644 --- a/es/components/articleMenu/list/index.d.ts +++ b/es/components/articleMenu/list/index.d.ts @@ -1,13 +1,14 @@ +/// import { GenerateUrlFn } from "../../../types/Article"; import { EntityDict } from "../../../oak-app-domain"; declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; onArticleClick: (atricleId: string) => void; - empty: React.ReactNode | undefined; + empty: import("react").ReactNode; changeAddArticle: (show: boolean) => void; generateUrl: GenerateUrlFn; }>) => React.ReactElement; diff --git a/es/components/articleMenu/treeCell/index.d.ts b/es/components/articleMenu/treeCell/index.d.ts index 62f135048..cf2f68008 100644 --- a/es/components/articleMenu/treeCell/index.d.ts +++ b/es/components/articleMenu/treeCell/index.d.ts @@ -3,7 +3,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< onRemove: () => void; onUpdateName: (name: string) => Promise; onChildEditArticleChange: (data: string) => void; - show: "edit" | "doc" | "preview"; + show: "preview" | "doc" | "edit"; getBreadcrumbItemsByParent: (breadcrumbItems: string[]) => void; breadItems: string[]; drawerOpen: boolean; @@ -25,6 +25,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< setCurrentArticle: (id: string) => void; onMenuViewById: (articleMenuId: string) => void; setCopyArticleUrl: (id: string) => string; - origin: null | EntityDict["extraFile"]["Schema"]["origin"]; + origin: import("../../../types/Config").CosOrigin | null; }>) => React.ReactElement; export default _default; diff --git a/es/components/articleMenu/treeList/index.d.ts b/es/components/articleMenu/treeList/index.d.ts index 9cb126f75..c2bb66915 100644 --- a/es/components/articleMenu/treeList/index.d.ts +++ b/es/components/articleMenu/treeList/index.d.ts @@ -4,7 +4,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< entityId: string; parentId: string | undefined; onGrandChildEditArticleChange: (data: string) => void; - show: "edit" | "doc" | "preview"; + show: "preview" | "doc" | "edit"; articleMenuId: string; articleId: string; getBreadcrumbItems: (breadcrumbItems: string[]) => void; @@ -31,6 +31,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< setCurrentArticle: (id: string) => void; onMenuViewById: (articleMenuId: string) => void; setCopyArticleUrl: (id: string) => string; - origin: null | EntityDict["extraFile"]["Schema"]["origin"]; + origin: import("../../../types/Config").CosOrigin | null; }>) => React.ReactElement; export default _default; diff --git a/es/components/articleMenu/treeManager/index.d.ts b/es/components/articleMenu/treeManager/index.d.ts index 087c217ff..5cfce96f5 100644 --- a/es/components/articleMenu/treeManager/index.d.ts +++ b/es/components/articleMenu/treeManager/index.d.ts @@ -2,7 +2,7 @@ import { EntityDict } from "../../../oak-app-domain/EntityDict"; declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; onArticleEdit: (articleId: string) => void; setCopyArticleUrl: (articleId: string) => string; - origin: EntityDict["extraFile"]["Schema"]["origin"] | null; + origin: import("../../../types/Config").CosOrigin | null; scrollId: string; activeColor: string | undefined; }>) => React.ReactElement; diff --git a/es/components/changePassword/byMobile/index.d.ts b/es/components/changePassword/byMobile/index.d.ts index 9b24ef2db..9e6eb4aca 100644 --- a/es/components/changePassword/byMobile/index.d.ts +++ b/es/components/changePassword/byMobile/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/changePassword/byPassword/index.d.ts b/es/components/changePassword/byPassword/index.d.ts index 9b24ef2db..9e6eb4aca 100644 --- a/es/components/changePassword/byPassword/index.d.ts +++ b/es/components/changePassword/byPassword/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/common/download/index.d.ts b/es/components/common/download/index.d.ts index 35b6ec953..13d24ef6c 100644 --- a/es/components/common/download/index.d.ts +++ b/es/components/common/download/index.d.ts @@ -1,3 +1,4 @@ +/// import * as React from 'react'; type IDownloadProps = { children?: React.ReactNode; @@ -8,9 +9,9 @@ type IDownloadProps = { }; declare function Download(props: IDownloadProps): React.JSX.Element; declare namespace Download { - var onDownload: (data: ArrayBuffer | ReadableStream, filename: string) => Promise; + var onDownload: (data: ArrayBuffer | ReadableStream, filename: string) => Promise; var base64ToBlob: (base64String: string) => Blob; var arrayBufferToBase64: (buffer: Buffer) => string; - var base64ToArrayBuffer: (base64String: string) => ArrayBuffer; + var base64ToArrayBuffer: (base64String: string) => ArrayBufferLike; } export default Download; diff --git a/es/components/common/errorPage/index.d.ts b/es/components/common/errorPage/index.d.ts index 4f66d7816..19593d8e7 100644 --- a/es/components/common/errorPage/index.d.ts +++ b/es/components/common/errorPage/index.d.ts @@ -4,8 +4,8 @@ import { ReactComponentProps } from 'oak-frontend-base'; import { ECode } from '../../../types/ErrorPage'; declare const _default: (props: ReactComponentProps) => React.ReactElement; diff --git a/es/components/common/qrCode/index.d.ts b/es/components/common/qrCode/index.d.ts index b6dc556f5..772ca4b3a 100644 --- a/es/components/common/qrCode/index.d.ts +++ b/es/components/common/qrCode/index.d.ts @@ -2,21 +2,21 @@ import { EntityDict } from '../../../oak-app-domain'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; import { ReactComponentProps } from 'oak-frontend-base'; declare const _default: (props: ReactComponentProps void; - onRefresh?: () => void; - size?: number; + onDownload?: ((qrCodeImage: string, filename?: string) => void) | undefined; + onRefresh?: (() => void) | undefined; + size?: number | undefined; url: string; - loading?: boolean; - disableDownload?: boolean; + loading?: boolean | undefined; + disableDownload?: boolean | undefined; disabled: boolean; color: string; bgColor: string; maskColor: string; maskTextColor: string; maskText: string; - mode: "simple" | "default"; + mode: 'simple' | 'default'; }>) => React.ReactElement; export default _default; diff --git a/es/components/common/tabBar/index.d.ts b/es/components/common/tabBar/index.d.ts index 11ce7e31d..97fd2535a 100644 --- a/es/components/common/tabBar/index.d.ts +++ b/es/components/common/tabBar/index.d.ts @@ -6,11 +6,11 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< redDot: boolean; text: string; pagePath: string; - iconName?: string; - selectedIconName?: string; - iconPath?: string; - selectedIconPath?: string; - iconSize?: string; + iconName?: string | undefined; + selectedIconName?: string | undefined; + iconPath?: string | undefined; + selectedIconPath?: string | undefined; + iconSize?: string | undefined; }[]; color: string; selectedColor: string; diff --git a/es/components/config/style/platform/index.d.ts b/es/components/config/style/platform/index.d.ts index 9224d2cdc..2f2afe1c1 100644 --- a/es/components/config/style/platform/index.d.ts +++ b/es/components/config/style/platform/index.d.ts @@ -1,7 +1,7 @@ import { Style } from '../../../../types/Style'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; diff --git a/es/components/config/upsert/index.d.ts b/es/components/config/upsert/index.d.ts index a4b61c5c2..9bf014f88 100644 --- a/es/components/config/upsert/index.d.ts +++ b/es/components/config/upsert/index.d.ts @@ -1,7 +1,7 @@ import { Config } from '../../../types/Config'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; diff --git a/es/components/domain/detail/index.d.ts b/es/components/domain/detail/index.d.ts index cfd5bb519..a7112bd2e 100644 --- a/es/components/domain/detail/index.d.ts +++ b/es/components/domain/detail/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/domain/upsert/index.d.ts b/es/components/domain/upsert/index.d.ts index cfd5bb519..a7112bd2e 100644 --- a/es/components/domain/upsert/index.d.ts +++ b/es/components/domain/upsert/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/editor/index.d.ts b/es/components/editor/index.d.ts index 2738bc808..b00654764 100644 --- a/es/components/editor/index.d.ts +++ b/es/components/editor/index.d.ts @@ -12,6 +12,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< entityId: string; tag1: string; tag2: string; - origin: EntityDict["extraFile"]["Schema"]["origin"] | null; + origin: import("../../types/Config").CosOrigin | null; }>) => React.ReactElement; export default _default; diff --git a/es/components/extraFile/avatar/index.d.ts b/es/components/extraFile/avatar/index.d.ts index 81779da02..e84a8ae1b 100644 --- a/es/components/extraFile/avatar/index.d.ts +++ b/es/components/extraFile/avatar/index.d.ts @@ -4,6 +4,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< entity: keyof EntityDict; entityId: string; autoUpload: boolean; - origin: EntityDict["extraFile"]["Schema"]["origin"] | null; + origin: import("../../../types/Config").CosOrigin | null; }>) => React.ReactElement; export default _default; diff --git a/es/components/extraFile/commit/index.d.ts b/es/components/extraFile/commit/index.d.ts index 9fc209ec1..12db2bd2c 100644 --- a/es/components/extraFile/commit/index.d.ts +++ b/es/components/extraFile/commit/index.d.ts @@ -1,3 +1,4 @@ +/// 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'; @@ -8,14 +9,31 @@ type AfterCommit = (() => void) | undefined; type BeforeCommit = (() => boolean | undefined | Promise) | undefined; declare const _default: (props: ReactComponentProps) => unknown) | undefined; + type?: "reset" | "submit" | "button" | undefined; + shape?: "default" | "rounded" | "rectangular" | undefined; + children?: import("react").ReactNode; + } & Pick & import("react").ButtonHTMLAttributes, "id" | "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & { + className?: string | undefined; + style?: (import("react").CSSProperties & Partial>) | undefined; + tabIndex?: number | undefined; + } & import("react").AriaAttributes) | undefined; afterCommit?: AfterCommit; beforeCommit?: BeforeCommit; - messageProps?: MessageProps | boolean; + messageProps?: boolean | MessageProps | undefined; }>) => React.ReactElement; export default _default; diff --git a/es/components/extraFile/crop/index.d.ts b/es/components/extraFile/crop/index.d.ts index 31c97a1e0..76b906ef0 100644 --- a/es/components/extraFile/crop/index.d.ts +++ b/es/components/extraFile/crop/index.d.ts @@ -20,7 +20,7 @@ declare const _default: ) => React.ReactElement; export default _default; diff --git a/es/components/extraFile/upload/index.d.ts b/es/components/extraFile/upload/index.d.ts index cbfc7b559..28f0f6cf4 100644 --- a/es/components/extraFile/upload/index.d.ts +++ b/es/components/extraFile/upload/index.d.ts @@ -1,3 +1,4 @@ +/// import { EntityDict } from '../../../oak-app-domain'; import { FileState } from '../../../features/extraFile'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; @@ -20,7 +21,7 @@ declare const _default: Promise; }>) => React.ReactElement; export default _default; diff --git a/es/components/extraFile/upload/web.d.ts b/es/components/extraFile/upload/web.d.ts index 557f90d9b..6fbe667ff 100644 --- a/es/components/extraFile/upload/web.d.ts +++ b/es/components/extraFile/upload/web.d.ts @@ -8,23 +8,23 @@ export interface UploadHandle { } declare const _default: React.ForwardRefExoticComponent Promise | boolean; - style?: React.CSSProperties; - className?: string; - directory?: boolean; - onPreview?: (file: UploadFile) => void; - onDownload?: (file: UploadFile) => void; - showUploadList?: boolean; - children?: JSX.Element; - disableInsert?: boolean; - disableDownload?: boolean; - disableDelete?: boolean; - disablePreview?: boolean; + accept?: string | undefined; + maxNumber?: number | undefined; + multiple?: boolean | undefined; + draggable?: boolean | undefined; + theme?: Theme | undefined; + beforeUpload?: ((file: File) => Promise | boolean) | undefined; + style?: React.CSSProperties | undefined; + className?: string | undefined; + directory?: boolean | undefined; + onPreview?: ((file: UploadFile) => void) | undefined; + onDownload?: ((file: UploadFile) => void) | undefined; + showUploadList?: boolean | undefined; + children?: JSX.Element | undefined; + disableInsert?: boolean | undefined; + disableDownload?: boolean | undefined; + disableDelete?: boolean | undefined; + disablePreview?: boolean | undefined; }, { onRemove: (file: UploadFile) => void; addFileByWeb: (file: UploadFile) => void; diff --git a/es/components/login/oauth/authorize/web.pc.d.ts b/es/components/login/oauth/authorize/web.pc.d.ts index 54bc0cc57..368ac8fe5 100644 --- a/es/components/login/oauth/authorize/web.pc.d.ts +++ b/es/components/login/oauth/authorize/web.pc.d.ts @@ -5,13 +5,13 @@ declare const Authorize: (props: WebComponentProps declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/message/detail/index.d.ts b/es/components/message/detail/index.d.ts index 8e5aeae49..b6a428c8d 100644 --- a/es/components/message/detail/index.d.ts +++ b/es/components/message/detail/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/message/list/index.d.ts b/es/components/message/list/index.d.ts index 59c862ae1..7d50f35ad 100644 --- a/es/components/message/list/index.d.ts +++ b/es/components/message/list/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/messageTypeSmsTemplate/list/index.d.ts b/es/components/messageTypeSmsTemplate/list/index.d.ts index 344a6070e..cd5b93954 100644 --- a/es/components/messageTypeSmsTemplate/list/index.d.ts +++ b/es/components/messageTypeSmsTemplate/list/index.d.ts @@ -1,6 +1,6 @@ import { EntityDict } from '../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/mobile/login/index.d.ts b/es/components/mobile/login/index.d.ts index bc8043074..c5b493c7e 100644 --- a/es/components/mobile/login/index.d.ts +++ b/es/components/mobile/login/index.d.ts @@ -2,6 +2,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< onlyCaptcha: boolean; onlyPassword: boolean; eventLoggedIn: string; - callback: ((() => void) | undefined); + callback: (() => void) | undefined; }>) => React.ReactElement; export default _default; diff --git a/es/components/mobile/manageList/index.d.ts b/es/components/mobile/manageList/index.d.ts index 9f53f5a71..1423e77bb 100644 --- a/es/components/mobile/manageList/index.d.ts +++ b/es/components/mobile/manageList/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/my/avatar/index.d.ts b/es/components/my/avatar/index.d.ts index 6b4976c3a..cecab0c89 100644 --- a/es/components/my/avatar/index.d.ts +++ b/es/components/my/avatar/index.d.ts @@ -1,6 +1,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; diff --git a/es/components/my/message/index.d.ts b/es/components/my/message/index.d.ts index fc416ef2a..4007eded7 100644 --- a/es/components/my/message/index.d.ts +++ b/es/components/my/message/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/oauth/management/oauthApps/upsert/index.js b/es/components/oauth/management/oauthApps/upsert/index.js index 2a12b74d4..67ef3a967 100644 --- a/es/components/oauth/management/oauthApps/upsert/index.js +++ b/es/components/oauth/management/oauthApps/upsert/index.js @@ -6,9 +6,9 @@ export default OakComponent({ name: 1, description: 1, redirectUris: 1, - logo: 1, // string + logo: 1, isConfidential: 1, - scopes: 1, // string[] + scopes: 1, ableState: 1, requirePKCE: 1, }, diff --git a/es/components/oauth/management/oauthApps/upsert/web.pc.d.ts b/es/components/oauth/management/oauthApps/upsert/web.pc.d.ts index a654c41ab..81947c0e3 100644 --- a/es/components/oauth/management/oauthApps/upsert/web.pc.d.ts +++ b/es/components/oauth/management/oauthApps/upsert/web.pc.d.ts @@ -2,7 +2,7 @@ import React from 'react'; import { RowWithActions, WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../../../../oak-app-domain'; declare const Upsert: (props: WebComponentProps; + item: RowWithActions; clientSecret: string; isCreation: boolean; open: boolean; diff --git a/es/components/oauth/management/oauthApps/web.pc.d.ts b/es/components/oauth/management/oauthApps/web.pc.d.ts index 476053768..734c71852 100644 --- a/es/components/oauth/management/oauthApps/web.pc.d.ts +++ b/es/components/oauth/management/oauthApps/web.pc.d.ts @@ -1,8 +1,8 @@ import React from 'react'; import { RowWithActions, WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../../../oak-app-domain'; -declare const OauthProvider: (props: WebComponentProps[]; +declare const OauthProvider: (props: WebComponentProps[]; systemId: string; }>) => React.JSX.Element; export default OauthProvider; diff --git a/es/components/oauth/management/oauthProvider/upsert/web.pc.d.ts b/es/components/oauth/management/oauthProvider/upsert/web.pc.d.ts index 655c0f251..3745bce8a 100644 --- a/es/components/oauth/management/oauthProvider/upsert/web.pc.d.ts +++ b/es/components/oauth/management/oauthProvider/upsert/web.pc.d.ts @@ -2,7 +2,7 @@ import React from 'react'; import { RowWithActions, WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../../../../oak-app-domain'; declare const Upsert: (props: WebComponentProps; + item: RowWithActions; open: boolean; onCancel: () => void; onOk: () => void; diff --git a/es/components/oauth/management/oauthProvider/web.pc.d.ts b/es/components/oauth/management/oauthProvider/web.pc.d.ts index d95afb547..72c18d5ae 100644 --- a/es/components/oauth/management/oauthProvider/web.pc.d.ts +++ b/es/components/oauth/management/oauthProvider/web.pc.d.ts @@ -1,8 +1,8 @@ import React from 'react'; import { RowWithActions, WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../../../oak-app-domain'; -declare const OauthProvider: (props: WebComponentProps[]; +declare const OauthProvider: (props: WebComponentProps[]; systemId: string; }>) => React.JSX.Element; export default OauthProvider; diff --git a/es/components/oauth/records/web.pc.d.ts b/es/components/oauth/records/web.pc.d.ts index 2e1766f5c..50fc56a14 100644 --- a/es/components/oauth/records/web.pc.d.ts +++ b/es/components/oauth/records/web.pc.d.ts @@ -2,8 +2,8 @@ import React from 'react'; import { RowWithActions, WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../../oak-app-domain'; declare const Records: (props: WebComponentProps[]; + list: RowWithActions[]; }, { - revoke: (item: RowWithActions) => void; + revoke: (item: RowWithActions) => void; }>) => React.JSX.Element; export default Records; diff --git a/es/components/parasite/excess/index.d.ts b/es/components/parasite/excess/index.d.ts index 4b5cde729..aeab4e2c1 100644 --- a/es/components/parasite/excess/index.d.ts +++ b/es/components/parasite/excess/index.d.ts @@ -1,3 +1,4 @@ +/// import { EntityDict } from '../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/parasite/upsert/index.d.ts b/es/components/parasite/upsert/index.d.ts index 3bbe5ff2a..cb8a698e0 100644 --- a/es/components/parasite/upsert/index.d.ts +++ b/es/components/parasite/upsert/index.d.ts @@ -5,7 +5,7 @@ declare const _default: declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/platform/upsert/index.d.ts b/es/components/platform/upsert/index.d.ts index 92179f82c..2f4ee4714 100644 --- a/es/components/platform/upsert/index.d.ts +++ b/es/components/platform/upsert/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/session/forMessage/index.d.ts b/es/components/session/forMessage/index.d.ts index 162fded2e..3040df8a6 100644 --- a/es/components/session/forMessage/index.d.ts +++ b/es/components/session/forMessage/index.d.ts @@ -1,7 +1,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps Array; + entityDisplay: (data: any) => any[]; entityProjection: any; }>) => React.ReactElement; export default _default; diff --git a/es/components/session/header/index.d.ts b/es/components/session/header/index.d.ts index fc416ef2a..4007eded7 100644 --- a/es/components/session/header/index.d.ts +++ b/es/components/session/header/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/session/list/index.d.ts b/es/components/session/list/index.d.ts index 419f5cf42..bf432d40c 100644 --- a/es/components/session/list/index.d.ts +++ b/es/components/session/list/index.d.ts @@ -4,10 +4,10 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< entity: string; entityFilter: any; entityFilterSubStr: string; - entityDisplay: (data: EntityDict["session"]["Schema"][] | RowWithActions[]) => Array; + entityDisplay: (data: EntityDict['session']['Schema'][] | RowWithActions[]) => any[]; entityProjection: any; sessionId: string; dialog: boolean; - onItemClick: ((sessionId: string) => {}) | undefined | null; + onItemClick: ((sessionId: string) => {}) | null | undefined; }>) => React.ReactElement; export default _default; diff --git a/es/components/sessionMessage/list/index.d.ts b/es/components/sessionMessage/list/index.d.ts index 41e8e86d4..ab50d269f 100644 --- a/es/components/sessionMessage/list/index.d.ts +++ b/es/components/sessionMessage/list/index.d.ts @@ -6,7 +6,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< dialog: boolean; entity: string; entityId: string; - entityDisplay: (data: EntityDict["session"]["Schema"][] | RowWithActions[]) => Array; + entityDisplay: (data: EntityDict['session']['Schema'][] | RowWithActions[]) => any[]; entityProjection: any; }>) => React.ReactElement; export default _default; diff --git a/es/components/subscription/config/upsert/index.d.ts b/es/components/subscription/config/upsert/index.d.ts index ae1dbd523..e5f2d178d 100644 --- a/es/components/subscription/config/upsert/index.d.ts +++ b/es/components/subscription/config/upsert/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/subscription/detail/index.d.ts b/es/components/subscription/detail/index.d.ts index 5a7970c9c..66d28049e 100644 --- a/es/components/subscription/detail/index.d.ts +++ b/es/components/subscription/detail/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/subwayLine/picker/index.d.ts b/es/components/subwayLine/picker/index.d.ts index 7907e4ed6..12eb7190d 100644 --- a/es/components/subwayLine/picker/index.d.ts +++ b/es/components/subwayLine/picker/index.d.ts @@ -1,5 +1,5 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps void) | undefined; onConfirm: ((stationIds: string[]) => void) | undefined; selectIds: string[] | undefined; diff --git a/es/components/system/detail/index.d.ts b/es/components/system/detail/index.d.ts index aaf164c34..8bf853bbb 100644 --- a/es/components/system/detail/index.d.ts +++ b/es/components/system/detail/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/system/upsert/index.d.ts b/es/components/system/upsert/index.d.ts index aaf164c34..8bf853bbb 100644 --- a/es/components/system/upsert/index.d.ts +++ b/es/components/system/upsert/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/token/me/emptyBody/index.d.ts b/es/components/token/me/emptyBody/index.d.ts index ce03a624e..094ac520b 100644 --- a/es/components/token/me/emptyBody/index.d.ts +++ b/es/components/token/me/emptyBody/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/token/me/index.d.ts b/es/components/token/me/index.d.ts index c3b729bd6..85b087bea 100644 --- a/es/components/token/me/index.d.ts +++ b/es/components/token/me/index.d.ts @@ -1,8 +1,9 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; myInfoUrl: string; manageUserUrl: string; loginUrl: string; - Body: React.ReactNode | undefined; + Body: import("react").ReactNode; }>) => React.ReactElement; export default _default; diff --git a/es/components/user/authenticate/idCard/index.d.ts b/es/components/user/authenticate/idCard/index.d.ts index ad2c0daa9..4fa77e554 100644 --- a/es/components/user/authenticate/idCard/index.d.ts +++ b/es/components/user/authenticate/idCard/index.d.ts @@ -1,6 +1,6 @@ import { EntityDict } from '../../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps void) | undefined; needUploadPhotos: boolean; diff --git a/es/components/user/login/index.js b/es/components/user/login/index.js index 0ce1ecb46..148f24b59 100644 --- a/es/components/user/login/index.js +++ b/es/components/user/login/index.js @@ -17,16 +17,16 @@ export default OakComponent({ allowPassword: false, allowWechatMp: false, setLoginModeMp(value) { this.setLoginMode(value); }, - smsDigit: 4, //短信验证码位数 - emailDigit: 4, //邮箱验证码位数 + smsDigit: 4, + emailDigit: 4, pwdMode: 'all', //密码明文密文存储模式 }, properties: { onlyCaptcha: false, onlyPassword: false, disabled: '', - redirectUri: '', // 微信登录后的redirectUri,要指向wechatUser/login去处理 - url: '', // 登录系统之后要返回的页面 + redirectUri: '', + url: '', callback: undefined, // 登录成功回调,排除微信登录方式 }, formData({ features, props }) { diff --git a/es/components/user/password/verify/index.d.ts b/es/components/user/password/verify/index.d.ts index 721288d6b..c5fb2e667 100644 --- a/es/components/user/password/verify/index.d.ts +++ b/es/components/user/password/verify/index.d.ts @@ -1,4 +1,4 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps void); + onVerified: (() => void) | undefined; }>) => React.ReactElement; export default _default; diff --git a/es/components/user/password/verify/web.d.ts b/es/components/user/password/verify/web.d.ts index 8c7e08cdd..cb271e15f 100644 --- a/es/components/user/password/verify/web.d.ts +++ b/es/components/user/password/verify/web.d.ts @@ -1,3 +1,4 @@ +/// import { WebComponentProps } from "oak-frontend-base"; import { EntityDict } from "../../../../oak-app-domain"; export default function Render(props: WebComponentProps import { WebComponentProps } from "oak-frontend-base"; import { EntityDict } from "../../../../oak-app-domain"; export default function Render(props: WebComponentProps void; onPickRows: (ids: string[]) => void; - pickedRowIds?: string[]; - pickedRelationIds?: string[]; + pickedRowIds?: string[] | undefined; + pickedRelationIds?: string[] | undefined; oakPath: string; }) => React.ReactElement) | undefined; hideInfo: boolean; hideTip: boolean; - afterClaim: ((ueg: EntityDict["userEntityGrant"]["OpSchema"]) => void) | undefined; + afterClaim: ((ueg: EntityDict['userEntityGrant']['OpSchema']) => void) | undefined; }>) => React.ReactElement; export default _default; diff --git a/es/components/userEntityGrant/claim/ubPicker/index.d.ts b/es/components/userEntityGrant/claim/ubPicker/index.d.ts index d7583bcca..3ff190b84 100644 --- a/es/components/userEntityGrant/claim/ubPicker/index.d.ts +++ b/es/components/userEntityGrant/claim/ubPicker/index.d.ts @@ -4,8 +4,8 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< entity: keyof EntityDict; entityFilter: any; relationIds: string[]; - rule: EntityDict["userEntityGrant"]["OpSchema"]["rule"]; - ruleOnRow: EntityDict["userEntityGrant"]["OpSchema"]["ruleOnRow"]; + rule: "single" | "all" | "free"; + ruleOnRow: "single" | "all" | "free"; onPickRelations: (ids: string[]) => void; onPickRows: (ids: string[]) => void; pickedRowIds: string[] | undefined; diff --git a/es/components/userEntityGrant/upsert/index.d.ts b/es/components/userEntityGrant/upsert/index.d.ts index 5ab1ea9b4..0268e541f 100644 --- a/es/components/userEntityGrant/upsert/index.d.ts +++ b/es/components/userEntityGrant/upsert/index.d.ts @@ -6,12 +6,12 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< relationEntity: string; relationEntityFilter: any; relationIds: string[]; - type: EntityDict["userEntityGrant"]["Schema"]["type"]; - redirectToAfterConfirm: EntityDict["userEntityGrant"]["Schema"]["redirectTo"]; + type: "grant" | "transfer"; + redirectToAfterConfirm: import("../../../oak-app-domain/UserEntityGrant/_baseSchema").RedirectToProps | null | undefined; claimUrl: string; qrCodeType: QrCodeType; multiple: boolean; - rule: EntityDict["userEntityGrant"]["OpSchema"]["rule"]; - ruleOnRow: EntityDict["userEntityGrant"]["OpSchema"]["ruleOnRow"]; + rule: "single" | "all" | "free"; + ruleOnRow: "single" | "all" | "free"; }>) => React.ReactElement; export default _default; diff --git a/es/components/userRelation/upsert/byMobile/index.d.ts b/es/components/userRelation/upsert/byMobile/index.d.ts index 83fdd447c..7ed47c734 100644 --- a/es/components/userRelation/upsert/byMobile/index.d.ts +++ b/es/components/userRelation/upsert/byMobile/index.d.ts @@ -4,9 +4,9 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; declare const _default: (props: ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/userRelation/upsert/byUser/index.d.ts b/es/components/userRelation/upsert/byUser/index.d.ts index 4940119bf..57ff8d988 100644 --- a/es/components/userRelation/upsert/byUser/index.d.ts +++ b/es/components/userRelation/upsert/byUser/index.d.ts @@ -4,7 +4,7 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; declare const _default: (props: ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/userRelation/upsert/byUserEntityGrant/index.d.ts b/es/components/userRelation/upsert/byUserEntityGrant/index.d.ts index f72c8f3fc..5c6e1bdab 100644 --- a/es/components/userRelation/upsert/byUserEntityGrant/index.d.ts +++ b/es/components/userRelation/upsert/byUserEntityGrant/index.d.ts @@ -7,12 +7,12 @@ declare const _default: void; + rule: EntityDict['userEntityGrant']['Schema']['rule']; + ruleOnRow: EntityDict['userEntityGrant']['OpSchema']['ruleOnRow']; + onUserEntityGrantCreated?: ((id: string) => void) | undefined; }>) => React.ReactElement; export default _default; diff --git a/es/components/userRelation/upsert/index.d.ts b/es/components/userRelation/upsert/index.d.ts index bfce90975..924306f4c 100644 --- a/es/components/userRelation/upsert/index.d.ts +++ b/es/components/userRelation/upsert/index.d.ts @@ -7,8 +7,8 @@ declare const _default: ; - mode: "byMobile" | "byUserEntityGrant" | "byEmail"; + passwordRequired?: boolean | undefined; + disabledMethods: Array<'email' | 'mobile' | 'userEntityGrant'>; + mode: 'byMobile' | 'byUserEntityGrant' | 'byEmail'; }>) => React.ReactElement; export default _default; diff --git a/es/components/userRelation/upsert/onUser/index.d.ts b/es/components/userRelation/upsert/onUser/index.d.ts index 1f0ec1ff8..cafe99e04 100644 --- a/es/components/userRelation/upsert/onUser/index.d.ts +++ b/es/components/userRelation/upsert/onUser/index.d.ts @@ -2,7 +2,7 @@ import { EntityDict } from '../../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; passwordRequired: boolean; diff --git a/es/components/userRelation/upsert/onUser/userRelation/index.d.ts b/es/components/userRelation/upsert/onUser/userRelation/index.d.ts index 3ce27eed3..5db0a88be 100644 --- a/es/components/userRelation/upsert/onUser/userRelation/index.d.ts +++ b/es/components/userRelation/upsert/onUser/userRelation/index.d.ts @@ -2,6 +2,6 @@ import { EntityDict } from '../../../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/wechatLogin/confirm/index.d.ts b/es/components/wechatLogin/confirm/index.d.ts index ddbd0e992..e9d6f92ca 100644 --- a/es/components/wechatLogin/confirm/index.d.ts +++ b/es/components/wechatLogin/confirm/index.d.ts @@ -1,2 +1,5 @@ -declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; +declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/wechatLogin/confirm/index.js b/es/components/wechatLogin/confirm/index.js index 103a7102c..a56184f4f 100644 --- a/es/components/wechatLogin/confirm/index.js +++ b/es/components/wechatLogin/confirm/index.js @@ -10,6 +10,10 @@ export default OakComponent({ successed: 1, }, isList: false, + properties: { + wechatLoginResultPage: '/wechatLogin/confirm', + wechatUserLoginPage: '/wechatUser/login', + }, formData({ data: wechatLogin, features }) { const loginUserId = features.token.getUserId(true); const user = wechatLogin?.user; @@ -27,25 +31,16 @@ export default OakComponent({ appId, }; }, - listeners: {}, methods: { getCodeAndRedirect() { - const state = encodeURIComponent(`/wechatLogin/confirm?oakId=${this.props.oakId}`); - // if (process.env.NODE_ENV === 'development') { - // this.navigateTo( - // { - // url: '/wechatUser/login', - // wechatLoginId: this.props.oakId, - // code: `CODE_${Math.random()}`, - // state, - // }, - // ); - // } - // else { + const { wechatLoginConfirmPage, wechatUserLoginPage } = this.props; + const wechatLoginId = this.props.oakId; + const state = encodeURIComponent(`${wechatLoginConfirmPage}?oakId=${wechatLoginId}`); const { appId } = this.state; - const redirectUrl = `https%3A%2F%2F${window.location.host}%2FwechatUser%2Flogin%3FwechatLoginId%3D${this.props.oakId}`; //网址转义 `https://${window.location.host}/wechatUser/login?wechatLoginId=${this.props.oakId}` - window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`; - // } + const host = window.location.host; + const protocol = window.location.protocol === 'https:' ? 'https' : 'http'; + const redirectUri = encodeURIComponent(`${protocol}://${host}${wechatUserLoginPage}?wechatLoginId=${wechatLoginId}`); + window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`; } }, }); diff --git a/es/components/wechatLogin/qrCode/index.d.ts b/es/components/wechatLogin/qrCode/index.d.ts index 6f4ca60a8..6724d807e 100644 --- a/es/components/wechatLogin/qrCode/index.d.ts +++ b/es/components/wechatLogin/qrCode/index.d.ts @@ -1,7 +1,9 @@ import { EntityDict } from '../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/wechatLogin/qrCode/index.js b/es/components/wechatLogin/qrCode/index.js index 79865982e..60b34de3f 100644 --- a/es/components/wechatLogin/qrCode/index.js +++ b/es/components/wechatLogin/qrCode/index.js @@ -29,13 +29,18 @@ export default OakComponent({ type: 'bind', url: '', size: undefined, + disableBack: false, + wechatLoginConfirmPage: '/wechatLogin/confirm' }, methods: { async createWechatLogin() { - const { type = 'bind' } = this.props; + const { type = 'bind', wechatLoginConfirmPage } = this.props; const { result: wechatLoginId } = await this.features.cache.exec('createWechatLogin', { type, interval: Interval, + router: { + pathname: wechatLoginConfirmPage + } }); this.setState({ wechatLoginId, @@ -115,6 +120,7 @@ export default OakComponent({ }, // 每秒调取下面方法,监听用户是否已在微信端授权登录或绑定 async getWechatLogin2() { + const { url, disableBack } = this.props; const { wechatLoginId } = this.state; const { data: [wechatLogin], } = await this.features.cache.refresh('wechatLogin', { data: { @@ -136,17 +142,22 @@ export default OakComponent({ successful: successed, type, }, async () => { - // 未登录的情况下才走这里 - if (successed && type === 'login') { - await this.features.token.loginByWechatInWebEnv(wechatLoginId); - const { url } = this.props; + // 登录/绑定的情况下才走这里 + if (successed) { + if (type === 'login') { + await this.features.token.loginByWechatInWebEnv(wechatLoginId); + } + // url存在则跳转 if (url) { this.redirectTo({ url: url, }); return; } - this.navigateBack(); + // 登录成功且没有url则返回 + if (!disableBack) { + this.navigateBack(); + } } }); }, diff --git a/es/components/wechatMenu/menuInfo/index.d.ts b/es/components/wechatMenu/menuInfo/index.d.ts index a13918aba..f7b3a780b 100644 --- a/es/components/wechatMenu/menuInfo/index.d.ts +++ b/es/components/wechatMenu/menuInfo/index.d.ts @@ -3,7 +3,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps< config: any; menuIndex: number; changeConfig: (config: any) => void; - publish: (iState: "wait" | "fail") => void; + publish: (iState: 'wait' | 'fail') => void; getErrorIndex: (errorIndex: number[]) => void; createMenu: () => void; selectedBtn: number; diff --git a/es/components/wechatUser/bindingList/index.d.ts b/es/components/wechatUser/bindingList/index.d.ts index aaff0d728..ab29006fe 100644 --- a/es/components/wechatUser/bindingList/index.d.ts +++ b/es/components/wechatUser/bindingList/index.d.ts @@ -1,3 +1,4 @@ +/// import { EntityDict } from '../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/wechatUser/login/index.d.ts b/es/components/wechatUser/login/index.d.ts index fc416ef2a..4007eded7 100644 --- a/es/components/wechatUser/login/index.d.ts +++ b/es/components/wechatUser/login/index.d.ts @@ -1,2 +1,3 @@ +/// declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/components/wechatUser/unbindBtn/index.d.ts b/es/components/wechatUser/unbindBtn/index.d.ts index 3315ada56..611b25119 100644 --- a/es/components/wechatUser/unbindBtn/index.d.ts +++ b/es/components/wechatUser/unbindBtn/index.d.ts @@ -1,3 +1,4 @@ +/// import { EntityDict } from '../../../oak-app-domain'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; export default _default; diff --git a/es/endpoints/wechat.js b/es/endpoints/wechat.js index 6cb67b262..307489a05 100644 --- a/es/endpoints/wechat.js +++ b/es/endpoints/wechat.js @@ -332,7 +332,7 @@ async function setUserSubscribed(openId, eventKey, context) { scene: sceneStr, time: `${Date.now()}`, }); - const title = type === 'bind' ? '扫码绑定' : '扫码登录'; + const title = type === 'bind' ? '立即绑定' : '立即登录'; const description = type === 'bind' ? '去绑定' : '去登录'; if (!expired) { wechatInstance.sendServeMessage({ diff --git a/es/entities/WechatLogin.d.ts b/es/entities/WechatLogin.d.ts index 38e3120ec..7e5c37fd5 100644 --- a/es/entities/WechatLogin.d.ts +++ b/es/entities/WechatLogin.d.ts @@ -6,6 +6,11 @@ import { QrCodeType } from '../types/Config'; import { EntityDesc } from 'oak-domain/lib/types/EntityDesc'; import { Schema as Token } from './Token'; import { Schema as WechatUser } from './WechatUser'; +type Router = { + pathname: string; + props?: Record; + state?: Record; +}; export interface Schema extends EntityShape { user?: User; type: 'bind' | 'login'; @@ -17,9 +22,11 @@ export interface Schema extends EntityShape { codes: Array; tokens?: Array; wechatUser?: WechatUser; + router?: Router; } export type Action = 'success'; export declare const entityDesc: EntityDesc; +export {}; diff --git a/es/entities/WechatLogin.js b/es/entities/WechatLogin.js index 336d2e3ee..c5bdcf358 100644 --- a/es/entities/WechatLogin.js +++ b/es/entities/WechatLogin.js @@ -13,6 +13,7 @@ export const entityDesc = { qrCodeType: '二维码类型', tokens: '相关令牌', wechatUser: '微信用户', + router: '目标路由', }, action: { success: '成功', diff --git a/es/oak-app-domain/WechatLogin/Storage.js b/es/oak-app-domain/WechatLogin/Storage.js index 22576416a..c09b742e0 100644 --- a/es/oak-app-domain/WechatLogin/Storage.js +++ b/es/oak-app-domain/WechatLogin/Storage.js @@ -31,6 +31,9 @@ export const desc = { wechatUserId: { type: "ref", ref: "wechatUser" + }, + router: { + type: "object" } }, actionType: "crud", diff --git a/es/oak-app-domain/WechatLogin/_baseSchema.d.ts b/es/oak-app-domain/WechatLogin/_baseSchema.d.ts index d0feaadad..4c77b8436 100644 --- a/es/oak-app-domain/WechatLogin/_baseSchema.d.ts +++ b/es/oak-app-domain/WechatLogin/_baseSchema.d.ts @@ -1,9 +1,14 @@ -import { ForeignKey } from "oak-domain/lib/types/DataType"; -import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; +import { ForeignKey, JsonProjection } from "oak-domain/lib/types/DataType"; +import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey, JsonFilter } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { Action, ParticularAction } from "./Action"; import { Boolean, Text, Datetime } from "oak-domain/lib/types/DataType"; import { QrCodeType } from "../../types/Config"; +type Router = { + pathname: string; + props?: Record; + state?: Record; +}; export type OpSchema = EntityShape & { userId?: ForeignKey<"user"> | null; type: "bind" | "login"; @@ -13,6 +18,7 @@ export type OpSchema = EntityShape & { expiresAt?: Datetime | null; expired?: Boolean | null; wechatUserId?: ForeignKey<"wechatUser"> | null; + router?: Router | null; } & { [A in ExpressionKey]?: any; }; @@ -30,6 +36,7 @@ export type OpFilter = { expiresAt: Q_DateValue; expired: Q_BooleanValue; wechatUserId: Q_StringValue; + router: JsonFilter; } & ExprOp; export type OpProjection = { "#id"?: NodeId; @@ -46,6 +53,7 @@ export type OpProjection = { expiresAt?: number; expired?: number; wechatUserId?: number; + router?: number | JsonProjection; } & Partial>; export type OpSortAttr = Partial<{ id: number; @@ -60,7 +68,9 @@ export type OpSortAttr = Partial<{ expiresAt: number; expired: number; wechatUserId: number; + router: number; [k: string]: any; } | ExprOp>; export type OpAction = OakMakeAction; export type OpUpdateAction = "update" | ParticularAction | string; +export {}; diff --git a/es/oak-app-domain/WechatLogin/locales/zh_CN.json b/es/oak-app-domain/WechatLogin/locales/zh_CN.json index c20f44619..b5f8b0a14 100644 --- a/es/oak-app-domain/WechatLogin/locales/zh_CN.json +++ b/es/oak-app-domain/WechatLogin/locales/zh_CN.json @@ -10,7 +10,8 @@ "expiresAt": "过期时间", "qrCodeType": "二维码类型", "tokens": "相关令牌", - "wechatUser": "微信用户" + "wechatUser": "微信用户", + "router": "目标路由" }, "action": { "success": "成功" diff --git a/es/triggers/index.d.ts b/es/triggers/index.d.ts index e5cf26df7..551febe7a 100644 --- a/es/triggers/index.d.ts +++ b/es/triggers/index.d.ts @@ -1,2 +1,2 @@ -declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[]; +declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[]; export default _default; diff --git a/es/triggers/wechatLogin.js b/es/triggers/wechatLogin.js index 069140a1a..b5ed118c5 100644 --- a/es/triggers/wechatLogin.js +++ b/es/triggers/wechatLogin.js @@ -9,7 +9,8 @@ const triggers = [ fn: async ({ operation }, context, params) => { const { data, filter } = operation; const fn = async (wechatLoginData) => { - const { id } = wechatLoginData; + const { id, router } = wechatLoginData; + assert(router?.pathname, 'wechatLogin必须指定router pathname'); Object.assign(wechatLoginData, { expired: false, successed: false, @@ -28,7 +29,7 @@ const triggers = [ entity: 'wechatLogin', entityId: id, props: { - pathname: '/wechatLogin/confirm', + pathname: router?.pathname, props: { oakId: id, }, diff --git a/es/utils/email/index.d.ts b/es/utils/email/index.d.ts index eb86950e8..5a3295714 100644 --- a/es/utils/email/index.d.ts +++ b/es/utils/email/index.d.ts @@ -10,5 +10,5 @@ export declare function getEmail(origin: string): Email(options: EmailOptions, context: BRC): Promise<{ success: boolean; - error?: string; + error?: string | undefined; }>; diff --git a/es/utils/oauth/index.d.ts b/es/utils/oauth/index.d.ts index 51da6fd52..5631b6123 100644 --- a/es/utils/oauth/index.d.ts +++ b/es/utils/oauth/index.d.ts @@ -10,8 +10,8 @@ type UserID = { avatarUrl: string | null; }; export type UserInfoHandler = (data: UserInfo) => UserID | Promise; -export declare const registerOauthUserinfoHandler: (type: EntityDict["oauthProvider"]["Schema"]["type"], handler: UserInfoHandler) => void; -export declare const processUserInfo: (type: EntityDict["oauthProvider"]["Schema"]["type"], data: UserInfo) => UserID | Promise; +export declare const registerOauthUserinfoHandler: (type: EntityDict['oauthProvider']['Schema']['type'], handler: UserInfoHandler) => void; +export declare const processUserInfo: (type: EntityDict['oauthProvider']['Schema']['type'], data: UserInfo) => UserID | Promise; export declare function checkOauthTokenAvaliable(context: BackendRuntimeContext, token: string | undefined): Promise<{ error: string | null; statusCode?: number; diff --git a/lib/aspects/AspectDict.d.ts b/lib/aspects/AspectDict.d.ts index 619960621..61eb14ba7 100644 --- a/lib/aspects/AspectDict.d.ts +++ b/lib/aspects/AspectDict.d.ts @@ -292,11 +292,13 @@ export type AspectDict = { * 创建微信登录会话(用于扫码登录场景) * @param type 登录类型(login-登录,bind-绑定) * @param interval 会话有效期(毫秒) + * @param router 扫码目标路由 * @returns 返回登录会话 ID */ createWechatLogin: (params: { type: EntityDict['wechatLogin']['Schema']['type']; interval: number; + router: EntityDict['wechatLogin']['Schema']['router']; }, context: BackendRuntimeContext) => Promise; /** * 解绑微信用户 diff --git a/lib/aspects/template.d.ts b/lib/aspects/template.d.ts index ddac06395..d3bbe7f7f 100644 --- a/lib/aspects/template.d.ts +++ b/lib/aspects/template.d.ts @@ -19,6 +19,6 @@ export declare function syncWechatTemplate(params: { example: string; keywordEnumValueList: { keywordCode: string; - enumValueList: Array; + enumValueList: string[]; }[]; }[]>; diff --git a/lib/aspects/token.js b/lib/aspects/token.js index 97f8db6b5..4ca1e822b 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -1,28 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.setUpTokenAndUser = setUpTokenAndUser; -exports.loadTokenInfo = loadTokenInfo; -exports.loginByMobile = loginByMobile; -exports.verifyPassword = verifyPassword; -exports.loginByAccount = loginByAccount; -exports.loginByEmail = loginByEmail; -exports.bindByMobile = bindByMobile; -exports.bindByEmail = bindByEmail; -exports.setUserAvatarFromWechat = setUserAvatarFromWechat; -exports.refreshWechatPublicUserInfo = refreshWechatPublicUserInfo; -exports.loginByWechat = loginByWechat; -exports.loginWechatNative = loginWechatNative; -exports.loginWechat = loginWechat; -exports.loginWechatMp = loginWechatMp; -exports.syncUserInfoWechatMp = syncUserInfoWechatMp; -exports.sendCaptchaByMobile = sendCaptchaByMobile; -exports.sendCaptchaByEmail = sendCaptchaByEmail; -exports.switchTo = switchTo; -exports.getWechatMpUserPhoneNumber = getWechatMpUserPhoneNumber; -exports.logout = logout; -exports.wakeupParasite = wakeupParasite; -exports.refreshToken = refreshToken; -exports.loginWebByMpToken = loginWebByMpToken; +exports.loginWebByMpToken = exports.refreshToken = exports.wakeupParasite = exports.logout = exports.getWechatMpUserPhoneNumber = exports.switchTo = exports.sendCaptchaByEmail = exports.sendCaptchaByMobile = exports.syncUserInfoWechatMp = exports.loginWechatMp = exports.loginWechat = exports.loginWechatNative = exports.loginByWechat = exports.refreshWechatPublicUserInfo = exports.setUserAvatarFromWechat = exports.bindByEmail = exports.bindByMobile = exports.loginByEmail = exports.loginByAccount = exports.verifyPassword = exports.loginByMobile = exports.loadTokenInfo = exports.setUpTokenAndUser = void 0; const tslib_1 = require("tslib"); const uuid_1 = require("oak-domain/lib/utils/uuid"); const WechatSDK_1 = tslib_1.__importDefault(require("oak-external-sdk/lib/WechatSDK")); @@ -402,6 +380,7 @@ createData, user) { } } } +exports.setUpTokenAndUser = setUpTokenAndUser; async function setupMobile(mobile, env, context) { const result2 = await context.select('mobile', { data: { @@ -465,6 +444,7 @@ async function loadTokenInfo(tokenValue, context) { }, }, {}); } +exports.loadTokenInfo = loadTokenInfo; async function loginByMobile(params, context) { const { mobile, captcha, env, disableRegister } = params; const loginLogic = async (isRoot) => { @@ -560,6 +540,7 @@ async function loginByMobile(params, context) { closeRootMode(); return tokenValue; } +exports.loginByMobile = loginByMobile; async function verifyPassword(params, context) { const { password } = params; const systemId = context.getSystemId(); @@ -624,6 +605,7 @@ async function verifyPassword(params, context) { } }, {}); } +exports.verifyPassword = verifyPassword; async function loginByAccount(params, context) { const { account, password, env } = params; let needUpdatePassword = false; @@ -976,6 +958,7 @@ async function loginByAccount(params, context) { closeRootMode(); return tokenValue; } +exports.loginByAccount = loginByAccount; async function loginByEmail(params, context) { const { email, captcha, env, disableRegister } = params; const loginLogic = async () => { @@ -1046,6 +1029,7 @@ async function loginByEmail(params, context) { closeRootMode(); return tokenValue; } +exports.loginByEmail = loginByEmail; async function bindByMobile(params, context) { const { mobile, captcha, env, } = params; const userId = context.getCurrentUserId(); @@ -1157,6 +1141,7 @@ async function bindByMobile(params, context) { await bindLogic(); closeRootMode(); } +exports.bindByMobile = bindByMobile; async function bindByEmail(params, context) { const { email, captcha, env, } = params; const userId = context.getCurrentUserId(); @@ -1269,6 +1254,7 @@ async function bindByEmail(params, context) { await bindLogic(); closeRootMode(); } +exports.bindByEmail = bindByEmail; async function setupLoginName(name, env, context) { const result2 = await context.select('loginName', { data: { @@ -1509,6 +1495,7 @@ async function setUserAvatarFromWechat(params, context) { }, {}); } } +exports.setUserAvatarFromWechat = setUserAvatarFromWechat; async function tryRefreshWechatPublicUserInfo(wechatUserId, context) { const [wechatUser] = await context.select('wechatUser', { data: { @@ -1611,6 +1598,7 @@ async function refreshWechatPublicUserInfo({}, context) { (0, assert_1.assert)(token.entityId); return await tryRefreshWechatPublicUserInfo(token.entityId, context); } +exports.refreshWechatPublicUserInfo = refreshWechatPublicUserInfo; // 用户在微信端授权登录后,在web端触发该方法 async function loginByWechat(params, context) { const { wechatLoginId, env } = params; @@ -1640,6 +1628,7 @@ async function loginByWechat(params, context) { closeRootMode(); return tokenValue; } +exports.loginByWechat = loginByWechat; async function loginFromWechatEnv(code, env, context, wechatLoginId) { const application = context.getApplication(); const { type, config, systemId } = application; @@ -1678,7 +1667,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { wechatMp: 'mp', native: 'native', }; - const createWechatUserAndReturnTokenId = async (user, wechatLoginId) => { + const createWechatUserAndReturnTokenId = async (user) => { const wechatUserCreateData = { id: await (0, uuid_1.generateNewIdAsync)(), unionId, @@ -1687,13 +1676,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { applicationId: application.id, ...wechatUserData, }; - let tokenValue; - if (wechatLoginId) { - tokenValue = await setUpTokenAndUser(env, context, 'wechatLogin', wechatLoginId, undefined, user); - } - else { - tokenValue = await setUpTokenAndUser(env, context, 'wechatUser', undefined, wechatUserCreateData, user); - } + const tokenValue = await setUpTokenAndUser(env, context, 'wechatUser', undefined, wechatUserCreateData, user); return { tokenValue, wechatUserId: wechatUserCreateData.id }; }; // 扫码者 @@ -1796,12 +1779,12 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { }, }, { dontCollect: true }); const tokenValue = await setUpTokenAndUser(env, context, 'wechatUser', wechatUser.id, undefined, wechatLoginData.user); - await updateWechatLogin({ successed: true }); + await updateWechatLogin({ successed: true, wechatUserId: wechatUser.id }); return tokenValue; } else { - const { tokenValue } = await createWechatUserAndReturnTokenId(wechatLoginData.user); - await updateWechatLogin({ successed: true }); + const { tokenValue, wechatUserId } = await createWechatUserAndReturnTokenId(wechatLoginData.user); + await updateWechatLogin({ successed: true, wechatUserId }); return tokenValue; } } @@ -1855,6 +1838,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { await updateWechatLogin({ userId: wechatUser.userId, successed: true, + wechatUserId: wechatUser.id, }); return tokenValue; } @@ -1870,7 +1854,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { action: 'create', data: userData, }, {}); - const { tokenValue, wechatUserId } = await createWechatUserAndReturnTokenId(userData, wechatLoginId); + const { tokenValue, wechatUserId } = await createWechatUserAndReturnTokenId(userData); await updateWechatLogin({ userId, wechatUserId, successed: true }); return tokenValue; } @@ -1973,7 +1957,8 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) { } } // 到这里都是要同时创建wechatUser和user对象了 - return (await createWechatUserAndReturnTokenId()).tokenValue; + const { tokenValue } = await createWechatUserAndReturnTokenId(); + return tokenValue; } /** * 微信App授权登录 @@ -1988,6 +1973,7 @@ async function loginWechatNative({ code, env, }, context) { closeRootMode(); return tokenValue; } +exports.loginWechatNative = loginWechatNative; /** * 公众号授权登录 * @param param0 @@ -2002,22 +1988,10 @@ async function loginWechat({ code, env, wechatLoginId, }, context) { if (tokenInfo.entity === 'wechatUser') { await tryRefreshWechatPublicUserInfo(tokenInfo.entityId, context); } - else if (tokenInfo.entity === 'wechatLogin') { - const [wechatLogin] = await context.select('wechatLogin', { - data: { - id: 1, - wechatUserId: 1, - }, - filter: { - id: tokenInfo.entityId, - }, - }, {}); - (0, assert_1.assert)(wechatLogin?.wechatUserId); - await tryRefreshWechatPublicUserInfo(wechatLogin.wechatUserId, context); - } closeRootMode(); return tokenValue; } +exports.loginWechat = loginWechat; /** * 小程序授权登录 * @param param0 @@ -2031,6 +2005,7 @@ async function loginWechatMp({ code, env, }, context) { closeRootMode(); return tokenValue; } +exports.loginWechatMp = loginWechatMp; /** * 同步从wx.getUserProfile拿到的用户信息 * @param param0 @@ -2084,6 +2059,7 @@ async function syncUserInfoWechatMp({ nickname, avatarUrl, encryptedData, iv, si // 实测发现解密出来的和userInfo完全一致…… await setUserInfoFromWechat(user, { nickname, avatar: avatarUrl }, context); } +exports.syncUserInfoWechatMp = syncUserInfoWechatMp; async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context) { const { type } = env; let visitorId = mobile; @@ -2257,6 +2233,7 @@ async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context) return '验证码发送失败'; } } +exports.sendCaptchaByMobile = sendCaptchaByMobile; async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) { const { type } = env; let visitorId = email; @@ -2409,6 +2386,7 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) { return '验证码发送失败'; } } +exports.sendCaptchaByEmail = sendCaptchaByEmail; async function switchTo({ userId }, context) { const reallyRoot = context.isReallyRoot(); if (!reallyRoot) { @@ -2430,6 +2408,7 @@ async function switchTo({ userId }, context) { }, }, {}); } +exports.switchTo = switchTo; async function getWechatMpUserPhoneNumber({ code, env }, context) { const application = context.getApplication(); const { type, config, systemId } = application; @@ -2445,6 +2424,7 @@ async function getWechatMpUserPhoneNumber({ code, env }, context) { closeRootMode(); return reuslt; } +exports.getWechatMpUserPhoneNumber = getWechatMpUserPhoneNumber; async function logout(params, context) { const { tokenValue } = params; if (tokenValue) { @@ -2467,6 +2447,7 @@ async function logout(params, context) { closeRootMode(); } } +exports.logout = logout; /** * 创建一个当前parasite上的token * @param params @@ -2533,6 +2514,7 @@ async function wakeupParasite(params, context) { closeRootMode(); return tokenValue; } +exports.wakeupParasite = wakeupParasite; /** * todo 检查登录环境一致性,同一个token不能跨越不同设备 * @param env1 @@ -2605,8 +2587,8 @@ async function refreshToken(params, context) { // 只有server模式去刷新token // 'development' | 'production' | 'staging' const intervals = { - development: 7200 * 1000, // 2小时 - staging: 600 * 1000, // 十分钟 + development: 7200 * 1000, + staging: 600 * 1000, production: 600 * 1000, // 十分钟 }; let applicationId = token.applicationId; @@ -2679,6 +2661,7 @@ async function refreshToken(params, context) { closeRootMode(); return tokenValue; } +exports.refreshToken = refreshToken; /** * 使用微信小程序中的token登录web * @param tokenValue @@ -2746,3 +2729,4 @@ async function loginWebByMpToken(params, context) { closeRootMode(); return tokenValue; } +exports.loginWebByMpToken = loginWebByMpToken; diff --git a/lib/aspects/wechatLogin.d.ts b/lib/aspects/wechatLogin.d.ts index 9c13e80d8..c6bd46f98 100644 --- a/lib/aspects/wechatLogin.d.ts +++ b/lib/aspects/wechatLogin.d.ts @@ -3,4 +3,5 @@ import { BRC } from '../types/RuntimeCxt'; export declare function createWechatLogin(params: { type: EntityDict['wechatLogin']['Schema']['type']; interval: number; + router: EntityDict['wechatLogin']['Schema']['router']; }, context: BRC): Promise; diff --git a/lib/aspects/wechatLogin.js b/lib/aspects/wechatLogin.js index 240aa8f59..662c32d93 100644 --- a/lib/aspects/wechatLogin.js +++ b/lib/aspects/wechatLogin.js @@ -3,12 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createWechatLogin = void 0; const uuid_1 = require("oak-domain/lib/utils/uuid"); async function createWechatLogin(params, context) { - const { type, interval } = params; + const { type, interval, router } = params; let userId; if (type === 'bind') { userId = context.getCurrentUserId(); } const id = await (0, uuid_1.generateNewIdAsync)(); + let _router = router; + // router为空则默认为/wechatLogin/confirm + if (!router) { + _router = { + pathname: '/wechatLogin/confirm', + props: { + oakId: id, + }, + }; + } + else { + _router.props = { + oakId: id, + }; + } const createData = { id, type, @@ -16,11 +31,10 @@ async function createWechatLogin(params, context) { expired: false, qrCodeType: 'wechatPublic', successed: false, + router: _router, }; if (userId) { - Object.assign(createData, { - userId, - }); + createData.userId = userId; } if (type === 'login') { const closeRoot = context.openRootMode(); diff --git a/lib/endpoints/wechat.js b/lib/endpoints/wechat.js index 7fc183eb6..364c94e3b 100644 --- a/lib/endpoints/wechat.js +++ b/lib/endpoints/wechat.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.registerWeChatPublicEventCallback = registerWeChatPublicEventCallback; +exports.registerWeChatPublicEventCallback = void 0; const tslib_1 = require("tslib"); const assert_1 = require("oak-domain/lib/utils/assert"); const url_1 = tslib_1.__importDefault(require("url")); @@ -29,6 +29,7 @@ function registerWeChatPublicEventCallback(appId, callback) { (0, assert_1.assert)(!CALLBACK.hasOwnProperty(appId)); CALLBACK[appId] = callback; } +exports.registerWeChatPublicEventCallback = registerWeChatPublicEventCallback; /** * 用户取关事件,注意要容wechatUser不存在的情况 * @param openId @@ -336,7 +337,7 @@ async function setUserSubscribed(openId, eventKey, context) { scene: sceneStr, time: `${Date.now()}`, }); - const title = type === 'bind' ? '扫码绑定' : '扫码登录'; + const title = type === 'bind' ? '立即绑定' : '立即登录'; const description = type === 'bind' ? '去绑定' : '去登录'; if (!expired) { wechatInstance.sendServeMessage({ diff --git a/lib/entities/WechatLogin.d.ts b/lib/entities/WechatLogin.d.ts index 38e3120ec..7e5c37fd5 100644 --- a/lib/entities/WechatLogin.d.ts +++ b/lib/entities/WechatLogin.d.ts @@ -6,6 +6,11 @@ import { QrCodeType } from '../types/Config'; import { EntityDesc } from 'oak-domain/lib/types/EntityDesc'; import { Schema as Token } from './Token'; import { Schema as WechatUser } from './WechatUser'; +type Router = { + pathname: string; + props?: Record; + state?: Record; +}; export interface Schema extends EntityShape { user?: User; type: 'bind' | 'login'; @@ -17,9 +22,11 @@ export interface Schema extends EntityShape { codes: Array; tokens?: Array; wechatUser?: WechatUser; + router?: Router; } export type Action = 'success'; export declare const entityDesc: EntityDesc; +export {}; diff --git a/lib/entities/WechatLogin.js b/lib/entities/WechatLogin.js index 648601b9d..1a391cfc1 100644 --- a/lib/entities/WechatLogin.js +++ b/lib/entities/WechatLogin.js @@ -16,6 +16,7 @@ exports.entityDesc = { qrCodeType: '二维码类型', tokens: '相关令牌', wechatUser: '微信用户', + router: '目标路由', }, action: { success: '成功', diff --git a/lib/features/index.js b/lib/features/index.js index 98a2c12cc..5897a25b4 100644 --- a/lib/features/index.js +++ b/lib/features/index.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.create = create; -exports.initialize = initialize; +exports.initialize = exports.create = void 0; const tslib_1 = require("tslib"); const token_1 = require("./token"); const extraFile_1 = require("./extraFile"); @@ -38,6 +37,7 @@ function create(basicFeatures) { userWechatPublicTag, }; } +exports.create = create; const selectionRewriter_1 = require("../utils/selectionRewriter"); async function initialize(features, access, config, clazzes) { features.cache.registerSelectionRewriter(selectionRewriter_1.rewriteSelection); @@ -56,3 +56,4 @@ async function initialize(features, access, config, clazzes) { } } } +exports.initialize = initialize; diff --git a/lib/oak-app-domain/WechatLogin/Storage.js b/lib/oak-app-domain/WechatLogin/Storage.js index 678e6fa32..33c9c0049 100644 --- a/lib/oak-app-domain/WechatLogin/Storage.js +++ b/lib/oak-app-domain/WechatLogin/Storage.js @@ -34,6 +34,9 @@ exports.desc = { wechatUserId: { type: "ref", ref: "wechatUser" + }, + router: { + type: "object" } }, actionType: "crud", diff --git a/lib/oak-app-domain/WechatLogin/_baseSchema.d.ts b/lib/oak-app-domain/WechatLogin/_baseSchema.d.ts index d0feaadad..4c77b8436 100644 --- a/lib/oak-app-domain/WechatLogin/_baseSchema.d.ts +++ b/lib/oak-app-domain/WechatLogin/_baseSchema.d.ts @@ -1,9 +1,14 @@ -import { ForeignKey } from "oak-domain/lib/types/DataType"; -import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; +import { ForeignKey, JsonProjection } from "oak-domain/lib/types/DataType"; +import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey, JsonFilter } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { Action, ParticularAction } from "./Action"; import { Boolean, Text, Datetime } from "oak-domain/lib/types/DataType"; import { QrCodeType } from "../../types/Config"; +type Router = { + pathname: string; + props?: Record; + state?: Record; +}; export type OpSchema = EntityShape & { userId?: ForeignKey<"user"> | null; type: "bind" | "login"; @@ -13,6 +18,7 @@ export type OpSchema = EntityShape & { expiresAt?: Datetime | null; expired?: Boolean | null; wechatUserId?: ForeignKey<"wechatUser"> | null; + router?: Router | null; } & { [A in ExpressionKey]?: any; }; @@ -30,6 +36,7 @@ export type OpFilter = { expiresAt: Q_DateValue; expired: Q_BooleanValue; wechatUserId: Q_StringValue; + router: JsonFilter; } & ExprOp; export type OpProjection = { "#id"?: NodeId; @@ -46,6 +53,7 @@ export type OpProjection = { expiresAt?: number; expired?: number; wechatUserId?: number; + router?: number | JsonProjection; } & Partial>; export type OpSortAttr = Partial<{ id: number; @@ -60,7 +68,9 @@ export type OpSortAttr = Partial<{ expiresAt: number; expired: number; wechatUserId: number; + router: number; [k: string]: any; } | ExprOp>; export type OpAction = OakMakeAction; export type OpUpdateAction = "update" | ParticularAction | string; +export {}; diff --git a/lib/oak-app-domain/WechatLogin/locales/zh_CN.json b/lib/oak-app-domain/WechatLogin/locales/zh_CN.json index c20f44619..b5f8b0a14 100644 --- a/lib/oak-app-domain/WechatLogin/locales/zh_CN.json +++ b/lib/oak-app-domain/WechatLogin/locales/zh_CN.json @@ -10,7 +10,8 @@ "expiresAt": "过期时间", "qrCodeType": "二维码类型", "tokens": "相关令牌", - "wechatUser": "微信用户" + "wechatUser": "微信用户", + "router": "目标路由" }, "action": { "success": "成功" diff --git a/lib/triggers/index.d.ts b/lib/triggers/index.d.ts index e5cf26df7..551febe7a 100644 --- a/lib/triggers/index.d.ts +++ b/lib/triggers/index.d.ts @@ -1,2 +1,2 @@ -declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[]; +declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[]; export default _default; diff --git a/lib/triggers/wechatLogin.js b/lib/triggers/wechatLogin.js index 806d4ad66..33a771e69 100644 --- a/lib/triggers/wechatLogin.js +++ b/lib/triggers/wechatLogin.js @@ -11,7 +11,8 @@ const triggers = [ fn: async ({ operation }, context, params) => { const { data, filter } = operation; const fn = async (wechatLoginData) => { - const { id } = wechatLoginData; + const { id, router } = wechatLoginData; + (0, assert_1.assert)(router?.pathname, 'wechatLogin必须指定router pathname'); Object.assign(wechatLoginData, { expired: false, successed: false, @@ -30,7 +31,7 @@ const triggers = [ entity: 'wechatLogin', entityId: id, props: { - pathname: '/wechatLogin/confirm', + pathname: router?.pathname, props: { oakId: id, }, diff --git a/lib/utils/email/index.d.ts b/lib/utils/email/index.d.ts index eb86950e8..5a3295714 100644 --- a/lib/utils/email/index.d.ts +++ b/lib/utils/email/index.d.ts @@ -10,5 +10,5 @@ export declare function getEmail(origin: string): Email(options: EmailOptions, context: BRC): Promise<{ success: boolean; - error?: string; + error?: string | undefined; }>; diff --git a/lib/utils/oauth/index.d.ts b/lib/utils/oauth/index.d.ts index 51da6fd52..5631b6123 100644 --- a/lib/utils/oauth/index.d.ts +++ b/lib/utils/oauth/index.d.ts @@ -10,8 +10,8 @@ type UserID = { avatarUrl: string | null; }; export type UserInfoHandler = (data: UserInfo) => UserID | Promise; -export declare const registerOauthUserinfoHandler: (type: EntityDict["oauthProvider"]["Schema"]["type"], handler: UserInfoHandler) => void; -export declare const processUserInfo: (type: EntityDict["oauthProvider"]["Schema"]["type"], data: UserInfo) => UserID | Promise; +export declare const registerOauthUserinfoHandler: (type: EntityDict['oauthProvider']['Schema']['type'], handler: UserInfoHandler) => void; +export declare const processUserInfo: (type: EntityDict['oauthProvider']['Schema']['type'], data: UserInfo) => UserID | Promise; export declare function checkOauthTokenAvaliable(context: BackendRuntimeContext, token: string | undefined): Promise<{ error: string | null; statusCode?: number; diff --git a/lib/utils/oauth/index.js b/lib/utils/oauth/index.js index 3aaf3b1ab..bdc0f28af 100644 --- a/lib/utils/oauth/index.js +++ b/lib/utils/oauth/index.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.processUserInfo = exports.registerOauthUserinfoHandler = void 0; -exports.checkOauthTokenAvaliable = checkOauthTokenAvaliable; +exports.checkOauthTokenAvaliable = exports.processUserInfo = exports.registerOauthUserinfoHandler = void 0; const uuid_1 = require("oak-domain/lib/utils/uuid"); const Projection_1 = require("../../types/Projection"); const handler_1 = require("./handler"); @@ -99,3 +98,4 @@ async function checkOauthTokenAvaliable(context, token) { }, {}); return { error: null, tokenRecord }; } +exports.checkOauthTokenAvaliable = checkOauthTokenAvaliable; diff --git a/src/aspects/AspectDict.ts b/src/aspects/AspectDict.ts index b2df4e8d4..313b91f8c 100644 --- a/src/aspects/AspectDict.ts +++ b/src/aspects/AspectDict.ts @@ -405,12 +405,14 @@ export type AspectDict = { * 创建微信登录会话(用于扫码登录场景) * @param type 登录类型(login-登录,bind-绑定) * @param interval 会话有效期(毫秒) + * @param router 扫码目标路由 * @returns 返回登录会话 ID */ createWechatLogin: ( params: { type: EntityDict['wechatLogin']['Schema']['type']; interval: number; + router: EntityDict['wechatLogin']['Schema']['router']; }, context: BackendRuntimeContext ) => Promise; diff --git a/src/aspects/token.ts b/src/aspects/token.ts index d52fcc55a..a92f60848 100644 --- a/src/aspects/token.ts +++ b/src/aspects/token.ts @@ -2150,7 +2150,6 @@ async function loginFromWechatEnv( const createWechatUserAndReturnTokenId = async ( user?: EntityDict['user']['Schema'], - wechatLoginId?: string, ) => { const wechatUserCreateData: CreateWechatUser = { id: await generateNewIdAsync(), @@ -2160,27 +2159,15 @@ async function loginFromWechatEnv( applicationId: application!.id!, ...wechatUserData, }; - - let tokenValue; - if (wechatLoginId) { - tokenValue = await setUpTokenAndUser( - env, - context, - 'wechatLogin', - wechatLoginId, - undefined, - user - ); - } else { - tokenValue = await setUpTokenAndUser( - env, - context, - 'wechatUser', - undefined, - wechatUserCreateData, - user, - ) - } + + const tokenValue = await setUpTokenAndUser( + env, + context, + 'wechatUser', + undefined, + wechatUserCreateData, + user, + ) return { tokenValue, wechatUserId: wechatUserCreateData.id }; }; @@ -2311,13 +2298,13 @@ async function loginFromWechatEnv( undefined, wechatLoginData.user! ); - await updateWechatLogin({ successed: true }); + await updateWechatLogin({ successed: true, wechatUserId: wechatUser.id }); return tokenValue; } else { - const { tokenValue } = await createWechatUserAndReturnTokenId( + const { tokenValue, wechatUserId } = await createWechatUserAndReturnTokenId( wechatLoginData.user!, ); - await updateWechatLogin({ successed: true }); + await updateWechatLogin({ successed: true, wechatUserId }); return tokenValue; } } @@ -2386,6 +2373,7 @@ async function loginFromWechatEnv( await updateWechatLogin({ userId: wechatUser.userId, successed: true, + wechatUserId: wechatUser.id, }); return tokenValue; } else { @@ -2406,7 +2394,6 @@ async function loginFromWechatEnv( ); const { tokenValue, wechatUserId } = await createWechatUserAndReturnTokenId( userData as EntityDict['user']['Schema'], - wechatLoginId, ); await updateWechatLogin({ userId, wechatUserId, successed: true }); return tokenValue; @@ -2542,7 +2529,8 @@ async function loginFromWechatEnv( } // 到这里都是要同时创建wechatUser和user对象了 - return (await createWechatUserAndReturnTokenId()).tokenValue; + const { tokenValue } = await createWechatUserAndReturnTokenId(); + return tokenValue; } /** @@ -2597,21 +2585,6 @@ export async function loginWechat( await context.setTokenValue(tokenValue); if (tokenInfo.entity === 'wechatUser') { await tryRefreshWechatPublicUserInfo(tokenInfo.entityId!, context); - } else if (tokenInfo.entity === 'wechatLogin') { - const [wechatLogin] = await context.select('wechatLogin', - { - data: { - id: 1, - wechatUserId: 1, - }, - filter: { - id: tokenInfo.entityId, - }, - }, - {} - ) - assert(wechatLogin?.wechatUserId); - await tryRefreshWechatPublicUserInfo(wechatLogin.wechatUserId, context); } closeRootMode(); diff --git a/src/aspects/wechatLogin.ts b/src/aspects/wechatLogin.ts index b8ecb8b1b..0f2ae9688 100644 --- a/src/aspects/wechatLogin.ts +++ b/src/aspects/wechatLogin.ts @@ -8,34 +8,49 @@ export async function createWechatLogin( params: { type: EntityDict['wechatLogin']['Schema']['type']; interval: number; + router: EntityDict['wechatLogin']['Schema']['router']; }, context: BRC ) { - const { type, interval } = params; + const { type, interval, router } = params; let userId; if (type === 'bind') { userId = context.getCurrentUserId(); } const id = await generateNewIdAsync(); - const createData = { + let _router = router; + // router为空则默认为/wechatLogin/confirm + if (!router) { + _router = { + pathname: '/wechatLogin/confirm', + props: { + oakId: id, + }, + } + } + else { + _router!.props = { + oakId: id, + } + } + const createData: createWechatLoginData = { id, type, expiresAt: Date.now() + interval, expired: false, qrCodeType: 'wechatPublic', successed: false, + router: _router, }; if (userId) { - Object.assign(createData, { - userId, - }) + createData.userId = userId; } if (type === 'login') { const closeRoot = context.openRootMode(); await context.operate('wechatLogin', { id: await generateNewIdAsync(), action: 'create', - data: createData as createWechatLoginData, + data: createData, }, { dontCollect: true, }); @@ -44,7 +59,7 @@ export async function createWechatLogin( await context.operate('wechatLogin', { id: await generateNewIdAsync(), action: 'create', - data: createData as createWechatLoginData, + data: createData, }, { dontCollect: true, }); diff --git a/src/components/wechatLogin/confirm/index.ts b/src/components/wechatLogin/confirm/index.ts index 624812eb3..19cb2e480 100644 --- a/src/components/wechatLogin/confirm/index.ts +++ b/src/components/wechatLogin/confirm/index.ts @@ -12,6 +12,10 @@ export default OakComponent({ successed: 1, }, isList: false, + properties: { + wechatLoginResultPage: '/wechatLogin/confirm', // wechatLogin 结果页面,默认使用wechatLogin 确认页面 + wechatUserLoginPage: '/wechatUser/login', + }, formData({ data: wechatLogin, features }) { const loginUserId = features.token.getUserId(true); const user = wechatLogin?.user; @@ -30,25 +34,16 @@ export default OakComponent({ appId, }; }, - listeners: {}, methods: { getCodeAndRedirect() { - const state = encodeURIComponent(`/wechatLogin/confirm?oakId=${this.props.oakId}`); - // if (process.env.NODE_ENV === 'development') { - // this.navigateTo( - // { - // url: '/wechatUser/login', - // wechatLoginId: this.props.oakId, - // code: `CODE_${Math.random()}`, - // state, - // }, - // ); - // } - // else { - const { appId } = this.state; - const redirectUrl = `https%3A%2F%2F${window.location.host}%2FwechatUser%2Flogin%3FwechatLoginId%3D${this.props.oakId}`; //网址转义 `https://${window.location.host}/wechatUser/login?wechatLoginId=${this.props.oakId}` - window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect` - // } + const { wechatLoginConfirmPage, wechatUserLoginPage } = this.props; + const wechatLoginId = this.props.oakId; + const state = encodeURIComponent(`${wechatLoginConfirmPage}?oakId=${wechatLoginId}`); + const { appId } = this.state; + const host = window.location.host; + const protocol = window.location.protocol === 'https:' ? 'https' : 'http'; + const redirectUri = encodeURIComponent(`${protocol}://${host}${wechatUserLoginPage}?wechatLoginId=${wechatLoginId}`); + window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect` } }, }); diff --git a/src/components/wechatLogin/qrCode/index.ts b/src/components/wechatLogin/qrCode/index.ts index 9131480ef..16f7f4ea8 100644 --- a/src/components/wechatLogin/qrCode/index.ts +++ b/src/components/wechatLogin/qrCode/index.ts @@ -30,17 +30,22 @@ export default OakComponent({ }, properties: { type: 'bind' as EntityDict['wechatLogin']['Schema']['type'], - url: '', + url: '', // 扫码登录/绑定成功跳转的页面 size: undefined, + disableBack: false, // 扫码登录/绑定成功后 是否禁用返回 + wechatLoginConfirmPage: '/wechatLogin/confirm' }, methods: { async createWechatLogin() { - const { type = 'bind' } = this.props; + const { type = 'bind', wechatLoginConfirmPage } = this.props; const { result: wechatLoginId } = await this.features.cache.exec( 'createWechatLogin', { type, interval: Interval, + router: { + pathname: wechatLoginConfirmPage + } } ); this.setState( @@ -128,6 +133,7 @@ export default OakComponent({ }, // 每秒调取下面方法,监听用户是否已在微信端授权登录或绑定 async getWechatLogin2() { + const { url, disableBack } = this.props; const { wechatLoginId } = this.state; const { data: [wechatLogin], @@ -153,19 +159,25 @@ export default OakComponent({ type, }, async () => { - // 未登录的情况下才走这里 - if (successed && type === 'login') { - await this.features.token.loginByWechatInWebEnv( - wechatLoginId - ); - const { url } = this.props; + // 登录/绑定的情况下才走这里 + if (successed) { + if (type === 'login') { + await this.features.token.loginByWechatInWebEnv( + wechatLoginId + ); + } + + // url存在则跳转 if (url) { this.redirectTo({ url: url, }); return; } - this.navigateBack(); + // 登录成功且没有url则返回 + if (!disableBack) { + this.navigateBack(); + } } } ); diff --git a/src/components/wechatQrCode/scan/index.ts b/src/components/wechatQrCode/scan/index.ts index e83b49cb7..821a87b2a 100644 --- a/src/components/wechatQrCode/scan/index.ts +++ b/src/components/wechatQrCode/scan/index.ts @@ -87,8 +87,7 @@ export default OakComponent({ if (!wechatQrCode.expired) { const { props = {}, state = {}, pathname } = wechatQrCode!.props!; - const url = - pathname.substring(0, 1) === '/' ? pathname : `/${pathname}`; + const url = pathname.substring(0, 1) === '/' ? pathname : `/${pathname}`; this.redirectTo( { diff --git a/src/endpoints/wechat.ts b/src/endpoints/wechat.ts index 5fcba2e97..2e88d0173 100644 --- a/src/endpoints/wechat.ts +++ b/src/endpoints/wechat.ts @@ -436,7 +436,7 @@ async function setUserSubscribed( } ) - const title = type === 'bind' ? '扫码绑定' : '扫码登录'; + const title = type === 'bind' ? '立即绑定' : '立即登录'; const description = type === 'bind' ? '去绑定' : '去登录'; if (!expired) { wechatInstance.sendServeMessage({ @@ -462,9 +462,7 @@ async function setUserSubscribed( } } } else { - console.warn( - `线上有扫描二维码场景值,但找不到对应的qrCode,eventKey是${eventKey}` - ); + console.warn(`线上有扫描二维码场景值,但找不到对应的qrCode,eventKey是${eventKey}`); } } await doUpdate(); diff --git a/src/entities/WechatLogin.ts b/src/entities/WechatLogin.ts index 0c724e3f4..50a9fb3dc 100644 --- a/src/entities/WechatLogin.ts +++ b/src/entities/WechatLogin.ts @@ -7,6 +7,12 @@ import { EntityDesc } from 'oak-domain/lib/types/EntityDesc'; import { Schema as Token } from './Token'; import { Schema as WechatUser } from './WechatUser'; +type Router = { + pathname: string; + props?: Record; + state?: Record; +}; + export interface Schema extends EntityShape { user?: User; type: 'bind' | 'login'; @@ -18,6 +24,7 @@ export interface Schema extends EntityShape { codes: Array; tokens?: Array; wechatUser?: WechatUser; + router?: Router; } export type Action = 'success'; @@ -46,6 +53,7 @@ export const entityDesc: EntityDesc< qrCodeType: '二维码类型', tokens: '相关令牌', wechatUser: '微信用户', + router: '目标路由', }, action: { success: '成功', diff --git a/src/triggers/wechatLogin.ts b/src/triggers/wechatLogin.ts index 76988b134..3ddbb12a3 100644 --- a/src/triggers/wechatLogin.ts +++ b/src/triggers/wechatLogin.ts @@ -15,7 +15,8 @@ const triggers: Trigger>[] = [ fn: async ({ operation }, context, params) => { const { data, filter } = operation; const fn = async (wechatLoginData: CreateWechatLoginData) => { - const { id } = wechatLoginData; + const { id, router } = wechatLoginData; + assert(router?.pathname, 'wechatLogin必须指定router pathname'); Object.assign(wechatLoginData, { expired: false, @@ -37,7 +38,7 @@ const triggers: Trigger>[] = [ entity: 'wechatLogin', entityId: id, props: { - pathname: '/wechatLogin/confirm', + pathname: router?.pathname!, props: { oakId: id, }, diff --git a/upgrade/5.10.9/01.sql b/upgrade/5.10.9/01.sql new file mode 100644 index 000000000..b97178c4f --- /dev/null +++ b/upgrade/5.10.9/01.sql @@ -0,0 +1,2 @@ + +alter table wechatLogin add router json default null; \ No newline at end of file