@oj-module/cli 0.1.20 → 0.1.21
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/devkit/manual.md +14 -6
- package/package.json +2 -2
- package/shell-dist/assets/runtime.js +25 -3
- package/shell-dist/index.html +2 -2
- package/shell-dist/versions.json +3 -3
- package/src/build.ts +2 -0
- package/vendor/host-versions.json +3 -3
package/devkit/manual.md
CHANGED
|
@@ -1071,22 +1071,30 @@ t("menu.books") // ❌ 会去 common namespace 找
|
|
|
1071
1071
|
**运行期数据**,在页面里把数据拿到后覆盖:
|
|
1072
1072
|
|
|
1073
1073
|
```tsx
|
|
1074
|
-
import { useTabsStore } from "@oj-module/runtime";
|
|
1074
|
+
import { useTabKey, useTabsStore } from "@oj-module/runtime";
|
|
1075
1075
|
|
|
1076
1076
|
const setTableTitle = useTabsStore(s => s.setTableTitle);
|
|
1077
|
-
const
|
|
1077
|
+
const tabKey = useTabKey(); // 本页自己的页签 key(见下方陷阱说明,**不要**用 useLocation 现取值)
|
|
1078
1078
|
|
|
1079
1079
|
useEffect(() => {
|
|
1080
|
-
if (doc?.name) setTableTitle(
|
|
1081
|
-
}, [doc?.name,
|
|
1080
|
+
if (doc?.name) setTableTitle(tabKey, doc.name);
|
|
1081
|
+
}, [doc?.name, tabKey, setTableTitle]);
|
|
1082
1082
|
```
|
|
1083
1083
|
|
|
1084
|
+
> 陷阱(keepAlive):开启多页签后,keepalive-for-react 把页面缓存在隐藏容器里,而
|
|
1085
|
+
> LocationContext 在 KeepAlive **之上**——切页签时缓存树随**激活页**位置重渲染,缓存页里的
|
|
1086
|
+
> `useLocation()` 返回的是别家页签的路径。用它当 key 会把本页标题写到当前激活页签上
|
|
1087
|
+
> (典型症状:最后打开的文档页把之后切换到的每个页签都改成自己的标题)。`useTabKey()`
|
|
1088
|
+
> 首渲染捕获本页真实 key,存活期内稳定,是 `setTableTitle` / `resetTableTitle` / `addTab`
|
|
1089
|
+
> 定位页签的**唯一**正确取口。runtime < 0.1.21 无此 hook 时,本地等价实现:首渲染
|
|
1090
|
+
> `useRef(removeTrailingSlash(useLocation().pathname))` 捕获一次。
|
|
1091
|
+
|
|
1084
1092
|
三点约束:
|
|
1085
1093
|
|
|
1086
|
-
1.
|
|
1094
|
+
1. 页签 key 一律经 `useTabKey()` 取(= `removeTrailingSlash(location.pathname)` 归一后的值);
|
|
1087
1095
|
2. `setTableTitle` 只改**已打开**的页签,故要在页面渲染后(数据就绪时)调用,不能提前于路由挂载;
|
|
1088
1096
|
3. 只在页签 key 与内容**一一对应**时这样用(如 `/doc/:id`——一个 id 一个页签)。若同一路径会被
|
|
1089
|
-
复用展示不同内容(列表页/`index` 路由),离开时必须 `resetTableTitle(
|
|
1097
|
+
复用展示不同内容(列表页/`index` 路由),离开时必须 `resetTableTitle(tabKey)`,否则再进来看到
|
|
1090
1098
|
上一个内容的标题。
|
|
1091
1099
|
|
|
1092
1100
|
推荐形态(照 `web/src/home/pages/`、`web/src/personal-center/pages/my-profile/` 抄):
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oj-module/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.21",
|
|
5
5
|
"description": "React Antd Admin 模块工程命令行工具(含预构建宿主 shell-dist)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@faker-js/faker": "^10.4.0",
|
|
52
|
-
"@oj-module/runtime": "0.1.
|
|
52
|
+
"@oj-module/runtime": "0.1.21",
|
|
53
53
|
"@redocly/cli": "^2.51.0",
|
|
54
54
|
"@tailwindcss/vite": "^4.3.0",
|
|
55
55
|
"esbuild": "^0.28.2",
|
|
@@ -255,10 +255,10 @@ function getAppInfo() {
|
|
|
255
255
|
return {
|
|
256
256
|
"pkg": {
|
|
257
257
|
"name": "@oj-module/runtime",
|
|
258
|
-
"version": "0.1.
|
|
258
|
+
"version": "0.1.21",
|
|
259
259
|
"license": "MIT"
|
|
260
260
|
},
|
|
261
|
-
"lastBuildTime": "2026-10-15
|
|
261
|
+
"lastBuildTime": "2026-10-15 18:45:29"
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
var init_get_app_info = __esmMin((() => {}));
|
|
@@ -9372,6 +9372,28 @@ function getBooleanOptions(t) {
|
|
|
9372
9372
|
}];
|
|
9373
9373
|
}
|
|
9374
9374
|
//#endregion
|
|
9375
|
+
//#region src/hooks/use-tab-key/index.ts
|
|
9376
|
+
init_remove_trailing_slash();
|
|
9377
|
+
/**
|
|
9378
|
+
* 本页自己的页签 key(`removeTrailingSlash(pathname)`),供 `setTableTitle` /
|
|
9379
|
+
* `resetTableTitle` / `addTab` 定位页签。
|
|
9380
|
+
*
|
|
9381
|
+
* keepAlive 陷阱:keepalive-for-react 把页面缓存在隐藏 portal 里,而 LocationContext
|
|
9382
|
+
* 在 KeepAlive **之上**——切 tab 时缓存树随**激活页**位置重渲染,缓存页里的
|
|
9383
|
+
* `useLocation()` 返回的是别家页签的路径。若拿它当页签 key,`setTableTitle` 会把
|
|
9384
|
+
* 本页标题写到当前激活页签上(最后打开的文档页把之后切换到的每个页签都改成自己的标题)。
|
|
9385
|
+
*
|
|
9386
|
+
* 页签存活期内 key 不变(宿主 cacheKey = pathname+search,一页一路径),故首渲染
|
|
9387
|
+
* (此时本页必是激活页)捕获一次即可;缓存树后续多少次重渲染都不会漂移。
|
|
9388
|
+
* 需要跟随导航的位置信息请直接用 `useLocation`,不要用本 hook。
|
|
9389
|
+
*/
|
|
9390
|
+
function useTabKey() {
|
|
9391
|
+
const { pathname } = useLocation();
|
|
9392
|
+
const keyRef = useRef(void 0);
|
|
9393
|
+
if (keyRef.current === void 0) keyRef.current = removeTrailingSlash(pathname);
|
|
9394
|
+
return keyRef.current;
|
|
9395
|
+
}
|
|
9396
|
+
//#endregion
|
|
9375
9397
|
//#region src/module-loader/define-module.ts
|
|
9376
9398
|
/**
|
|
9377
9399
|
* 声明一个模块。
|
|
@@ -27441,4 +27463,4 @@ init_ri();
|
|
|
27441
27463
|
init_menu_icons();
|
|
27442
27464
|
init_tree();
|
|
27443
27465
|
//#endregion
|
|
27444
|
-
export { AccessControl, AccessControlRoles, AntdApp, BasicButton, BasicContent, BasicTable, EmbeddedIcon, ErrorBoundary, ExternalIcon, FormAvatarItem, FormTreeItem, Iframe, LayoutCenterIcon, LayoutEffects, LayoutLeftIcon, LayoutRightIcon, MixedNavigationIcon, OutsidePageIcon, PageError, ProfileCardIcon, RiAccountCircleLine, RiContrastFill, RiFullscreenExitLine, RiFullscreenLine, RiMailCheckLine, RiMoonIcon, RiReactjsLine, RiSunIcon, RiUserSettingsLine, ServerErrorIcon, SideNavigationIcon, TopNavigationIcon, TwoColumnNavigationIcon, accessControlCodes, defineModule, fetchAddMenuItem, fetchAddRoleItem, fetchAsyncRoutes, fetchDeleteMenuItem, fetchDeleteRoleItem, fetchLogin, fetchLogout, fetchMenuByRoleId, fetchMenuList, fetchRefreshToken, fetchRoleList, fetchRoleMenu, fetchUpdateMenuItem, fetchUpdateRoleItem, fetchUserInfo, filterTree, getAllExpandedKeys, getAppInfo, getBooleanOptions, getModule, getModules, getRedirectPath, getRegisteredApiPrefix, getRegisteredStore, getRoutes, getYesNoOptions, handleTree, loadAll, mapTree, menuIcons, notify, permissionPrefix, setupI18n, traverseTreeValues, unloadModule, useAccess, useAuthStore, usePreferences, useSlotNodes, useTabsStore, useUserStore, external_exports as z };
|
|
27466
|
+
export { AccessControl, AccessControlRoles, AntdApp, BasicButton, BasicContent, BasicTable, EmbeddedIcon, ErrorBoundary, ExternalIcon, FormAvatarItem, FormTreeItem, Iframe, LayoutCenterIcon, LayoutEffects, LayoutLeftIcon, LayoutRightIcon, MixedNavigationIcon, OutsidePageIcon, PageError, ProfileCardIcon, RiAccountCircleLine, RiContrastFill, RiFullscreenExitLine, RiFullscreenLine, RiMailCheckLine, RiMoonIcon, RiReactjsLine, RiSunIcon, RiUserSettingsLine, ServerErrorIcon, SideNavigationIcon, TopNavigationIcon, TwoColumnNavigationIcon, accessControlCodes, defineModule, fetchAddMenuItem, fetchAddRoleItem, fetchAsyncRoutes, fetchDeleteMenuItem, fetchDeleteRoleItem, fetchLogin, fetchLogout, fetchMenuByRoleId, fetchMenuList, fetchRefreshToken, fetchRoleList, fetchRoleMenu, fetchUpdateMenuItem, fetchUpdateRoleItem, fetchUserInfo, filterTree, getAllExpandedKeys, getAppInfo, getBooleanOptions, getModule, getModules, getRedirectPath, getRegisteredApiPrefix, getRegisteredStore, getRoutes, getYesNoOptions, handleTree, loadAll, mapTree, menuIcons, notify, permissionPrefix, setupI18n, traverseTreeValues, unloadModule, useAccess, useAuthStore, usePreferences, useSlotNodes, useTabKey, useTabsStore, useUserStore, external_exports as z };
|
package/shell-dist/index.html
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" href="/favicon.ico" />
|
|
7
7
|
<title>React Antd Admin · Shell</title>
|
|
8
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self' https://modules.cdn.example.com 'wasm-unsafe-eval' 'nonce-
|
|
8
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self' https://modules.cdn.example.com 'wasm-unsafe-eval' 'nonce-tZIZWgEHDhCICXVOR+DUzQ=='; script-src-attr 'none'; connect-src 'self' data: https://modules.cdn.example.com; style-src 'self' https://modules.cdn.example.com 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; frame-src https://ant.design https://react.dev https://condorheroblog.github.io; form-action 'none'; base-uri 'none'; object-src 'none'; upgrade-insecure-requests" />
|
|
9
9
|
|
|
10
|
-
<script type="importmap" nonce="
|
|
10
|
+
<script type="importmap" nonce="tZIZWgEHDhCICXVOR+DUzQ==">{
|
|
11
11
|
"imports": {
|
|
12
12
|
"react": "/assets/react.js",
|
|
13
13
|
"react/jsx-runtime": "/assets/jsx-runtime.js",
|
package/shell-dist/versions.json
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
"react-router": "7.18.2",
|
|
8
8
|
"react-router/dom": "7.18.2",
|
|
9
9
|
"@tanstack/react-query": "5.102.8",
|
|
10
|
-
"@oj-module/runtime": "0.1.
|
|
11
|
-
"@oj-module/runtime/contract": "0.1.
|
|
12
|
-
"@oj-module/runtime/contract/errors": "0.1.
|
|
10
|
+
"@oj-module/runtime": "0.1.21",
|
|
11
|
+
"@oj-module/runtime/contract": "0.1.21",
|
|
12
|
+
"@oj-module/runtime/contract/errors": "0.1.21",
|
|
13
13
|
"@plane/kit": "0.1.20",
|
|
14
14
|
"@plane/editor": "0.1.20",
|
|
15
15
|
"antd": "6.6.1",
|
package/src/build.ts
CHANGED
|
@@ -74,6 +74,8 @@ export const permissionPrefix = "permission:button";
|
|
|
74
74
|
export const useAuthStore = _fn;
|
|
75
75
|
export const useUserStore = _fn;
|
|
76
76
|
export const useTabsStore = _fn;
|
|
77
|
+
// 页签 key 唯一正确取口(keepAlive 下 useLocation 是激活页位置,0.1.21)
|
|
78
|
+
export const useTabKey = _fn;
|
|
77
79
|
// 图标
|
|
78
80
|
export const menuIcons = _obj;
|
|
79
81
|
export const EmbeddedIcon = _fn;
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"react-router": "7.18.2",
|
|
9
9
|
"react-router/dom": "7.18.2",
|
|
10
10
|
"@tanstack/react-query": "5.102.8",
|
|
11
|
-
"@oj-module/runtime": "0.1.
|
|
12
|
-
"@oj-module/runtime/contract": "0.1.
|
|
13
|
-
"@oj-module/runtime/contract/errors": "0.1.
|
|
11
|
+
"@oj-module/runtime": "0.1.21",
|
|
12
|
+
"@oj-module/runtime/contract": "0.1.21",
|
|
13
|
+
"@oj-module/runtime/contract/errors": "0.1.21",
|
|
14
14
|
"@plane/kit": "0.1.20",
|
|
15
15
|
"@plane/editor": "0.1.20",
|
|
16
16
|
"antd": "6.6.1",
|