Skip to content

Commit 99a7a70

Browse files
committed
· 修正: ControlNode.js 若干BUG
· 新增: Depend.js 用于尝试解决依赖问题(尚未完成) · 新增: FlexTools.css 用于使用flex快速控制容器内元素位置
1 parent 350887f commit 99a7a70

4 files changed

Lines changed: 169 additions & 7 deletions

File tree

Template/Public/JavaScript/ControlNode.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Date: 2020-04-29 10:13:23
33
* @LastEditors : MemoryShadow
4-
* @LastEditTime : 2021-01-07 13:07:51
4+
* @LastEditTime : 2021-01-08 00:32:42
55
* @Effect: 内置类ControlNode,用于控制节点,并包含一些内置的控件,可以快速创建
66
* //!注:此类未完全完成,请勿用于生产环境
77
*/
@@ -110,7 +110,7 @@ function ControlNode(MainNodeID) {
110110
case 'string':
111111
for (var index = 0; index < this.length(); index++) {
112112
var Node = this.Node_Data_List[index];
113-
if (Node.id == Key) {
113+
if (Node.id === Key) {
114114
return Node;
115115
}
116116
}
@@ -252,7 +252,7 @@ ControlNode.getInputNode = function (NodeDataType, Value, Candidate, isDisable)
252252
}
253253

254254
/**
255-
* 获取一个指定样式的输入框
255+
* 获取一个指定样式的按钮
256256
* @param {String} NodeDataType 节点数据类型,以下是支持的值
257257
* [default: 默认形式, link: 链接形式]
258258
* @param {String} Value 按钮的显示内容
@@ -262,23 +262,27 @@ ControlNode.getInputNode = function (NodeDataType, Value, Candidate, isDisable)
262262
* @return {JSON} 此输入控件的描述JSON对象
263263
*/
264264
ControlNode.getButtonNode = function (NodeDataType, Value, onClick, isDisable) {
265+
let NodeObj = {};
265266
switch (NodeDataType) {
266267
case 'link':
267-
return JSON.parse(JSON.stringify({
268+
NodeObj = JSON.parse(JSON.stringify({
268269
"Tag": "a",
269270
"Class": isDisable ? "button disable" : "button enable",
270271
"Href": onClick,
271272
"Text": Value
272273
}));
273-
274+
break;
274275
default:
275-
return JSON.parse(JSON.stringify({
276+
NodeObj = JSON.parse(JSON.stringify({
276277
"Tag": "button",
277278
"Disabled": isDisable ? "disable" : false,
278279
"OnClick": onClick,
279280
"Text": Value
280281
}));
282+
NodeObj['OnClick'] = onClick;
283+
break;
281284
}
285+
return NodeObj;
282286
}
283287

284288
/**
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* @Date : 2021-01-07 23:18:20
3+
* @Author : MemoryShadow
4+
* @LastEditors : MemoryShadow
5+
* @LastEditTime : 2021-01-08 00:32:33
6+
* @Description : 用于处理依赖的Depend类
7+
*/
8+
9+
/**
10+
* 将指定资源添加至加载队列中并加载,用于处理依赖
11+
* @param {String} ResourcesURL 指定资源URL
12+
*/
13+
function Depend(ResourcesURL) {
14+
// 此资源的URL
15+
this.ResourcesURL;
16+
// 此资源的类型
17+
this.ResourcesType;
18+
// 此对象在公共队列中的位置
19+
this.thisObjectIndex;
20+
21+
/**
22+
* 解析当前URL的类型
23+
* @returns {String} 类型
24+
*/
25+
this.AnalysisResourcesType = function (e) {
26+
this.ResourcesType = this.ResourcesURL.split(".").pop();
27+
return this.ResourcesType;
28+
}
29+
30+
/**
31+
* 构造器
32+
* @param {String} ResourcesURL 指定资源URL
33+
*/
34+
this.constructor = function (ResourcesURL) {
35+
this.ResourcesURL = ResourcesURL;
36+
this.ResourcesType = this.AnalysisResourcesType();
37+
this.thisObjectIndex = Depend.ObjectList.length;
38+
// 将自身添加至对象列
39+
Depend.ObjectList.push(this);
40+
}
41+
42+
this.constructor(ResourcesURL, ResourcesType);
43+
}
44+
45+
/**
46+
* 索引
47+
* @param {int,String} Key 要用于索引的Key
48+
* @return {ControlNode} 指定的控制对象
49+
*/
50+
Depend.indexOf = function (Key) {
51+
// 判断是数字还是字符串
52+
switch (typeof Key) {
53+
case 'number': // 数字索引就直接索引
54+
return Depend.ObjectList[Key];
55+
case 'string': // 是字符串,就逐一匹配
56+
for (var index = 0; index < Depend.ObjectList.length; index++) {
57+
var depend = Depend.ObjectList[index];
58+
if (depend.ResourcesURL === Key) {
59+
return depend;
60+
}
61+
}
62+
return undefined
63+
64+
default:
65+
return undefined;
66+
}
67+
}
68+
69+
/**
70+
* 获取指定节点的控制对象
71+
* @param {string} MainNodeID 指定要作为主节点的ID
72+
* @return {ControlNode} 指定的控制对象
73+
*/
74+
Depend.valueOf = function (index) {
75+
// 检查是否存在重复的对象,如果有,就直接返回,没有的情况下才创建新对象
76+
if (ControlNode.indexOf(index) == undefined) {
77+
// 如果没有,就New新的值
78+
return new ControlNode(index);
79+
} else {
80+
// 如果不为空,就返回指定的内容
81+
return ControlNode.indexOf(index);
82+
}
83+
}
84+
85+
// 数据队列(避免重复导入同一个文件)
86+
Depend.ObjectList = [];
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
.FlexTools {
2+
display: flex;
3+
}
4+
5+
.FlexTools div {
6+
display: flex;
7+
}
8+
9+
.column {
10+
display: flex;
11+
flex-direction: column;
12+
}
13+
14+
.column.left {
15+
align-items: flex-start;
16+
}
17+
18+
.column.right {
19+
align-items: flex-end;
20+
}
21+
22+
.column.top {
23+
justify-content: flex-start;
24+
}
25+
26+
.column.bottom {
27+
justify-content: flex-end;
28+
}
29+
30+
.column.Wcenter {
31+
align-items: center;
32+
}
33+
34+
.column.Hcenter {
35+
justify-content: center;
36+
}
37+
38+
.row {
39+
display: flex;
40+
flex-direction: row;
41+
}
42+
43+
.row.right {
44+
justify-content: flex-start;
45+
}
46+
47+
.row.right {
48+
justify-content: flex-end;
49+
}
50+
51+
.row.top {
52+
display: flex;
53+
align-items: flex-start;
54+
}
55+
56+
.row.bottom {
57+
align-items: flex-end;
58+
}
59+
60+
.row.Wcenter {
61+
justify-content: center;
62+
}
63+
64+
.row.Hcenter {
65+
align-items: center;
66+
}
67+
68+
.center {
69+
display: flex;
70+
align-items: center;
71+
justify-content: center;
72+
}

Template/Public/Style/PublicCSS.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Date : 2020-10-18 10:52:43
33
* @Author : MemoryShadow
44
* @LastEditors : MemoryShadow
5-
* @LastEditTime : 2020-10-18 18:14:15
5+
* @LastEditTime : 2021-01-07 23:00:40
66
* @Description : 基础组件css样式
77
*/
88

0 commit comments

Comments
 (0)