2.0.1
This commit is contained in:
parent
1ba0b64037
commit
2f595853a1
|
|
@ -20,6 +20,11 @@ var OakProperties = {
|
||||||
};
|
};
|
||||||
var oakBehavior = Behavior({
|
var oakBehavior = Behavior({
|
||||||
methods: {
|
methods: {
|
||||||
|
setDisablePulldownRefresh: function (able) {
|
||||||
|
this.setState({
|
||||||
|
oakDisablePulldownRefresh: able,
|
||||||
|
});
|
||||||
|
},
|
||||||
t: function (key, params) {
|
t: function (key, params) {
|
||||||
// common: {
|
// common: {
|
||||||
// GREETING: 'Hello {{name}}, nice to see you.',
|
// GREETING: 'Hello {{name}}, nice to see you.',
|
||||||
|
|
@ -138,7 +143,7 @@ var oakBehavior = Behavior({
|
||||||
return tslib_1.__generator(this, function (_a) {
|
return tslib_1.__generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0:
|
case 0:
|
||||||
if (!(!this.state.oakLoading && this.iAmThePage())) return [3 /*break*/, 2];
|
if (!(!this.state.oakLoading && this.iAmThePage() && !this.state.oakDisablePulldownRefresh && !this.props.oakDisablePulldownRefresh)) return [3 /*break*/, 2];
|
||||||
return [4 /*yield*/, this.refresh()];
|
return [4 /*yield*/, this.refresh()];
|
||||||
case 1:
|
case 1:
|
||||||
_a.sent();
|
_a.sent();
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@ var OakComponentBase = /** @class */ (function (_super) {
|
||||||
function OakComponentBase() {
|
function OakComponentBase() {
|
||||||
return _super !== null && _super.apply(this, arguments) || this;
|
return _super !== null && _super.apply(this, arguments) || this;
|
||||||
}
|
}
|
||||||
|
OakComponentBase.prototype.setDisablePulldownRefresh = function (able) {
|
||||||
|
this.setState({
|
||||||
|
oakDisablePulldownRefresh: able,
|
||||||
|
});
|
||||||
|
};
|
||||||
OakComponentBase.prototype.onPathSet = function () {
|
OakComponentBase.prototype.onPathSet = function () {
|
||||||
return page_common_1.onPathSet.call(this, this.oakOption);
|
return page_common_1.onPathSet.call(this, this.oakOption);
|
||||||
};
|
};
|
||||||
|
|
@ -394,6 +399,7 @@ function createComponent(option, features) {
|
||||||
_this.checkReachBottom();
|
_this.checkReachBottom();
|
||||||
};
|
};
|
||||||
var methodProps = {
|
var methodProps = {
|
||||||
|
setDisablePulldownRefresh: function (able) { return _this.setDisablePulldownRefresh(able); },
|
||||||
t: function (key, params) { return _this.t(key, params); },
|
t: function (key, params) { return _this.t(key, params); },
|
||||||
execute: function (action) {
|
execute: function (action) {
|
||||||
return _this.execute(action);
|
return _this.execute(action);
|
||||||
|
|
@ -524,7 +530,9 @@ function createComponent(option, features) {
|
||||||
return this.props.routeMatch;
|
return this.props.routeMatch;
|
||||||
};
|
};
|
||||||
OakComponentWrapper.prototype.supportPullDownRefresh = function () {
|
OakComponentWrapper.prototype.supportPullDownRefresh = function () {
|
||||||
return this.props.width === 'xs' && this.iAmThePage();
|
var _a = this.props.oakDisablePulldownRefresh, oakDisablePulldownRefresh = _a === void 0 ? false : _a;
|
||||||
|
var disable2 = this.state.oakDisablePulldownRefresh;
|
||||||
|
return this.props.width === 'xs' && this.iAmThePage() && !oakDisablePulldownRefresh && !disable2;
|
||||||
};
|
};
|
||||||
OakComponentWrapper.prototype.registerPageScroll = function () {
|
OakComponentWrapper.prototype.registerPageScroll = function () {
|
||||||
window.addEventListener('scroll', this.scrollEvent);
|
window.addEventListener('scroll', this.scrollEvent);
|
||||||
|
|
@ -590,9 +598,8 @@ function createComponent(option, features) {
|
||||||
OakComponentWrapper.prototype.render = function () {
|
OakComponentWrapper.prototype.render = function () {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var oakPullDownRefreshLoading = this.state.oakPullDownRefreshLoading;
|
var oakPullDownRefreshLoading = this.state.oakPullDownRefreshLoading;
|
||||||
var _a = this.props.oakDisablePulldownRefresh, oakDisablePulldownRefresh = _a === void 0 ? false : _a;
|
|
||||||
var Render = getRender.call(this);
|
var Render = getRender.call(this);
|
||||||
if (this.supportPullDownRefresh() && !oakDisablePulldownRefresh) {
|
if (this.supportPullDownRefresh()) {
|
||||||
var Child = react_1.default.cloneElement((0, jsx_runtime_1.jsx)(web_1.PullToRefresh, { onRefresh: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
var Child = react_1.default.cloneElement((0, jsx_runtime_1.jsx)(web_1.PullToRefresh, { onRefresh: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||||
return tslib_1.__generator(this, function (_a) {
|
return tslib_1.__generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
declare const withRouter: (Component: React.ComponentType<any>, { path, properties }: {
|
declare const withRouter: (Component: React.ComponentType<any>, { path, properties }: {
|
||||||
path?: string | undefined;
|
path?: string | undefined;
|
||||||
properties?: WechatMiniprogram.Component.PropertyOption | undefined;
|
properties?: Record<string, WechatMiniprogram.Component.AllProperty | FunctionConstructor> | undefined;
|
||||||
}) => React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
}) => React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
||||||
export default withRouter;
|
export default withRouter;
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ export declare type OakNavigateToParameters<ED extends EntityDict & BaseEntityDi
|
||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
};
|
};
|
||||||
export declare type OakCommonComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
export declare type OakCommonComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
||||||
|
setDisablePulldownRefresh: (able: boolean) => void;
|
||||||
sub: (type: string, callback: Function) => void;
|
sub: (type: string, callback: Function) => void;
|
||||||
unsub: (type: string, callback: Function) => void;
|
unsub: (type: string, callback: Function) => void;
|
||||||
pub: (type: string, options?: any) => void;
|
pub: (type: string, options?: any) => void;
|
||||||
|
|
@ -182,6 +183,7 @@ export declare type OakListComponentMethods<ED extends EntityDict & BaseEntityDi
|
||||||
addItem: (data: Omit<ED[T]['CreateSingle']['data'], 'id'>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
addItem: (data: Omit<ED[T]['CreateSingle']['data'], 'id'>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
||||||
removeItem: (id: string, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
removeItem: (id: string, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
||||||
updateItem: (data: ED[T]['Update']['data'], id: string, action?: ED[T]['Action'], beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
updateItem: (data: ED[T]['Update']['data'], id: string, action?: ED[T]['Action'], beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
||||||
|
recoverItem: (id: string) => void;
|
||||||
};
|
};
|
||||||
declare type ComponentOnPropsChangeOption = {
|
declare type ComponentOnPropsChangeOption = {
|
||||||
path?: string;
|
path?: string;
|
||||||
|
|
@ -206,9 +208,10 @@ export declare type OakComponentData<ED extends EntityDict & BaseEntityDict, T e
|
||||||
oakEntity: T;
|
oakEntity: T;
|
||||||
oakFullpath: string;
|
oakFullpath: string;
|
||||||
oakLegalActions?: ED[T]['Action'][];
|
oakLegalActions?: ED[T]['Action'][];
|
||||||
|
oakDisablePulldownRefresh: boolean;
|
||||||
};
|
};
|
||||||
export declare type MakeOakComponent<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>> = <T extends keyof ED, FormedData extends WechatMiniprogram.Component.DataOption, IsList extends boolean, TData extends WechatMiniprogram.Component.DataOption, TProperty extends WechatMiniprogram.Component.PropertyOption, TMethod extends WechatMiniprogram.Component.MethodOption>(options: OakComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod>) => React.ComponentType<any>;
|
export declare type MakeOakComponent<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>> = <T extends keyof ED, FormedData extends WechatMiniprogram.Component.DataOption, IsList extends boolean, TData extends WechatMiniprogram.Component.DataOption, TProperty extends WechatMiniprogram.Component.PropertyOption, TMethod extends WechatMiniprogram.Component.MethodOption>(options: OakComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod>) => React.ComponentType<any>;
|
||||||
export declare type WebComponentCommonMethodNames = 'setNotification' | 'setMessage' | 'navigateTo' | 'navigateBack' | 'redirectTo' | 'clean' | 't' | 'execute' | 'refresh';
|
export declare type WebComponentCommonMethodNames = 'setNotification' | 'setMessage' | 'navigateTo' | 'navigateBack' | 'redirectTo' | 'clean' | 't' | 'execute' | 'refresh' | 'setDisablePulldownRefresh';
|
||||||
export declare type WebComponentListMethodNames = 'loadMore' | 'setFilters' | 'addNamedFilter' | 'removeNamedFilter' | 'removeNamedFilterByName' | 'setNamedSorters' | 'addNamedSorter' | 'removeNamedSorter' | 'removeNamedSorterByName' | 'setPageSize' | 'setCurrentPage' | 'addItem' | 'removeItem' | 'updateItem';
|
export declare type WebComponentListMethodNames = 'loadMore' | 'setFilters' | 'addNamedFilter' | 'removeNamedFilter' | 'removeNamedFilterByName' | 'setNamedSorters' | 'addNamedSorter' | 'removeNamedSorter' | 'removeNamedSorterByName' | 'setPageSize' | 'setCurrentPage' | 'addItem' | 'removeItem' | 'updateItem';
|
||||||
export declare type WebComponentSingleMethodNames = 'update' | 'remove';
|
export declare type WebComponentSingleMethodNames = 'update' | 'remove';
|
||||||
export declare type WebComponentProps<ED extends EntityDict & BaseEntityDict, T extends keyof ED, IsList extends boolean, TData extends WechatMiniprogram.Component.DataOption = {}, TMethod extends WechatMiniprogram.Component.MethodOption = {}> = {
|
export declare type WebComponentProps<ED extends EntityDict & BaseEntityDict, T extends keyof ED, IsList extends boolean, TData extends WechatMiniprogram.Component.DataOption = {}, TMethod extends WechatMiniprogram.Component.MethodOption = {}> = {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "oak-frontend-base",
|
"name": "oak-frontend-base",
|
||||||
"version": "1.0.15",
|
"version": "2.0.1",
|
||||||
"description": "oak框架中前端与业务逻辑无关的平台部分",
|
"description": "oak框架中前端与业务逻辑无关的平台部分",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "XuChang"
|
"name": "XuChang"
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ export function initialize<
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const aspectDict2 = Object.assign({}, aspectDict, commonAspectDict);
|
const aspectDict2 = Object.assign({}, aspectDict, commonAspectDict);
|
||||||
const checkers2 = (checkers || []).concat(createDynamicCheckers<ED>(storageSchema));
|
const checkers2 = (checkers || []).concat(createDynamicCheckers<ED, Cxt>(storageSchema));
|
||||||
const triggers2 = createDynamicTriggers<ED, Cxt>(storageSchema).concat(triggers || []);
|
const triggers2 = createDynamicTriggers<ED, Cxt>(storageSchema).concat(triggers || []);
|
||||||
const debugStore = createDebugStore(
|
const debugStore = createDebugStore(
|
||||||
storageSchema,
|
storageSchema,
|
||||||
|
|
@ -124,7 +124,7 @@ export function initialize<
|
||||||
}
|
}
|
||||||
Object.assign(features, basicFeatures, userDefinedfeatures);
|
Object.assign(features, basicFeatures, userDefinedfeatures);
|
||||||
|
|
||||||
checkers2.forEach((checker) => cacheStore.registerChecker(checker));
|
checkers2.forEach((checker) => cacheStore.registerChecker(checker as Checker<ED, keyof ED, SyncContext<ED>>));
|
||||||
if (actionDict) {
|
if (actionDict) {
|
||||||
const { checkers: adCheckers } = analyzeActionDefDict(
|
const { checkers: adCheckers } = analyzeActionDefDict(
|
||||||
storageSchema,
|
storageSchema,
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export function initialize<
|
||||||
checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>,
|
checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>,
|
||||||
actionDict?: ActionDictOfEntityDict<ED>
|
actionDict?: ActionDictOfEntityDict<ED>
|
||||||
) {
|
) {
|
||||||
const checkers2 = (checkers || []).concat(createDynamicCheckers<ED>(storageSchema));
|
const checkers2 = (checkers || []).concat(createDynamicCheckers<ED, Cxt>(storageSchema));
|
||||||
|
|
||||||
const features = {} as FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
const features = {} as FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ export function initialize<
|
||||||
}
|
}
|
||||||
Object.assign(features, basicFeatures, userDefinedfeatures);
|
Object.assign(features, basicFeatures, userDefinedfeatures);
|
||||||
|
|
||||||
checkers2.forEach((checker) => cacheStore.registerChecker(checker));
|
checkers2.forEach((checker) => cacheStore.registerChecker(checker as Checker<ED, keyof ED, SyncContext<ED>>));
|
||||||
if (actionDict) {
|
if (actionDict) {
|
||||||
const { checkers: adCheckers } = analyzeActionDefDict(
|
const { checkers: adCheckers } = analyzeActionDefDict(
|
||||||
storageSchema,
|
storageSchema,
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ const oakBehavior = Behavior<
|
||||||
WechatMiniprogram.Component.PropertyOption,
|
WechatMiniprogram.Component.PropertyOption,
|
||||||
OakCommonComponentMethods<EDD, keyof EDD> & OakListComponentMethods<EDD, keyof EDD> & OakSingleComponentMethods<EDD, keyof EDD> & {
|
OakCommonComponentMethods<EDD, keyof EDD> & OakListComponentMethods<EDD, keyof EDD> & OakSingleComponentMethods<EDD, keyof EDD> & {
|
||||||
iAmThePage: () => boolean;
|
iAmThePage: () => boolean;
|
||||||
setState: (data: Record<string, any>, callback: () => void) => void;
|
setState: (data: Record<string, any>, callback?: () => void) => void;
|
||||||
onLoad: (query: Record<string, any>) => Promise<void>;
|
onLoad: (query: Record<string, any>) => Promise<void>;
|
||||||
onPullDownRefresh: () => Promise<void>;
|
onPullDownRefresh: () => Promise<void>;
|
||||||
onReachBottom: () => Promise<void>;
|
onReachBottom: () => Promise<void>;
|
||||||
|
|
@ -83,6 +83,11 @@ const oakBehavior = Behavior<
|
||||||
>
|
>
|
||||||
}>({
|
}>({
|
||||||
methods: {
|
methods: {
|
||||||
|
setDisablePulldownRefresh(able) {
|
||||||
|
this.setState({
|
||||||
|
oakDisablePulldownRefresh: able,
|
||||||
|
});
|
||||||
|
},
|
||||||
t(key: string, params?: object) {
|
t(key: string, params?: object) {
|
||||||
// common: {
|
// common: {
|
||||||
// GREETING: 'Hello {{name}}, nice to see you.',
|
// GREETING: 'Hello {{name}}, nice to see you.',
|
||||||
|
|
@ -123,7 +128,7 @@ const oakBehavior = Behavior<
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
setState(data: Record<string, any>, callback: () => void) {
|
setState(data: Record<string, any>, callback?: () => void) {
|
||||||
this.setData(data, () => {
|
this.setData(data, () => {
|
||||||
this.state = this.data;
|
this.state = this.data;
|
||||||
callback && callback.call(this);
|
callback && callback.call(this);
|
||||||
|
|
@ -194,7 +199,7 @@ const oakBehavior = Behavior<
|
||||||
},
|
},
|
||||||
|
|
||||||
async onPullDownRefresh() {
|
async onPullDownRefresh() {
|
||||||
if (!this.state.oakLoading && this.iAmThePage()) {
|
if (!this.state.oakLoading && this.iAmThePage() && !this.state.oakDisablePulldownRefresh && !this.props.oakDisablePulldownRefresh) {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
}
|
}
|
||||||
await wx.stopPullDownRefresh();
|
await wx.stopPullDownRefresh();
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,7 @@ export type OakListComponentMethods<ED extends EntityDict & BaseEntityDict, T ex
|
||||||
addItem: (data: Omit<ED[T]['CreateSingle']['data'], 'id'>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
addItem: (data: Omit<ED[T]['CreateSingle']['data'], 'id'>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
||||||
removeItem: (id: string, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
removeItem: (id: string, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
||||||
updateItem: (data: ED[T]['Update']['data'], id: string, action?: ED[T]['Action'], beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
updateItem: (data: ED[T]['Update']['data'], id: string, action?: ED[T]['Action'], beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
||||||
|
recoverItem: (id: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ComponentOnPropsChangeOption = {
|
type ComponentOnPropsChangeOption = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue