x-error-lib 0.2.0 → 0.2.2

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.
@@ -2,23 +2,8 @@ const e = {
2
2
  "network error": "{code} {message}",
3
3
  "request timeout": "request timeout",
4
4
  "user not found": "user not found"
5
- }, a = {
6
- verb: {
7
- apply: "apply",
8
- arrange: "arrange",
9
- call: "call",
10
- create: "create",
11
- debug: "debug",
12
- delete: "delete",
13
- deploy: "deploy",
14
- filter: "filter",
15
- get: "get",
16
- list: "list",
17
- move: "move",
18
- open: "open",
19
- remove: "remove",
20
- update: "update"
21
- },
5
+ }, r = {}, a = {
6
+ formatName: "{verb} {resource}",
22
7
  resource: {
23
8
  app: "app",
24
9
  app_group: "app group",
@@ -47,11 +32,28 @@ const e = {
47
32
  org_role: "org role",
48
33
  org_structure: "org sturcture",
49
34
  task: "task"
35
+ },
36
+ verb: {
37
+ apply: "apply",
38
+ arrange: "arrange",
39
+ call: "call",
40
+ create: "create",
41
+ debug: "debug",
42
+ delete: "delete",
43
+ deploy: "deploy",
44
+ filter: "filter",
45
+ get: "get",
46
+ list: "list",
47
+ move: "move",
48
+ open: "open",
49
+ remove: "remove",
50
+ update: "update"
50
51
  }
51
- }, r = {
52
+ }, o = {
52
53
  error: e,
54
+ object: r,
53
55
  permission: a
54
56
  };
55
57
  export {
56
- r as default
58
+ o as default
57
59
  };
package/dist/i18n.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { I18n } from 'vue-i18n';
2
- export declare function loadLocaleMessage(i18n: I18n, locale: string): Promise<void>;
1
+ export declare function loadLocaleMessage(i18n: any, locale: string): Promise<void>;
2
+ export declare function getErrorMessage(i18n: any, error: any): string;
package/dist/index.js CHANGED
@@ -1,14 +1,34 @@
1
- import { nextTick as s } from "vue";
2
- const r = (t, o) => {
3
- const e = t[o];
4
- return e ? typeof e == "function" ? e() : Promise.resolve(e) : new Promise((a, n) => {
5
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(n.bind(null, new Error("Unknown variable dynamic import: " + o)));
1
+ import { nextTick as i } from "vue";
2
+ const l = (r, t) => {
3
+ const e = r[t];
4
+ return e ? typeof e == "function" ? e() : Promise.resolve(e) : new Promise((n, s) => {
5
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(s.bind(null, new Error("Unknown variable dynamic import: " + t)));
6
6
  });
7
7
  };
8
- async function c(t, o) {
9
- const e = await r(/* @__PURE__ */ Object.assign({ "./locales/en.ts": () => import("./en-C1qGDy9z.js"), "./locales/zhHans.ts": () => import("./zhHans-DL-jY7Ji.js") }), `./locales/${o}.ts`);
10
- return t.global.setLocaleMessage(o, e.default), s();
8
+ async function f(r, t) {
9
+ const e = await l(/* @__PURE__ */ Object.assign({ "./locales/en.ts": () => import("./en-CZ-X6wzC.js"), "./locales/zhHans.ts": () => import("./zhHans-Cn6omP_e.js") }), `./locales/${t}.ts`);
10
+ return r.global.setLocaleMessage(t, e.default), i();
11
+ }
12
+ function m(r, t) {
13
+ if (typeof t != "string")
14
+ return r.global.t("error.network error", t);
15
+ const e = c(t);
16
+ let n = r.global.t(e.main), s = "";
17
+ for (let o in e.extras) {
18
+ let a = r.global.t("object." + o);
19
+ a += "=", a += e.extras[o], s !== "" && (s += ", "), s += a;
20
+ }
21
+ return s !== "" && (n += "; ", n += s), n;
22
+ }
23
+ function c(r) {
24
+ const t = { main: "", extras: {} };
25
+ let e = r.split(";");
26
+ return console.assert(e.length > 0), t.main = e[0], e = ((e == null ? void 0 : e[1]) ?? "").split(","), e.forEach((s) => {
27
+ const o = s.split("=");
28
+ o.length >= 2 && (t.extras[o[0]] = o[1]);
29
+ }), t;
11
30
  }
12
31
  export {
13
- c as loadLocaleMessage
32
+ m as getErrorMessage,
33
+ f as loadLocaleMessage
14
34
  };
@@ -2,23 +2,8 @@ const e = {
2
2
  "network error": "{code} {message}",
3
3
  "request timeout": "请求超时",
4
4
  "user not found": "用户未找到"
5
- }, r = {
6
- verb: {
7
- apply: "应用",
8
- arrange: "整理",
9
- call: "调用",
10
- create: "创建",
11
- debug: "调试",
12
- delete: "删除",
13
- deploy: "部署",
14
- filter: "过滤",
15
- get: "获取",
16
- list: "列举",
17
- move: "移动",
18
- open: "打开",
19
- remove: "移除",
20
- update: "更新"
21
- },
5
+ }, r = {}, a = {
6
+ formatName: "{verb}{resource}",
22
7
  resource: {
23
8
  app: "应用",
24
9
  app_group: "应用分组",
@@ -47,11 +32,28 @@ const e = {
47
32
  org_role: "组织角色",
48
33
  org_structure: "组织结构",
49
34
  task: "任务"
35
+ },
36
+ verb: {
37
+ apply: "应用",
38
+ arrange: "整理",
39
+ call: "调用",
40
+ create: "创建",
41
+ debug: "调试",
42
+ delete: "删除",
43
+ deploy: "部署",
44
+ filter: "过滤",
45
+ get: "获取",
46
+ list: "列举",
47
+ move: "移动",
48
+ open: "打开",
49
+ remove: "移除",
50
+ update: "更新"
50
51
  }
51
- }, a = {
52
+ }, o = {
52
53
  error: e,
53
- permission: r
54
+ object: r,
55
+ permission: a
54
56
  };
55
57
  export {
56
- a as default
58
+ o as default
57
59
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-error-lib",
3
3
  "private": false,
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",