efront 3.11.0 → 3.11.4

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/apps/kugou/api.js CHANGED
@@ -2,15 +2,18 @@
2
2
  "https://m.kugou.com/": {
3
3
  "song-info": "get app/i/getSongInfo.php?cmd=playInfo&from=mkugou&hash",
4
4
  "slider-src": "get:[].mod-slider>.swipe-wrap>div .#src=img!src&href=a!href",
5
- "songs-list": "get:[].panel-songslist>li .#hash=!id&.panel-songs-item-name>span!innerText",
6
- "rank-list": "get:[].panel-img-list>li rank/list#href=a!href&=a!href\\rank-info&imgurl=img!_src&name=p|innerText",
7
- "rank-info": "get:[].panel-songslist>li rank/info/:id#src=!id&name=.panel-songs-item-name|innerText&data=.panel-songs-item-download/innerText",
8
- "plist-index": "get:[].panel-img-list>li plist/index#href=a!href&=a!href\\plist-info&imgurl=img!_src&name=.panel-img-content-first|innerText&count=.panel-img-content-sub|innerText",
9
- "plist-info": "get:[].panel-songslist>li plist/list/:id#name=.panel-songs-item-name|innerText&data=.panel-songs-item-download/innerText",
5
+ "songs-list": "get:[].panel-songslist%20li .#hash=!id&.panel-songs-item-name>span!innerText",
6
+ "rank-list": "get:[].panel-img-list%20li rank/list#href=a!href&=a!href\\rank-info&imgurl=img!_src&name=p|innerText",
7
+ "rank-info": "get:[].panel-songslist%20li rank/info/:id#src=!id&name=.panel-songs-item-name|innerText&data=.panel-songs-item-download/innerText",
8
+ "plist-index": "get:[].panel-img-list%20li plist/index#href=a!href&=a!href\\plist-info&imgurl=img!_src&name=.panel-img-content-first|innerText&count=.panel-img-content-sub|innerText",
9
+ "plist-info": "get:[].panel-songslist%20li plist/list/:id#name=.panel-songs-item-name|innerText&data=.panel-songs-item-download/innerText",
10
10
  "search-hot": "get api/v3/search/hot?format=json&plat=0&count=30",
11
11
  "singer-class": "get:[].bd%20li singer/class#href=a!href&=a!href\\singer-list&name=a|innerText&group=?parentNode",
12
- "singer-list": "get:[].singer-img-list>li singer/list/:id#href=a!href&=a!href\\singer-info&imgurl=img!_src&name=p|innerText",
13
- "singer-info": "mget:[].singer-songs-list>li singer/info/:id#hash=!id&singer=.singer-name|innerText&name=.song-name|innerText&data=em/innerText"
12
+ "singer-list": "get:[].singer-img-list>li singer/list/:id#href=a!href&=a!href\\singer-info0&imgurl=img!_src&name=p|innerText",
13
+ "singer-info0": "mget:[].singer-songs-list>li singer/info/:id#hash=!id&singer=.singer-name|innerText&name=.song-name|innerText&data=em/innerText"
14
+ },
15
+ "https://www.kugou.com/": {
16
+ "singer-info": "cget:link[rel]+script yy/singer/home/:id.html",
14
17
  },
