paas-component-library 1.0.93 → 1.0.94

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paas-component-library",
3
3
  "private": false,
4
- "version": "1.0.93",
4
+ "version": "1.0.94",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -148,28 +148,30 @@ export default {
148
148
 
149
149
  autoSelectMenu() {
150
150
  let path = window.location.hash || '';
151
- path = path.replace('#', '');
151
+ path = path.replace('#', '').split('?')[0];
152
152
 
153
153
  if (!this.data || this.data.length === 0) return;
154
154
 
155
- let current = this.current;
156
- if (!current) {
157
- current = this.data[0]?.url || '';
155
+ let matchedItem = null;
156
+ let currentFromStore = this.current;
157
+
158
+ if (path && path !== '/') {
159
+ matchedItem = this.findItemByKey(this.data, path);
160
+ if (!matchedItem) {
161
+ matchedItem = this.findItemByPathPrefix(this.data, path);
162
+ }
158
163
  }
159
- if (path === '' || path === '/') {
160
- path = current;
164
+
165
+ if (!matchedItem && currentFromStore) {
166
+ matchedItem = this.findItemByKey(this.data, currentFromStore);
167
+ }
168
+
169
+ if (!matchedItem) {
170
+ matchedItem = this.findFirstLeaf(this.data);
161
171
  }
162
- const matchedItem = this.findItemByKey(this.data, current);
163
172
 
164
173
  if (matchedItem) {
165
174
  this.selectAndOpenMenu(matchedItem);
166
- this.$router.replace(path); // 避免堆叠历史
167
- } else {
168
- const firstItem = this.findFirstLeaf(this.data);
169
- if (firstItem) {
170
- this.selectAndOpenMenu(firstItem);
171
- this.$router.replace(path); // 避免堆叠历史
172
- }
173
175
  }
174
176
  },
175
177
 
@@ -202,6 +204,20 @@ export default {
202
204
  return null;
203
205
  },
204
206
 
207
+ findItemByPathPrefix(menuList, path) {
208
+ if (!menuList || !path) return null;
209
+ for (const item of menuList) {
210
+ if (path.startsWith(item.key + '/') || path === item.key) {
211
+ return item;
212
+ }
213
+ if (item.children) {
214
+ const found = this.findItemByPathPrefix(item.children, path);
215
+ if (found) return found;
216
+ }
217
+ }
218
+ return null;
219
+ },
220
+
205
221
  findFirstLeaf(menuList) {
206
222
  for (const item of menuList) {
207
223
  if (item.children && item.children.length > 0) {