cabloy 5.1.49 → 5.1.50

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.1.50
4
+
5
+ ### Features
6
+
7
+ - Update tab-related behavior and rendering.
8
+
9
+ ### Bug Fixes
10
+
11
+ - Reset tabs when the layout refreshes.
12
+ - Improve active tab route matching.
13
+ - Handle alias routes correctly for active tabs.
14
+ - Improve navigation for localized home routes.
15
+
16
+ ### Improvements
17
+
18
+ - Refine tab rendering logic.
19
+
3
20
  ## 5.1.49
4
21
 
5
22
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cabloy",
3
- "version": "5.1.49",
3
+ "version": "5.1.50",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A Node.js fullstack framework",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova",
3
- "version": "5.1.92",
3
+ "version": "5.1.93",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A vue3 framework with ioc",
6
6
  "keywords": [
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "zova-core": "^5.1.48",
49
- "zova-suite-a-zova": "^5.1.91"
49
+ "zova-suite-a-zova": "^5.1.92"
50
50
  },
51
51
  "devDependencies": {
52
52
  "clean-package": "^2.2.0",
@@ -1,4 +1,3 @@
1
- import { RouterLink } from '@cabloy/vue-router';
2
1
  import { z } from 'zod';
3
2
  import { BeanControllerPageBase, Use } from 'zova';
4
3
  import { Controller } from 'zova-module-a-bean';
@@ -27,7 +26,6 @@ export class ControllerPageToolTwo extends BeanControllerPageBase {
27
26
  <div>{`id: ${pageData?.id}`}</div>
28
27
  <div>{`name: ${pageData?.name}`}</div>
29
28
  <div>{`married: ${pageData?.married}`}</div>
30
- <RouterLink to={this.sys.env.ROUTER_PAGE_HOME}>Go Home</RouterLink>
31
29
  </div>
32
30
  );
33
31
  }
@@ -1,5 +1,6 @@
1
1
  export default {
2
2
  Home: 'Home',
3
+ GoHome: 'Go Home',
3
4
  LanguageEnglish: 'English',
4
5
  LanguageChinese: 'Chinese',
5
6
  };
@@ -1,5 +1,6 @@
1
1
  export default {
2
2
  Home: '主页',
3
+ GoHome: '返回首页',
3
4
  LanguageEnglish: '英语',
4
5
  LanguageChinese: '简体中文',
5
6
  };
@@ -1,4 +1,3 @@
1
- import { RouterLink } from '@cabloy/vue-router';
2
1
  import { classes } from 'typestyle';
3
2
  import { BeanControllerPageBase } from 'zova';
4
3
  import { Controller } from 'zova-module-a-bean';
@@ -26,7 +25,14 @@ export class ControllerPageErrorNotFound extends BeanControllerPageBase {
26
25
  <div>
27
26
  <div class={this.cTitle}>404</div>
28
27
  <div class={this.cDescription}>Oops. Nothing here...</div>
29
- <RouterLink to={this.sys.env.ROUTER_PAGE_HOME}>Go Home</RouterLink>
28
+ <button
29
+ class="btn btn-primary"
30
+ onClick={() => {
31
+ this.app.$gotoHome();
32
+ }}
33
+ >
34
+ {this.scope.locale.GoHome()}
35
+ </button>
30
36
  </div>
31
37
  </div>
32
38
  );
@@ -92,7 +92,7 @@ export class ControllerLayoutWeb extends BeanControllerBase {
92
92
  return this.$$modelMenu.retrieveMenus().data;
93
93
  },
94
94
  () => {
95
- this.$$modelTabs.updateAllTabInfos(this._getInitialTabs());
95
+ this.$$modelTabs.resetAllTabInfos();
96
96
  },
97
97
  );
98
98
  }
