feat:1、weichatLogin实体增加router,表示扫码跳转的目标路由, 通过aspect默认传入wechatLogin/confirm;2、修正微信公众号扫码登录和绑定时,createWechatUserAndReturnTokenId不需要传入wechatLoginId

This commit is contained in:
wkj 2025-12-25 14:57:32 +08:00
parent 4227430080
commit ffcac7f843
131 changed files with 468 additions and 347 deletions

View File

@ -292,11 +292,13 @@ export type AspectDict<ED extends EntityDict> = {
*
* @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<ED>) => Promise<string>;
/**
*

View File

@ -19,6 +19,6 @@ export declare function syncWechatTemplate<ED extends EntityDict>(params: {
example: string;
keywordEnumValueList: {
keywordCode: string;
enumValueList: Array<string>;
enumValueList: string[];
}[];
}[]>;

View File

@ -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;

View File

@ -3,4 +3,5 @@ import { BRC } from '../types/RuntimeCxt';
export declare function createWechatLogin<ED extends EntityDict>(params: {
type: EntityDict['wechatLogin']['Schema']['type'];
interval: number;
router: EntityDict['wechatLogin']['Schema']['router'];
}, context: BRC<ED>): Promise<string>;

View File

@ -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();

View File

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

View File

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

View File

@ -1,3 +1,4 @@
/// <reference types="@uiw/react-amap-types" />
import React from 'react';
export type PositionProps = {
loadUI: boolean;

View File

@ -1,3 +1,4 @@
/// <reference types="@uiw/react-amap-types" />
import React from 'react';
import { ModalProps } from 'antd';
import { GeolocationProps } from '@uiw/react-amap';

View File

@ -1,3 +1,4 @@
/// <reference types="@uiw/react-amap-types" />
import React from 'react';
import { MapProps, APILoaderConfig } from '@uiw/react-amap';
import './index.less';

View File

@ -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<EntityDict, keyof EntityDict, false, {
currentConfig: EntityDict["application"]["OpSchema"]["config"];
currentConfig: EntityDict['application']['OpSchema']['config'];
dirty: boolean;
entity: string;
name: string;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,13 @@
/// <reference types="react" />
import { EntityDict } from "../../../oak-app-domain";
import { GenerateUrlFn } from "../../../types/Article";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, keyof EntityDict, false, {
entity: string;
entityId: string;
title: string;
origin: null | EntityDict["extraFile"]["Schema"]["origin"];
menuEmpty: React.ReactNode | undefined;
articleEmpty: React.ReactNode | undefined;
origin: import("../../../types/Config").CosOrigin | null;
menuEmpty: import("react").ReactNode;
articleEmpty: import("react").ReactNode;
generateUrl: GenerateUrlFn;
}>) => React.ReactElement;
export default _default;

View File

@ -1,13 +1,14 @@
/// <reference types="react" />
import { GenerateUrlFn } from "../../../types/Article";
import { EntityDict } from "../../../oak-app-domain";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "articleMenu", true, {
entity: string;
entityId: string;
parentId: string | undefined;
origin: EntityDict["extraFile"]["Schema"]["origin"] | null;
origin: import("../../../types/Config").CosOrigin | null;
onMenuClick: (menuId: string, menuName: string, isArticle: boolean) => void;
onArticleClick: (atricleId: string) => void;
empty: React.ReactNode | undefined;
empty: import("react").ReactNode;
changeAddArticle: (show: boolean) => void;
generateUrl: GenerateUrlFn;
}>) => React.ReactElement;

View File

@ -3,7 +3,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
onRemove: () => void;
onUpdateName: (name: string) => Promise<void>;
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;

View File

@ -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;

View File

@ -2,7 +2,7 @@ import { EntityDict } from "../../../oak-app-domain/EntityDict";
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "articleMenu", true, {
entity: string;
entityId: string;
show: "edit" | "doc" | "preview";
show: "preview" | "doc" | "edit";
articleMenuId: string;
articleId: string;
tocPosition: "none" | "left" | "right";
@ -13,7 +13,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
onArticlePreview: (content?: string, title?: string) => 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;

View File

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

View File

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

View File

@ -1,3 +1,4 @@
/// <reference types="node" />
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<void>;
var onDownload: (data: ArrayBuffer | ReadableStream<any>, filename: string) => Promise<void>;
var base64ToBlob: (base64String: string) => Blob;
var arrayBufferToBase64: (buffer: Buffer) => string;
var base64ToArrayBuffer: (base64String: string) => ArrayBuffer;
var base64ToArrayBuffer: (base64String: string) => ArrayBufferLike;
}
export default Download;

View File

@ -4,8 +4,8 @@ import { ReactComponentProps } from 'oak-frontend-base';
import { ECode } from '../../../types/ErrorPage';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
code: ECode;
title?: string;
desc?: string;
title?: string | undefined;
desc?: string | undefined;
children?: React.ReactNode;
icon?: React.ReactNode;
}>) => React.ReactElement;

View File

@ -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: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
filename?: string;
expiresAt?: number;
filename?: string | undefined;
expiresAt?: number | undefined;
tips?: React.ReactNode;
onDownload?: (qrCodeImage: string, filename?: string) => 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;

View File

@ -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;

View File

@ -1,7 +1,7 @@
import { Style } from '../../../../types/Style';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../../oak-app-domain").EntityDict, keyof import("../../../../oak-app-domain").EntityDict, false, {
style: Style;
entity: "system" | "platform" | "application";
entity: "platform" | "application" | "system";
entityId: string;
name: string;
}>) => React.ReactElement;

View File

@ -1,7 +1,7 @@
import { Config } from '../../../types/Config';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, false, {
config: Config;
entity: "system" | "platform";
entity: "platform" | "system";
name: string;
entityId: string;
}>) => React.ReactElement;

View File

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

View File

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

View File

@ -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;

View File

@ -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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,13 +5,13 @@ declare const Authorize: (props: WebComponentProps<EntityDict, keyof EntityDict,
loading: boolean;
hasError: boolean;
errorMsg: string;
userInfo: EntityDict["token"]["Schema"]["user"] | null;
userInfo: EntityDict['token']['Schema']['user'] | null;
response_type: string;
client_id: string;
redirect_uri: string;
scope: string;
state: string;
clientInfo: EntityDict["oauthApplication"]["Schema"] | null;
clientInfo: EntityDict['oauthApplication']['Schema'] | null;
name: string;
nickname: string;
mobile: string;

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import { EntityDict } from '../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "messageTypeSmsTemplate", true, {
systemId: string;
origin: EntityDict["smsTemplate"]["Schema"]["origin"];
origin: import("../../../oak-app-domain/SmsTemplate/_baseSchema").Origin;
}>) => React.ReactElement;
export default _default;

View File

@ -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;

View File

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

View File

@ -1,6 +1,6 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, false, {
shape: string;
size: number | string;
size: string | number;
iconColor: string;
iconName: string;
}>) => React.ReactElement;

View File

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

View File

@ -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,
},

View File

@ -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<EntityDict, "oauthApplication", false, {
item: RowWithActions<EntityDict, "oauthApplication">;
item: RowWithActions<EntityDict, 'oauthApplication'>;
clientSecret: string;
isCreation: boolean;
open: boolean;

View File

@ -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<EntityDict, "oauthApplication", true, {
list: RowWithActions<EntityDict, "oauthApplication">[];
declare const OauthProvider: (props: WebComponentProps<EntityDict, 'oauthApplication', true, {
list: RowWithActions<EntityDict, 'oauthApplication'>[];
systemId: string;
}>) => React.JSX.Element;
export default OauthProvider;

View File

@ -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<EntityDict, "oauthProvider", false, {
item: RowWithActions<EntityDict, "oauthProvider">;
item: RowWithActions<EntityDict, 'oauthProvider'>;
open: boolean;
onCancel: () => void;
onOk: () => void;

View File

@ -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<EntityDict, "oauthProvider", true, {
list: RowWithActions<EntityDict, "oauthProvider">[];
declare const OauthProvider: (props: WebComponentProps<EntityDict, 'oauthProvider', true, {
list: RowWithActions<EntityDict, 'oauthProvider'>[];
systemId: string;
}>) => React.JSX.Element;
export default OauthProvider;

View File

@ -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<EntityDict, "oauthUserAuthorization", true, {
list: RowWithActions<EntityDict, "oauthUserAuthorization">[];
list: RowWithActions<EntityDict, 'oauthUserAuthorization'>[];
}, {
revoke: (item: RowWithActions<EntityDict, "oauthUserAuthorization">) => void;
revoke: (item: RowWithActions<EntityDict, 'oauthUserAuthorization'>) => void;
}>) => React.JSX.Element;
export default Records;

View File

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

View File

@ -5,7 +5,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
entity: keyof ED2;
entityId: string;
relation: string;
redirectTo: EntityDict["parasite"]["Schema"]["redirectTo"];
redirectTo: EntityDict['parasite']['Schema']['redirectTo'];
multiple: boolean;
nameLabel: string;
nameRequired: boolean;

View File

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

View File

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

View File

@ -1,7 +1,7 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, false, {
sessionId: string;
isEntity: boolean;
entityDisplay: (data: any) => Array<any>;
entityDisplay: (data: any) => any[];
entityProjection: any;
}>) => React.ReactElement;
export default _default;

View File

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

View File

@ -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<EntityDict, "session">[]) => Array<any>;
entityDisplay: (data: EntityDict['session']['Schema'][] | RowWithActions<EntityDict, 'session'>[]) => any[];
entityProjection: any;
sessionId: string;
dialog: boolean;
onItemClick: ((sessionId: string) => {}) | undefined | null;
onItemClick: ((sessionId: string) => {}) | null | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -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<EntityDict, "session">[]) => Array<any>;
entityDisplay: (data: EntityDict['session']['Schema'][] | RowWithActions<EntityDict, 'session'>[]) => any[];
entityProjection: any;
}>) => React.ReactElement;
export default _default;

View File

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

View File

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

View File

@ -1,5 +1,5 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, true, {
areaId: string | undefined | null;
areaId: string | null | undefined;
onCancel: (() => void) | undefined;
onConfirm: ((stationIds: string[]) => void) | undefined;
selectIds: string[] | undefined;

View File

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

View File

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

View File

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

View File

@ -1,8 +1,9 @@
/// <reference types="react" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "token", true, {
onMyInfoClicked: () => void;
myInfoUrl: string;
manageUserUrl: string;
loginUrl: string;
Body: React.ReactNode | undefined;
Body: import("react").ReactNode;
}>) => React.ReactElement;
export default _default;

View File

@ -1,6 +1,6 @@
import { EntityDict } from '../../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "extraFile", true, {
origin: EntityDict["extraFile"]["Schema"]["origin"] | null;
origin: import("../../../../types/Config").CosOrigin | null;
idCardType: string;
entityId: string;
entity: string;

View File

@ -1,6 +1,6 @@
import { EntityDict } from '../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "user", false, {
origin: EntityDict["extraFile"]["Schema"]["origin"] | null;
origin: import("../../../types/Config").CosOrigin | null;
autoUpload: boolean;
onFinish: (() => void) | undefined;
needUploadPhotos: boolean;

View File

@ -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 }) {

View File

@ -1,4 +1,4 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../../oak-app-domain").EntityDict, keyof import("../../../../oak-app-domain").EntityDict, boolean, {
onVerified: undefined | (() => void);
onVerified: (() => void) | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -1,3 +1,4 @@
/// <reference types="react" />
import { WebComponentProps } from "oak-frontend-base";
import { EntityDict } from "../../../../oak-app-domain";
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {

View File

@ -1,3 +1,4 @@
/// <reference types="react" />
import { WebComponentProps } from "oak-frontend-base";
import { EntityDict } from "../../../../oak-app-domain";
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {

View File

@ -1,20 +1,20 @@
import { EntityDict } from '../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "userEntityGrant", false, {
picker: ((props: {
disabled?: boolean;
disabled?: boolean | undefined;
entity: keyof EntityDict;
entityFilter: object;
relationIds: string[];
rule: EntityDict["userEntityGrant"]["OpSchema"]["rule"];
ruleOnRow: EntityDict["userEntityGrant"]["OpSchema"]["ruleOnRow"];
rule: EntityDict['userEntityGrant']['OpSchema']['rule'];
ruleOnRow: EntityDict['userEntityGrant']['OpSchema']['ruleOnRow'];
onPickRelations: (ids: string[]) => 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;

View File

@ -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;

View File

@ -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;

View File

@ -4,9 +4,9 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
entity: keyof ED2;
entityId: string;
relations: EntityDict["relation"]["OpSchema"][];
passwordRequired?: boolean;
allowUpdateName?: boolean;
allowUpdateNickname?: boolean;
relations: EntityDict['relation']['OpSchema'][];
passwordRequired?: boolean | undefined;
allowUpdateName?: boolean | undefined;
allowUpdateNickname?: boolean | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -4,7 +4,7 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
entity: keyof ED2;
entityId: string;
allowUpdateName?: boolean;
allowUpdateNickname?: boolean;
allowUpdateName?: boolean | undefined;
allowUpdateNickname?: boolean | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -7,12 +7,12 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
entityId: string;
redirectToAfterConfirm: ED2["userEntityGrant"]["Schema"]["redirectTo"];
qrCodeType: QrCodeType;
type: EntityDict["userEntityGrant"]["Schema"]["type"];
relations: EntityDict["relation"]["OpSchema"][];
type: EntityDict['userEntityGrant']['Schema']['type'];
relations: EntityDict['relation']['OpSchema'][];
claimUrl: string;
multiple: boolean;
rule: EntityDict["userEntityGrant"]["Schema"]["rule"];
ruleOnRow: EntityDict["userEntityGrant"]["OpSchema"]["ruleOnRow"];
onUserEntityGrantCreated?: (id: string) => void;
rule: EntityDict['userEntityGrant']['Schema']['rule'];
ruleOnRow: EntityDict['userEntityGrant']['OpSchema']['ruleOnRow'];
onUserEntityGrantCreated?: ((id: string) => void) | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -7,8 +7,8 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
redirectToAfterConfirm: ED2["userEntityGrant"]["Schema"]["redirectTo"];
claimUrl: string;
qrCodeType: string;
passwordRequired?: boolean;
disabledMethods: Array<"email" | "mobile" | "userEntityGrant">;
mode: "byMobile" | "byUserEntityGrant" | "byEmail";
passwordRequired?: boolean | undefined;
disabledMethods: Array<'email' | 'mobile' | 'userEntityGrant'>;
mode: 'byMobile' | 'byUserEntityGrant' | 'byEmail';
}>) => React.ReactElement;
export default _default;

View File

@ -2,7 +2,7 @@ import { EntityDict } from '../../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "user", false, {
entity: keyof EntityDict;
entityId: string;
relations: EntityDict["relation"]["OpSchema"][];
relations: import("../../../../oak-app-domain/Relation/_baseSchema").OpSchema[];
mobile: string;
setPasswordConfirm: (value: boolean) => void;
passwordRequired: boolean;

View File

@ -2,6 +2,6 @@ import { EntityDict } from '../../../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "userRelation", true, {
entity: keyof EntityDict;
entityId: string;
relations: EntityDict["relation"]["OpSchema"][];
relations: import("../../../../../oak-app-domain/Relation/_baseSchema").OpSchema[];
}>) => React.ReactElement;
export default _default;

View File

@ -1,2 +1,5 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "wechatLogin", false, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "wechatLogin", false, {
wechatLoginResultPage: string;
wechatUserLoginPage: string;
}>) => React.ReactElement;
export default _default;

View File

@ -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`;
}
},
});

View File

@ -1,7 +1,9 @@
import { EntityDict } from '../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, keyof EntityDict, false, {
type: EntityDict["wechatLogin"]["Schema"]["type"];
type: "bind" | "login";
url: string;
size: undefined;
disableBack: boolean;
wechatLoginConfirmPage: string;
}>) => React.ReactElement;
export default _default;

View File

@ -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();
}
}
});
},

View File

@ -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;

View File

@ -1,3 +1,4 @@
/// <reference types="wechat-miniprogram" />
import { EntityDict } from '../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "wechatUser", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
export default _default;

View File

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

View File

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

View File

@ -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({

View File

@ -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<string, any>;
state?: Record<string, any>;
};
export interface Schema extends EntityShape {
user?: User;
type: 'bind' | 'login';
@ -17,9 +22,11 @@ export interface Schema extends EntityShape {
codes: Array<WechatQrCode>;
tokens?: Array<Token>;
wechatUser?: WechatUser;
router?: Router;
}
export type Action = 'success';
export declare const entityDesc: EntityDesc<Schema, Action, '', {
type: Schema['type'];
qrCodeType: QrCodeType;
}>;
export {};

View File

@ -13,6 +13,7 @@ export const entityDesc = {
qrCodeType: '二维码类型',
tokens: '相关令牌',
wechatUser: '微信用户',
router: '目标路由',
},
action: {
success: '成功',

View File

@ -31,6 +31,9 @@ export const desc = {
wechatUserId: {
type: "ref",
ref: "wechatUser"
},
router: {
type: "object"
}
},
actionType: "crud",

View File

@ -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<string, any>;
state?: Record<string, any>;
};
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<Router>;
} & ExprOp<OpAttr | string>;
export type OpProjection = {
"#id"?: NodeId;
@ -46,6 +53,7 @@ export type OpProjection = {
expiresAt?: number;
expired?: number;
wechatUserId?: number;
router?: number | JsonProjection<Router>;
} & Partial<ExprOp<OpAttr | string>>;
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<OpAttr | string>>;
export type OpAction = OakMakeAction<Action | string>;
export type OpUpdateAction = "update" | ParticularAction | string;
export {};

View File

@ -10,7 +10,8 @@
"expiresAt": "过期时间",
"qrCodeType": "二维码类型",
"tokens": "相关令牌",
"wechatUser": "微信用户"
"wechatUser": "微信用户",
"router": "目标路由"
},
"action": {
"success": "成功"

Some files were not shown because too many files have changed in this diff Show More