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.
package/README.md CHANGED
@@ -63,7 +63,9 @@ const menu: SideItem[] = [
63
63
  ```
64
64
 
65
65
  magic block:**一条路由 = 一个块** —— **块外面不放任何东西**(标题 / 按钮 / 参数展示都写进块自己的
66
- `index.open.html`),块占满这条标签页:
66
+ `index.open.html`),块占满这条标签页。这条不只是"请注意"级的约定:块页会核对"这条路由渲染的
67
+ 是不是我",被人套一层包装页(`MyOrderPage.vue` 里 `<MagicBlockPage/>` 再加点东西)时它在
68
+ `vite dev` 里**直接抛**、打包产物里 `console.error` —— 违规的页面打不开:
67
69
 
68
70
  ```ts
69
71
  // main.ts:这一条路由就是这个块(没有页面文件)。
@@ -78,20 +80,26 @@ const tab = await magicBlock.context() // { path, params, que
78
80
  await magicBlock.setTabTitle('订单 SO-42', 'pi pi-file') // 给所属那条标签起名
79
81
  ```
80
82
 
81
- 后端地址走 `VITE_API_BASE`(默认 `http://localhost:3000`)。
83
+ 后端地址:**默认相对本站**(空串)。跨源部署时由**宿主**在自己的入口里给一次 ——
84
+ `app.use(labull, { apiBase: import.meta.env.VITE_API_BASE })`,或者 `setApiBase('https://api.你的域名')`。
85
+
86
+ 🔴 **别让库去读 `import.meta.env`**:这个包发布的是**预编译 dist**,而 `import.meta.env.*` 是 Vite 在
87
+ **构建时**做的静态替换 —— 库构建那一刻没设这个变量 ⇒ 它被换成字面量烧进产物,你的 `.env` 再也
88
+ 覆盖不了(0.1.29 及以前就是这样:产物里烧死 `http://localhost:3000`,登录之后所有接口打到
89
+ **访问者自己那台机器**)。那一句读法必须写在**你自己的源码**里,替换才会发生在**你的**构建里。
82
90
 
83
91
  ## subpath 对照表(原包 → 现在怎么 import)
84
92
 
85
93
  | 原来 | 现在 | 内容 |
86
94
  |---|---|---|
87
95
  | `@labull/theme` | `labull-framework/style.css`(或 `labull-framework/theme`) | `--sp-*` token + 完整主题层 + 结构类 + primeicons |
88
- | `@labull/auth` | `labull-framework/auth` | `useAuth()` / `apiFetch()` / `ensureAuthenticated()` / `createAuthGate()` / `API_BASE` |
96
+ | `@labull/auth` | `labull-framework/auth` | `useAuth()` / `apiFetch()` / `ensureAuthenticated()` / `createAuthGate()` / `setApiBase()`(后端地址,**运行期**给)/ `API_BASE`(当前值,活绑定) |
89
97
  | `@labull/ui` | `labull-framework/ui` | `ProductShell` / `ProductSide` / `ProductTabs` / `TabPage` / `AppSearch` / `UserMenu` / `labull` 插件,以及标签那一套:`openTab` / `activateTab` / `closeTab` / `useTabs` / `useTabContext` |
90
98
  | `@labull/magic-block` | `labull-framework/magic-block` | `MagicBlockPage`(一条路由 = 一个块,**唯一入口**) / `MagicBlockConsole` / 清单校验 / bridge |
91
99
 
92
100
  根入口 `labull-framework` = `auth` + `ui`(最常用的两层)。
93
101
 
94
- 🔴 **它故意不 re-export `magic-block`**:`magic-block` 与 `auth` 都导出 `API_BASE`,
102
+ 🔴 **它故意不 re-export `magic-block`**:`magic-block` 与 `auth` 都导出 `API_BASE`(以及 `setApiBase`),
95
103
  两路 `export *` 撞同一个名字是打包器层面的歧义。要块就从 `labull-framework/magic-block` 拿。
96
104
 
97
105
  ## 两份东西要知道
package/dist/auth.js CHANGED
@@ -1,17 +1,18 @@
1
- import { A as s, a as t, C as r, b as u, c as A, d as c, e as h, f as i, g as n, h as E, l as o, i as S, j as _, u as l } from "./chunk-index-BWpDbB19.js";
1
+ import { A as s, a as t, C as r, b as u, c as A, d as i, e as c, f as h, g as n, h as E, l as o, i as S, j as _, s as l, u as I } from "./chunk-index-BVIJeFeJ.js";
2
2
  export {
3
3
  s as API_BASE,
4
4
  t as AUTH_DEADLINE_MS,
5
5
  r as CLEAR_SESSION_DEADLINE_MS,
6
6
  u as apiFetch,
7
7
  A as authHeaders,
8
- c as createAuthGate,
9
- h as currentPath,
10
- i as currentUser,
8
+ i as createAuthGate,
9
+ c as currentPath,
10
+ h as currentUser,
11
11
  n as currentUserInTime,
12
12
  E as ensureAuthenticated,
13
13
  o as loginUrl,
14
14
  S as loginWithRedirect,
15
15
  _ as logout,
16
- l as useAuth
16
+ l as setApiBase,
17
+ I as useAuth
17
18
  };
@@ -1,4 +1,4 @@
1
- import { reactive as h, computed as p, ref as y, provide as T, inject as g } from "vue";
1
+ import { reactive as h, computed as p, ref as y, inject as T, provide as g } from "vue";
2
2
  import { useRouter as w } from "vue-router";
3
3
  const c = h({ tabs: [], active: "" });
4
4
  let r = null;
@@ -103,10 +103,10 @@ function M(t) {
103
103
  C(t.key, a, l);
104
104
  }
105
105
  };
106
- return T(m, i), i;
106
+ return g(m, i), i;
107
107
  }
108
108
  function P() {
109
- const t = g(m, null);
109
+ const t = T(m, null);
110
110
  if (!t) throw new Error("[labull] 这里不在标签页里:页面与 magic block 必须放在外壳的标签内容区(标签页)里。");
111
111
  return t;
112
112
  }