efront 4.22.9 → 4.22.10

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.
@@ -133,13 +133,12 @@
133
133
  historys.forEach((a, i) => map[a] = i + 1);
134
134
  result.splice(0, result.length);
135
135
  var actived, actived_value = 0;
136
- var zimoilPath = zimoli.getInitPath();
137
136
  var a = function (menu) {
138
137
  var res = checkroles(user.roles, menu.roles);
139
138
  if (res) {
140
139
  if (savedChildren[menu.id] instanceof Array) menu.children = savedChildren[menu.id].filter(a);
141
140
  if (menu.path) {
142
- if (!firstMenu || menu.path === zimoilPath) firstMenu = menu;
141
+ if (!firstMenu) firstMenu = menu;
143
142
  if (map[menu.path] > actived_value) {
144
143
  actived = menu;
145
144
  actived_value = map[menu.path];
@@ -165,6 +164,19 @@
165
164
  first_opened = false;
166
165
  return result;
167
166
  };
167
+ var findMenu = function (path) {
168
+ if (!path) return;
169
+ var run = function (list) {
170
+ for (var o of list) {
171
+ if (o.path === path) return o;
172
+ if (o.children) {
173
+ o = run(o.children);
174
+ if (o) return o;
175
+ }
176
+ }
177
+ };
178
+ return run(result);
179
+ }
168
180
  var setActive = function (p, active) {
169
181
  while (p) {
170
182
  p.active = active;
@@ -198,7 +210,8 @@
198
210
  result.open = function (menu) {
199
211
  if (!menu) {
200
212
  if (first_opened && result.active) return;
201
- menu = result.active || firstMenu;
213
+ var zimoilPath = zimoli.getInitPath();
214
+ menu = result.active || findMenu(zimoilPath) || firstMenu;
202
215
  if (!menu?.path) return;
203
216
  first_opened = true;
204
217
  zimoli.switch(null, null, menu);
@@ -379,7 +379,7 @@ function create(pagepath, args, from, needroles) {
379
379
  return alert(i18n`没有权限!`, 0);
380
380
  }
381
381
  if (!pg) return;
382
- history[current_history].wardable = true;
382
+ if (history[current_history]) history[current_history].wardable = true;
383
383
  var _with_length = _with_elements.length;
384
384
  state.onback = function (handler) {
385
385
  _pageback_listener = handler;
@@ -687,6 +687,8 @@ var _switch = zimoli.switch = function (history_name = default_history, target_b
687
687
  setZimoliParams(pagepath, { roles, data: args, id, options });
688
688
  emptyState = pagepath;
689
689
  }
690
+ }
691
+ if (isString(emptyState)) {
690
692
  if (!history[current_history]) root_path = (history[current_history] = createEmptyHistory(emptyState))[0];
691
693
  else {
692
694
  var _history = history[current_history];
@@ -749,6 +751,7 @@ zimoli.createState = createState;
749
751
  // 家中进了贼,我们是把家让给它,还是找机会把贼杀了。
750
752
  var getInitPath = zimoli.getInitPath = function () {
751
753
  var h = history[current_history];
754
+ if (!h) return locationInitHash;
752
755
  if (h.length < 2) return pathFromHash(locationInitHash);
753
756
  return h[0];
754
757
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.22.9",
3
+ "version": "4.22.10",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {