Merge branch 'release'
This commit is contained in:
commit
5c239d5975
|
|
@ -42,7 +42,7 @@ async function execWatcher(store, watcher, context) {
|
|||
const data = typeof actionData === 'function' ? await actionData() : actionData; // 这里有个奇怪的编译错误,不理解 by Xc
|
||||
const result = await store.operate(entity, {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
action: action,
|
||||
data,
|
||||
filter: filter2
|
||||
}, context, {
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
|
|||
update(data: ED[T]['Update']['data'], action?: ED[T]['Action']): void;
|
||||
remove(): void;
|
||||
setDirty(): void;
|
||||
composeOperations(): Array<{
|
||||
composeOperations(fromParent?: boolean): Array<{
|
||||
entity: keyof ED;
|
||||
operation: ED[keyof ED]['Operation'];
|
||||
}> | undefined;
|
||||
|
|
|
|||
|
|
@ -206,6 +206,9 @@ class ListNode extends Node {
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total += 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count += 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -217,6 +220,9 @@ class ListNode extends Node {
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total += 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -236,6 +242,9 @@ class ListNode extends Node {
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -245,6 +254,9 @@ class ListNode extends Node {
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -286,6 +298,12 @@ class ListNode extends Node {
|
|||
ids.forEach((id) => {
|
||||
if (!rows2.find(ele => ele.id === id)) {
|
||||
unset(this.sr, id);
|
||||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -626,17 +644,27 @@ class ListNode extends Node {
|
|||
if (!this.dirty) {
|
||||
return;
|
||||
}
|
||||
const parentFilter = this.parent instanceof SingleNode && this.parent.getParentFilter(this);
|
||||
const operations = [];
|
||||
for (const id in this.updates) {
|
||||
if (this.updates[id]) {
|
||||
const operation = cloneDeep(this.updates[id]);
|
||||
if (parentFilter) {
|
||||
if (operation.action === 'create') {
|
||||
Object.assign(operation.data, parentFilter);
|
||||
}
|
||||
else {
|
||||
operation.filter = combineFilters(this.entity, this.schema, [operation.filter, parentFilter]);
|
||||
}
|
||||
}
|
||||
operations.push({
|
||||
entity: this.entity,
|
||||
operation: cloneDeep(this.updates[id]),
|
||||
operation,
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const id in this.children) {
|
||||
const childOperation = this.children[id].composeOperations();
|
||||
const childOperation = this.children[id].composeOperations(true);
|
||||
if (childOperation) {
|
||||
// 现在因为后台有not null检查,不能先create再update,所以还是得合并成一个
|
||||
assert(childOperation.length === 1);
|
||||
|
|
@ -750,7 +778,7 @@ class ListNode extends Node {
|
|||
// this.publish();
|
||||
}
|
||||
async refresh(pageNumber, append) {
|
||||
const { entity, pagination } = this;
|
||||
const { entity, pagination, getTotal } = this;
|
||||
const { currentPage, pageSize, randomRange } = pagination;
|
||||
const currentPage3 = typeof pageNumber === 'number' ? pageNumber : currentPage;
|
||||
assert(!randomRange || !currentPage3, 'list在访问数据时,如果设置了randomRange,则不应再有pageNumber');
|
||||
|
|
@ -1122,15 +1150,21 @@ class SingleNode extends Node {
|
|||
}
|
||||
super.setDirty();
|
||||
}
|
||||
composeOperations() {
|
||||
composeOperations(fromParent) {
|
||||
if (this.dirty) {
|
||||
// 如果父亲是一个list,这里可能是create出来的新结点,要到parent上获取create动作
|
||||
if (this.parent instanceof ListNode && !fromParent) {
|
||||
const operations = this.parent.composeOperations();
|
||||
return operations.filter(ele => ele.operation.action === 'create' && ele.operation.data.id === this.id ||
|
||||
ele.operation.filter.id === this.id);
|
||||
}
|
||||
const operation = this.operation && cloneDeep(this.operation);
|
||||
if (operation) {
|
||||
operation.filter = this.getFilter();
|
||||
for (const ele in this.children) {
|
||||
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||
const child = this.children[ele];
|
||||
const childOperations = child.composeOperations();
|
||||
const childOperations = child.composeOperations(true);
|
||||
if (childOperations) {
|
||||
if (child instanceof SingleNode) {
|
||||
assert(childOperations.length === 1);
|
||||
|
|
@ -1479,7 +1513,7 @@ class VirtualNode extends Feature {
|
|||
const operationss = [];
|
||||
const operationDict = {};
|
||||
for (const ele in this.children) {
|
||||
const operation = this.children[ele].composeOperations();
|
||||
const operation = this.children[ele].composeOperations(true);
|
||||
if (operation) {
|
||||
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||
if (operationDict[idx]) {
|
||||
|
|
|
|||
|
|
@ -179,10 +179,4 @@ export class SubScriber extends Feature {
|
|||
return this.socket.id;
|
||||
}
|
||||
}
|
||||
|
||||
closeSocket() {
|
||||
if (this.socket) {
|
||||
this.socket.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ export type RowWithActions<ED extends EntityDict & BaseEntityDict, T extends key
|
|||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||
};
|
||||
};
|
||||
type FeatureDef<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, AsyncContext<ED>>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends DataOption, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = (keyof (FD & BasicFeatures<ED>)) | {
|
||||
type FeatureDef<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends DataOption, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = (keyof (FD & BasicFeatures<ED>)) | {
|
||||
feature: keyof (FD & BasicFeatures<ED>);
|
||||
behavior?: 'reRender' | 'refresh';
|
||||
callback?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => void;
|
||||
};
|
||||
type DevideWidth = 'pc' | 'mobile';
|
||||
interface ComponentOption<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, AsyncContext<ED>>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends DataOption, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> {
|
||||
interface ComponentOption<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends DataOption, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> {
|
||||
isList?: IsList;
|
||||
getTotal?: {
|
||||
max: number;
|
||||
|
|
@ -83,7 +83,7 @@ export type ReactComponentProps<ED extends EntityDict & BaseEntityDict, T extend
|
|||
style?: Record<string, any>;
|
||||
};
|
||||
export type ComponentData<ED extends EntityDict & BaseEntityDict, T extends keyof ED, FormedData extends DataOption, TData extends DataOption> = TData & FormedData & OakComponentData<ED, T>;
|
||||
export type ComponentPublicThisType<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, AsyncContext<ED>>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends Record<string, any> = {}, TProperty extends DataOption = {}, TMethod extends MethodOption = {}, EMethod extends Record<string, Function> = {}> = {
|
||||
export type ComponentPublicThisType<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends Record<string, any> = {}, TProperty extends DataOption = {}, TMethod extends MethodOption = {}, EMethod extends Record<string, Function> = {}> = {
|
||||
features: FD & BasicFeatures<ED>;
|
||||
state: ComponentData<ED, T, FormedData, TData>;
|
||||
props: Readonly<ComponentProps<ED, T, TProperty>>;
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ export const isWeiXin = window && /MicroMessenger/i.test(navigator.userAgent);
|
|||
export const isWeiXinDevTools = window && /wechatdevtools/i.test(navigator.userAgent);
|
||||
//是否在微信小程序内
|
||||
//@ts-ignore
|
||||
export const isWeiXinMp = window && window.__wxjs_environment === 'miniprogram' || /miniProgram/i.test(navigator.userAgent);
|
||||
export const isWeiXinMp = window && window.__wxjs_environment === 'miniprogram' || (navigator && /miniProgram/i.test(navigator.userAgent));
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ async function execWatcher(store, watcher, context) {
|
|||
const data = typeof actionData === 'function' ? await actionData() : actionData; // 这里有个奇怪的编译错误,不理解 by Xc
|
||||
const result = await store.operate(entity, {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action,
|
||||
action: action,
|
||||
data,
|
||||
filter: filter2
|
||||
}, context, {
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
|
|||
update(data: ED[T]['Update']['data'], action?: ED[T]['Action']): void;
|
||||
remove(): void;
|
||||
setDirty(): void;
|
||||
composeOperations(): Array<{
|
||||
composeOperations(fromParent?: boolean): Array<{
|
||||
entity: keyof ED;
|
||||
operation: ED[keyof ED]['Operation'];
|
||||
}> | undefined;
|
||||
|
|
|
|||
|
|
@ -209,6 +209,9 @@ class ListNode extends Node {
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total += 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count += 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -220,6 +223,9 @@ class ListNode extends Node {
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total += 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -239,6 +245,9 @@ class ListNode extends Node {
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -248,6 +257,9 @@ class ListNode extends Node {
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -289,6 +301,12 @@ class ListNode extends Node {
|
|||
ids.forEach((id) => {
|
||||
if (!rows2.find(ele => ele.id === id)) {
|
||||
(0, lodash_1.unset)(this.sr, id);
|
||||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -629,17 +647,27 @@ class ListNode extends Node {
|
|||
if (!this.dirty) {
|
||||
return;
|
||||
}
|
||||
const parentFilter = this.parent instanceof SingleNode && this.parent.getParentFilter(this);
|
||||
const operations = [];
|
||||
for (const id in this.updates) {
|
||||
if (this.updates[id]) {
|
||||
const operation = (0, lodash_1.cloneDeep)(this.updates[id]);
|
||||
if (parentFilter) {
|
||||
if (operation.action === 'create') {
|
||||
Object.assign(operation.data, parentFilter);
|
||||
}
|
||||
else {
|
||||
operation.filter = (0, filter_1.combineFilters)(this.entity, this.schema, [operation.filter, parentFilter]);
|
||||
}
|
||||
}
|
||||
operations.push({
|
||||
entity: this.entity,
|
||||
operation: (0, lodash_1.cloneDeep)(this.updates[id]),
|
||||
operation,
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const id in this.children) {
|
||||
const childOperation = this.children[id].composeOperations();
|
||||
const childOperation = this.children[id].composeOperations(true);
|
||||
if (childOperation) {
|
||||
// 现在因为后台有not null检查,不能先create再update,所以还是得合并成一个
|
||||
(0, assert_1.assert)(childOperation.length === 1);
|
||||
|
|
@ -753,7 +781,7 @@ class ListNode extends Node {
|
|||
// this.publish();
|
||||
}
|
||||
async refresh(pageNumber, append) {
|
||||
const { entity, pagination } = this;
|
||||
const { entity, pagination, getTotal } = this;
|
||||
const { currentPage, pageSize, randomRange } = pagination;
|
||||
const currentPage3 = typeof pageNumber === 'number' ? pageNumber : currentPage;
|
||||
(0, assert_1.assert)(!randomRange || !currentPage3, 'list在访问数据时,如果设置了randomRange,则不应再有pageNumber');
|
||||
|
|
@ -1125,15 +1153,21 @@ class SingleNode extends Node {
|
|||
}
|
||||
super.setDirty();
|
||||
}
|
||||
composeOperations() {
|
||||
composeOperations(fromParent) {
|
||||
if (this.dirty) {
|
||||
// 如果父亲是一个list,这里可能是create出来的新结点,要到parent上获取create动作
|
||||
if (this.parent instanceof ListNode && !fromParent) {
|
||||
const operations = this.parent.composeOperations();
|
||||
return operations.filter(ele => ele.operation.action === 'create' && ele.operation.data.id === this.id ||
|
||||
ele.operation.filter.id === this.id);
|
||||
}
|
||||
const operation = this.operation && (0, lodash_1.cloneDeep)(this.operation);
|
||||
if (operation) {
|
||||
operation.filter = this.getFilter();
|
||||
for (const ele in this.children) {
|
||||
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||
const child = this.children[ele];
|
||||
const childOperations = child.composeOperations();
|
||||
const childOperations = child.composeOperations(true);
|
||||
if (childOperations) {
|
||||
if (child instanceof SingleNode) {
|
||||
(0, assert_1.assert)(childOperations.length === 1);
|
||||
|
|
@ -1482,7 +1516,7 @@ class VirtualNode extends Feature_1.Feature {
|
|||
const operationss = [];
|
||||
const operationDict = {};
|
||||
for (const ele in this.children) {
|
||||
const operation = this.children[ele].composeOperations();
|
||||
const operation = this.children[ele].composeOperations(true);
|
||||
if (operation) {
|
||||
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||
if (operationDict[idx]) {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ class SubScriber extends Feature_1.Feature {
|
|||
if (this.socketState === 'unconnected') {
|
||||
return this.connect();
|
||||
}
|
||||
else if (this.socketState === 'connecting') {
|
||||
return this.connect();
|
||||
}
|
||||
else if (this.socketState === 'connected' && newEvents.length > 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.socket.emit('sub', newEvents, (result) => {
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ export type RowWithActions<ED extends EntityDict & BaseEntityDict, T extends key
|
|||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||
};
|
||||
};
|
||||
type FeatureDef<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, AsyncContext<ED>>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends DataOption, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = (keyof (FD & BasicFeatures<ED>)) | {
|
||||
type FeatureDef<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends DataOption, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = (keyof (FD & BasicFeatures<ED>)) | {
|
||||
feature: keyof (FD & BasicFeatures<ED>);
|
||||
behavior?: 'reRender' | 'refresh';
|
||||
callback?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => void;
|
||||
};
|
||||
type DevideWidth = 'pc' | 'mobile';
|
||||
interface ComponentOption<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, AsyncContext<ED>>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends DataOption, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> {
|
||||
interface ComponentOption<IsList extends boolean, ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, TData extends DataOption, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> {
|
||||
isList?: IsList;
|
||||
getTotal?: {
|
||||
max: number;
|
||||
|
|
@ -83,7 +83,7 @@ export type ReactComponentProps<ED extends EntityDict & BaseEntityDict, T extend
|
|||
style?: Record<string, any>;
|
||||
};
|
||||
export type ComponentData<ED extends EntityDict & BaseEntityDict, T extends keyof ED, FormedData extends DataOption, TData extends DataOption> = TData & FormedData & OakComponentData<ED, T>;
|
||||
export type ComponentPublicThisType<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, AsyncContext<ED>>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends Record<string, any> = {}, TProperty extends DataOption = {}, TMethod extends MethodOption = {}, EMethod extends Record<string, Function> = {}> = {
|
||||
export type ComponentPublicThisType<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends Record<string, any> = {}, TProperty extends DataOption = {}, TMethod extends MethodOption = {}, EMethod extends Record<string, Function> = {}> = {
|
||||
features: FD & BasicFeatures<ED>;
|
||||
state: ComponentData<ED, T, FormedData, TData>;
|
||||
props: Readonly<ComponentProps<ED, T, TProperty>>;
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ exports.isWeiXin = window && /MicroMessenger/i.test(navigator.userAgent);
|
|||
exports.isWeiXinDevTools = window && /wechatdevtools/i.test(navigator.userAgent);
|
||||
//是否在微信小程序内
|
||||
//@ts-ignore
|
||||
exports.isWeiXinMp = window && window.__wxjs_environment === 'miniprogram' || /miniProgram/i.test(navigator.userAgent);
|
||||
exports.isWeiXinMp = window && window.__wxjs_environment === 'miniprogram' || (navigator && /miniProgram/i.test(navigator.userAgent));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oak-frontend-base",
|
||||
"version": "5.1.1",
|
||||
"version": "5.1.2",
|
||||
"description": "oak框架中前端与业务逻辑无关的平台部分",
|
||||
"author": {
|
||||
"name": "XuChang"
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
"history": "^5.3.0",
|
||||
"i18n-js": "^4.3.0",
|
||||
"node-schedule": "^2.1.1",
|
||||
"oak-common-aspect": "~3.0.0",
|
||||
"oak-domain": "~5.0.8",
|
||||
"oak-common-aspect": "^3.0.0",
|
||||
"oak-domain": "~5.0.9",
|
||||
"oak-memory-tree-store": "~3.3.1",
|
||||
"ol": "^7.3.0",
|
||||
"react-native-device-info": "^10.12.0",
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ async function execWatcher<ED extends EntityDict & BaseEntityDict, Cxt extends A
|
|||
const data = typeof actionData === 'function' ? await (actionData as Function)() : actionData; // 这里有个奇怪的编译错误,不理解 by Xc
|
||||
const result = await store.operate(entity, {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
action: action as string,
|
||||
data,
|
||||
filter: filter2
|
||||
}, context, {
|
||||
|
|
|
|||
|
|
@ -276,6 +276,9 @@ class ListNode<
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total += 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -288,6 +291,9 @@ class ListNode<
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total += 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -307,6 +313,9 @@ class ListNode<
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -316,6 +325,9 @@ class ListNode<
|
|||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -360,6 +372,12 @@ class ListNode<
|
|||
(id) => {
|
||||
if (!rows2.find(ele => ele.id === id)) {
|
||||
unset(this.sr, id);
|
||||
if (typeof this.pagination.total === 'number') {
|
||||
this.pagination.total -= 1;
|
||||
}
|
||||
if (typeof this.pagination.count === 'number') {
|
||||
this.pagination.count -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -779,19 +797,29 @@ class ListNode<
|
|||
return;
|
||||
}
|
||||
|
||||
const parentFilter = this.parent instanceof SingleNode && this.parent.getParentFilter<T>(this as any);
|
||||
const operations: Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation'] }> = [];
|
||||
|
||||
for (const id in this.updates) {
|
||||
if (this.updates[id]) {
|
||||
const operation = cloneDeep(this.updates[id]);
|
||||
if (parentFilter) {
|
||||
if (operation.action === 'create') {
|
||||
Object.assign(operation.data, parentFilter);
|
||||
}
|
||||
else {
|
||||
operation.filter = combineFilters(this.entity, this.schema, [operation.filter, parentFilter]);
|
||||
}
|
||||
}
|
||||
operations.push({
|
||||
entity: this.entity,
|
||||
operation: cloneDeep(this.updates[id]),
|
||||
operation,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (const id in this.children) {
|
||||
const childOperation = this.children[id].composeOperations();
|
||||
const childOperation = this.children[id].composeOperations(true);
|
||||
if (childOperation) {
|
||||
// 现在因为后台有not null检查,不能先create再update,所以还是得合并成一个
|
||||
assert(childOperation.length === 1);
|
||||
|
|
@ -921,7 +949,7 @@ class ListNode<
|
|||
}
|
||||
|
||||
async refresh(pageNumber?: number, append?: boolean) {
|
||||
const { entity, pagination } = this;
|
||||
const { entity, pagination, getTotal } = this;
|
||||
const { currentPage, pageSize, randomRange } = pagination;
|
||||
const currentPage3 =
|
||||
typeof pageNumber === 'number' ? pageNumber : currentPage;
|
||||
|
|
@ -958,9 +986,13 @@ class ListNode<
|
|||
if (append) {
|
||||
this.loadingMore = false;
|
||||
}
|
||||
|
||||
|
||||
// 这里不能publish,因为
|
||||
this.saveRefreshResult(selectResult, append, currentPage3);
|
||||
this.saveRefreshResult(
|
||||
selectResult,
|
||||
append,
|
||||
currentPage3
|
||||
);
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
|
|
@ -1354,19 +1386,28 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
super.setDirty();
|
||||
}
|
||||
|
||||
composeOperations(): Array<{
|
||||
composeOperations(fromParent?: boolean): Array<{
|
||||
entity: keyof ED;
|
||||
operation: ED[keyof ED]['Operation'];
|
||||
}> | undefined {
|
||||
if (this.dirty) {
|
||||
const operation = this.operation && cloneDeep(this.operation);
|
||||
// 如果父亲是一个list,这里可能是create出来的新结点,要到parent上获取create动作
|
||||
if (this.parent instanceof ListNode && !fromParent) {
|
||||
const operations = this.parent.composeOperations();
|
||||
|
||||
return operations!.filter(
|
||||
ele => ele.operation.action === 'create' && (ele.operation.data as ED[keyof ED]['CreateSingle']['data']).id === this.id ||
|
||||
ele.operation.filter!.id === this.id
|
||||
)!;
|
||||
}
|
||||
|
||||
const operation = this.operation && cloneDeep(this.operation);
|
||||
if (operation) {
|
||||
operation.filter = this.getFilter();
|
||||
for (const ele in this.children) {
|
||||
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||
const child = this.children[ele];
|
||||
const childOperations = child!.composeOperations();
|
||||
const childOperations = child!.composeOperations(true);
|
||||
if (childOperations) {
|
||||
if (child instanceof SingleNode) {
|
||||
assert(childOperations.length === 1);
|
||||
|
|
@ -1746,7 +1787,7 @@ class VirtualNode<
|
|||
const operationss = [];
|
||||
const operationDict: Record<string, any> = {};
|
||||
for (const ele in this.children) {
|
||||
const operation = this.children[ele].composeOperations();
|
||||
const operation = this.children[ele].composeOperations(true);
|
||||
if (operation) {
|
||||
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||
if (operationDict[idx]) {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ type FeatureDef<
|
|||
T extends keyof ED,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, AsyncContext<ED>>>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>,
|
||||
FormedData extends Record<string, any>,
|
||||
TData extends DataOption,
|
||||
|
|
@ -127,7 +127,7 @@ interface ComponentOption<
|
|||
T extends keyof ED,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, AsyncContext<ED>>>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>,
|
||||
FormedData extends Record<string, any>,
|
||||
TData extends DataOption,
|
||||
|
|
@ -217,7 +217,7 @@ export type ComponentPublicThisType<
|
|||
T extends keyof ED,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, AsyncContext<ED>>>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>,
|
||||
FormedData extends Record<string, any>,
|
||||
IsList extends boolean,
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ export const isWeiXin = window && /MicroMessenger/i.test(navigator.userAgent);
|
|||
export const isWeiXinDevTools = window && /wechatdevtools/i.test(navigator.userAgent);
|
||||
//是否在微信小程序内
|
||||
//@ts-ignore
|
||||
export const isWeiXinMp = window && window.__wxjs_environment === 'miniprogram' || /miniProgram/i.test(navigator.userAgent);
|
||||
export const isWeiXinMp = window && window.__wxjs_environment === 'miniprogram' || (navigator && /miniProgram/i.test(navigator.userAgent));
|
||||
|
|
|
|||
Loading…
Reference in New Issue