@zhongguo168a/yxeditor-common 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +59 -111
- package/dist/index.esm.js +91 -147
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -298,7 +298,7 @@ interface IEventManager {
|
|
|
298
298
|
/**
|
|
299
299
|
* 事件派发器
|
|
300
300
|
*/
|
|
301
|
-
declare class
|
|
301
|
+
declare class EventDispatcher implements IEventManager {
|
|
302
302
|
constructor();
|
|
303
303
|
dispose(): void;
|
|
304
304
|
/**
|
|
@@ -347,7 +347,7 @@ declare class EventManager implements IEventManager {
|
|
|
347
347
|
/**
|
|
348
348
|
* 全局的事件派发器
|
|
349
349
|
*/
|
|
350
|
-
declare const eventmgr:
|
|
350
|
+
declare const eventmgr: EventDispatcher;
|
|
351
351
|
|
|
352
352
|
declare class TreeIterator {
|
|
353
353
|
break(): void;
|
|
@@ -507,7 +507,7 @@ declare class TreeNode<T = any> {
|
|
|
507
507
|
fixDepthAndRoot(depth: number, root: TreeRoot): void;
|
|
508
508
|
toString(): string;
|
|
509
509
|
}
|
|
510
|
-
declare class TreeRoot<NODE = any> extends
|
|
510
|
+
declare class TreeRoot<NODE = any> extends EventDispatcher {
|
|
511
511
|
/**
|
|
512
512
|
* 添加数据节点
|
|
513
513
|
* dispatchParams = {node:TreeNode, parent:TreeNode|TreeRoot}
|
|
@@ -622,7 +622,7 @@ declare class ListNode {
|
|
|
622
622
|
getTag(name: string): any;
|
|
623
623
|
setTag(name: string, value: any): void;
|
|
624
624
|
}
|
|
625
|
-
declare class ListSource extends
|
|
625
|
+
declare class ListSource extends EventDispatcher {
|
|
626
626
|
/**
|
|
627
627
|
* 通过数组创建 ListSource。ListSource的id自动生成。如果需要指定编号,可设置 idCreator
|
|
628
628
|
* @param arr
|
|
@@ -807,8 +807,8 @@ declare class DictSource extends Dictionary<string, DictNode> {
|
|
|
807
807
|
static EVENT_TAGS_SET: string;
|
|
808
808
|
setNodeTags(node: DictNode, tag: string, value: any): void;
|
|
809
809
|
refreshNode(node: DictNode): void;
|
|
810
|
-
get dispatcher():
|
|
811
|
-
protected _dispatcher:
|
|
810
|
+
get dispatcher(): EventDispatcher;
|
|
811
|
+
protected _dispatcher: EventDispatcher;
|
|
812
812
|
}
|
|
813
813
|
|
|
814
814
|
declare class ListIterator {
|
|
@@ -919,10 +919,11 @@ declare class ControllerDict extends Dictionary<string, IController> {
|
|
|
919
919
|
}
|
|
920
920
|
declare class ControllerRepo extends ControllerDict {
|
|
921
921
|
constructor();
|
|
922
|
-
|
|
922
|
+
register(controller: IController): void;
|
|
923
923
|
remove(name: string): void;
|
|
924
924
|
dispose(): void;
|
|
925
925
|
}
|
|
926
|
+
declare const ctrlrepo: ControllerRepo;
|
|
926
927
|
|
|
927
928
|
interface IModule {
|
|
928
929
|
}
|
|
@@ -935,7 +936,7 @@ declare class SimpleModel {
|
|
|
935
936
|
get core(): IModule;
|
|
936
937
|
protected _mod: any;
|
|
937
938
|
}
|
|
938
|
-
declare class Model extends
|
|
939
|
+
declare class Model extends EventDispatcher {
|
|
939
940
|
constructor(core?: IModule);
|
|
940
941
|
get module(): IModule;
|
|
941
942
|
protected _module: any;
|
|
@@ -1006,44 +1007,7 @@ declare class Route {
|
|
|
1006
1007
|
private _params;
|
|
1007
1008
|
protected _route: string;
|
|
1008
1009
|
}
|
|
1009
|
-
|
|
1010
|
-
declare class ViewController extends Controller {
|
|
1011
|
-
constructor(routeName: string, config?: {
|
|
1012
|
-
layer?: string;
|
|
1013
|
-
tags?: string[];
|
|
1014
|
-
enableHistory?: boolean;
|
|
1015
|
-
});
|
|
1016
|
-
open(...args: any[]): void;
|
|
1017
|
-
close(...args: any[]): void;
|
|
1018
|
-
protected onOpening(view: View): void;
|
|
1019
|
-
protected onOpened(view: View): void;
|
|
1020
|
-
protected onClosing(view: View): void;
|
|
1021
|
-
protected onClosed(view: View): void;
|
|
1022
|
-
protected onRefresh(view: View): void;
|
|
1023
|
-
openByRoute(route: Route): View;
|
|
1024
|
-
private openView;
|
|
1025
|
-
openComplete(view: View): void;
|
|
1026
|
-
/**
|
|
1027
|
-
* viewrepo中存在页面才会关闭
|
|
1028
|
-
* @param route
|
|
1029
|
-
* @returns
|
|
1030
|
-
*/
|
|
1031
|
-
closeByRoute(route?: Route): View;
|
|
1032
|
-
private closeView;
|
|
1033
|
-
closeComplete(view: View): void;
|
|
1034
|
-
refresh(): void;
|
|
1035
|
-
get layer(): string;
|
|
1036
|
-
hasTags(tags: string[]): boolean;
|
|
1037
|
-
setLayer(name: string): this;
|
|
1038
|
-
setTags(tags: string[]): this;
|
|
1039
|
-
get lastView(): View;
|
|
1040
|
-
get route(): Route;
|
|
1041
|
-
get enableHistory(): boolean;
|
|
1042
|
-
protected _enableHistory: boolean;
|
|
1043
|
-
protected _route: Route;
|
|
1044
|
-
protected _lastView: View;
|
|
1045
|
-
protected _tags: {};
|
|
1046
|
-
protected _layer: string;
|
|
1010
|
+
declare class RouteList extends List<Route> {
|
|
1047
1011
|
}
|
|
1048
1012
|
|
|
1049
1013
|
declare enum ViewState {
|
|
@@ -1064,23 +1028,8 @@ declare enum ViewState {
|
|
|
1064
1028
|
*/
|
|
1065
1029
|
Closeing = 3
|
|
1066
1030
|
}
|
|
1067
|
-
declare
|
|
1068
|
-
Opening = "opening",
|
|
1069
|
-
Opened = "opened",
|
|
1070
|
-
Closeing = "closeing",
|
|
1071
|
-
Closed = "closed",
|
|
1072
|
-
Stop = "stop"
|
|
1073
|
-
}
|
|
1074
|
-
declare class View extends EventManager {
|
|
1031
|
+
declare class View extends EventDispatcher {
|
|
1075
1032
|
constructor(controller: ViewController, route: Route);
|
|
1076
|
-
/**
|
|
1077
|
-
* 等待打开完成指令
|
|
1078
|
-
*/
|
|
1079
|
-
waitOpenComplete(): void;
|
|
1080
|
-
waitCloseComplete(): void;
|
|
1081
|
-
openComplete(): void;
|
|
1082
|
-
closeComplete(): void;
|
|
1083
|
-
stop(reason: LinkError): void;
|
|
1084
1033
|
/**
|
|
1085
1034
|
* 等待发送的结果
|
|
1086
1035
|
* 如果返回 null,表示主动取消 [cancel]
|
|
@@ -1099,26 +1048,6 @@ declare class View extends EventManager {
|
|
|
1099
1048
|
protected _route: Route;
|
|
1100
1049
|
}
|
|
1101
1050
|
|
|
1102
|
-
/**
|
|
1103
|
-
* 视图管理器
|
|
1104
|
-
* 打开一个视图的时候,可能会听过加载资源,读取数据,调整布局,切换特效等处理,所以使用视图模式封装视图打开关闭的逻辑
|
|
1105
|
-
*/
|
|
1106
|
-
declare class ViewLayer {
|
|
1107
|
-
name: string;
|
|
1108
|
-
constructor(name: string);
|
|
1109
|
-
close(): void;
|
|
1110
|
-
/**
|
|
1111
|
-
* 历史记录
|
|
1112
|
-
*/
|
|
1113
|
-
getHistory(): Route[];
|
|
1114
|
-
back(): void;
|
|
1115
|
-
/**
|
|
1116
|
-
* 当前的页面
|
|
1117
|
-
*/
|
|
1118
|
-
currentView: View;
|
|
1119
|
-
protected _history: Route[];
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
1051
|
declare class UIObjectDict extends Dictionary<string, any | List> {
|
|
1123
1052
|
/**
|
|
1124
1053
|
* 获取唯一的
|
|
@@ -1134,39 +1063,58 @@ declare var uidict: UIObjectDict;
|
|
|
1134
1063
|
|
|
1135
1064
|
declare class ViewList extends List<View> {
|
|
1136
1065
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1066
|
+
|
|
1067
|
+
declare class ViewController extends Controller {
|
|
1068
|
+
constructor(routeName: string);
|
|
1140
1069
|
/**
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
*/
|
|
1070
|
+
* 当视图需要通过路由打开时,需要实现此方法
|
|
1071
|
+
* @param route
|
|
1072
|
+
*/
|
|
1145
1073
|
open(route: Route): View;
|
|
1146
|
-
|
|
1074
|
+
protected onOpening(view: View): void;
|
|
1075
|
+
protected onOpened(view: View): void;
|
|
1076
|
+
protected onClosing(view: View): void;
|
|
1077
|
+
protected onClosed(view: View): void;
|
|
1078
|
+
protected refreshView(view: View): void;
|
|
1079
|
+
protected openView(view: View): void;
|
|
1147
1080
|
/**
|
|
1148
|
-
|
|
1081
|
+
* 等待打开完成指令
|
|
1082
|
+
*/
|
|
1083
|
+
protected waitOpenComplete(view: View): void;
|
|
1084
|
+
protected openComplete(view: View): void;
|
|
1085
|
+
/**
|
|
1086
|
+
* 当视图需要通过路由关闭时,需要实现此方法
|
|
1149
1087
|
* @param route
|
|
1088
|
+
* @returns
|
|
1150
1089
|
*/
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
* @param
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1090
|
+
close(route?: Route): View;
|
|
1091
|
+
/**
|
|
1092
|
+
* 关闭相斥的视图对象
|
|
1093
|
+
* 1. 关闭同一层的所有视图对象
|
|
1094
|
+
* 2. 关闭符合相斥规则的视图对象
|
|
1095
|
+
* @param view
|
|
1096
|
+
* @param validFunc 符合条件的视图对象会被关闭
|
|
1097
|
+
* @returns 被关闭的视图
|
|
1098
|
+
*/
|
|
1099
|
+
closeExclusion(validFunc?: (existed: View) => boolean): ViewList;
|
|
1100
|
+
protected closeView(view: View): void;
|
|
1101
|
+
protected waitCloseComplete(view: View): void;
|
|
1102
|
+
protected closeComplete(view: View): void;
|
|
1103
|
+
refresh(): void;
|
|
1104
|
+
get layer(): string;
|
|
1105
|
+
hasTags(tags: string[]): boolean;
|
|
1106
|
+
setLayer(name: string): this;
|
|
1107
|
+
setTags(tags: string[]): this;
|
|
1108
|
+
useHistory(): this;
|
|
1109
|
+
get lastView(): View;
|
|
1110
|
+
get route(): Route;
|
|
1111
|
+
get enableHistory(): boolean;
|
|
1112
|
+
protected _enableHistory: boolean;
|
|
1113
|
+
protected _route: Route;
|
|
1114
|
+
protected _lastView: View;
|
|
1115
|
+
protected _tags: {};
|
|
1116
|
+
protected _layer: string;
|
|
1117
|
+
}
|
|
1170
1118
|
|
|
1171
1119
|
/**
|
|
1172
1120
|
* 事件字符串分隔符
|
|
@@ -2030,5 +1978,5 @@ declare class WidgetUtil {
|
|
|
2030
1978
|
}
|
|
2031
1979
|
declare var widgetutil: WidgetUtil;
|
|
2032
1980
|
|
|
2033
|
-
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil,
|
|
1981
|
+
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteList, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectDict, UIPoolConfig, UISingleConfig, UIUtil, ViewController, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uidict, uimgr, uiutil, widgetutil };
|
|
2034
1982
|
export type { CreatorFunction, DisposeFunction, IController, IError, IEventManager, IExtend, IListItem, IModel, IModule, ITreeListItem, RecycleFunction };
|
package/dist/index.esm.js
CHANGED
|
@@ -772,7 +772,7 @@ const log = logmgr.getEventLogger();
|
|
|
772
772
|
/**
|
|
773
773
|
* 事件派发器
|
|
774
774
|
*/
|
|
775
|
-
class
|
|
775
|
+
class EventDispatcher {
|
|
776
776
|
constructor() {
|
|
777
777
|
this._isPause = false;
|
|
778
778
|
this._onEventItems = {};
|
|
@@ -1005,7 +1005,7 @@ class EventManager {
|
|
|
1005
1005
|
/**
|
|
1006
1006
|
* 全局的事件派发器
|
|
1007
1007
|
*/
|
|
1008
|
-
const eventmgr = new
|
|
1008
|
+
const eventmgr = new EventDispatcher();
|
|
1009
1009
|
let eventPool = new Pool({
|
|
1010
1010
|
creatorFunction: function () {
|
|
1011
1011
|
return new XEvent();
|
|
@@ -2282,7 +2282,7 @@ class TreeNode {
|
|
|
2282
2282
|
return `TreeNode[${this.id}]`;
|
|
2283
2283
|
}
|
|
2284
2284
|
}
|
|
2285
|
-
class TreeRoot extends
|
|
2285
|
+
class TreeRoot extends EventDispatcher {
|
|
2286
2286
|
static create() {
|
|
2287
2287
|
return new TreeRoot();
|
|
2288
2288
|
}
|
|
@@ -2550,7 +2550,7 @@ class ListNode {
|
|
|
2550
2550
|
this.getTags()[name] = value;
|
|
2551
2551
|
}
|
|
2552
2552
|
}
|
|
2553
|
-
class ListSource extends
|
|
2553
|
+
class ListSource extends EventDispatcher {
|
|
2554
2554
|
constructor() {
|
|
2555
2555
|
super(...arguments);
|
|
2556
2556
|
this._data = [];
|
|
@@ -3060,7 +3060,7 @@ class DictNode {
|
|
|
3060
3060
|
class DictSource extends Dictionary {
|
|
3061
3061
|
constructor() {
|
|
3062
3062
|
super(...arguments);
|
|
3063
|
-
this._dispatcher = new
|
|
3063
|
+
this._dispatcher = new EventDispatcher();
|
|
3064
3064
|
}
|
|
3065
3065
|
setNodeTags(node, tag, value) {
|
|
3066
3066
|
let tags = node.getTags();
|
|
@@ -3407,7 +3407,7 @@ class ControllerRepo extends ControllerDict {
|
|
|
3407
3407
|
constructor() {
|
|
3408
3408
|
super();
|
|
3409
3409
|
}
|
|
3410
|
-
|
|
3410
|
+
register(controller) {
|
|
3411
3411
|
if (this.get(controller.name)) {
|
|
3412
3412
|
throw new Error("重复创建控制器: " + name);
|
|
3413
3413
|
}
|
|
@@ -3426,6 +3426,7 @@ class ControllerRepo extends ControllerDict {
|
|
|
3426
3426
|
});
|
|
3427
3427
|
}
|
|
3428
3428
|
}
|
|
3429
|
+
const ctrlrepo = new ControllerRepo();
|
|
3429
3430
|
|
|
3430
3431
|
// 用于描述数据及之间的关系
|
|
3431
3432
|
// 也可提供对控制器的封装
|
|
@@ -3437,7 +3438,7 @@ class SimpleModel {
|
|
|
3437
3438
|
return this._mod;
|
|
3438
3439
|
}
|
|
3439
3440
|
}
|
|
3440
|
-
class Model extends
|
|
3441
|
+
class Model extends EventDispatcher {
|
|
3441
3442
|
constructor(core) {
|
|
3442
3443
|
super();
|
|
3443
3444
|
this._module = core;
|
|
@@ -3506,7 +3507,7 @@ var ViewEvent;
|
|
|
3506
3507
|
// 停止
|
|
3507
3508
|
ViewEvent["Stop"] = "stop";
|
|
3508
3509
|
})(ViewEvent || (ViewEvent = {}));
|
|
3509
|
-
class View extends
|
|
3510
|
+
class View extends EventDispatcher {
|
|
3510
3511
|
constructor(controller, route) {
|
|
3511
3512
|
super();
|
|
3512
3513
|
this._waitOpenComplete = false;
|
|
@@ -3517,25 +3518,6 @@ class View extends EventManager {
|
|
|
3517
3518
|
this._controller = controller;
|
|
3518
3519
|
this._route = route;
|
|
3519
3520
|
}
|
|
3520
|
-
/**
|
|
3521
|
-
* 等待打开完成指令
|
|
3522
|
-
*/
|
|
3523
|
-
waitOpenComplete() {
|
|
3524
|
-
this._waitOpenComplete = true;
|
|
3525
|
-
}
|
|
3526
|
-
waitCloseComplete() {
|
|
3527
|
-
this._waitCloseComplete = true;
|
|
3528
|
-
}
|
|
3529
|
-
openComplete() {
|
|
3530
|
-
this._waitOpenComplete = false;
|
|
3531
|
-
this._controller.openComplete(this);
|
|
3532
|
-
}
|
|
3533
|
-
closeComplete() {
|
|
3534
|
-
this._waitOpenComplete = false;
|
|
3535
|
-
this._controller.closeComplete(this);
|
|
3536
|
-
}
|
|
3537
|
-
stop(reason) {
|
|
3538
|
-
}
|
|
3539
3521
|
/**
|
|
3540
3522
|
* 等待发送的结果
|
|
3541
3523
|
* 如果返回 null,表示主动取消 [cancel]
|
|
@@ -3708,6 +3690,8 @@ class Route {
|
|
|
3708
3690
|
}
|
|
3709
3691
|
// 打开界面缓存的route对象
|
|
3710
3692
|
Route.data = {};
|
|
3693
|
+
class RouteList extends List {
|
|
3694
|
+
}
|
|
3711
3695
|
|
|
3712
3696
|
class UIObjectDict extends Dictionary {
|
|
3713
3697
|
/**
|
|
@@ -3763,45 +3747,18 @@ class UIObjectDict extends Dictionary {
|
|
|
3763
3747
|
}
|
|
3764
3748
|
var uidict = new UIObjectDict();
|
|
3765
3749
|
|
|
3750
|
+
class ViewList extends List {
|
|
3751
|
+
}
|
|
3766
3752
|
/**
|
|
3767
|
-
*
|
|
3768
|
-
* 打开一个视图的时候,可能会听过加载资源,读取数据,调整布局,切换特效等处理,所以使用视图模式封装视图打开关闭的逻辑
|
|
3753
|
+
* 路由唯一编号->视图
|
|
3769
3754
|
*/
|
|
3770
|
-
class
|
|
3771
|
-
constructor(name) {
|
|
3772
|
-
this.name = name;
|
|
3773
|
-
this._history = [];
|
|
3774
|
-
}
|
|
3775
|
-
close() {
|
|
3776
|
-
if (this.currentView) {
|
|
3777
|
-
this.currentView.controller.closeByRoute();
|
|
3778
|
-
}
|
|
3779
|
-
}
|
|
3780
|
-
/**
|
|
3781
|
-
* 历史记录
|
|
3782
|
-
*/
|
|
3783
|
-
getHistory() {
|
|
3784
|
-
return this._history;
|
|
3785
|
-
}
|
|
3786
|
-
back() {
|
|
3787
|
-
viewrepo.open(this._history.pop());
|
|
3788
|
-
}
|
|
3789
|
-
}
|
|
3790
|
-
|
|
3791
|
-
class ViewList extends List {
|
|
3755
|
+
class ViewDict extends Dictionary {
|
|
3792
3756
|
}
|
|
3793
|
-
class ViewRepo extends
|
|
3757
|
+
class ViewRepo extends ViewDict {
|
|
3794
3758
|
constructor() {
|
|
3795
3759
|
super();
|
|
3796
3760
|
this._indexLayer = {};
|
|
3797
3761
|
this._indexRoute = {};
|
|
3798
|
-
this._ctrlDict = new ControllerDict();
|
|
3799
|
-
this.onSet(this, (item) => {
|
|
3800
|
-
this._indexRoute[item.route.key] = item;
|
|
3801
|
-
});
|
|
3802
|
-
this.onDelete(this, (item) => {
|
|
3803
|
-
delete this._indexRoute[item.route.key];
|
|
3804
|
-
});
|
|
3805
3762
|
}
|
|
3806
3763
|
openByString(route) {
|
|
3807
3764
|
return this.open(new Route(route));
|
|
@@ -3816,14 +3773,14 @@ class ViewRepo extends ViewList {
|
|
|
3816
3773
|
if (!controller) {
|
|
3817
3774
|
throw new Error("view controller no register: " + route.path);
|
|
3818
3775
|
}
|
|
3819
|
-
return controller.
|
|
3776
|
+
return controller.open(route);
|
|
3820
3777
|
}
|
|
3821
3778
|
close(route) {
|
|
3822
3779
|
let controller = this.getController(route.path);
|
|
3823
3780
|
if (!controller) {
|
|
3824
3781
|
throw new Error("view controller no register: " + route.path);
|
|
3825
3782
|
}
|
|
3826
|
-
controller.
|
|
3783
|
+
controller.close(route);
|
|
3827
3784
|
}
|
|
3828
3785
|
/**
|
|
3829
3786
|
* 如果页面存在,则刷新
|
|
@@ -3836,7 +3793,7 @@ class ViewRepo extends ViewList {
|
|
|
3836
3793
|
}
|
|
3837
3794
|
}
|
|
3838
3795
|
getByRoute(route) {
|
|
3839
|
-
return this.
|
|
3796
|
+
return this.get(route.key);
|
|
3840
3797
|
}
|
|
3841
3798
|
listByRoutePath(path) {
|
|
3842
3799
|
let list = new ViewList();
|
|
@@ -3856,28 +3813,8 @@ class ViewRepo extends ViewList {
|
|
|
3856
3813
|
});
|
|
3857
3814
|
return list;
|
|
3858
3815
|
}
|
|
3859
|
-
getLayerMain() {
|
|
3860
|
-
return this._indexLayer["main"];
|
|
3861
|
-
}
|
|
3862
|
-
/**
|
|
3863
|
-
* @param name
|
|
3864
|
-
*/
|
|
3865
|
-
getLayer(name) {
|
|
3866
|
-
return this.getOrNewLayer(name);
|
|
3867
|
-
}
|
|
3868
|
-
getOrNewLayer(name) {
|
|
3869
|
-
let layer = this._indexLayer[name];
|
|
3870
|
-
if (!layer) {
|
|
3871
|
-
layer = new ViewLayer(name);
|
|
3872
|
-
this._indexLayer[name] = layer;
|
|
3873
|
-
}
|
|
3874
|
-
return layer;
|
|
3875
|
-
}
|
|
3876
3816
|
getController(name) {
|
|
3877
|
-
return
|
|
3878
|
-
}
|
|
3879
|
-
registerController(ctrl) {
|
|
3880
|
-
this._ctrlDict.set(ctrl.name, ctrl);
|
|
3817
|
+
return ctrlrepo.get(name);
|
|
3881
3818
|
}
|
|
3882
3819
|
get objectDict() {
|
|
3883
3820
|
let dict = this._objectDict;
|
|
@@ -3891,26 +3828,24 @@ class ViewRepo extends ViewList {
|
|
|
3891
3828
|
const viewrepo = new ViewRepo();
|
|
3892
3829
|
|
|
3893
3830
|
class ViewController extends Controller {
|
|
3894
|
-
constructor(routeName
|
|
3831
|
+
constructor(routeName) {
|
|
3895
3832
|
super(routeName);
|
|
3896
3833
|
this._enableHistory = false;
|
|
3897
3834
|
this._tags = {};
|
|
3898
3835
|
this._route = new Route(routeName);
|
|
3899
|
-
if (config) {
|
|
3900
|
-
if (config.layer) {
|
|
3901
|
-
this._layer = config.layer;
|
|
3902
|
-
}
|
|
3903
|
-
if (config.tags) {
|
|
3904
|
-
this._tags = config.tags;
|
|
3905
|
-
}
|
|
3906
|
-
if (config.enableHistory) {
|
|
3907
|
-
this._enableHistory = config.enableHistory;
|
|
3908
|
-
}
|
|
3909
|
-
}
|
|
3910
3836
|
}
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3837
|
+
/**
|
|
3838
|
+
* 当视图需要通过路由打开时,需要实现此方法
|
|
3839
|
+
* @param route
|
|
3840
|
+
*/
|
|
3841
|
+
open(route) {
|
|
3842
|
+
let oldView = viewrepo.getByRoute(route);
|
|
3843
|
+
if (oldView) {
|
|
3844
|
+
this.closeView(oldView);
|
|
3845
|
+
}
|
|
3846
|
+
let view = new View(this, route);
|
|
3847
|
+
this.openView(view);
|
|
3848
|
+
return view;
|
|
3914
3849
|
}
|
|
3915
3850
|
onOpening(view) {
|
|
3916
3851
|
}
|
|
@@ -3920,36 +3855,7 @@ class ViewController extends Controller {
|
|
|
3920
3855
|
}
|
|
3921
3856
|
onClosed(view) {
|
|
3922
3857
|
}
|
|
3923
|
-
|
|
3924
|
-
}
|
|
3925
|
-
openByRoute(route) {
|
|
3926
|
-
let newview;
|
|
3927
|
-
let oldview;
|
|
3928
|
-
if (this._layer) {
|
|
3929
|
-
let layer = viewrepo.getLayer(this._layer);
|
|
3930
|
-
oldview = layer.currentView;
|
|
3931
|
-
if (oldview) {
|
|
3932
|
-
let currentRoute = oldview.route;
|
|
3933
|
-
if (currentRoute.key == route.key) {
|
|
3934
|
-
return oldview;
|
|
3935
|
-
}
|
|
3936
|
-
// 关闭
|
|
3937
|
-
let currentCtrl = oldview.controller;
|
|
3938
|
-
currentCtrl.closeView(oldview);
|
|
3939
|
-
if (currentCtrl._enableHistory) {
|
|
3940
|
-
layer.getHistory().push(oldview.route);
|
|
3941
|
-
}
|
|
3942
|
-
}
|
|
3943
|
-
newview = new View(this, route);
|
|
3944
|
-
layer.currentView = newview;
|
|
3945
|
-
}
|
|
3946
|
-
else {
|
|
3947
|
-
newview = new View(this, route);
|
|
3948
|
-
}
|
|
3949
|
-
//
|
|
3950
|
-
this.openView(newview);
|
|
3951
|
-
//
|
|
3952
|
-
return newview;
|
|
3858
|
+
refreshView(view) {
|
|
3953
3859
|
}
|
|
3954
3860
|
openView(view) {
|
|
3955
3861
|
if (!view) {
|
|
@@ -3958,12 +3864,17 @@ class ViewController extends Controller {
|
|
|
3958
3864
|
if (view.state != ViewState.Closed) {
|
|
3959
3865
|
return;
|
|
3960
3866
|
}
|
|
3867
|
+
let route = view.route;
|
|
3868
|
+
if (viewrepo.get(route.key)) {
|
|
3869
|
+
throw `视图已存在: route=${route.key}`;
|
|
3870
|
+
}
|
|
3871
|
+
viewrepo.set(route.key, view);
|
|
3961
3872
|
this._lastView = view;
|
|
3962
3873
|
view.state = ViewState.Opening;
|
|
3963
3874
|
view.dispatch(ViewEvent.Opening);
|
|
3964
3875
|
//
|
|
3965
3876
|
try {
|
|
3966
|
-
|
|
3877
|
+
//
|
|
3967
3878
|
this.onOpening(view);
|
|
3968
3879
|
// @ts-ignore
|
|
3969
3880
|
if (!view._waitOpenComplete) {
|
|
@@ -3981,36 +3892,59 @@ class ViewController extends Controller {
|
|
|
3981
3892
|
this.closeView(view);
|
|
3982
3893
|
}
|
|
3983
3894
|
}
|
|
3895
|
+
/**
|
|
3896
|
+
* 等待打开完成指令
|
|
3897
|
+
*/
|
|
3898
|
+
waitOpenComplete(view) {
|
|
3899
|
+
// @ts-ignore
|
|
3900
|
+
view._waitOpenComplete = true;
|
|
3901
|
+
}
|
|
3984
3902
|
openComplete(view) {
|
|
3985
3903
|
if (!view) {
|
|
3986
3904
|
return;
|
|
3987
3905
|
}
|
|
3988
3906
|
this._lastView = view;
|
|
3989
3907
|
view.state = ViewState.Opened;
|
|
3908
|
+
// @ts-ignore
|
|
3909
|
+
view._waitOpenComplete = false;
|
|
3990
3910
|
this.onOpened(view);
|
|
3991
3911
|
view.dispatch(ViewEvent.Opened);
|
|
3992
3912
|
}
|
|
3993
3913
|
/**
|
|
3994
|
-
*
|
|
3914
|
+
* 当视图需要通过路由关闭时,需要实现此方法
|
|
3995
3915
|
* @param route
|
|
3996
3916
|
* @returns
|
|
3997
3917
|
*/
|
|
3998
|
-
|
|
3999
|
-
let
|
|
4000
|
-
if (
|
|
4001
|
-
|
|
4002
|
-
lastview = layer.currentView;
|
|
4003
|
-
layer.currentView = null;
|
|
4004
|
-
if (this._enableHistory) {
|
|
4005
|
-
// 清空历史记录
|
|
4006
|
-
layer.getHistory().length = 0;
|
|
4007
|
-
}
|
|
3918
|
+
close(route) {
|
|
3919
|
+
let view = viewrepo.getByRoute(route);
|
|
3920
|
+
if (view) {
|
|
3921
|
+
this.closeView(view);
|
|
4008
3922
|
}
|
|
4009
|
-
|
|
4010
|
-
|
|
3923
|
+
return view;
|
|
3924
|
+
}
|
|
3925
|
+
/**
|
|
3926
|
+
* 关闭相斥的视图对象
|
|
3927
|
+
* 1. 关闭同一层的所有视图对象
|
|
3928
|
+
* 2. 关闭符合相斥规则的视图对象
|
|
3929
|
+
* @param view
|
|
3930
|
+
* @param validFunc 符合条件的视图对象会被关闭
|
|
3931
|
+
* @returns 被关闭的视图
|
|
3932
|
+
*/
|
|
3933
|
+
closeExclusion(validFunc = undefined) {
|
|
3934
|
+
if (!validFunc) {
|
|
3935
|
+
return;
|
|
4011
3936
|
}
|
|
4012
|
-
|
|
4013
|
-
|
|
3937
|
+
let closedList = new ViewList();
|
|
3938
|
+
viewrepo.forEach((key, item, iterator) => {
|
|
3939
|
+
if (validFunc(item)) {
|
|
3940
|
+
closedList.push(item);
|
|
3941
|
+
}
|
|
3942
|
+
});
|
|
3943
|
+
closedList.forEach((index, item) => {
|
|
3944
|
+
let currentCtrl = item.controller;
|
|
3945
|
+
currentCtrl.closeView(item);
|
|
3946
|
+
});
|
|
3947
|
+
return closedList;
|
|
4014
3948
|
}
|
|
4015
3949
|
closeView(view) {
|
|
4016
3950
|
if (!view) {
|
|
@@ -4038,13 +3972,19 @@ class ViewController extends Controller {
|
|
|
4038
3972
|
console.error(e.stack);
|
|
4039
3973
|
}
|
|
4040
3974
|
}
|
|
3975
|
+
waitCloseComplete(view) {
|
|
3976
|
+
// @ts-ignore
|
|
3977
|
+
view._waitCloseComplete = true;
|
|
3978
|
+
}
|
|
4041
3979
|
closeComplete(view) {
|
|
4042
3980
|
if (!view) {
|
|
4043
3981
|
return;
|
|
4044
3982
|
}
|
|
4045
|
-
viewrepo.
|
|
3983
|
+
viewrepo.delete(view.route.key);
|
|
4046
3984
|
this._lastView = view;
|
|
4047
3985
|
// @ts-ignore
|
|
3986
|
+
view._waitCloseComplete = false;
|
|
3987
|
+
// @ts-ignore
|
|
4048
3988
|
let objectDict = view._objectDict;
|
|
4049
3989
|
if (objectDict) {
|
|
4050
3990
|
objectDict.clear();
|
|
@@ -4054,7 +3994,7 @@ class ViewController extends Controller {
|
|
|
4054
3994
|
this.onClosed(view);
|
|
4055
3995
|
}
|
|
4056
3996
|
refresh() {
|
|
4057
|
-
this.
|
|
3997
|
+
this.refreshView(this._lastView);
|
|
4058
3998
|
}
|
|
4059
3999
|
get layer() {
|
|
4060
4000
|
return this._layer;
|
|
@@ -4079,6 +4019,10 @@ class ViewController extends Controller {
|
|
|
4079
4019
|
this._tags = tags;
|
|
4080
4020
|
return this;
|
|
4081
4021
|
}
|
|
4022
|
+
useHistory() {
|
|
4023
|
+
this._enableHistory = true;
|
|
4024
|
+
return this;
|
|
4025
|
+
}
|
|
4082
4026
|
get lastView() {
|
|
4083
4027
|
return this._lastView;
|
|
4084
4028
|
}
|
|
@@ -6363,5 +6307,5 @@ class WidgetUtil {
|
|
|
6363
6307
|
}
|
|
6364
6308
|
var widgetutil = new WidgetUtil();
|
|
6365
6309
|
|
|
6366
|
-
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil,
|
|
6310
|
+
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteList, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectDict, UIPoolConfig, UISingleConfig, UIUtil, ViewController, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uidict, uimgr, uiutil, widgetutil };
|
|
6367
6311
|
//# sourceMappingURL=index.esm.js.map
|