@@ -17,7 +17,7 @@ export class RenderHeader extends BeanRenderBase {
17
17
  <button
18
18
  class="btn btn-square btn-ghost"
19
19
  onClick={() => {
20
- this.app.$gotoHome({ params: { locale: true } });
20
+ this.app.$gotoHome();
21
21
  }}
22
22
  >
23
23
  <ZIcon name=":social:cabloy" width={24}></ZIcon>
@@ -22,13 +22,10 @@ export class RenderLocale extends BeanRenderBase {
22
22
  <a
23
23
  onClick={event => {
24
24
  if (metaLocale) {
25
- const fullPath = this.$router.resolveName(currentRoute.name as any, {
26
- params: Object.assign({}, currentRoute.params, {
27
- locale: key === this.sys.config.locale.default ? '' : key,
28
- }),
25
+ this.app.$gotoPage(currentRoute.matched[0].path, {
26
+ params: { ...currentRoute.params, locale: key },
29
27
  query: currentRoute.query,
30
28
  });
31
- this.$router.push(fullPath);
32
29
  } else {
33
30
  this.$$serviceLocale.setLocale(key as any);
34
31
  }
@@ -16,7 +16,6 @@ export class RenderTabs extends BeanRenderBase {
16
16
  public renderTabs(): VNode | undefined {
17
17
  const $$modelTabs = this.$$modelTabs;
18
18
  if (!$$modelTabs) return;
19
-
20
19
  const domTabs = $$modelTabs.tabs.map(tab => {
21
20
  return this._renderMenuItem(tab.info as TypeMenuItem, true, tab.tabKey);
22
21
  });
@@ -144,9 +143,7 @@ export class RenderTabs extends BeanRenderBase {
144
143
 
145
144
  private _isMenuLeafCurrent(item: TypeMenuLeaf): boolean {
146
145
  if (item.external || !item.link) return false;
147
- const currentRoute = this.$currentRoute;
148
- if (!currentRoute) return false;
149
- return currentRoute.fullPath === item.link;
146
+ return this.$router.checkActiveOfFullPath(item.link);
150
147
  }
151
148
 
152
149
  private _getMenuItemKey(item: TypeMenuItem): string {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-router",
3
- "version": "5.1.22",
3
+ "version": "5.1.23",
4
4
  "gitHead": "09d901d17140a80ee0764211b441cda72fd94663",
5
5
  "description": "router",
6
6
  "keywords": [
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  RouteLocationMatched,
3
3
  RouteLocationNormalizedLoaded,
4
+ RouteLocationNormalizedLoadedGeneric,
4
5
  RouteLocationResolvedGeneric,
5
6
  Router,
6
7
  RouterOptions,
@@ -18,7 +19,7 @@ import {
18
19
  import { BeanBase, cast, deepExtend } from 'zova';
19
20
  import { Sys } from 'zova-module-a-bean';
20
21
 
21
- import { getRealRouteName, getRouteMatched, isRouterName } from '../lib/utils.js';
22
+ import { getCurrentRoute, getRealRouteName, getRouteMatched, isRouterName } from '../lib/utils.js';
22
23
  import {
23
24
  IModuleRoute,
24
25
  IModuleRouteComponent,
@@ -98,11 +99,10 @@ export class SysRouter extends BeanBase {
98
99
  ) {
99
100
  const query = options?.query;
100
101
  let params = options?.params;
101
- if (cast(params)?.locale === true) {
102
- const locale =
103
- this.app.meta.locale.current === this.sys.config.locale.default
104
- ? undefined
105
- : this.app.meta.locale.current;
102
+ const paramsLocale = cast(params)?.locale;
103
+ if (paramsLocale !== undefined) {
104
+ const localeCurrent = paramsLocale === true ? this.app.meta.locale.current : paramsLocale;
105
+ const locale = localeCurrent === this.sys.config.locale.default ? undefined : localeCurrent;
106
106
  params = Object.assign({}, params, { locale });
107
107
  }
108
108
  const pagePath = combineParamsAndQuery(path, { params, query });
@@ -144,6 +144,28 @@ export class SysRouter extends BeanBase {
144
144
  return this.sys.meta.module.exists(moduleName);
145
145
  }
146
146
 
147
+ public checkActiveOfFullPath(
148
+ fullPath: string,
149
+ currentRoute?: RouteLocationNormalizedLoadedGeneric,
150
+ ): boolean {
151
+ if (!currentRoute) {
152
+ currentRoute = getCurrentRoute(this.ctx)?.value;
153
+ }
154
+ if (!currentRoute) return false;
155
+ if (currentRoute.fullPath === fullPath) return true;
156
+ if (!currentRoute.matched || currentRoute.matched.length === 0) return false;
157
+ return currentRoute.matched.some(routeAlias => {
158
+ const fullPathAlias = this.getPagePath(
159
+ routeAlias.path as never,
160
+ {
161
+ params: currentRoute.params,
162
+ query: currentRoute.query,
163
+ } as never,
164
+ );
165
+ return fullPathAlias === fullPath;
166
+ });
167
+ }
168
+
147
169
  public async ensureRoute(pagePath: string) {
148
170
  // try to resolve, support alias route
149
171
  let route = this._vueRouterSys.resolve(pagePath);
@@ -57,7 +57,7 @@ export class MonkeySys
57
57
  if (options?.returnTo) {
58
58
  const returnTo =
59
59
  typeof options?.returnTo === 'string' ? options?.returnTo : app.$getCurrentPagePath();
60
- if (returnTo !== app.sys.env.ROUTER_PAGE_HOME) {
60
+ if (returnTo !== app.$getPagePathHome()) {
61
61
  query[app.sys.env.ROUTER_KEY_RETURNTO] = returnTo;
62
62
  }
63
63
  }
@@ -81,7 +81,8 @@ export class MonkeySys
81
81
  }
82
82
  };
83
83
  app.$gotoHome = (options?: IGotoPageOptions) => {
84
- return app.$gotoPage(app.sys.env.ROUTER_PAGE_HOME, options);
84
+ const pagePath = app.$getPagePathHome(options);
85
+ return app.$gotoPage(pagePath, { ...options, params: undefined });
85
86
  };
86
87
  app.$gotoLogin = (returnTo?: string, cause?: string) => {
87
88
  if (!returnTo && cast(app.meta.$router.currentRoute)?.path === app.sys.env.ROUTER_PAGE_LOGIN)
@@ -102,7 +103,7 @@ export class MonkeySys
102
103
  const pagePath =
103
104
  returnTo ||
104
105
  cast(app.meta.$router.currentRoute)?.query?.[app.sys.env.ROUTER_KEY_RETURNTO] ||
105
- app.sys.env.ROUTER_PAGE_HOME;
106
+ app.$getPagePathHome();
106
107
  return pagePath;
107
108
  };
108
109
  app.$getCurrentPagePath = (): string | undefined => {
@@ -114,5 +115,16 @@ export class MonkeySys
114
115
  }
115
116
  return cast(app.meta.$router.currentRoute)?.fullPath;
116
117
  };
118
+ app.$getPagePathHome = (options?: IGotoPageOptions): string => {
119
+ let params = options?.params;
120
+ if (params?.locale === undefined) {
121
+ params = Object.assign({}, params, { locale: true });
122
+ }
123
+ // not handle options?.query
124
+ return app.meta.$router.getPagePath(
125
+ app.sys.env.ROUTER_PAGE_HOME as never,
126
+ { params } as never,
127
+ );
128
+ };
117
129
  }
118
130
  }
@@ -55,6 +55,7 @@ declare module 'zova' {
55
55
  $gotoReturnTo(returnTo?: string): TypeGotoPageResult;
56
56
  $getReturnTo(returnTo?: string): string;
57
57
  $getCurrentPagePath(): string | undefined;
58
+ $getPagePathHome(options?: IGotoPageOptions): string;
58
59
  }
59
60
 
60
61
  export interface AppMeta {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-routertabs",
3
- "version": "5.1.24",
3
+ "version": "5.1.25",
4
4
  "gitHead": "09d901d17140a80ee0764211b441cda72fd94663",
5
5
  "description": "routertabs",
6
6
  "keywords": [
@@ -183,6 +183,10 @@ export class ModelTabs extends BeanModelBase {
183
183
  return true;
184
184
  }
185
185
 
186
+ resetAllTabInfos() {
187
+ this.tabs = this._getInitialTabs() as RouteTab[];
188
+ }
189
+
186
190
  updateAllTabInfos(tabInitials?: RouteTabInitial[]) {
187
191
  for (const tab of this.tabs) {
188
192
  const tabInitial = tabInitials?.find(item => item.tabKey === tab.tabKey);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-suite-a-zova",
3
- "version": "5.1.91",
3
+ "version": "5.1.92",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "zova",
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  "zova-module-a-meta": "^5.1.15",
24
24
  "zova-module-a-model": "^5.1.23",
25
25
  "zova-module-a-openapi": "^5.1.30",
26
- "zova-module-a-router": "^5.1.22",
26
+ "zova-module-a-router": "^5.1.23",
27
27
  "zova-module-a-routerstack": "^5.1.20",
28
- "zova-module-a-routertabs": "^5.1.24",
28
+ "zova-module-a-routertabs": "^5.1.25",
29
29
  "zova-module-a-ssr": "^5.1.18",
30
30
  "zova-module-a-ssrhmr": "^5.1.16",
31
31
  "zova-module-a-ssrserver": "^5.1.15",