labull-framework 0.1.28 → 0.1.30

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.
@@ -1,5 +1,9 @@
1
- import { ref as c, computed as T } from "vue";
2
- const l = "http://localhost:3000", h = 8e3, C = 1500, y = "labull.csrf", P = "x-labull-csrf", $ = ["GET", "HEAD", "OPTIONS"], u = c(null);
1
+ import { ref as l, computed as T } from "vue";
2
+ let i = "";
3
+ function U(t) {
4
+ i = String(t ?? "").trim().replace(/\/+$/, "");
5
+ }
6
+ const h = 8e3, $ = 1500, y = "labull.csrf", C = "x-labull-csrf", P = ["GET", "HEAD", "OPTIONS"], u = l(null);
3
7
  function v(t) {
4
8
  for (const e of (typeof document > "u" ? "" : document.cookie).split(";")) {
5
9
  const [n, ...s] = e.trim().split("=");
@@ -9,17 +13,17 @@ function v(t) {
9
13
  }
10
14
  function m(t = "GET", e = !1) {
11
15
  const n = e ? { "Content-Type": "application/json" } : {}, s = v(y);
12
- return s && !$.includes(t.toUpperCase()) && (n[P] = s), n;
16
+ return s && !P.includes(t.toUpperCase()) && (n[C] = s), n;
13
17
  }
14
18
  async function E(t, e = {}) {
15
- const n = String(e.method ?? "GET").toUpperCase(), s = await fetch(`${l}${t}`, {
19
+ const n = String(e.method ?? "GET").toUpperCase(), s = await fetch(`${i}${t}`, {
16
20
  ...e,
17
21
  method: n,
18
22
  credentials: "include",
19
23
  headers: { ...m(n, e.body !== void 0), ...e.headers ?? {} }
20
24
  });
21
25
  if (!s.ok) {
22
- const o = await s.json().catch(() => null), a = typeof o?.message == "string" ? o.message : "";
26
+ const r = await s.json().catch(() => null), a = typeof r?.message == "string" ? r.message : "";
23
27
  throw Object.assign(new Error(a || `请求失败:${s.status} ${t}`), { status: s.status });
24
28
  }
25
29
  return s.status === 204 ? void 0 : await s.json();
@@ -31,13 +35,13 @@ function f() {
31
35
  }
32
36
  function O(t = f()) {
33
37
  const e = t.startsWith("/") && !t.startsWith("//") ? t : "/";
34
- return `${l}/auth/login?redirect=${encodeURIComponent(e)}`;
38
+ return `${i}/auth/login?redirect=${encodeURIComponent(e)}`;
35
39
  }
36
40
  function w(t = f()) {
37
41
  window.location.assign(O(t));
38
42
  }
39
43
  function _() {
40
- u.value = null, window.location.assign(`${l}/auth/logout`);
44
+ u.value = null, window.location.assign(`${i}/auth/logout`);
41
45
  }
42
46
  async function b() {
43
47
  try {
@@ -46,9 +50,9 @@ async function b() {
46
50
  } catch (t) {
47
51
  const e = t?.status;
48
52
  return (e === 401 || e === 403) && await Promise.race([
49
- fetch(`${l}/auth/logout`, { method: "POST", credentials: "include", headers: m("POST", !0) }).catch(() => {
53
+ fetch(`${i}/auth/logout`, { method: "POST", credentials: "include", headers: m("POST", !0) }).catch(() => {
50
54
  }),
51
- new Promise((n) => setTimeout(n, C))
55
+ new Promise((n) => setTimeout(n, $))
52
56
  ]), u.value = null, null;
53
57
  }
54
58
  }
@@ -63,37 +67,37 @@ async function p(t = h) {
63
67
  e !== void 0 && clearTimeout(e);
64
68
  }
65
69
  }
66
- async function U(t = f(), e = h) {
70
+ async function D(t = f(), e = h) {
67
71
  const n = await p(e);
68
72
  return n !== "timeout" && n ? n : (n !== "timeout" && w(t), null);
69
73
  }
70
- function D(t = {}) {
71
- const e = t.deadlineMs ?? h, n = c(!1), s = c(!1), o = c(!1);
74
+ function R(t = {}) {
75
+ const e = t.deadlineMs ?? h, n = l(!1), s = l(!1), r = l(!1);
72
76
  let a = null, d = !1;
73
- async function S(r) {
74
- const i = await p(e);
75
- if (i !== "timeout" && i) {
76
- d = !0, s.value = !1, o.value = !1, n.value = !0;
77
+ async function S(o) {
78
+ const c = await p(e);
79
+ if (c !== "timeout" && c) {
80
+ d = !0, s.value = !1, r.value = !1, n.value = !0;
77
81
  return;
78
82
  }
79
- if (n.value = !1, s.value = !0, o.value = i === "timeout", i !== "timeout")
83
+ if (n.value = !1, s.value = !0, r.value = c === "timeout", c !== "timeout")
80
84
  try {
81
- w(r);
85
+ w(o);
82
86
  } catch {
83
87
  console.warn("[labull] 整页跳登录没成功;界面上的手动登录链接还在。");
84
88
  }
85
89
  }
86
- function g(r) {
87
- return d ? Promise.resolve() : a || (a = S(r).finally(() => {
90
+ function g(o) {
91
+ return d ? Promise.resolve() : a || (a = S(o).finally(() => {
88
92
  a = null;
89
93
  }), a);
90
94
  }
91
- function A(r) {
92
- d = !1, n.value = !1, g(r);
95
+ function A(o) {
96
+ d = !1, n.value = !1, g(o);
93
97
  }
94
- return { open: n, denied: s, unreachable: o, pass: g, recheck: A };
98
+ return { open: n, denied: s, unreachable: r, pass: g, recheck: A };
95
99
  }
96
- function R() {
100
+ function j() {
97
101
  async function t() {
98
102
  const e = await p();
99
103
  return e === "timeout" ? null : e;
@@ -112,18 +116,19 @@ function R() {
112
116
  };
113
117
  }
114
118
  export {
115
- l as A,
116
- C,
119
+ i as A,
120
+ $ as C,
117
121
  h as a,
118
122
  E as b,
119
123
  m as c,
120
- D as d,
124
+ R as d,
121
125
  f as e,
122
126
  b as f,
123
127
  p as g,
124
- U as h,
128
+ D as h,
125
129
  w as i,
126
130
  _ as j,
127
131
  O as l,
128
- R as u
132
+ U as s,
133
+ j as u
129
134
  };
package/dist/index.js CHANGED
@@ -1,38 +1,39 @@
1
- import { A as e, a as t, C as r, b as o, c as l, d as i, e as u, f as c, g as n, h as T, l as b, i as A, j as p, u as d } from "./chunk-index-BWpDbB19.js";
2
- import { A as S, P as E, a as _, b as P, _ as U, U as f, i as g, l as I } from "./chunk-index-BN-lnG-w.js";
3
- import { T as C, a as N, c as m, f as D, i as L, b as v, o as M, p as B, s as H, u as O, d as R } from "./chunk-ProductShell.vue_vue_type_style_index_0_scoped_06035587_lang-BpRKKThg.js";
1
+ import { A as e, a as t, C as r, b as o, c as i, d as l, e as u, f as c, g as n, h as T, l as A, i as b, j as p, s as d, u as h } from "./chunk-index-BVIJeFeJ.js";
2
+ import { A as E, P as _, a as P, b as U, _ as f, U as g, i as I, l as x } from "./chunk-index-3dQJWK2S.js";
3
+ import { T as N, a as m, c as D, f as L, i as v, b as B, o as M, p as H, s as O, u as R, d as j } from "./chunk-ProductShell.vue_vue_type_style_index_0_scoped_06035587_lang-Fky1ghd2.js";
4
4
  export {
5
5
  e as API_BASE,
6
6
  t as AUTH_DEADLINE_MS,
7
- S as AppSearch,
7
+ E as AppSearch,
8
8
  r as CLEAR_SESSION_DEADLINE_MS,
9
- E as ProductShell,
10
- _ as ProductSide,
11
- P as ProductTabs,
12
- C as TAB_CONTEXT,
13
- U as TabPage,
14
- f as UserMenu,
15
- N as activateTab,
9
+ _ as ProductShell,
10
+ P as ProductSide,
11
+ U as ProductTabs,
12
+ N as TAB_CONTEXT,
13
+ f as TabPage,
14
+ g as UserMenu,
15
+ m as activateTab,
16
16
  o as apiFetch,
17
- l as authHeaders,
18
- m as closeTab,
19
- i as createAuthGate,
17
+ i as authHeaders,
18
+ D as closeTab,
19
+ l as createAuthGate,
20
20
  u as currentPath,
21
21
  c as currentUser,
22
22
  n as currentUserInTime,
23
23
  T as ensureAuthenticated,
24
- D as followUrl,
25
- g as installApp,
26
- L as installTabNavigator,
27
- v as isInstanceLocation,
28
- I as labull,
29
- b as loginUrl,
30
- A as loginWithRedirect,
24
+ L as followUrl,
25
+ I as installApp,
26
+ v as installTabNavigator,
27
+ B as isInstanceLocation,
28
+ x as labull,
29
+ A as loginUrl,
30
+ b as loginWithRedirect,
31
31
  p as logout,
32
32
  M as openTab,
33
- B as provideTabContext,
34
- H as setTabTitle,
35
- d as useAuth,
36
- O as useTabContext,
37
- R as useTabs
33
+ H as provideTabContext,
34
+ d as setApiBase,
35
+ O as setTabTitle,
36
+ h as useAuth,
37
+ R as useTabContext,
38
+ j as useTabs
38
39
  };