login去掉了navigate的代码
This commit is contained in:
parent
bacd91f0a9
commit
fa7ff9ceba
|
|
@ -1,2 +1,2 @@
|
|||
declare const checkers: (import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "mobile", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "token", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "message", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "parasite", import("..").RuntimeCxt>)[];
|
||||
declare const checkers: (import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "token", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "mobile", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "message", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "parasite", import("..").RuntimeCxt>)[];
|
||||
export default checkers;
|
||||
|
|
|
|||
|
|
@ -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: "application" | "platform" | "system";
|
||||
entity: "application" | "system" | "platform";
|
||||
entityId: string;
|
||||
name: string;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
|
|
|
|||
|
|
@ -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: "platform" | "system";
|
||||
entity: "system" | "platform";
|
||||
name: string;
|
||||
entityId: string;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
|
|
|
|||
|
|
@ -12,19 +12,19 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
type?: ButtonProps['type'] | AmButtonProps['type'];
|
||||
executeText?: string | undefined;
|
||||
buttonProps?: (ButtonProps & {
|
||||
color?: "success" | "default" | "warning" | "primary" | "danger" | undefined;
|
||||
color?: "primary" | "success" | "warning" | "default" | "danger" | undefined;
|
||||
fill?: "none" | "solid" | "outline" | undefined;
|
||||
size?: "small" | "middle" | "large" | "mini" | undefined;
|
||||
size?: "small" | "large" | "middle" | "mini" | undefined;
|
||||
block?: boolean | undefined;
|
||||
loading?: boolean | "auto" | undefined;
|
||||
loadingText?: string | undefined;
|
||||
loadingIcon?: import("react").ReactNode;
|
||||
disabled?: boolean | undefined;
|
||||
onClick?: ((event: import("react").MouseEvent<HTMLButtonElement, MouseEvent>) => unknown) | undefined;
|
||||
type?: "button" | "reset" | "submit" | undefined;
|
||||
type?: "button" | "submit" | "reset" | undefined;
|
||||
shape?: "default" | "rounded" | "rectangular" | undefined;
|
||||
children?: import("react").ReactNode;
|
||||
} & Pick<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, "id" | "onMouseDown" | "onMouseUp" | "onTouchStart" | "onTouchEnd"> & {
|
||||
} & Pick<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, "id" | "onMouseUp" | "onMouseDown" | "onTouchStart" | "onTouchEnd"> & {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,5 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
onlyPassword: boolean;
|
||||
disabled: string;
|
||||
redirectUri: string;
|
||||
url: string;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ export default OakComponent({
|
|||
onlyCaptcha: false,
|
||||
onlyPassword: false,
|
||||
disabled: '',
|
||||
redirectUri: '',
|
||||
url: '', // 登录成功后redirectTo的页面,不配置的话就认为是goBack
|
||||
redirectUri: '', // 微信登录后的redirectUri,要指向wechatUser/login去处理
|
||||
},
|
||||
formData({ features, props }) {
|
||||
const { lastSendAt } = this.state;
|
||||
|
|
@ -50,13 +49,6 @@ export default OakComponent({
|
|||
};
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
// 如果已登录, 返回上一页
|
||||
const token = this.features.token.getTokenValue();
|
||||
if (token) {
|
||||
this.navigateBack();
|
||||
}
|
||||
},
|
||||
async ready() {
|
||||
const application = this.features.application.getApplication();
|
||||
let loginMode = await this.load(LOGIN_MODE) || 2;
|
||||
|
|
@ -130,7 +122,6 @@ export default OakComponent({
|
|||
}
|
||||
},
|
||||
async loginByMobile(mobile, password, captcha) {
|
||||
const { url } = this.props;
|
||||
try {
|
||||
this.setState({
|
||||
loading: true,
|
||||
|
|
@ -139,13 +130,6 @@ export default OakComponent({
|
|||
this.setState({
|
||||
loading: false,
|
||||
});
|
||||
if (url) {
|
||||
this.redirectTo({
|
||||
url,
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.navigateBack();
|
||||
}
|
||||
catch (err) {
|
||||
this.setState({
|
||||
|
|
|
|||
|
|
@ -118,43 +118,41 @@ export default function Render(props) {
|
|||
if (url) {
|
||||
state = encodeURIComponent(decodeURIComponent(url));
|
||||
}
|
||||
return (<div className={Style['loginbox-main']}>
|
||||
<div className={classNames(Style['loginbox-wrap'], {
|
||||
return (<div className={classNames(Style['loginbox-wrap'], {
|
||||
[Style['loginbox-wrap__mobile']]: width === 'xs',
|
||||
})}>
|
||||
{options?.length > 1 && (<div className={Style['loginbox-hd']}>
|
||||
<Segmented className={Style.segmented} value={loginMode} block onChange={setLoginMode} options={options.map((ele) => ({
|
||||
{options?.length > 1 && (<div className={Style['loginbox-hd']}>
|
||||
<Segmented className={Style.segmented} value={loginMode} block onChange={setLoginMode} options={options.map((ele) => ({
|
||||
value: ele.value,
|
||||
label: t(`${ele.label}`),
|
||||
}))}></Segmented>
|
||||
</div>)}
|
||||
</div>)}
|
||||
|
||||
<div className={classNames(Style['loginbox-bd'], {
|
||||
<div className={classNames(Style['loginbox-bd'], {
|
||||
[Style['loginbox-bd__grant']]: isSupportGrant,
|
||||
})}>
|
||||
{isSupportGrant ? (<div className={Style['loginbox-grant']}>
|
||||
<WeChatLoginGrant disabled={!!disabled} disableText={disabled} appId={appId} scope="snsapi_userinfo" redirectUri={redirectUri} state={state}/>
|
||||
</div>) : (<>
|
||||
<div className={Style['loginbox-password']} style={{
|
||||
{isSupportGrant ? (<div className={Style['loginbox-grant']}>
|
||||
<WeChatLoginGrant disabled={!!disabled} disableText={disabled} appId={appId} scope="snsapi_userinfo" redirectUri={redirectUri} state={state}/>
|
||||
</div>) : (<>
|
||||
<div className={Style['loginbox-password']} style={{
|
||||
display: loginMode === 1 ? 'block' : 'none',
|
||||
}}>
|
||||
{LoginPassword}
|
||||
</div>
|
||||
<div className={Style['loginbox-mobile']} style={{
|
||||
{LoginPassword}
|
||||
</div>
|
||||
<div className={Style['loginbox-mobile']} style={{
|
||||
display: loginMode === 2 ? 'block' : 'none',
|
||||
}}>
|
||||
{LoginCaptcha}
|
||||
</div>
|
||||
<div className={Style['loginbox-qrcode']} style={{
|
||||
{LoginCaptcha}
|
||||
</div>
|
||||
<div className={Style['loginbox-qrcode']} style={{
|
||||
display: loginMode === 3 ? 'block' : 'none',
|
||||
}}>
|
||||
{/* 因为在选择授权方式时,微信网站和微信公众号授权登录二者只存其一,
|
||||
所以这里可以按这个判断分开显示 */}
|
||||
{isSupportWechat && (<WeChatLoginQrCode disabled={disabled} disableText={disabled} appId={appId} scope="snsapi_login" redirectUri={redirectUri} state={state} href="data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAyMDBweDt9Ci5zdGF0dXNfaWNvbiB7ZGlzcGxheTogbm9uZX0KLmltcG93ZXJCb3ggLnN0YXR1cyB7dGV4dC1hbGlnbjogY2VudGVyO30gCg=="/>)}
|
||||
{isSupportWechatPublic && (<WechatLoginQrCodeForPublic type="login" oakPath="$login-wechatLogin/qrCode" oakAutoUnmount={true} url={state}/>)}
|
||||
</div>
|
||||
</>)}
|
||||
</div>
|
||||
{/* 因为在选择授权方式时,微信网站和微信公众号授权登录二者只存其一,
|
||||
所以这里可以按这个判断分开显示 */}
|
||||
{isSupportWechat && (<WeChatLoginQrCode disabled={disabled} disableText={disabled} appId={appId} scope="snsapi_login" redirectUri={redirectUri} state={state} href="data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAyMDBweDt9Ci5zdGF0dXNfaWNvbiB7ZGlzcGxheTogbm9uZX0KLmltcG93ZXJCb3ggLnN0YXR1cyB7dGV4dC1hbGlnbjogY2VudGVyO30gCg=="/>)}
|
||||
{isSupportWechatPublic && (<WechatLoginQrCodeForPublic type="login" oakPath="$login-wechatLogin/qrCode" oakAutoUnmount={true} url={state}/>)}
|
||||
</div>
|
||||
</>)}
|
||||
</div>
|
||||
</div>);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,23 +23,19 @@ export default function Render(props) {
|
|||
},
|
||||
]}>
|
||||
<>
|
||||
<Input disabled={!isNew && !allowUpdateName} onChange={(value) => {
|
||||
if (isNew) {
|
||||
update({
|
||||
name: value,
|
||||
});
|
||||
}
|
||||
<Input disabled={!isNew && !allowUpdateName} onChange={(value) => {
|
||||
update({
|
||||
name: value,
|
||||
});
|
||||
}} value={name} placeholder={t('placeholder.name')}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('user:attr.nickname')} name="nickname">
|
||||
<>
|
||||
<Input disabled={!isNew && !allowUpdateNickname} value={nickname} onChange={(value) => {
|
||||
if (isNew) {
|
||||
update({
|
||||
nickname: value,
|
||||
});
|
||||
}
|
||||
<Input disabled={!isNew && !allowUpdateNickname} value={nickname} onChange={(value) => {
|
||||
update({
|
||||
nickname: value,
|
||||
});
|
||||
}} placeholder={t('placeholder.nickname')}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
declare let messageTypes: string[];
|
||||
export default messageTypes;
|
||||
export declare function registMessageType(messageType: string[]): void;
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
import { uniq } from 'oak-domain/lib/utils/lodash';
|
||||
let messageTypes = [];
|
||||
export default messageTypes;
|
||||
export function registMessageType(messageType) {
|
||||
let messageTypes2 = messageTypes.concat(messageType);
|
||||
messageTypes = uniq(messageTypes2);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { ROOT_MOBILE_ID, ROOT_TOKEN_ID, ROOT_USER_ID } from '../constants';
|
||||
export const users = [
|
||||
{
|
||||
password: 'oak@2022',
|
||||
password: '',
|
||||
nickname: 'root',
|
||||
name: 'root',
|
||||
isRoot: true,
|
||||
|
|
|
|||
|
|
@ -60,9 +60,10 @@ export async function subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
|||
return true;
|
||||
}
|
||||
export function createComponent(option, features) {
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, ...rest } = option;
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, features: optionFeatures, ...rest } = option;
|
||||
const { relatedMessageTypes } = wechatMp || {};
|
||||
const { ready, attached, show, hide, ...restLifeTimes } = lifetimes || {};
|
||||
const tokenFeatures = optionFeatures?.find(ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token'));
|
||||
return createBaseComponent({
|
||||
data: typeof data === 'function'
|
||||
? function () {
|
||||
|
|
@ -142,9 +143,6 @@ export function createComponent(option, features) {
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
if (!userInsensitive) {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
}
|
||||
this.addFeatureSub('application', () => this.getMessageTypeTemplate());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
|
|
@ -172,6 +170,10 @@ export function createComponent(option, features) {
|
|||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
wechatMp,
|
||||
...rest,
|
||||
}, features);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { createComponent as createBaseComponent } from 'oak-frontend-base/es/page.native';
|
||||
export function createComponent(option, features) {
|
||||
const { lifetimes, methods, ...rest } = option;
|
||||
const { attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { methods, features: optionFeatures, userInsensitive, ...rest } = option;
|
||||
const tokenFeatures = optionFeatures?.find(ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token'));
|
||||
return createBaseComponent({
|
||||
methods: {
|
||||
async subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
||||
|
|
@ -9,13 +9,10 @@ export function createComponent(option, features) {
|
|||
},
|
||||
...methods,
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
...rest,
|
||||
}, features);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { createComponent as createBaseComponent } from 'oak-frontend-base/es/page.web';
|
||||
export function createComponent(option, features) {
|
||||
const { lifetimes, methods, ...rest } = option;
|
||||
const { attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { methods, features: optionFeatures, userInsensitive, ...rest } = option;
|
||||
const tokenFeatures = optionFeatures?.find(ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token'));
|
||||
return createBaseComponent({
|
||||
methods: {
|
||||
async subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
||||
|
|
@ -9,13 +9,10 @@ export function createComponent(option, features) {
|
|||
},
|
||||
...methods,
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
...rest,
|
||||
}, features);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
declare const _default: (import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "account", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>>)[];
|
||||
declare const _default: (import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "account", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>>)[];
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
declare const checkers: (import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "mobile", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "token", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "message", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "parasite", import("..").RuntimeCxt>)[];
|
||||
declare const checkers: (import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "token", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "mobile", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "message", import("..").RuntimeCxt> | import("oak-domain").Checker<import("../oak-app-domain").EntityDict, "parasite", import("..").RuntimeCxt>)[];
|
||||
export default checkers;
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
declare let messageTypes: string[];
|
||||
export default messageTypes;
|
||||
export declare function registMessageType(messageType: string[]): void;
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.registMessageType = void 0;
|
||||
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
let messageTypes = [];
|
||||
exports.default = messageTypes;
|
||||
function registMessageType(messageType) {
|
||||
let messageTypes2 = messageTypes.concat(messageType);
|
||||
messageTypes = (0, lodash_1.uniq)(messageTypes2);
|
||||
}
|
||||
exports.registMessageType = registMessageType;
|
||||
|
|
@ -4,7 +4,7 @@ exports.tokens = exports.mobiles = exports.users = void 0;
|
|||
const constants_1 = require("../constants");
|
||||
exports.users = [
|
||||
{
|
||||
password: 'oak@2022',
|
||||
password: '',
|
||||
nickname: 'root',
|
||||
name: 'root',
|
||||
isRoot: true,
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@ async function subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
|||
}
|
||||
exports.subscribeMpMessage = subscribeMpMessage;
|
||||
function createComponent(option, features) {
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, ...rest } = option;
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, features: optionFeatures, ...rest } = option;
|
||||
const { relatedMessageTypes } = wechatMp || {};
|
||||
const { ready, attached, show, hide, ...restLifeTimes } = lifetimes || {};
|
||||
const tokenFeatures = optionFeatures?.find(ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token'));
|
||||
return (0, page_mp_1.createComponent)({
|
||||
data: typeof data === 'function'
|
||||
? function () {
|
||||
|
|
@ -146,9 +147,6 @@ function createComponent(option, features) {
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
if (!userInsensitive) {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
}
|
||||
this.addFeatureSub('application', () => this.getMessageTypeTemplate());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
|
|
@ -176,6 +174,10 @@ function createComponent(option, features) {
|
|||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
wechatMp,
|
||||
...rest,
|
||||
}, features);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.createComponent = void 0;
|
||||
const page_native_1 = require("oak-frontend-base/es/page.native");
|
||||
function createComponent(option, features) {
|
||||
const { lifetimes, methods, ...rest } = option;
|
||||
const { attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { methods, features: optionFeatures, userInsensitive, ...rest } = option;
|
||||
const tokenFeatures = optionFeatures?.find(ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token'));
|
||||
return (0, page_native_1.createComponent)({
|
||||
methods: {
|
||||
async subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
||||
|
|
@ -12,13 +12,10 @@ function createComponent(option, features) {
|
|||
},
|
||||
...methods,
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
...rest,
|
||||
}, features);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.createComponent = void 0;
|
||||
const page_web_1 = require("oak-frontend-base/es/page.web");
|
||||
function createComponent(option, features) {
|
||||
const { lifetimes, methods, ...rest } = option;
|
||||
const { attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { methods, features: optionFeatures, userInsensitive, ...rest } = option;
|
||||
const tokenFeatures = optionFeatures?.find(ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token'));
|
||||
return (0, page_web_1.createComponent)({
|
||||
methods: {
|
||||
async subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
||||
|
|
@ -12,13 +12,10 @@ function createComponent(option, features) {
|
|||
},
|
||||
...methods,
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
...rest,
|
||||
}, features);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
declare const _default: (import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "account", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>>)[];
|
||||
declare const _default: (import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "account", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>>)[];
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ export default OakComponent({
|
|||
onlyPassword: false,
|
||||
disabled: '',
|
||||
redirectUri: '', // 微信登录后的redirectUri,要指向wechatUser/login去处理
|
||||
url: '', // 登录成功后redirectTo的页面,不配置的话就认为是goBack
|
||||
},
|
||||
formData({ features, props }) {
|
||||
const { lastSendAt } = this.state;
|
||||
|
|
@ -59,13 +58,6 @@ export default OakComponent({
|
|||
};
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
// 如果已登录, 返回上一页
|
||||
const token = this.features.token.getTokenValue();
|
||||
if (token) {
|
||||
this.navigateBack();
|
||||
}
|
||||
},
|
||||
async ready() {
|
||||
const application = this.features.application.getApplication();
|
||||
|
||||
|
|
@ -142,8 +134,6 @@ export default OakComponent({
|
|||
password?: string,
|
||||
captcha?: string
|
||||
) {
|
||||
const { url } = this.props;
|
||||
|
||||
try {
|
||||
this.setState({
|
||||
loading: true,
|
||||
|
|
@ -156,13 +146,6 @@ export default OakComponent({
|
|||
this.setState({
|
||||
loading: false,
|
||||
});
|
||||
if (url) {
|
||||
this.redirectTo({
|
||||
url,
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.navigateBack();
|
||||
} catch (err) {
|
||||
this.setState({
|
||||
loading: false,
|
||||
|
|
|
|||
|
|
@ -250,92 +250,90 @@ export default function Render(
|
|||
}
|
||||
|
||||
return (
|
||||
<div className={Style['loginbox-main']}>
|
||||
<div
|
||||
className={classNames(Style['loginbox-wrap'], {
|
||||
[Style['loginbox-wrap__mobile']]: width === 'xs',
|
||||
})}
|
||||
>
|
||||
{options?.length > 1 && (
|
||||
<div className={Style['loginbox-hd']}>
|
||||
<Segmented
|
||||
className={Style.segmented}
|
||||
value={loginMode}
|
||||
block
|
||||
onChange={setLoginMode}
|
||||
options={options.map((ele) => ({
|
||||
value: ele.value,
|
||||
label: t(`${ele.label}`),
|
||||
}))}
|
||||
></Segmented>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div
|
||||
className={classNames(Style['loginbox-wrap'], {
|
||||
[Style['loginbox-wrap__mobile']]: width === 'xs',
|
||||
className={classNames(Style['loginbox-bd'], {
|
||||
[Style['loginbox-bd__grant']]: isSupportGrant,
|
||||
})}
|
||||
>
|
||||
{options?.length > 1 && (
|
||||
<div className={Style['loginbox-hd']}>
|
||||
<Segmented
|
||||
className={Style.segmented}
|
||||
value={loginMode}
|
||||
block
|
||||
onChange={setLoginMode}
|
||||
options={options.map((ele) => ({
|
||||
value: ele.value,
|
||||
label: t(`${ele.label}`),
|
||||
}))}
|
||||
></Segmented>
|
||||
{isSupportGrant ? (
|
||||
<div className={Style['loginbox-grant']}>
|
||||
<WeChatLoginGrant
|
||||
disabled={!!disabled}
|
||||
disableText={disabled}
|
||||
appId={appId}
|
||||
scope="snsapi_userinfo"
|
||||
redirectUri={redirectUri}
|
||||
state={state}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div
|
||||
className={classNames(Style['loginbox-bd'], {
|
||||
[Style['loginbox-bd__grant']]: isSupportGrant,
|
||||
})}
|
||||
>
|
||||
{isSupportGrant ? (
|
||||
<div className={Style['loginbox-grant']}>
|
||||
<WeChatLoginGrant
|
||||
disabled={!!disabled}
|
||||
disableText={disabled}
|
||||
appId={appId}
|
||||
scope="snsapi_userinfo"
|
||||
redirectUri={redirectUri}
|
||||
state={state}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div
|
||||
className={Style['loginbox-password']}
|
||||
style={{
|
||||
display: loginMode === 1 ? 'block' : 'none',
|
||||
}}
|
||||
>
|
||||
{LoginPassword}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div
|
||||
className={Style['loginbox-password']}
|
||||
style={{
|
||||
display: loginMode === 1 ? 'block' : 'none',
|
||||
}}
|
||||
>
|
||||
{LoginPassword}
|
||||
</div>
|
||||
<div
|
||||
className={Style['loginbox-mobile']}
|
||||
style={{
|
||||
display: loginMode === 2 ? 'block' : 'none',
|
||||
}}
|
||||
>
|
||||
{LoginCaptcha}
|
||||
</div>
|
||||
<div
|
||||
className={Style['loginbox-qrcode']}
|
||||
style={{
|
||||
display: loginMode === 3 ? 'block' : 'none',
|
||||
}}
|
||||
>
|
||||
{/* 因为在选择授权方式时,微信网站和微信公众号授权登录二者只存其一,
|
||||
<div
|
||||
className={Style['loginbox-mobile']}
|
||||
style={{
|
||||
display: loginMode === 2 ? 'block' : 'none',
|
||||
}}
|
||||
>
|
||||
{LoginCaptcha}
|
||||
</div>
|
||||
<div
|
||||
className={Style['loginbox-qrcode']}
|
||||
style={{
|
||||
display: loginMode === 3 ? 'block' : 'none',
|
||||
}}
|
||||
>
|
||||
{/* 因为在选择授权方式时,微信网站和微信公众号授权登录二者只存其一,
|
||||
所以这里可以按这个判断分开显示 */}
|
||||
{isSupportWechat && (
|
||||
<WeChatLoginQrCode
|
||||
disabled={disabled}
|
||||
disableText={disabled}
|
||||
appId={appId}
|
||||
scope="snsapi_login"
|
||||
redirectUri={redirectUri}
|
||||
state={state}
|
||||
href="data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAyMDBweDt9Ci5zdGF0dXNfaWNvbiB7ZGlzcGxheTogbm9uZX0KLmltcG93ZXJCb3ggLnN0YXR1cyB7dGV4dC1hbGlnbjogY2VudGVyO30gCg=="
|
||||
/>
|
||||
)}
|
||||
{isSupportWechatPublic && (
|
||||
<WechatLoginQrCodeForPublic
|
||||
type="login"
|
||||
oakPath="$login-wechatLogin/qrCode"
|
||||
oakAutoUnmount={true}
|
||||
url={state}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{isSupportWechat && (
|
||||
<WeChatLoginQrCode
|
||||
disabled={disabled}
|
||||
disableText={disabled}
|
||||
appId={appId}
|
||||
scope="snsapi_login"
|
||||
redirectUri={redirectUri}
|
||||
state={state}
|
||||
href="data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAyMDBweDt9Ci5zdGF0dXNfaWNvbiB7ZGlzcGxheTogbm9uZX0KLmltcG93ZXJCb3ggLnN0YXR1cyB7dGV4dC1hbGlnbjogY2VudGVyO30gCg=="
|
||||
/>
|
||||
)}
|
||||
{isSupportWechatPublic && (
|
||||
<WechatLoginQrCodeForPublic
|
||||
type="login"
|
||||
oakPath="$login-wechatLogin/qrCode"
|
||||
oakAutoUnmount={true}
|
||||
url={state}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { ROOT_MOBILE_ID, ROOT_ROLE_ID, ROOT_TOKEN_ID, ROOT_USER_ID } from '../co
|
|||
|
||||
export const users: Array<UserCreate> = [
|
||||
{
|
||||
password: 'oak@2022',
|
||||
password: '',
|
||||
nickname: 'root',
|
||||
name: 'root',
|
||||
isRoot: true,
|
||||
|
|
|
|||
|
|
@ -124,10 +124,13 @@ export function createComponent<
|
|||
>,
|
||||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD,
|
||||
) {
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, ...rest } = option;
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, features: optionFeatures, ...rest } = option;
|
||||
const { relatedMessageTypes } = wechatMp || {};
|
||||
const { ready, attached, show, hide, ...restLifeTimes } = lifetimes || {};
|
||||
|
||||
const tokenFeatures = optionFeatures?.find(
|
||||
ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token')
|
||||
);
|
||||
return createBaseComponent<
|
||||
IsList,
|
||||
ED,
|
||||
|
|
@ -249,9 +252,6 @@ export function createComponent<
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
if (!userInsensitive) {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
}
|
||||
this.addFeatureSub('application', () =>
|
||||
this.getMessageTypeTemplate()
|
||||
);
|
||||
|
|
@ -281,6 +281,10 @@ export function createComponent<
|
|||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
wechatMp,
|
||||
...rest,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -38,9 +38,11 @@ export function createComponent<
|
|||
>,
|
||||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD,
|
||||
) {
|
||||
const { lifetimes, methods, ...rest } = option;
|
||||
const { attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { methods, features: optionFeatures, userInsensitive, ...rest } = option;
|
||||
|
||||
const tokenFeatures = optionFeatures?.find(
|
||||
ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token')
|
||||
);
|
||||
return createBaseComponent<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod & {
|
||||
subscribeMpMessage: (messageTypes: string[], haveToAccept?: boolean, tip?: string) => Promise<boolean>;
|
||||
}>({
|
||||
|
|
@ -50,13 +52,10 @@ export function createComponent<
|
|||
},
|
||||
...(methods as TMethod),
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
...rest,
|
||||
}, features) as React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
||||
}
|
||||
|
|
@ -38,9 +38,11 @@ export function createComponent<
|
|||
>,
|
||||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD,
|
||||
) {
|
||||
const { lifetimes, methods, ...rest } = option;
|
||||
const { attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { methods, features: optionFeatures, userInsensitive, ...rest } = option;
|
||||
|
||||
const tokenFeatures = optionFeatures?.find(
|
||||
ele => ele === 'token' || (typeof ele === 'object' && ele.feature === 'token')
|
||||
);
|
||||
return createBaseComponent<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod & {
|
||||
subscribeMpMessage: (messageTypes: string[], haveToAccept?: boolean, tip?: string) => Promise<boolean>;
|
||||
}>({
|
||||
|
|
@ -50,13 +52,10 @@ export function createComponent<
|
|||
},
|
||||
...(methods as TMethod),
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
features: (userInsensitive || !!tokenFeatures) ? optionFeatures : (optionFeatures || []).concat([{
|
||||
feature: 'token',
|
||||
behavior: 'refresh'
|
||||
}]),
|
||||
...rest,
|
||||
}, features) as React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
||||
}
|
||||
Loading…
Reference in New Issue