subcribe use in features
This commit is contained in:
parent
a6671278d6
commit
1a61cbfc1c
|
|
@ -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" | "system" | "platform";
|
||||
entity: "application" | "platform" | "system";
|
||||
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: "system" | "platform";
|
||||
entity: "platform" | "system";
|
||||
name: string;
|
||||
entityId: string;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
|
|
|
|||
|
|
@ -14,17 +14,17 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
buttonProps?: (ButtonProps & {
|
||||
color?: "success" | "default" | "warning" | "primary" | "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" | "submit" | "reset" | undefined;
|
||||
type?: "button" | "reset" | "submit" | undefined;
|
||||
shape?: "default" | "rounded" | "rectangular" | undefined;
|
||||
children?: import("react").ReactNode;
|
||||
} & Pick<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, "id" | "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
|
||||
} & 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;
|
||||
|
|
|
|||
|
|
@ -20,9 +20,5 @@ export default OakComponent({
|
|||
data,
|
||||
};
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.message.subscribe(() => this.reRender()));
|
||||
}
|
||||
}
|
||||
features: ['message'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,11 +50,7 @@ export default OakComponent({
|
|||
messages,
|
||||
};
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.reRender()));
|
||||
},
|
||||
},
|
||||
features: ['message'],
|
||||
methods: {
|
||||
goDetailById(id) {
|
||||
this.navigateTo({
|
||||
|
|
|
|||
|
|
@ -19,9 +19,4 @@ export default OakComponent({
|
|||
avatarUrl: '',
|
||||
};
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.reRender()));
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,12 +27,7 @@ export default OakComponent({
|
|||
properties: {
|
||||
showLogout: false,
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.reRender()));
|
||||
this.subscribed.push(this.features.cache.subscribe(() => this.reRender()));
|
||||
},
|
||||
},
|
||||
features: ['cache'],
|
||||
methods: {
|
||||
logout() {
|
||||
this.features.token.logout();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export class Token extends Feature {
|
|||
else {
|
||||
this.tokenValue = undefined;
|
||||
}
|
||||
this.publish();
|
||||
}
|
||||
constructor(cache, storage, environment) {
|
||||
super();
|
||||
|
|
@ -201,7 +202,7 @@ export class Token extends Feature {
|
|||
code,
|
||||
env: env,
|
||||
});
|
||||
this.publish();
|
||||
// this.publish();
|
||||
}
|
||||
async wakeupParasite(id) {
|
||||
const env = await this.environment.getEnv();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
||||
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
||||
import { Q_DateValue, Q_NumberValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
||||
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult } from "oak-domain/lib/types/Entity";
|
||||
import { GenericAction } from "oak-domain/lib/actions/action";
|
||||
|
|
@ -27,8 +27,8 @@ export type Schema = EntityShape & {
|
|||
messageTypeSmsTemplate$template?: Array<MessageTypeSmsTemplate.Schema>;
|
||||
messageTypeSmsTemplate$template$$aggr?: AggregationResult<MessageTypeSmsTemplate.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
type AttrFilter = {
|
||||
id: Q_StringValue;
|
||||
$$createAt$$: Q_DateValue;
|
||||
|
|
@ -156,4 +156,4 @@ export type EntityDef = {
|
|||
CreateSingle: CreateSingleOperation;
|
||||
CreateMulti: CreateMultipleOperation;
|
||||
};
|
||||
export { };
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -60,10 +60,19 @@ export async function subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
|||
return true;
|
||||
}
|
||||
export function createComponent(option, features) {
|
||||
const { wechatMp, methods, lifetimes, ...rest } = option;
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, ...rest } = option;
|
||||
const { relatedMessageTypes } = wechatMp || {};
|
||||
const { ready, attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { ready, attached, show, hide, ...restLifeTimes } = lifetimes || {};
|
||||
return createBaseComponent({
|
||||
data: typeof data === 'function' ? function () {
|
||||
return {
|
||||
__userId: undefined,
|
||||
...(data.call(this)),
|
||||
};
|
||||
} : {
|
||||
__userId: undefined,
|
||||
...data,
|
||||
},
|
||||
methods: {
|
||||
async subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
||||
return await subscribeMpMessage.call(this, messageTypes, haveToAccept, tip);
|
||||
|
|
@ -72,7 +81,9 @@ export function createComponent(option, features) {
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.refresh()));
|
||||
if (!userInsensitive) {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
}
|
||||
attached && attached.call(this);
|
||||
},
|
||||
ready() {
|
||||
|
|
@ -123,6 +134,22 @@ export function createComponent(option, features) {
|
|||
}
|
||||
ready && ready.call(this);
|
||||
},
|
||||
show() {
|
||||
if (!userInsensitive) {
|
||||
const userId = this.features.token.getUserId(true);
|
||||
if (userId !== this.state.__userId) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
},
|
||||
hide() {
|
||||
if (!userInsensitive) {
|
||||
const userId = this.features.token.getUserId(true);
|
||||
this.setState({
|
||||
__userId: userId,
|
||||
});
|
||||
}
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
wechatMp,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export function createComponent(option, features) {
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.refresh()));
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export function createComponent(option, features) {
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.refresh()));
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
|
|
|
|||
|
|
@ -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, "wechatMpJump", 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, "wechatMenu", 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, "article", import("..").BackendRuntimeContext<import("../oak-app-domain").EntityDict>> | 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, "wechatLogin", 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, "wechatQrCode", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt> | import("oak-domain").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC> | 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, "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>>)[];
|
||||
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>>)[];
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export declare function createToDo<ED extends EntityDict & BaseEntityDict, T ext
|
|||
title: string;
|
||||
description?: string;
|
||||
redirectTo: EntityDict['toDo']['OpSchema']['redirectTo'];
|
||||
}, userIds?: string[]): Promise<1 | 0>;
|
||||
}, userIds?: string[]): Promise<0 | 1>;
|
||||
/**
|
||||
* 完成todo例程,当在entity对象上进行action操作时(操作条件是filter),将对应的todo完成
|
||||
* 必须在entity的action的后trigger中调用
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
|||
export type OakComponentOption<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD & GAD<ED, Cxt>>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends Record<string, any>, TProperty extends DataOption, TMethod extends Record<string, Function>> = BaseOakComponentOption<IsList, ED, T, Cxt, FrontCxt, AD & GAD<ED, Cxt>, FD & GFD<ED, Cxt, FrontCxt, AD & GAD<ED, Cxt>>, FormedData, TData, TProperty, TMethod, {
|
||||
subscribeMpMessage: (messageTypes: string[], haveToAccept?: boolean, tip?: string) => Promise<boolean>;
|
||||
}> & Partial<{
|
||||
userInsensitive?: true;
|
||||
wechatMp: {
|
||||
relatedMessageTypes?: string[];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const x2js_1 = tslib_1.__importDefault(require("x2js"));
|
|||
const oak_external_sdk_1 = require("oak-external-sdk");
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const domain_1 = require("../utils/domain");
|
||||
const url_2 = require("oak-domain/lib/utils/domain");
|
||||
const domain_2 = require("oak-domain/lib/utils/domain");
|
||||
const session_1 = require("../aspects/session");
|
||||
const application_1 = require("../aspects/application");
|
||||
const X2Js = new x2js_1.default();
|
||||
|
|
@ -231,7 +231,7 @@ async function setUserSubscribed(openId, eventKey, context) {
|
|||
(0, assert_1.assert)(appMp, '公众号推送小程序码时找不到关联的小程序');
|
||||
const { config } = appMp;
|
||||
const { appId } = config;
|
||||
const url = (0, url_2.composeUrl)('pages/wechatQrCode/scan/index', {
|
||||
const url = (0, domain_2.composeUrl)('pages/wechatQrCode/scan/index', {
|
||||
scene: sceneStr,
|
||||
time: `${Date.now()}`,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class Token extends oak_frontend_base_1.Feature {
|
|||
else {
|
||||
this.tokenValue = undefined;
|
||||
}
|
||||
this.publish();
|
||||
}
|
||||
constructor(cache, storage, environment) {
|
||||
super();
|
||||
|
|
@ -204,7 +205,7 @@ class Token extends oak_frontend_base_1.Feature {
|
|||
code,
|
||||
env: env,
|
||||
});
|
||||
this.publish();
|
||||
// this.publish();
|
||||
}
|
||||
async wakeupParasite(id) {
|
||||
const env = await this.environment.getEnv();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
||||
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
||||
import { Q_DateValue, Q_NumberValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
||||
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult } from "oak-domain/lib/types/Entity";
|
||||
import { GenericAction } from "oak-domain/lib/actions/action";
|
||||
|
|
@ -27,8 +27,8 @@ export type Schema = EntityShape & {
|
|||
messageTypeSmsTemplate$template?: Array<MessageTypeSmsTemplate.Schema>;
|
||||
messageTypeSmsTemplate$template$$aggr?: AggregationResult<MessageTypeSmsTemplate.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
type AttrFilter = {
|
||||
id: Q_StringValue;
|
||||
$$createAt$$: Q_DateValue;
|
||||
|
|
@ -156,4 +156,4 @@ export type EntityDef = {
|
|||
CreateSingle: CreateSingleOperation;
|
||||
CreateMulti: CreateMultipleOperation;
|
||||
};
|
||||
export { };
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -64,10 +64,19 @@ async function subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
|||
}
|
||||
exports.subscribeMpMessage = subscribeMpMessage;
|
||||
function createComponent(option, features) {
|
||||
const { wechatMp, methods, lifetimes, ...rest } = option;
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, ...rest } = option;
|
||||
const { relatedMessageTypes } = wechatMp || {};
|
||||
const { ready, attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { ready, attached, show, hide, ...restLifeTimes } = lifetimes || {};
|
||||
return (0, page_mp_1.createComponent)({
|
||||
data: typeof data === 'function' ? function () {
|
||||
return {
|
||||
__userId: undefined,
|
||||
...(data.call(this)),
|
||||
};
|
||||
} : {
|
||||
__userId: undefined,
|
||||
...data,
|
||||
},
|
||||
methods: {
|
||||
async subscribeMpMessage(messageTypes, haveToAccept, tip) {
|
||||
return await subscribeMpMessage.call(this, messageTypes, haveToAccept, tip);
|
||||
|
|
@ -76,7 +85,9 @@ function createComponent(option, features) {
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.refresh()));
|
||||
if (!userInsensitive) {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
}
|
||||
attached && attached.call(this);
|
||||
},
|
||||
ready() {
|
||||
|
|
@ -127,6 +138,22 @@ function createComponent(option, features) {
|
|||
}
|
||||
ready && ready.call(this);
|
||||
},
|
||||
show() {
|
||||
if (!userInsensitive) {
|
||||
const userId = this.features.token.getUserId(true);
|
||||
if (userId !== this.state.__userId) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
},
|
||||
hide() {
|
||||
if (!userInsensitive) {
|
||||
const userId = this.features.token.getUserId(true);
|
||||
this.setState({
|
||||
__userId: userId,
|
||||
});
|
||||
}
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
wechatMp,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function createComponent(option, features) {
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.refresh()));
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function createComponent(option, features) {
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(this.features.token.subscribe(() => this.refresh()));
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
declare const _default: (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, "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, "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, "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>>)[];
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
const oak_external_sdk_1 = require("oak-external-sdk");
|
||||
const url_1 = require("oak-domain/lib/utils/domain");
|
||||
const domain_1 = require("oak-domain/lib/utils/domain");
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const sms_1 = require("../utils/sms");
|
||||
const message_1 = require("./message");
|
||||
const domain_1 = require("../utils/domain");
|
||||
const domain_2 = require("../utils/domain");
|
||||
async function sendNotification(notification, context) {
|
||||
const { data, templateId, channel, messageSystemId, data1, id } = notification;
|
||||
const [messageSystem] = await context.select('messageSystem', {
|
||||
|
|
@ -50,7 +50,7 @@ async function sendNotification(notification, context) {
|
|||
const url = pathname.startsWith('/')
|
||||
? `pages${pathname}/index`
|
||||
: `pages/${pathname}/index`;
|
||||
page = (0, url_1.composeUrl)(url, Object.assign({}, router.props, router.state));
|
||||
page = (0, domain_1.composeUrl)(url, Object.assign({}, router.props, router.state));
|
||||
}
|
||||
// 根据当前环境决定消息推哪个版本
|
||||
const StateDict = {
|
||||
|
|
@ -119,11 +119,11 @@ async function sendNotification(notification, context) {
|
|||
const url = pathname.startsWith('/')
|
||||
? `pages${pathname}/index`
|
||||
: `pages/${pathname}/index`;
|
||||
page = (0, url_1.composeUrl)(url, Object.assign({}, router.props, router.state));
|
||||
page = (0, domain_1.composeUrl)(url, Object.assign({}, router.props, router.state));
|
||||
}
|
||||
else {
|
||||
const url = (0, domain_1.composeDomainUrl)(domain, pathname);
|
||||
page = (0, url_1.composeUrl)(url, Object.assign({}, router.props, router.state));
|
||||
const url = (0, domain_2.composeDomainUrl)(domain, pathname);
|
||||
page = (0, domain_1.composeUrl)(url, Object.assign({}, router.props, router.state));
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export declare function createToDo<ED extends EntityDict & BaseEntityDict, T ext
|
|||
title: string;
|
||||
description?: string;
|
||||
redirectTo: EntityDict['toDo']['OpSchema']['redirectTo'];
|
||||
}, userIds?: string[]): Promise<1 | 0>;
|
||||
}, userIds?: string[]): Promise<0 | 1>;
|
||||
/**
|
||||
* 完成todo例程,当在entity对象上进行action操作时(操作条件是filter),将对应的todo完成
|
||||
* 必须在entity的action的后trigger中调用
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
|||
export type OakComponentOption<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD & GAD<ED, Cxt>>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends Record<string, any>, TProperty extends DataOption, TMethod extends Record<string, Function>> = BaseOakComponentOption<IsList, ED, T, Cxt, FrontCxt, AD & GAD<ED, Cxt>, FD & GFD<ED, Cxt, FrontCxt, AD & GAD<ED, Cxt>>, FormedData, TData, TProperty, TMethod, {
|
||||
subscribeMpMessage: (messageTypes: string[], haveToAccept?: boolean, tip?: string) => Promise<boolean>;
|
||||
}> & Partial<{
|
||||
userInsensitive?: true;
|
||||
wechatMp: {
|
||||
relatedMessageTypes?: string[];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,13 +24,5 @@ export default OakComponent({
|
|||
data,
|
||||
};
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed!.push(
|
||||
this.features.message.subscribe(
|
||||
() => this.reRender()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
features: ['message'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -51,13 +51,7 @@ export default OakComponent({
|
|||
messages,
|
||||
};
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(
|
||||
this.features.token.subscribe(() => this.reRender())
|
||||
);
|
||||
},
|
||||
},
|
||||
features: ['message'],
|
||||
methods: {
|
||||
goDetailById(id: string) {
|
||||
this.navigateTo({
|
||||
|
|
|
|||
|
|
@ -23,11 +23,4 @@ export default OakComponent({
|
|||
avatarUrl: '',
|
||||
};
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(
|
||||
this.features.token.subscribe(() => this.reRender())
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,16 +38,7 @@ export default OakComponent({
|
|||
properties: {
|
||||
showLogout: false,
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(
|
||||
this.features.token.subscribe(() => this.reRender())
|
||||
);
|
||||
this.subscribed.push(
|
||||
this.features.cache.subscribe(() => this.reRender())
|
||||
);
|
||||
},
|
||||
},
|
||||
features: ['cache'],
|
||||
methods: {
|
||||
logout() {
|
||||
this.features.token.logout();
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ export class Token<
|
|||
else {
|
||||
this.tokenValue = undefined;
|
||||
}
|
||||
this.publish();
|
||||
}
|
||||
|
||||
constructor(cache: Cache<ED, Cxt, FrontCxt, AD>, storage: LocalStorage, environment: Environment) {
|
||||
|
|
@ -255,7 +256,7 @@ export class Token<
|
|||
code,
|
||||
env: env as WechatMpEnv,
|
||||
});
|
||||
this.publish();
|
||||
// this.publish();
|
||||
}
|
||||
|
||||
async wakeupParasite(id: string) {
|
||||
|
|
|
|||
|
|
@ -124,13 +124,28 @@ export function createComponent<
|
|||
>,
|
||||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD,
|
||||
) {
|
||||
const { wechatMp, methods, lifetimes, ...rest } = option;
|
||||
const { wechatMp, data, methods, lifetimes, userInsensitive, ...rest } = option;
|
||||
const { relatedMessageTypes } = wechatMp || {};
|
||||
const { ready, attached, ...restLifeTimes } = lifetimes || {};
|
||||
const { ready, attached, show, hide, ...restLifeTimes } = lifetimes || {};
|
||||
|
||||
return createBaseComponent<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod & {
|
||||
return createBaseComponent<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData & {
|
||||
__userId: string | undefined;
|
||||
}, TProperty, TMethod & {
|
||||
subscribeMpMessage: (messageTypes: string[], haveToAccept?: boolean, tip?: string) => Promise<boolean>;
|
||||
}>({
|
||||
data: typeof data === 'function' ? function() {
|
||||
return {
|
||||
__userId: undefined,
|
||||
...(data.call(this)),
|
||||
} as TData & {
|
||||
__userId: string | undefined;
|
||||
}
|
||||
} : {
|
||||
__userId: undefined,
|
||||
...data,
|
||||
} as TData & {
|
||||
__userId: string | undefined;
|
||||
},
|
||||
methods: {
|
||||
async subscribeMpMessage(messageTypes: string[], haveToAccept?: boolean, tip?: string) {
|
||||
return await subscribeMpMessage.call(this as any, messageTypes, haveToAccept, tip);
|
||||
|
|
@ -139,11 +154,9 @@ export function createComponent<
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(
|
||||
this.features.token.subscribe(
|
||||
() => this.refresh()
|
||||
)
|
||||
);
|
||||
if (!userInsensitive) {
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
}
|
||||
attached && attached.call(this);
|
||||
},
|
||||
ready() {
|
||||
|
|
@ -197,6 +210,22 @@ export function createComponent<
|
|||
}
|
||||
ready && ready.call(this);
|
||||
},
|
||||
show() {
|
||||
if (!userInsensitive) {
|
||||
const userId = this.features.token.getUserId(true);
|
||||
if (userId !== this.state.__userId) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
},
|
||||
hide() {
|
||||
if (!userInsensitive) {
|
||||
const userId = this.features.token.getUserId(true);
|
||||
this.setState({
|
||||
__userId: userId as string | undefined,
|
||||
} as any);
|
||||
}
|
||||
},
|
||||
...restLifeTimes,
|
||||
},
|
||||
wechatMp,
|
||||
|
|
|
|||
|
|
@ -52,11 +52,7 @@ export function createComponent<
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(
|
||||
this.features.token.subscribe(
|
||||
() => this.refresh()
|
||||
)
|
||||
);
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
|
|
|
|||
|
|
@ -52,11 +52,7 @@ export function createComponent<
|
|||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.subscribed.push(
|
||||
this.features.token.subscribe(
|
||||
() => this.refresh()
|
||||
)
|
||||
);
|
||||
this.addFeatureSub('token', () => this.refresh());
|
||||
attached && attached.call(this);
|
||||
},
|
||||
...restLifeTimes,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export type OakComponentOption<
|
|||
> = BaseOakComponentOption<IsList, ED, T, Cxt, FrontCxt, AD & GAD<ED, Cxt>, FD & GFD<ED, Cxt, FrontCxt, AD & GAD<ED, Cxt>>, FormedData, TData, TProperty, TMethod, {
|
||||
subscribeMpMessage: (messageTypes: string[], haveToAccept?: boolean, tip?: string) => Promise<boolean>;
|
||||
}> & Partial<{
|
||||
userInsensitive?: true;
|
||||
wechatMp: {
|
||||
relatedMessageTypes?: string[];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue