@kengic/vue 0.5.0 → 0.5.1

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.
@@ -6054,7 +6054,13 @@ const useKgStore = (e) => (store$7 || (store$7 = defineStore("Kg", {
6054
6054
  this.option = t;
6055
6055
  },
6056
6056
  t(t, ...r) {
6057
- return this.tFunction ? this.tFunction(t, ...r) : (Logger.error("\u7FFB\u8BD1\u65B9\u6CD5\u4E3A\u7A7A.", { key: t }), t);
6057
+ var a, o;
6058
+ if (!this.tFunction)
6059
+ return Logger.error("\u7FFB\u8BD1\u65B9\u6CD5\u4E3A\u7A7A.", { key: t }), t;
6060
+ if (!t)
6061
+ return "";
6062
+ let n = t != null ? t : "";
6063
+ return (n.startsWith("t('") && n.endsWith("')") || n.startsWith('t("') && n.endsWith('")')) && (n = (o = (a = n.match(/^t\(['|"](.*)?['|"]\)$/)) == null ? void 0 : a[1]) != null ? o : n), this.tFunction(n, ...r);
6058
6064
  }
6059
6065
  }
6060
6066
  }).bind(null, e != null ? e : pinia())), store$7);
@@ -6259,6 +6265,14 @@ class KgRouteUtil {
6259
6265
  }
6260
6266
  return null;
6261
6267
  }
6268
+ static translateMenus(t, r = "title") {
6269
+ if (!t)
6270
+ return [];
6271
+ const n = useKg();
6272
+ return t.forEach((a) => {
6273
+ a[r] = n.t(a[r]), KgRouteUtil.translateMenus(a.children, r);
6274
+ }), t;
6275
+ }
6262
6276
  }
6263
6277
  const getProps$k = () => ({
6264
6278
  kgType: {
@@ -9580,7 +9594,7 @@ const getProps$6 = () => ({}), KgSearchConfigModalConfig = defineComponent({
9580
9594
  setup(e, {
9581
9595
  emit: t
9582
9596
  }) {
9583
- return () => createVNode("div", null, [createTextVNode("TODO")]);
9597
+ return () => createVNode("div", null, [createTextVNode("FIXME")]);
9584
9598
  }
9585
9599
  });
9586
9600
  let store$2 = null;
@@ -13,12 +13,12 @@ export declare type IKgStateOption = {
13
13
  };
14
14
  /** 翻译方法. */
15
15
  export declare type T = {
16
- (key: string): string;
17
- (key: string, locale: string): string;
18
- (key: string, locale: string, list: unknown[]): string;
19
- (key: string, locale: string, named: Record<string, unknown>): string;
20
- (key: string, list: unknown[]): string;
21
- (key: string, named: Record<string, unknown>): string;
16
+ (key: string | undefined | null): string;
17
+ (key: string | undefined | null, locale: string): string;
18
+ (key: string | undefined | null, locale: string, list: unknown[]): string;
19
+ (key: string | undefined | null, locale: string, named: Record<string, unknown>): string;
20
+ (key: string | undefined | null, list: unknown[]): string;
21
+ (key: string | undefined | null, named: Record<string, unknown>): string;
22
22
  };
23
23
  export interface IKgState {
24
24
  /** 语言. */
@@ -10,6 +10,7 @@ export interface Menu {
10
10
  icon?: string;
11
11
  hideMenu?: boolean;
12
12
  children?: Menu[];
13
+ [key: string]: any;
13
14
  }
14
15
  /** 语言. */
15
16
  export declare type IKgLocale = 'zh_CN' | 'en' | 'ru' | 'ja' | 'ko';
@@ -12,4 +12,10 @@ export declare class KgRouteUtil {
12
12
  * @param path 菜单地址.
13
13
  */
14
14
  static getMenuByPath(menus: Array<Menu>, path: string): Menu | null;
15
+ /**
16
+ * 翻译菜单标题.
17
+ * @param menus 菜单列表, 可以是一棵树.
18
+ * @param titleKey 标题的属性名, 即要将哪个属性作为菜单的标题.
19
+ */
20
+ static translateMenus(menus?: Array<Menu> | null, titleKey?: string): Array<Menu>;
15
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kengic/vue",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build:dev": "rimraf dist && vue-tsc && vite build --mode development",