Merge branch 'dev' into release
This commit is contained in:
commit
7669933394
|
|
@ -13,10 +13,10 @@ export default function Locate(props) {
|
||||||
const searchRef = useRef();
|
const searchRef = useRef();
|
||||||
// 这里不能用useFeatures,因为无法引用lib里面的provider,引用src注入是不行的
|
// 这里不能用useFeatures,因为无法引用lib里面的provider,引用src注入是不行的
|
||||||
const featureGeo = useFeatures().geo;
|
const featureGeo = useFeatures().geo;
|
||||||
useEffect(() => {
|
const searchFn = () => {
|
||||||
if (searchValue?.length > 1) {
|
if (searchValue?.length > 1) {
|
||||||
setSearchLoading(true);
|
setSearchLoading(true);
|
||||||
featureGeo.searchPoi(searchValue).then((result) => {
|
featureGeo.searchPoi(searchValue, props.areaId, undefined, 0, 10).then((result) => {
|
||||||
setSearchLoading(false);
|
setSearchLoading(false);
|
||||||
setPois(result.map((ele, idx) => ({
|
setPois(result.map((ele, idx) => ({
|
||||||
...ele,
|
...ele,
|
||||||
|
|
@ -33,9 +33,14 @@ export default function Locate(props) {
|
||||||
else {
|
else {
|
||||||
setPois(undefined);
|
setPois(undefined);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
let handle;
|
||||||
|
useEffect(() => {
|
||||||
|
handle = setTimeout(searchFn, 1000);
|
||||||
}, [searchValue]);
|
}, [searchValue]);
|
||||||
const center = currentPoi?.coordinate || props.coordinate;
|
const center = currentPoi?.coordinate || props.coordinate;
|
||||||
const Locate = (<List className={Styles["location-list"]} header={<Input ref={searchRef} placeholder="请输入完整名称(如“浙江大学”)而非简称(如“浙大”)" value={searchValue} allowClear onChange={(e) => {
|
const Locate = (<List className={Styles["location-list"]} header={<Input ref={searchRef} placeholder="请输入完整名称(如“浙江大学”)而非简称(如“浙大”)" value={searchValue} allowClear onChange={(e) => {
|
||||||
|
clearTimeout(handle);
|
||||||
setSearchValue(e.target.value);
|
setSearchValue(e.target.value);
|
||||||
}} prefix={<SearchOutlined />} onFocus={() => {
|
}} prefix={<SearchOutlined />} onFocus={() => {
|
||||||
setMode('searchPoi');
|
setMode('searchPoi');
|
||||||
|
|
@ -76,6 +81,7 @@ export default function Locate(props) {
|
||||||
return (<Row gutter={[16, 16]} style={{
|
return (<Row gutter={[16, 16]} style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
minHeight: 600,
|
minHeight: 600,
|
||||||
|
maxHeight: '100%',
|
||||||
}}>
|
}}>
|
||||||
<Col xs={24} sm={14}>
|
<Col xs={24} sm={14}>
|
||||||
<Map2 style={{ height: '100%' }} id="location-map" center={center} markers={center ? [center] : undefined}/>
|
<Map2 style={{ height: '100%' }} id="location-map" center={center} markers={center ? [center] : undefined}/>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
.location-list {
|
.location-list {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow-y: scroll;
|
||||||
|
max-height: 600px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { assert } from 'oak-domain/lib/utils/assert';
|
import { assert } from 'oak-domain/lib/utils/assert';
|
||||||
|
import { wgs84togcj02 } from 'oak-domain/lib/utils/geo';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import OlMap from 'ol/Map';
|
import OlMap from 'ol/Map';
|
||||||
import Feature from 'ol/Feature';
|
import Feature from 'ol/Feature';
|
||||||
|
|
@ -27,6 +28,7 @@ export default function Map(props) {
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
source: new XYZ({
|
source: new XYZ({
|
||||||
|
// 用的高德的瓦片,gcj02坐标
|
||||||
url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}',
|
url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}',
|
||||||
wrapX: false,
|
wrapX: false,
|
||||||
}),
|
}),
|
||||||
|
|
@ -36,7 +38,7 @@ export default function Map(props) {
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
view: new View({
|
view: new View({
|
||||||
center: fromLonLat(props.center || DEFAULT_CENTER),
|
center: fromLonLat(wgs84togcj02(props.center || DEFAULT_CENTER)),
|
||||||
zoom: props.zoom || DEFAULT_ZOOM,
|
zoom: props.zoom || DEFAULT_ZOOM,
|
||||||
minZoom: props.unzoomable ? props.zoom : undefined,
|
minZoom: props.unzoomable ? props.zoom : undefined,
|
||||||
maxZoom: props.unzoomable ? props.zoom : undefined,
|
maxZoom: props.unzoomable ? props.zoom : undefined,
|
||||||
|
|
@ -59,7 +61,7 @@ export default function Map(props) {
|
||||||
}
|
}
|
||||||
if (!props.center) {
|
if (!props.center) {
|
||||||
locate().then(({ latitude, longitude }) => {
|
locate().then(({ latitude, longitude }) => {
|
||||||
map2.getView().setCenter(fromLonLat([longitude, latitude]));
|
map2.getView().setCenter(fromLonLat(wgs84togcj02([longitude, latitude])));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setMap(map2);
|
setMap(map2);
|
||||||
|
|
@ -71,13 +73,13 @@ export default function Map(props) {
|
||||||
const oc2 = toLonLat(originCenter);
|
const oc2 = toLonLat(originCenter);
|
||||||
if (oc2[0] !== props.center[0] || oc2[1] !== props.center[1]) {
|
if (oc2[0] !== props.center[0] || oc2[1] !== props.center[1]) {
|
||||||
map.getView().animate({
|
map.getView().animate({
|
||||||
center: fromLonLat(props.center),
|
center: fromLonLat(wgs84togcj02(props.center)),
|
||||||
duration: 500,
|
duration: 500,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
map.getView().setCenter(fromLonLat(props.center));
|
map.getView().setCenter(fromLonLat(wgs84togcj02(props.center)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [props.center]);
|
}, [props.center]);
|
||||||
|
|
@ -92,11 +94,11 @@ export default function Map(props) {
|
||||||
let feature = markerLayer.getSource().getFeatureById('markers');
|
let feature = markerLayer.getSource().getFeatureById('markers');
|
||||||
if (feature) {
|
if (feature) {
|
||||||
// feature.setGeometry(new MultiPoint(props.markers.map(ele => fromLonLat(ele))));
|
// feature.setGeometry(new MultiPoint(props.markers.map(ele => fromLonLat(ele))));
|
||||||
feature.setGeometry(new Point(fromLonLat(props.markers[0])));
|
feature.setGeometry(new Point(fromLonLat(wgs84togcj02(props.markers[0]))));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// feature = new Feature(new MultiPoint(props.markers.map(ele => fromLonLat(ele))));
|
// feature = new Feature(new MultiPoint(props.markers.map(ele => fromLonLat(ele))));
|
||||||
feature = new Feature(new Point(fromLonLat(props.markers[0])));
|
feature = new Feature(new Point(fromLonLat(wgs84togcj02(props.markers[0]))));
|
||||||
feature.setStyle(new Style({
|
feature.setStyle(new Style({
|
||||||
image: new Circle({
|
image: new Circle({
|
||||||
// 点的颜色
|
// 点的颜色
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"tips": {
|
|
||||||
"remove": "如果关系路径上关联了actionAuth或者relationAuth,删除将会失败"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { Cache } from './cache';
|
||||||
export declare class Geo<ED extends EntityDict & BaseEntityDict> extends Feature {
|
export declare class Geo<ED extends EntityDict & BaseEntityDict> extends Feature {
|
||||||
private cache;
|
private cache;
|
||||||
constructor(cache: Cache<ED>);
|
constructor(cache: Cache<ED>);
|
||||||
searchPoi(name: string, areaId?: string, typeCode?: string): Promise<{
|
searchPoi(name: string, areaId?: string, typeCode?: string, indexFrom?: number, count?: number): Promise<{
|
||||||
poiName: string;
|
poiName: string;
|
||||||
areaId: string;
|
areaId: string;
|
||||||
latitude: number;
|
latitude: number;
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,14 @@ export class Geo extends Feature {
|
||||||
super();
|
super();
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
async searchPoi(name, areaId, typeCode) {
|
async searchPoi(name, areaId, typeCode, indexFrom, count) {
|
||||||
const { result } = await this.cache.exec('geoService', {
|
const { result } = await this.cache.exec('geoService', {
|
||||||
api: 'geo',
|
api: 'geo',
|
||||||
params: {
|
params: {
|
||||||
name,
|
name,
|
||||||
areaId
|
areaId,
|
||||||
|
indexFrom,
|
||||||
|
count,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ declare class ListNode<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
||||||
*/
|
*/
|
||||||
updateItem(lsn: number, data: ED[T]['Update']['data'], id: string, action?: ED[T]['Action']): void;
|
updateItem(lsn: number, data: ED[T]['Update']['data'], id: string, action?: ED[T]['Action']): void;
|
||||||
updateItems(lsn: number, data: Record<string, ED[T]['Update']['data']>, ids: string[], action?: ED[T]['Action']): void;
|
updateItems(lsn: number, data: Record<string, ED[T]['Update']['data']>, ids: string[], action?: ED[T]['Action']): void;
|
||||||
composeOperations(): Array<{
|
composeOperations(includeModiBranch?: boolean): Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}> | undefined;
|
}> | undefined;
|
||||||
|
|
@ -214,7 +214,12 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
|
||||||
update(lsn: number, data: ED[T]['Update']['data'], action?: ED[T]['Action']): void;
|
update(lsn: number, data: ED[T]['Update']['data'], action?: ED[T]['Action']): void;
|
||||||
remove(lsn: number): void;
|
remove(lsn: number): void;
|
||||||
setDirty(): void;
|
setDirty(): void;
|
||||||
composeOperations(fromParent?: boolean): Array<{
|
/**
|
||||||
|
*
|
||||||
|
* @param includeModiBranch 如果显式置了boolean,代表只要考虑前项路径或者后项路径
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
composeOperations(includeModiBranch?: boolean): Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}> | undefined;
|
}> | undefined;
|
||||||
|
|
@ -249,7 +254,7 @@ declare class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<E
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
getFreshValue(): undefined;
|
getFreshValue(): undefined;
|
||||||
refresh(): Promise<void>;
|
refresh(): Promise<void>;
|
||||||
composeOperations(): Array<{
|
composeOperations(includeModiBranch?: boolean): Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}> | undefined;
|
}> | undefined;
|
||||||
|
|
|
||||||
|
|
@ -827,14 +827,14 @@ class ListNode extends EntityNode {
|
||||||
ids.forEach((id) => this.updateItemInner(lsn, data, id, action));
|
ids.forEach((id) => this.updateItemInner(lsn, data, id, action));
|
||||||
this.setDirty();
|
this.setDirty();
|
||||||
}
|
}
|
||||||
composeOperations() {
|
composeOperations(includeModiBranch) {
|
||||||
if (!this.dirty) {
|
if (!this.dirty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const intrinsticFilter = this.getIntrinsticFilters();
|
const intrinsticFilter = this.getIntrinsticFilters();
|
||||||
const ulmLsn = this.ulManager.maxLsn;
|
const ulmLsn = this.ulManager.maxLsn;
|
||||||
for (const id in this.children) {
|
for (const id in this.children) {
|
||||||
const childOperations = this.children[id].composeOperations(true);
|
const childOperations = this.children[id].composeOperations(includeModiBranch);
|
||||||
if (childOperations) {
|
if (childOperations) {
|
||||||
childOperations.forEach((childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation));
|
childOperations.forEach((childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation));
|
||||||
}
|
}
|
||||||
|
|
@ -1315,13 +1315,22 @@ class SingleNode extends EntityNode {
|
||||||
});
|
});
|
||||||
super.setDirty();
|
super.setDirty();
|
||||||
}
|
}
|
||||||
composeOperations(fromParent) {
|
/**
|
||||||
|
*
|
||||||
|
* @param includeModiBranch 如果显式置了boolean,代表只要考虑前项路径或者后项路径
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
composeOperations(includeModiBranch) {
|
||||||
if (this.dirty) {
|
if (this.dirty) {
|
||||||
const lsnMax = this.ulManager.maxLsn;
|
const lsnMax = this.ulManager.maxLsn;
|
||||||
for (const ele in this.children) {
|
for (const ele in this.children) {
|
||||||
|
if (ele.includes(MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch ||
|
||||||
|
(!ele.includes(MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||||
const child = this.children[ele];
|
const child = this.children[ele];
|
||||||
const childOperations = child.composeOperations(true);
|
const childOperations = child.composeOperations(includeModiBranch);
|
||||||
if (childOperations) {
|
if (childOperations) {
|
||||||
if (child instanceof SingleNode) {
|
if (child instanceof SingleNode) {
|
||||||
assert(childOperations.length === 1);
|
assert(childOperations.length === 1);
|
||||||
|
|
@ -1680,14 +1689,18 @@ class VirtualNode extends Node {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
composeOperations() {
|
composeOperations(includeModiBranch) {
|
||||||
/**
|
/**
|
||||||
* 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并
|
* 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并
|
||||||
*/
|
*/
|
||||||
const operationss = [];
|
const operationss = [];
|
||||||
const operationDict = {};
|
const operationDict = {};
|
||||||
for (const ele in this.children) {
|
for (const ele in this.children) {
|
||||||
const operation = this.children[ele].composeOperations(true);
|
if (ele.includes(MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch ||
|
||||||
|
(!ele.includes(MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const operation = this.children[ele].composeOperations(includeModiBranch);
|
||||||
if (operation) {
|
if (operation) {
|
||||||
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||||
if (operationDict[idx]) {
|
if (operationDict[idx]) {
|
||||||
|
|
@ -1928,7 +1941,7 @@ export class RunningTree extends Feature {
|
||||||
redoBranchOperations(path, allowInTxn) {
|
redoBranchOperations(path, allowInTxn) {
|
||||||
const { root } = analyzePath(path);
|
const { root } = analyzePath(path);
|
||||||
const rootNode = this.root[root];
|
const rootNode = this.root[root];
|
||||||
const opers = rootNode.composeOperations();
|
const opers = rootNode.composeOperations(path.includes(MODI_NEXT_PATH_SUFFIX));
|
||||||
if (opers) {
|
if (opers) {
|
||||||
this.cache.redoOperation(opers);
|
this.cache.redoOperation(opers);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,32 +37,63 @@ type FeatureDef<IsList extends boolean, ED extends EntityDict & BaseEntityDict,
|
||||||
type DevideWidth = 'pc' | 'mobile';
|
type DevideWidth = 'pc' | 'mobile';
|
||||||
export type CreateDataDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = ED[T]['CreateSingle']['data'] | (() => ED[T]['CreateSingle']['data']);
|
export type CreateDataDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = ED[T]['CreateSingle']['data'] | (() => ED[T]['CreateSingle']['data']);
|
||||||
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> = {}> {
|
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;
|
isList?: IsList;
|
||||||
zombie?: true;
|
zombie?: true;
|
||||||
getTotal?: {
|
getTotal?: {
|
||||||
max: number;
|
max: number;
|
||||||
deviceWidth?: DevideWidth | 'all';
|
deviceWidth?: DevideWidth | 'all';
|
||||||
} | number;
|
} | number;
|
||||||
|
/**
|
||||||
|
* 组件所关联的实体
|
||||||
|
*/
|
||||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
||||||
path?: string;
|
path?: string;
|
||||||
|
/**
|
||||||
|
* 需要监听的features
|
||||||
|
*/
|
||||||
features?: FeatureDef<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod>[];
|
features?: FeatureDef<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod>[];
|
||||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
||||||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 需要校验的actions
|
||||||
|
*/
|
||||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
||||||
|
/**
|
||||||
|
* 需要获取的数据字段
|
||||||
|
* 若嵌套在list中,需要保证父list组件能够覆盖子组件的projection
|
||||||
|
*/
|
||||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
||||||
append?: boolean;
|
append?: boolean;
|
||||||
|
/**
|
||||||
|
* 分页信息
|
||||||
|
*/
|
||||||
pagination?: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> | Array<Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> & {
|
pagination?: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> | Array<Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> & {
|
||||||
deviceWidth: DevideWidth;
|
deviceWidth: DevideWidth;
|
||||||
}>;
|
}>;
|
||||||
|
/**
|
||||||
|
* 过滤器
|
||||||
|
*/
|
||||||
filters?: Array<{
|
filters?: Array<{
|
||||||
filter: NonNullable<ED[T]['Selection']['filter']> | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
filter: NonNullable<ED[T]['Selection']['filter']> | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
|
/**
|
||||||
|
* 排序器
|
||||||
|
*/
|
||||||
sorters?: Array<{
|
sorters?: Array<{
|
||||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['sorter'] | NonNullable<ED[T]['Selection']['sorter']>[number]);
|
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['sorter'] | NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
|
/**
|
||||||
|
* 表单数据
|
||||||
|
* 在组件渲染前会调用此方法,将返回的数据放入组件的data中
|
||||||
|
* @param options 组件获取到的数据
|
||||||
|
* @returns 返回给页面的数据
|
||||||
|
*/
|
||||||
formData?: (options: {
|
formData?: (options: {
|
||||||
data: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
data: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
||||||
origin?: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
origin?: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
||||||
|
|
@ -74,8 +105,17 @@ interface ComponentOption<IsList extends boolean, ED extends EntityDict & BaseEn
|
||||||
modified: boolean;
|
modified: boolean;
|
||||||
}) => FormedData;
|
}) => FormedData;
|
||||||
ns?: T | T[];
|
ns?: T | T[];
|
||||||
|
/**
|
||||||
|
* 声明的State数据
|
||||||
|
*/
|
||||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
||||||
|
/**
|
||||||
|
* 需要参数传入的默认prop参数
|
||||||
|
*/
|
||||||
properties?: TProperty;
|
properties?: TProperty;
|
||||||
|
/**
|
||||||
|
* 自定义方法
|
||||||
|
*/
|
||||||
methods?: TMethod;
|
methods?: TMethod;
|
||||||
}
|
}
|
||||||
export type MiniprogramStyleMethods = {
|
export type MiniprogramStyleMethods = {
|
||||||
|
|
@ -106,17 +146,63 @@ export type ComponentFullThisType<ED extends EntityDict & BaseEntityDict, T exte
|
||||||
oakLifetime: OakLifetime;
|
oakLifetime: OakLifetime;
|
||||||
} & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
} & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
||||||
export type OakComponentOption<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 Record<string, any>, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = ComponentOption<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod> & Partial<{
|
export type OakComponentOption<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 Record<string, any>, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = ComponentOption<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod> & Partial<{
|
||||||
|
/**
|
||||||
|
* 生命周期回调
|
||||||
|
*/
|
||||||
lifetimes: {
|
lifetimes: {
|
||||||
|
/**
|
||||||
|
* 在组件实例刚刚被创建时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
created?(): void;
|
created?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例进入页面节点树时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
attached?(): void;
|
attached?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例进入页面节点树时执行
|
||||||
|
* async or sync
|
||||||
|
*/
|
||||||
ready?(): any;
|
ready?(): any;
|
||||||
|
/**
|
||||||
|
* 小程序专用,在组件实例被移动到节点树另一个位置时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
moved?(): void;
|
moved?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例被从页面节点树移除时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
detached?(): void;
|
detached?(): void;
|
||||||
|
/**
|
||||||
|
* 小程序专用,每当组件方法抛出错误时执行
|
||||||
|
* sync only
|
||||||
|
* @param err 错误信息
|
||||||
|
*/
|
||||||
error?(err: Error): void;
|
error?(err: Error): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面被展示时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
show?(): void;
|
show?(): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面被隐藏时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
hide?(): void;
|
hide?(): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面尺寸变化时执行
|
||||||
|
* sync only
|
||||||
|
* @param size 页面尺寸信息
|
||||||
|
*/
|
||||||
resize?(size: WechatMiniprogram.Page.IResizeOption): void;
|
resize?(size: WechatMiniprogram.Page.IResizeOption): void;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 监听器,监听State或者Props的变化
|
||||||
|
* 名称:监听的属性名
|
||||||
|
* 回调:监听的回调函数 (prev, next) => void
|
||||||
|
*/
|
||||||
listeners: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
listeners: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
||||||
}> & Partial<{
|
}> & Partial<{
|
||||||
wechatMp: {
|
wechatMp: {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { Cache } from './cache';
|
||||||
export declare class Geo<ED extends EntityDict & BaseEntityDict> extends Feature {
|
export declare class Geo<ED extends EntityDict & BaseEntityDict> extends Feature {
|
||||||
private cache;
|
private cache;
|
||||||
constructor(cache: Cache<ED>);
|
constructor(cache: Cache<ED>);
|
||||||
searchPoi(name: string, areaId?: string, typeCode?: string): Promise<{
|
searchPoi(name: string, areaId?: string, typeCode?: string, indexFrom?: number, count?: number): Promise<{
|
||||||
poiName: string;
|
poiName: string;
|
||||||
areaId: string;
|
areaId: string;
|
||||||
latitude: number;
|
latitude: number;
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,14 @@ class Geo extends Feature_1.Feature {
|
||||||
super();
|
super();
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
async searchPoi(name, areaId, typeCode) {
|
async searchPoi(name, areaId, typeCode, indexFrom, count) {
|
||||||
const { result } = await this.cache.exec('geoService', {
|
const { result } = await this.cache.exec('geoService', {
|
||||||
api: 'geo',
|
api: 'geo',
|
||||||
params: {
|
params: {
|
||||||
name,
|
name,
|
||||||
areaId
|
areaId,
|
||||||
|
indexFrom,
|
||||||
|
count,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ declare class ListNode<ED extends EntityDict & BaseEntityDict, T extends keyof E
|
||||||
*/
|
*/
|
||||||
updateItem(lsn: number, data: ED[T]['Update']['data'], id: string, action?: ED[T]['Action']): void;
|
updateItem(lsn: number, data: ED[T]['Update']['data'], id: string, action?: ED[T]['Action']): void;
|
||||||
updateItems(lsn: number, data: Record<string, ED[T]['Update']['data']>, ids: string[], action?: ED[T]['Action']): void;
|
updateItems(lsn: number, data: Record<string, ED[T]['Update']['data']>, ids: string[], action?: ED[T]['Action']): void;
|
||||||
composeOperations(): Array<{
|
composeOperations(includeModiBranch?: boolean): Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}> | undefined;
|
}> | undefined;
|
||||||
|
|
@ -214,7 +214,12 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
|
||||||
update(lsn: number, data: ED[T]['Update']['data'], action?: ED[T]['Action']): void;
|
update(lsn: number, data: ED[T]['Update']['data'], action?: ED[T]['Action']): void;
|
||||||
remove(lsn: number): void;
|
remove(lsn: number): void;
|
||||||
setDirty(): void;
|
setDirty(): void;
|
||||||
composeOperations(fromParent?: boolean): Array<{
|
/**
|
||||||
|
*
|
||||||
|
* @param includeModiBranch 如果显式置了boolean,代表只要考虑前项路径或者后项路径
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
composeOperations(includeModiBranch?: boolean): Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}> | undefined;
|
}> | undefined;
|
||||||
|
|
@ -249,7 +254,7 @@ declare class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<E
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
getFreshValue(): undefined;
|
getFreshValue(): undefined;
|
||||||
refresh(): Promise<void>;
|
refresh(): Promise<void>;
|
||||||
composeOperations(): Array<{
|
composeOperations(includeModiBranch?: boolean): Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}> | undefined;
|
}> | undefined;
|
||||||
|
|
|
||||||
|
|
@ -830,14 +830,14 @@ class ListNode extends EntityNode {
|
||||||
ids.forEach((id) => this.updateItemInner(lsn, data, id, action));
|
ids.forEach((id) => this.updateItemInner(lsn, data, id, action));
|
||||||
this.setDirty();
|
this.setDirty();
|
||||||
}
|
}
|
||||||
composeOperations() {
|
composeOperations(includeModiBranch) {
|
||||||
if (!this.dirty) {
|
if (!this.dirty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const intrinsticFilter = this.getIntrinsticFilters();
|
const intrinsticFilter = this.getIntrinsticFilters();
|
||||||
const ulmLsn = this.ulManager.maxLsn;
|
const ulmLsn = this.ulManager.maxLsn;
|
||||||
for (const id in this.children) {
|
for (const id in this.children) {
|
||||||
const childOperations = this.children[id].composeOperations(true);
|
const childOperations = this.children[id].composeOperations(includeModiBranch);
|
||||||
if (childOperations) {
|
if (childOperations) {
|
||||||
childOperations.forEach((childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation));
|
childOperations.forEach((childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation));
|
||||||
}
|
}
|
||||||
|
|
@ -1318,13 +1318,22 @@ class SingleNode extends EntityNode {
|
||||||
});
|
});
|
||||||
super.setDirty();
|
super.setDirty();
|
||||||
}
|
}
|
||||||
composeOperations(fromParent) {
|
/**
|
||||||
|
*
|
||||||
|
* @param includeModiBranch 如果显式置了boolean,代表只要考虑前项路径或者后项路径
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
composeOperations(includeModiBranch) {
|
||||||
if (this.dirty) {
|
if (this.dirty) {
|
||||||
const lsnMax = this.ulManager.maxLsn;
|
const lsnMax = this.ulManager.maxLsn;
|
||||||
for (const ele in this.children) {
|
for (const ele in this.children) {
|
||||||
|
if (ele.includes(exports.MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch ||
|
||||||
|
(!ele.includes(exports.MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||||
const child = this.children[ele];
|
const child = this.children[ele];
|
||||||
const childOperations = child.composeOperations(true);
|
const childOperations = child.composeOperations(includeModiBranch);
|
||||||
if (childOperations) {
|
if (childOperations) {
|
||||||
if (child instanceof SingleNode) {
|
if (child instanceof SingleNode) {
|
||||||
(0, assert_1.assert)(childOperations.length === 1);
|
(0, assert_1.assert)(childOperations.length === 1);
|
||||||
|
|
@ -1683,14 +1692,18 @@ class VirtualNode extends Node {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
composeOperations() {
|
composeOperations(includeModiBranch) {
|
||||||
/**
|
/**
|
||||||
* 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并
|
* 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并
|
||||||
*/
|
*/
|
||||||
const operationss = [];
|
const operationss = [];
|
||||||
const operationDict = {};
|
const operationDict = {};
|
||||||
for (const ele in this.children) {
|
for (const ele in this.children) {
|
||||||
const operation = this.children[ele].composeOperations(true);
|
if (ele.includes(exports.MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch ||
|
||||||
|
(!ele.includes(exports.MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const operation = this.children[ele].composeOperations(includeModiBranch);
|
||||||
if (operation) {
|
if (operation) {
|
||||||
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||||
if (operationDict[idx]) {
|
if (operationDict[idx]) {
|
||||||
|
|
@ -1931,7 +1944,7 @@ class RunningTree extends Feature_1.Feature {
|
||||||
redoBranchOperations(path, allowInTxn) {
|
redoBranchOperations(path, allowInTxn) {
|
||||||
const { root } = analyzePath(path);
|
const { root } = analyzePath(path);
|
||||||
const rootNode = this.root[root];
|
const rootNode = this.root[root];
|
||||||
const opers = rootNode.composeOperations();
|
const opers = rootNode.composeOperations(path.includes(exports.MODI_NEXT_PATH_SUFFIX));
|
||||||
if (opers) {
|
if (opers) {
|
||||||
this.cache.redoOperation(opers);
|
this.cache.redoOperation(opers);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,32 +37,63 @@ type FeatureDef<IsList extends boolean, ED extends EntityDict & BaseEntityDict,
|
||||||
type DevideWidth = 'pc' | 'mobile';
|
type DevideWidth = 'pc' | 'mobile';
|
||||||
export type CreateDataDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = ED[T]['CreateSingle']['data'] | (() => ED[T]['CreateSingle']['data']);
|
export type CreateDataDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = ED[T]['CreateSingle']['data'] | (() => ED[T]['CreateSingle']['data']);
|
||||||
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> = {}> {
|
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;
|
isList?: IsList;
|
||||||
zombie?: true;
|
zombie?: true;
|
||||||
getTotal?: {
|
getTotal?: {
|
||||||
max: number;
|
max: number;
|
||||||
deviceWidth?: DevideWidth | 'all';
|
deviceWidth?: DevideWidth | 'all';
|
||||||
} | number;
|
} | number;
|
||||||
|
/**
|
||||||
|
* 组件所关联的实体
|
||||||
|
*/
|
||||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
||||||
path?: string;
|
path?: string;
|
||||||
|
/**
|
||||||
|
* 需要监听的features
|
||||||
|
*/
|
||||||
features?: FeatureDef<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod>[];
|
features?: FeatureDef<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod>[];
|
||||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
||||||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 需要校验的actions
|
||||||
|
*/
|
||||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
||||||
|
/**
|
||||||
|
* 需要获取的数据字段
|
||||||
|
* 若嵌套在list中,需要保证父list组件能够覆盖子组件的projection
|
||||||
|
*/
|
||||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
||||||
append?: boolean;
|
append?: boolean;
|
||||||
|
/**
|
||||||
|
* 分页信息
|
||||||
|
*/
|
||||||
pagination?: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> | Array<Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> & {
|
pagination?: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> | Array<Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> & {
|
||||||
deviceWidth: DevideWidth;
|
deviceWidth: DevideWidth;
|
||||||
}>;
|
}>;
|
||||||
|
/**
|
||||||
|
* 过滤器
|
||||||
|
*/
|
||||||
filters?: Array<{
|
filters?: Array<{
|
||||||
filter: NonNullable<ED[T]['Selection']['filter']> | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
filter: NonNullable<ED[T]['Selection']['filter']> | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
|
/**
|
||||||
|
* 排序器
|
||||||
|
*/
|
||||||
sorters?: Array<{
|
sorters?: Array<{
|
||||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['sorter'] | NonNullable<ED[T]['Selection']['sorter']>[number]);
|
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['sorter'] | NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
|
/**
|
||||||
|
* 表单数据
|
||||||
|
* 在组件渲染前会调用此方法,将返回的数据放入组件的data中
|
||||||
|
* @param options 组件获取到的数据
|
||||||
|
* @returns 返回给页面的数据
|
||||||
|
*/
|
||||||
formData?: (options: {
|
formData?: (options: {
|
||||||
data: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
data: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
||||||
origin?: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
origin?: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
||||||
|
|
@ -74,8 +105,17 @@ interface ComponentOption<IsList extends boolean, ED extends EntityDict & BaseEn
|
||||||
modified: boolean;
|
modified: boolean;
|
||||||
}) => FormedData;
|
}) => FormedData;
|
||||||
ns?: T | T[];
|
ns?: T | T[];
|
||||||
|
/**
|
||||||
|
* 声明的State数据
|
||||||
|
*/
|
||||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
||||||
|
/**
|
||||||
|
* 需要参数传入的默认prop参数
|
||||||
|
*/
|
||||||
properties?: TProperty;
|
properties?: TProperty;
|
||||||
|
/**
|
||||||
|
* 自定义方法
|
||||||
|
*/
|
||||||
methods?: TMethod;
|
methods?: TMethod;
|
||||||
}
|
}
|
||||||
export type MiniprogramStyleMethods = {
|
export type MiniprogramStyleMethods = {
|
||||||
|
|
@ -106,17 +146,63 @@ export type ComponentFullThisType<ED extends EntityDict & BaseEntityDict, T exte
|
||||||
oakLifetime: OakLifetime;
|
oakLifetime: OakLifetime;
|
||||||
} & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
} & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
||||||
export type OakComponentOption<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 Record<string, any>, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = ComponentOption<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod> & Partial<{
|
export type OakComponentOption<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 Record<string, any>, TProperty extends DataOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = ComponentOption<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod> & Partial<{
|
||||||
|
/**
|
||||||
|
* 生命周期回调
|
||||||
|
*/
|
||||||
lifetimes: {
|
lifetimes: {
|
||||||
|
/**
|
||||||
|
* 在组件实例刚刚被创建时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
created?(): void;
|
created?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例进入页面节点树时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
attached?(): void;
|
attached?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例进入页面节点树时执行
|
||||||
|
* async or sync
|
||||||
|
*/
|
||||||
ready?(): any;
|
ready?(): any;
|
||||||
|
/**
|
||||||
|
* 小程序专用,在组件实例被移动到节点树另一个位置时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
moved?(): void;
|
moved?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例被从页面节点树移除时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
detached?(): void;
|
detached?(): void;
|
||||||
|
/**
|
||||||
|
* 小程序专用,每当组件方法抛出错误时执行
|
||||||
|
* sync only
|
||||||
|
* @param err 错误信息
|
||||||
|
*/
|
||||||
error?(err: Error): void;
|
error?(err: Error): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面被展示时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
show?(): void;
|
show?(): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面被隐藏时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
hide?(): void;
|
hide?(): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面尺寸变化时执行
|
||||||
|
* sync only
|
||||||
|
* @param size 页面尺寸信息
|
||||||
|
*/
|
||||||
resize?(size: WechatMiniprogram.Page.IResizeOption): void;
|
resize?(size: WechatMiniprogram.Page.IResizeOption): void;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 监听器,监听State或者Props的变化
|
||||||
|
* 名称:监听的属性名
|
||||||
|
* 回调:监听的回调函数 (prev, next) => void
|
||||||
|
*/
|
||||||
listeners: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
listeners: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
||||||
}> & Partial<{
|
}> & Partial<{
|
||||||
wechatMp: {
|
wechatMp: {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "oak-frontend-base",
|
"name": "oak-frontend-base",
|
||||||
"version": "5.3.19",
|
"version": "5.3.20",
|
||||||
"description": "oak框架中前端与业务逻辑无关的平台部分",
|
"description": "oak框架中前端与业务逻辑无关的平台部分",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "XuChang"
|
"name": "XuChang"
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
"node-schedule": "^2.1.1",
|
"node-schedule": "^2.1.1",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"oak-common-aspect": "^3.0.4",
|
"oak-common-aspect": "^3.0.4",
|
||||||
"oak-domain": "^5.1.10",
|
"oak-domain": "^5.1.11",
|
||||||
"oak-memory-tree-store": "^3.3.6",
|
"oak-memory-tree-store": "^3.3.6",
|
||||||
"ol": "^7.3.0",
|
"ol": "^7.3.0",
|
||||||
"rc-pagination": "^4.3.0",
|
"rc-pagination": "^4.3.0",
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,14 @@ export class Geo<
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchPoi(name: string, areaId?: string, typeCode?: string) {
|
async searchPoi(name: string, areaId?: string, typeCode?: string, indexFrom?: number, count?: number) {
|
||||||
const { result } = await this.cache.exec('geoService', {
|
const { result } = await this.cache.exec('geoService', {
|
||||||
api: 'geo',
|
api: 'geo',
|
||||||
params: {
|
params: {
|
||||||
name,
|
name,
|
||||||
areaId
|
areaId,
|
||||||
|
indexFrom,
|
||||||
|
count,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1036,7 +1036,7 @@ class ListNode<
|
||||||
this.setDirty();
|
this.setDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
composeOperations():
|
composeOperations(includeModiBranch?: boolean):
|
||||||
| Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation'] }>
|
| Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation'] }>
|
||||||
| undefined {
|
| undefined {
|
||||||
if (!this.dirty) {
|
if (!this.dirty) {
|
||||||
|
|
@ -1047,7 +1047,7 @@ class ListNode<
|
||||||
|
|
||||||
const ulmLsn = this.ulManager.maxLsn;
|
const ulmLsn = this.ulManager.maxLsn;
|
||||||
for (const id in this.children) {
|
for (const id in this.children) {
|
||||||
const childOperations = this.children[id].composeOperations(true);
|
const childOperations = this.children[id].composeOperations(includeModiBranch);
|
||||||
if (childOperations) {
|
if (childOperations) {
|
||||||
childOperations.forEach(
|
childOperations.forEach(
|
||||||
(childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation as any)
|
(childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation as any)
|
||||||
|
|
@ -1614,16 +1614,25 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
||||||
super.setDirty();
|
super.setDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
composeOperations(fromParent?: boolean): Array<{
|
/**
|
||||||
|
*
|
||||||
|
* @param includeModiBranch 如果显式置了boolean,代表只要考虑前项路径或者后项路径
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
composeOperations(includeModiBranch?: boolean): Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}> | undefined {
|
}> | undefined {
|
||||||
if (this.dirty) {
|
if (this.dirty) {
|
||||||
const lsnMax = this.ulManager.maxLsn;
|
const lsnMax = this.ulManager.maxLsn;
|
||||||
for (const ele in this.children) {
|
for (const ele in this.children) {
|
||||||
|
if (ele.includes(MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch ||
|
||||||
|
(!ele.includes(MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||||
const child = this.children[ele];
|
const child = this.children[ele];
|
||||||
const childOperations = child!.composeOperations(true);
|
const childOperations = child!.composeOperations(includeModiBranch);
|
||||||
if (childOperations) {
|
if (childOperations) {
|
||||||
if (child instanceof SingleNode) {
|
if (child instanceof SingleNode) {
|
||||||
assert(childOperations.length === 1);
|
assert(childOperations.length === 1);
|
||||||
|
|
@ -2015,14 +2024,18 @@ class VirtualNode<ED extends EntityDict & BaseEntityDict> extends Node<ED> {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
composeOperations(): Array<{ entity: keyof ED, operation: ED[keyof ED]['Operation'] }> | undefined {
|
composeOperations(includeModiBranch?: boolean): Array<{ entity: keyof ED, operation: ED[keyof ED]['Operation'] }> | undefined {
|
||||||
/**
|
/**
|
||||||
* 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并
|
* 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并
|
||||||
*/
|
*/
|
||||||
const operationss = [];
|
const operationss = [];
|
||||||
const operationDict: Record<string, any> = {};
|
const operationDict: Record<string, any> = {};
|
||||||
for (const ele in this.children) {
|
for (const ele in this.children) {
|
||||||
const operation = this.children[ele].composeOperations(true);
|
if (ele.includes(MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch ||
|
||||||
|
(!ele.includes(MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const operation = this.children[ele].composeOperations(includeModiBranch);
|
||||||
if (operation) {
|
if (operation) {
|
||||||
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele;
|
||||||
if (operationDict[idx]) {
|
if (operationDict[idx]) {
|
||||||
|
|
@ -2338,7 +2351,7 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
||||||
const { root } = analyzePath(path);
|
const { root } = analyzePath(path);
|
||||||
|
|
||||||
const rootNode = this.root[root];
|
const rootNode = this.root[root];
|
||||||
const opers = rootNode.composeOperations();
|
const opers = rootNode.composeOperations(path.includes(MODI_NEXT_PATH_SUFFIX));
|
||||||
if (opers) {
|
if (opers) {
|
||||||
this.cache.redoOperation(opers);
|
this.cache.redoOperation(opers);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,31 +137,62 @@ interface ComponentOption<
|
||||||
TMethod extends Record<string, Function>,
|
TMethod extends Record<string, Function>,
|
||||||
EMethod extends Record<string, Function> = {},
|
EMethod extends Record<string, Function> = {},
|
||||||
> {
|
> {
|
||||||
|
/**
|
||||||
|
* 是否为列表组件
|
||||||
|
*/
|
||||||
isList?: IsList;
|
isList?: IsList;
|
||||||
zombie?: true;
|
zombie?: true;
|
||||||
getTotal?: {
|
getTotal?: {
|
||||||
max: number;
|
max: number;
|
||||||
deviceWidth?: DevideWidth | 'all';
|
deviceWidth?: DevideWidth | 'all';
|
||||||
} | number;
|
} | number;
|
||||||
|
/**
|
||||||
|
* 组件所关联的实体
|
||||||
|
*/
|
||||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
||||||
path?: string;
|
path?: string;
|
||||||
|
/**
|
||||||
|
* 需要监听的features
|
||||||
|
*/
|
||||||
features?: FeatureDef<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod>[];
|
features?: FeatureDef<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod>[];
|
||||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
||||||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 需要校验的actions
|
||||||
|
*/
|
||||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
||||||
|
/**
|
||||||
|
* 需要获取的数据字段
|
||||||
|
* 若嵌套在list中,需要保证父list组件能够覆盖子组件的projection
|
||||||
|
*/
|
||||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
||||||
append?: boolean;
|
append?: boolean;
|
||||||
|
/**
|
||||||
|
* 分页信息
|
||||||
|
*/
|
||||||
pagination?: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> | Array<Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> & { deviceWidth: DevideWidth }>;
|
pagination?: Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> | Array<Pick<Pagination, 'currentPage' | 'pageSize' | 'randomRange'> & { deviceWidth: DevideWidth }>;
|
||||||
|
/**
|
||||||
|
* 过滤器
|
||||||
|
*/
|
||||||
filters?: Array<{
|
filters?: Array<{
|
||||||
filter: NonNullable<ED[T]['Selection']['filter']> | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
filter: NonNullable<ED[T]['Selection']['filter']> | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
|
/**
|
||||||
|
* 排序器
|
||||||
|
*/
|
||||||
sorters?: Array<{
|
sorters?: Array<{
|
||||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number]
|
sorter: NonNullable<ED[T]['Selection']['sorter']>[number]
|
||||||
| ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['sorter'] | NonNullable<ED[T]['Selection']['sorter']>[number]);
|
| ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['sorter'] | NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
|
/**
|
||||||
|
* 表单数据
|
||||||
|
* 在组件渲染前会调用此方法,将返回的数据放入组件的data中
|
||||||
|
* @param options 组件获取到的数据
|
||||||
|
* @returns 返回给页面的数据
|
||||||
|
*/
|
||||||
formData?: (options: {
|
formData?: (options: {
|
||||||
data: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
data: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
||||||
origin?: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
origin?: IsList extends true ? RowWithActions<ED, T>[] : RowWithActions<ED, T>;
|
||||||
|
|
@ -173,8 +204,17 @@ interface ComponentOption<
|
||||||
modified: boolean;
|
modified: boolean;
|
||||||
}) => FormedData;
|
}) => FormedData;
|
||||||
ns?: T | T[];
|
ns?: T | T[];
|
||||||
|
/**
|
||||||
|
* 声明的State数据
|
||||||
|
*/
|
||||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
||||||
|
/**
|
||||||
|
* 需要参数传入的默认prop参数
|
||||||
|
*/
|
||||||
properties?: TProperty;
|
properties?: TProperty;
|
||||||
|
/**
|
||||||
|
* 自定义方法
|
||||||
|
*/
|
||||||
methods?: TMethod;
|
methods?: TMethod;
|
||||||
// createData?: CreateDataDef<ED, T>;
|
// createData?: CreateDataDef<ED, T>;
|
||||||
};
|
};
|
||||||
|
|
@ -283,17 +323,63 @@ export type OakComponentOption<
|
||||||
EMethod extends Record<string, Function> = {},
|
EMethod extends Record<string, Function> = {},
|
||||||
> = ComponentOption<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod> &
|
> = ComponentOption<IsList, ED, T, Cxt, FrontCxt, AD, FD, FormedData, TData, TProperty, TMethod, EMethod> &
|
||||||
Partial<{
|
Partial<{
|
||||||
|
/**
|
||||||
|
* 生命周期回调
|
||||||
|
*/
|
||||||
lifetimes: {
|
lifetimes: {
|
||||||
|
/**
|
||||||
|
* 在组件实例刚刚被创建时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
created?(): void;
|
created?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例进入页面节点树时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
attached?(): void;
|
attached?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例进入页面节点树时执行
|
||||||
|
* async or sync
|
||||||
|
*/
|
||||||
ready?(): any;
|
ready?(): any;
|
||||||
|
/**
|
||||||
|
* 小程序专用,在组件实例被移动到节点树另一个位置时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
moved?(): void;
|
moved?(): void;
|
||||||
|
/**
|
||||||
|
* 在组件实例被从页面节点树移除时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
detached?(): void;
|
detached?(): void;
|
||||||
|
/**
|
||||||
|
* 小程序专用,每当组件方法抛出错误时执行
|
||||||
|
* sync only
|
||||||
|
* @param err 错误信息
|
||||||
|
*/
|
||||||
error?(err: Error): void;
|
error?(err: Error): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面被展示时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
show?(): void;
|
show?(): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面被隐藏时执行
|
||||||
|
* sync only
|
||||||
|
*/
|
||||||
hide?(): void;
|
hide?(): void;
|
||||||
|
/**
|
||||||
|
* 组件所在的页面尺寸变化时执行
|
||||||
|
* sync only
|
||||||
|
* @param size 页面尺寸信息
|
||||||
|
*/
|
||||||
resize?(size: WechatMiniprogram.Page.IResizeOption): void;
|
resize?(size: WechatMiniprogram.Page.IResizeOption): void;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 监听器,监听State或者Props的变化
|
||||||
|
* 名称:监听的属性名
|
||||||
|
* 回调:监听的回调函数 (prev, next) => void
|
||||||
|
*/
|
||||||
listeners: Record<string, (this: ComponentPublicThisType<
|
listeners: Record<string, (this: ComponentPublicThisType<
|
||||||
ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod
|
ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod
|
||||||
>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue