@zfqh/uniapp 0.2.10 → 0.2.11

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
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.2.11](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.10...@zfqh/uniapp@0.2.11) (2026-06-24)
7
+
8
+ **Note:** Version bump only for package @zfqh/uniapp
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.2.10](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.9...@zfqh/uniapp@0.2.10) (2026-06-24)
7
15
 
8
16
  **Note:** Version bump only for package @zfqh/uniapp
@@ -1,29 +1,19 @@
1
- // #ifndef APP-NVUE
1
+ // #ifndef APP
2
2
  import { useI18n as vueUseI18n } from 'vue-i18n';
3
3
  // #endif
4
+ // #ifdef APP
5
+ import { ref } from 'vue';
6
+ // #endif
4
7
  let _useI18n;
5
8
  // #ifdef APP
6
- // APP下不支持动态变量,需要重写
7
- function replacePlaceholders(str, values) {
8
- if (!values || typeof str !== 'string') {
9
- return str;
10
- }
11
- let out = str;
12
- for (const k of Object.keys(values)) {
13
- out = out.split(`{${k}}`).join(String(values[k]));
14
- }
15
- return out;
16
- }
17
- function t(key, values) {
18
- const { messages, locale } = uni.$i18n.global;
19
- const raw = messages[locale]?.[key] || key;
20
- return replacePlaceholders(raw, values);
21
- }
22
9
  _useI18n = function () {
23
- if (uni.$i18n.global.t !== t) {
24
- uni.$i18n.global.t = t;
25
- }
26
- return uni.$i18n.global;
10
+ const { t, locale: _locale, messages } = uni.$i18n.global;
11
+ const locale = ref(_locale);
12
+ return {
13
+ t,
14
+ locale,
15
+ messages,
16
+ };
27
17
  };
28
18
  // #endif
29
19
  // #ifndef APP
@@ -2,4 +2,4 @@ import { I18nOptions } from 'vue-i18n';
2
2
  export declare const defaultLocale: any;
3
3
  export declare const fallbackLocale = "zh-Hans";
4
4
  export declare function createI18n(opts: I18nOptions): import("vue-i18n").I18n<import("vue-i18n").LocaleMessages<import("vue-i18n").VueMessageType>, import("vue-i18n").IntlDateTimeFormats, import("vue-i18n").IntlNumberFormats, boolean>;
5
- export declare function getLocaleMessage(key: string): string;
5
+ export declare function getLocaleMessage(key: string, values?: Record<string, string>): string;
@@ -2,10 +2,31 @@ import { createI18n as _createI18n } from 'vue-i18n';
2
2
  import query from './query';
3
3
  export const defaultLocale = query.locale || uni.getLocale();
4
4
  export const fallbackLocale = 'zh-Hans';
5
+ // #ifdef APP
6
+ // APP下不支持动态变量,需要重写
7
+ function replacePlaceholders(str, values) {
8
+ if (!values || typeof str !== 'string') {
9
+ return str;
10
+ }
11
+ let out = str;
12
+ for (const k of Object.keys(values)) {
13
+ out = out.split(`{${k}}`).join(String(values[k]));
14
+ }
15
+ return out;
16
+ }
17
+ function t(key, values) {
18
+ const { messages, locale } = uni.$i18n.global;
19
+ const raw = messages[locale]?.[key] || key;
20
+ return replacePlaceholders(raw, values);
21
+ }
22
+ // #endif
5
23
  export function createI18n(opts) {
6
24
  const i18n = _createI18n(opts);
25
+ // #ifdef APP
26
+ i18n.global.t = t;
27
+ // #endif
7
28
  return (uni.$i18n = i18n);
8
29
  }
9
- export function getLocaleMessage(key) {
10
- return uni.$i18n?.global?.t(key) || key;
30
+ export function getLocaleMessage(key, values) {
31
+ return uni.$i18n?.global?.t(key, values) || key;
11
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zfqh/uniapp",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "uniapp公共模块",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -46,5 +46,5 @@
46
46
  "@types/qs": "^6.9.16",
47
47
  "@types/url-parse": "^1.4.11"
48
48
  },
49
- "gitHead": "a5025de96bb920ff3d8a94972b1842e21260fafe"
49
+ "gitHead": "4f9aae7510f83a5cd4b63d74f91993e12351e04f"
50
50
  }