15
18
  "http://mobilecdn.kugou.com/": {
16
19
  "search?keyword": "get:data.info api/v3/search/song?format=json&page=1&pagesize=30&showtype=1"
@@ -118,7 +118,7 @@ var scan = function (text) {
118
118
  }
119
119
 
120
120
  if (/^\-(\s|$)/.test(row)) {
121
- if (data || span > spacesize) push();
121
+ if (data || span >= spacesize) push();
122
122
  if (!parents[spacesize]) {
123
123
  var obj = [];
124
124
  push(obj);
@@ -33,10 +33,23 @@
33
33
  };
34
34
  var parseMenuList = function (items) {
35
35
  if (items instanceof Array) {
36
+ if (!items[0] || !items[0].name) {
37
+ var items1 = [];
38
+ for (var cx = 0, dx = items.length; cx < dx; cx++) {
39
+ var item = items[cx];
40
+ if (!item) continue;
41
+ item = parseMenuList(item);
42
+ items1.push.apply(items1, item);
43
+ items1.push({ line: true });
44
+ }
45
+ items1.pop();
46
+ items = items1;
47
+ }
36
48
  return items;
37
49
  }
38
50
  if (items instanceof Object) {
39
51
  var keys = Object.keys(items);
52
+
40
53
  items = keys.map(k => {
41
54
  var c = items[k];
42
55
  var item = {};
@@ -54,7 +67,8 @@
54
67
  if (/,/.test(name)) {
55
68
  var [name, ...roles] = name.split(',');
56
69
  }
57
- item.name = name;
70
+ if (/^\-+$/.test(name)) item.line = true;
71
+ else item.name = name;
58
72
  if (roles) item.roles = roles;
59
73
  if (path) item.path = path;
60
74
  if (data) item.params = parseKV(data);
@@ -68,6 +82,8 @@
68
82
  return [];
69
83
  };
70
84
  result.update = function (items) {
85
+ delete result.loading_promise;
86
+ delete result.then;
71
87
  items = parseMenuList(items);
72
88
  items.map(getChildren);
73
89
  var opened = data.getInstance("menu-opened");
@@ -174,10 +190,19 @@
174
190
  result.load(result.active);
175
191
  return result;
176
192
  };
177
- result.fetch = function (url) {
178
- data.from(url).loading_promise.then(result.update);
193
+ result.from = result.fetch = function (url) {
194
+ result.loading_promise = data.from(url).loading_promise.then(result.update);
195
+ result.then = then;
179
196
  return result;
180
197
  };
198
+ var then = function (ok, oh) {
199
+ if (this.loading_promise) {
200
+ return this.loading_promise.then(ok, oh);
201
+ }
202
+ delete result.then;
203
+ ok(result);
204
+ result.then = then;
205
+ };
181
206
  result.update(items);
182
207
  return result;
183
208
  });
@@ -1,10 +1,24 @@
1
- a => a.map(b => {
2
- var data = {};
3
- if (b.data) extend(data, {
4
- name: b.data.filename.replace(/^[\s\S]*?\s*\-\s*/, ''),
5
- singer: b.data.filename.replace(/\s*\-\s*[\s\S]*?$/, '')
6
- }, b.data);
7
- else extend(data, b);
8
- if (data.hash) data.hash = data.hash.replace(/^songs\_/i, '');
9
- return data;
10
- });
1
+ a => {
2
+ if (isElement(a)) {
3
+ var m = /songsdata\s*=\s*(\[[\s\S]*\])/.exec(a.innerText);
4
+ if (!m) throw new Error("无法加载数据!");
5
+ if (m) a = m[1];
6
+ a = JSON.parse(a);
7
+ console.log(a)
8
+ }
9
+ return a.map(b => {
10
+ var data = {};
11
+ if (b.data) extend(data, {
12
+ name: b.data.filename.replace(/^[\s\S]*?\s*\-\s*/, ''),
13
+ singer: b.data.filename.replace(/\s*\-\s*[\s\S]*?$/, '')
14
+ }, b.data);
15
+ else extend(data, b);
16
+ if (!data.singer) {
17
+ data.singer = data.author_name;
18
+ }
19
+ if (!data.name) data.name = data.audio_name;
20
+ if (data.hash) data.hash = data.hash.replace(/^songs\_/i, '');
21
+ return data;
22
+ });
23
+
24
+ }
@@ -19,6 +19,7 @@ function Item(value) {
19
19
  this.icon = value.icon;
20
20
  this.color = value.color;
21
21
  this.test = value.test;
22
+ this.line = value.line;
22
23
  }
23
24
  this.count = 0;//子项中的叶子节点数
24
25
  this.total = 0;//子项中的节点数
@@ -0,0 +1,47 @@
1
+ var keyMap = {};
2
+ on("keydown")(window, function (event) {
3
+ var { which } = event;
4
+ switch (event.which) {
5
+ case 18:
6
+ event.preventDefault();
7
+ break;
8
+ default:
9
+ var key = String.fromCharCode(which);
10
+ var elems = keyMap[key];
11
+ if (elems) while (elems.length) {
12
+ var elem = elems[elems.length - 1];
13
+ if (isMounted(elem)) break;
14
+ else elems.pop();
15
+ }
16
+ if (elem) {
17
+ var parent = elem.parentNode;
18
+ if (event.altKey || parent === document.activeElement || parent.ispop) {
19
+ event.preventDefault();
20
+ elem.click();
21
+ }
22
+ }
23
+ }
24
+ });
25
+ var bindAccesskey = function (btn, k) {
26
+ if (!keyMap[k]) keyMap[k] = [];
27
+ removeFromList(keyMap[k], btn);
28
+ keyMap[k].push(btn);
29
+ once("remove")(btn, function () {
30
+ removeFromList(keyMap[k], btn);
31
+ });
32
+ };
33
+ var getKeyFromText = function (btn) {
34
+ var { innerText } = btn;
35
+ var match = /\(\s*\_?\w\s*\)|\[\s*\_?\w\s*\]|\{\s*\_?\w\s*\}/.exec(innerText);
36
+ if (match) {
37
+ var accesskey = match[0].replace(/^\W*(\w)\W*$/g, '$1');
38
+ } else {
39
+ var accesskey = btn.getAttribute("accesskey");
40
+ }
41
+ if (!accesskey) return;
42
+ return accesskey.toUpperCase();
43
+ }
44
+ function main(elem, key = getKeyFromText(elem)) {
45
+ bindAccesskey(elem, key);
46
+ return elem;
47
+ }
@@ -2,28 +2,6 @@ var _label = createElement("span");
2
2
  var track = createElement(div);
3
3
  track.className = "track";
4
4
  _label.className = "label";
5
- var keyMap = {};
6
- on("keydown")(window, function (event) {
7
- var { which } = event;
8
- switch (event.which) {
9
- case 18:
10
- event.preventDefault();
11
- break;
12
- default:
13
- if (event.altKey) {
14
- var key = String.fromCharCode(which);
15
- var element = keyMap[key];
16
- if (element) {
17
- if (isMounted(element)) {
18
- event.preventDefault();
19
- element.click();
20
- } else {
21
- delete keyMap[key];
22
- }
23
- }
24
- }
25
- }
26
- });
27
5
 
28
6
  var btn = document.createElement("button");
29
7
  btn.tabIndex = 0;
@@ -75,17 +53,6 @@ var touchstart = function () {
75
53
  var canceltouchend = ontouchend(this, cancel);
76
54
  active.call(this);
77
55
  };
78
- var bindAccesskey = function (btn) {
79
- var { innerText } = btn;
80
- var match = /\(\s*\_?\w\s*\)|\[\s*\_?\w\s*\]|\{\s*\_?\w\s*\}/.exec(innerText);
81
- if (match) {
82
- var accesskey = match[0].replace(/^\W*(\w)\W*$/g, '$1');
83
- } else {
84
- var accesskey = btn.getAttribute("accesskey");
85
- }
86
- if (!accesskey) return;
87
- keyMap[accesskey.toUpperCase()] = btn;
88
- };
89
56
  function button(texter, type) {
90
57
  var tracker = createElement(track);
91
58
  var _texter;
@@ -18,7 +18,8 @@
18
18
  outline: none;
19
19
  user-select: none;
20
20
  }
21
- >.label{
21
+
22
+ >.label {
22
23
  position: relative;
23
24
  }
24
25
 
@@ -91,7 +92,7 @@
91
92
 
92
93
  >.track {
93
94
  background: #0001;
94
- box-shadow: inset 0 0 6px 6px #6fc3;
95
+ box-shadow: inset 0 0 6px 6px #00000006;
95
96
  }
96
97
  }
97
98
 
@@ -1,13 +1,9 @@
1
1
 
2
2
  var _slider = createElement(div);
3
- var empty = function (index, item) {
4
- if (!item) return;
5
- return document.createElement('empty');
6
- };
7
- var getGenerator = function (container) {
3
+ var getGenerator = function (container, tagName = 'item') {
8
4
  if (!container) return;
9
- if (!container.childNodes.length) return container.$generator || empty;
10
- var template = document.createElement("div");
5
+ if (!container.childNodes.length && container.$generator) return container.$generator;
6
+ var template = document.createElement(tagName);
11
7
  var templates = [].concat.apply([], container.childNodes).filter(a => {
12
8
  if (a.hasAttribute('insert')) {
13
9
  return false;
@@ -25,17 +21,24 @@ var getGenerator = function (container) {
25
21
  appendChild(template, templates);
26
22
  container.insertBefore = _slider.insertBefore;
27
23
  container.appendChild = _slider.appendChild;
28
- var scopes = container.$parentScopes.concat(container.$scope);
29
- return container.$generator = function (index, com) {
24
+ var scopes = container.$parentScopes || [];
25
+ if (container.$scope) scopes = scopes.concat(container.$scope);
26
+ return container.$generator = function (index, com, element) {
30
27
  if (!com) {
31
28
  if (!container.src || index >= container.src.length) return;
32
29
  com = container.src[index];
33
30
  }
34
31
  if (!com) return;
35
- var template1 = template.cloneNode(true);
36
- if (!template1.childNodes.length) return template1;
37
- var item = template1.childNodes[0];
38
- item.with = [].concat.apply([], template1.childNodes).slice(1);
32
+ if (!element) {
33
+ var template1 = template.cloneNode(true);
34
+ if (!template1.childNodes.length) {
35
+ element = template1;
36
+ }
37
+ else {
38
+ element = template1.childNodes[0];
39
+ if (template1.childNodes.length > 1) element.with = [].concat.apply([], template1.childNodes).slice(1);
40
+ }
41
+ }
39
42
  var parsedSrc = container.$src;
40
43
  if (parsedSrc) {
41
44
  var { keyName, itemName, indexName } = parsedSrc;
@@ -44,8 +47,8 @@ var getGenerator = function (container) {
44
47
  [itemName || '$item']: com,
45
48
  [indexName || '$index']: index
46
49
  };
47
- var newItem = render(item, newScope, scopes);
48
- if (item.with.length) newItem.with = render(item.with, newScope, scopes);
50
+ var newItem = render(element, newScope, scopes);
51
+ if (element.with) newItem.with = render(element.with, newScope, scopes);
49
52
  } else {
50
53
  var newScope = container.src[index];
51
54
  if (!isObject(newScope)) newScope = {
@@ -65,8 +68,8 @@ var getGenerator = function (container) {
65
68
  return this.$item;
66
69
  }
67
70
  }
68
- var newItem = render(item, newScope, scopes);
69
- newItem.with = render(newItem.with = item.with, newScope, scopes);
71
+ var newItem = render(element, newScope, scopes);
72
+ if (element.with) newItem.with = render(newItem.with = element.with, newScope, scopes);
70
73
  }
71
74
  return newItem;
72
75
  };
@@ -117,8 +117,9 @@ function main(elem, mode) {
117
117
  case "inline":
118
118
  case "t":
119
119
  case "tree":
120
+ mode = "tree";
120
121
  if (elem) {
121
- var generator = getGenerator(elem);
122
+ var generator = getGenerator(elem, 'menu-item');
122
123
  tree(elem, function (index, item) {
123
124
  var e = generator(index, item);
124
125
  if (!e || e.children.length) return e;
@@ -156,14 +157,16 @@ function main(elem, mode) {
156
157
  active(elem, item, item.value, target);
157
158
  };
158
159
  if ("$src" in elem) {
159
- getGenerator(elem);
160
+ getGenerator(elem, 'menu-item');
160
161
  care(elem, function (src) {
161
162
  menuList(elem, getTreeFromData(src), emit, direction);
163
+ elem.registerAsRoot();
162
164
  });
163
165
  }
164
166
  else {
165
167
  var nodes = getArrayNodes(elem);
166
168
  elem = menuList(elem, nodes, emit, direction);
169
+ elem.registerAsRoot();
167
170
  }
168
171
  break;
169
172
  default:
@@ -92,12 +92,15 @@ body:active & {
92
92
  display: block;
93
93
  overflow: hidden;
94
94
  text-overflow: hidden;
95
- height: 40px;
96
95
  position: relative;
97
96
  border-bottom: 1px solid #18333c;
97
+ border-top: none;
98
+ border-left: none;
99
+ border-right: none;
98
100
  padding: 0;
99
101
 
100
102
  menu-item {
103
+ line-height: 24px;
101
104
  display: inline-block;
102
105
 
103
106
  &.has-children:after {
@@ -110,11 +113,9 @@ body:active & {
110
113
  vertical-align: top;
111
114
  }
112
115
 
113
- .button {
114
- line-height: 40px;
115
- }
116
116
  }
117
117
 
118
+ &[mode=tree],
118
119
  &[mode=tree],
119
120
  &[type=tree],
120
121
  &[mode=inline],
@@ -122,46 +123,46 @@ body:active & {
122
123
  height: auto;
123
124
  box-shadow: none;
124
125
  padding: 0;
125
- margin: 0;
126
-
127
- // &[browser=samsung] {
128
- // .tab1 {
129
- // &.open s {
130
- // overflow : visible;
131
- // text-indent: -6.6pt;
132
- // }
133
- // &.closed s{
134
- // overflow : visible;
135
- // text-indent: 3.1pt;
136
- // }
137
- // }
138
- // }
139
-
140
- // &[browser=firefox] {
141
- // .tab1 {
142
- // &.open s {
143
- // text-indent: -8.6px;
144
- // }
145
-
146
- // &.closed s {
147
- // text-indent: -4.1px;
148
- // }
149
- // }
150
- // }
151
-
152
- // &[browser=safari] {
153
- // .tab1 {
154
- // &.open s {
155
- // text-indent: -5.6px;
156
- // }
157
-
158
- // &.closed s {
159
- // text-indent: -1.1px;
160
- // }
161
- // }
162
- // }
163
-
164
- .tab1 {
126
+
127
+ >.button {
128
+ box-shadow: none;
129
+ padding-top: 6px;
130
+ padding-bottom: 6px;
131
+ line-height: 20px;
132
+ font-size: 14px;
133
+
134
+ >b {
135
+ font-weight: normal;
136
+ }
137
+
138
+ &:not(.tab1) {
139
+ display: block;
140
+ background: #2c3b41;
141
+ color: #8aa4af;
142
+
143
+ &.checked,
144
+ &.actived,
145
+ &.selected {
146
+ color: #fff;
147
+ }
148
+ }
149
+
150
+ i {
151
+ margin-right: 10px;
152
+ }
153
+
154
+
155
+ &.hover {
156
+ text-shadow: none;
157
+ color: #fff;
158
+ }
159
+
160
+ }
161
+
162
+ >.tab1 {
163
+ font-size: 16px;
164
+ line-height: 28px;
165
+
165
166
  &.open {
166
167
  color: #fff;
167
168
  background: #1e282c;
@@ -218,45 +219,13 @@ body:active & {
218
219
 
219
220
  border-left: 3px solid transparent;
220
221
  display : block;
221
- height : 44px;
222
- line-height: 44px;
223
222
  font-size : 14px;
224
223
  color : #b8c7ce;
225
224
  }
226
225
 
227
- >.button {
228
- box-shadow: none;
229
-
230
-
231
- >b {
232
- font-weight: normal;
233
- }
234
-
235
- &:not(.tab1) {
236
- display: block;
237
- height: 36px;
238
- line-height: 36px;
239
- font-size: 14px;
240
- background: #2c3b41;
241
- color: #8aa4af;
242
-
243
- &.checked,
244
- &.actived,
245
- &.selected {
246
- color: #fff;
247
- }
248
- }
249
-
250
- i {
251
- margin-right: 10px;
252
- }
253
-
254
-
255
- &.hover {
256
- text-shadow: none;
257
- color: #fff;
258
- }
259
-
226
+ >[line],
227
+ >.line {
228
+ line-height: 0;
229
+ font-size: 0;
260
230
  }
261
-
262
231
  }
@@ -1,3 +1,4 @@
1
+ var preventDefault = function (e) { e.preventDefault() };
1
2
  function main(elem, scope, hasIcon) {
2
3
  var item = elem || document.createElement('menu-item');
3
4
  item.innerHTML = menuItem;
@@ -11,5 +12,6 @@ function main(elem, scope, hasIcon) {
11
12
  var icon = scope.icon;
12
13
  if (hasIcon === undefined) hasIcon = !!icon;
13
14
  render(item.children, { useIcon: hasIcon, hasIcon, name, icon });
15
+ if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
14
16
  return item;
15
17
  }
@@ -1,4 +1,20 @@
1
1
  i{
2
2
  display: inline-block;
3
3
  width: 1em;
4
+ }
5
+ &.line,
6
+ &[line] {
7
+ box-shadow: none;
8
+ >.track{
9
+ display: none;
10
+ }
11
+ line-height: 0;
12
+ font-size: 0;
13
+ &:after {
14
+ content: "";
15
+ display: block;
16
+ border-bottom: 1px solid;
17
+ opacity: .36;
18
+ margin: 0 -20px;
19
+ }
4
20
  }
@@ -1,4 +1,4 @@
1
- <menu-item ng-repeat="menu in menus" ng-if="!menu.hidden" ng-click="open(menu,this)"
2
- ng-mouseleave="clearTimeout(popTimer)" ng-mouseenter="popTimer=popMenu(menu,this)"
1
+ <menu-item ng-repeat="menu in menus" ng-if="!menu.hidden" ng-click="open.call(this)"
2
+ ng-mouseleave="cancel()" ng-mouseenter="popMenu.call(this)"
3
3
  ng-class="{'has-children':menu.children&&menu.children.length,'warn':menu.type==='danger'||menu.type==='warn'||menu.type==='red'}">
4
4
  </menu-item>