zova-core 5.1.85 → 5.1.87

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": "zova-core",
3
- "version": "5.1.85",
4
- "gitHead": "75a09e6a22891e958802ee649ed454db38f90c16",
3
+ "version": "5.1.87",
4
+ "gitHead": "ad6f4a6afb4c6f0ba968b84152fcf888b0450e3e",
5
5
  "description": "A vue3 framework with ioc",
6
6
  "keywords": [
7
7
  "ioc",
@@ -1,4 +1,5 @@
1
1
  export const LocaleModuleNameSeparator = '::';
2
+ export const LocalePattern = '[a-z]{2}-[a-z]{2}|[a-z]{2}';
2
3
 
3
4
  export interface IModuleLocale {
4
5
  (...args: any[]): string;
@@ -26,14 +26,17 @@ export class AppLocale extends BeanSimple {
26
26
 
27
27
  get current(): keyof ILocaleRecord {
28
28
  let locale = this[SymbolLocaleCurrent].value;
29
- if (!locale && this._cookieEnabled()) {
29
+ // always parse locale from cookie
30
+ // if (!locale && this._cookieEnabled()) {
31
+ if (!locale) {
30
32
  locale = this.metaCookie.getItem(this.sys.config.locale.storeKey);
31
33
  }
32
34
  if (!locale) locale = this.sys.config.locale.default;
33
35
  return locale as keyof ILocaleRecord;
34
36
  }
35
37
 
36
- set current(value: keyof ILocaleRecord) {
38
+ set current(value: keyof ILocaleRecord | '' | undefined) {
39
+ if (!value) value = this.sys.config.locale.default;
37
40
  if (this[SymbolLocaleCurrent].value === value) return;
38
41
  this[SymbolLocaleCurrent].value = value;
39
42
  if (this._cookieEnabled()) {
@@ -47,7 +50,11 @@ export class AppLocale extends BeanSimple {
47
50
 
48
51
  get tz(): string {
49
52
  let tz = this[SymbolTzCurrent].value;
50
- if (!tz && this._cookieEnabled()) tz = this.metaCookie.getItem(this.sys.config.tz.storeKey);
53
+ // always parse tz from cookie
54
+ // if (!tz && this._cookieEnabled()) {
55
+ if (!tz) {
56
+ tz = this.metaCookie.getItem(this.sys.config.tz.storeKey);
57
+ }
51
58
  if (!tz) tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
52
59
  return tz;
53
60
  }
@@ -263,3 +263,9 @@ export function throwErrorComponentUnmounted() {
263
263
  error.code = 600;
264
264
  throw error;
265
265
  }
266
+
267
+ export function ssr_load_local(key, defaultValue?) {
268
+ const __ssr_local = localStorage.getItem(key);
269
+ const value = __ssr_local ? JSON.parse(__ssr_local) : undefined;
270
+ return value ?? defaultValue;
271
+ }