@zat-design/sisyphus-react 4.5.6-beta.1 → 4.5.6-beta.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.
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable func-call-spacing */
2
2
  /* eslint-disable no-spaced-func */
3
- import { createContext, useMemo, useRef, useCallback, useState } from 'react';
3
+ import { createContext, useMemo, useRef, useCallback } from 'react';
4
4
  import classNames from 'classnames';
5
- import { useSetState, useToggle, useDeepCompareEffect } from 'ahooks';
5
+ import { useSetState, useToggle, useDeepCompareEffect, useScroll } from 'ahooks';
6
6
  import { ProWaterMark } from "../index";
7
7
  import { ProCollapse, ProFooter, ProHeader } from "./components";
8
8
  import { Header, Notice, Menu } from "./components/Layout/index";
@@ -53,10 +53,24 @@ const ProLayout = props => {
53
53
  const tabsManagerRef = useRef(null);
54
54
 
55
55
  // Tab 栏 Portal 挂载目标及动画状态
56
- const [tabsBarEl, setTabsBarEl] = useState(null);
57
- const [hasTabs, setHasTabs] = useState(false);
58
- // TabsManager 通过 onIframePureChange 报告的 pure 状态(iframe 嵌入 + 默认纯净渲染)
59
- const [isIframePure, setIsIframePure] = useState(false);
56
+ const [{
57
+ tabsBarEl,
58
+ hasTabs,
59
+ isIframePure
60
+ }, setTabsState] = useSetState({
61
+ tabsBarEl: null,
62
+ hasTabs: false,
63
+ isIframePure: false
64
+ });
65
+ // 稳定的 ref 回调,避免内联函数每次渲染都触发 setState 导致无限循环
66
+ const setTabsBarElRef = useCallback(el => setTabsState({
67
+ tabsBarEl: el
68
+ }), []);
69
+
70
+ // 仅 tabs 模式需要感知滚动位置(用于控制右上角圆弧伪元素的显隐)
71
+ // 非 tabs 模式传 null,useScroll 不挂载监听器
72
+ const scrollPos = useScroll(isTabsLayout ? document : null);
73
+ const isAtTop = (scrollPos?.top ?? 0) === 0;
60
74
  const [{
61
75
  notice,
62
76
  menus,
@@ -136,8 +150,12 @@ const ProLayout = props => {
136
150
  dataSource: menuDataSource,
137
151
  originalOnMenuClick: onMenuClick,
138
152
  tabsBarContainer: tabsBarEl,
139
- onTabsChange: setHasTabs,
140
- onIframePureChange: setIsIframePure,
153
+ onTabsChange: v => setTabsState({
154
+ hasTabs: v
155
+ }),
156
+ onIframePureChange: v => setTabsState({
157
+ isIframePure: v
158
+ }),
141
159
  children: children
142
160
  });
143
161
  };
@@ -263,8 +281,8 @@ const ProLayout = props => {
263
281
  }), /*#__PURE__*/_jsx(Notice, {
264
282
  ...noticeProps
265
283
  }), /*#__PURE__*/_jsx("div", {
266
- ref: setTabsBarEl,
267
- className: `pro-layout-tabs-bar-wrapper${hasTabs ? ' tabs-visible' : ''}${collapsed ? ' tabs-menu-open' : ''}`,
284
+ ref: setTabsBarElRef,
285
+ className: `pro-layout-tabs-bar-wrapper${hasTabs ? ' tabs-visible' : ''}${collapsed ? ' tabs-menu-open' : ''}${isAtTop ? ' tabs-at-top' : ''}`,
268
286
  style: {
269
287
  marginTop: effectiveHeaderHeight + noticeHeight
270
288
  }
@@ -431,6 +431,23 @@ export interface ProLayoutTabsInstance {
431
431
  * @description 获取标签页信息
432
432
  */
433
433
  getTabInfo: () => TabsInfoResult;
434
+ /**
435
+ * @description 在当前激活标签页内压入一个子视图(如详情页),入口页会被隐藏但不卸载
436
+ * @param node 要展示的子视图 React 节点
437
+ * @example
438
+ * ```tsx
439
+ * layoutTabs.pushView(<ProductDetail id={record.id} />);
440
+ * ```
441
+ */
442
+ pushView: (node: ReactNode) => void;
443
+ /**
444
+ * @description 返回上一层:销毁当前激活标签页的栈顶子视图,露出下一层(栈空时露出入口页)
445
+ */
446
+ back: () => void;
447
+ /**
448
+ * @description 获取当前激活标签页的子视图栈(栈底→栈顶顺序),入口页不在其中
449
+ */
450
+ getViewStack: () => ReactNode[];
434
451
  }
435
452
  /**
436
453
  * @description iframe 路由表配置项
@@ -325,6 +325,38 @@
325
325
  overflow: hidden;
326
326
  min-height: 0;
327
327
  }
328
+
329
+ // 右下角圆弧 + 横线截断:仅在页面顶部(tabs-at-top)时显示
330
+ // 滚动后 sticky 偏移导致背景错位,此时隐藏伪元素避免视觉异常
331
+ &.tabs-visible.tabs-at-top::after {
332
+ content: '';
333
+ position: absolute;
334
+ bottom: calc(-1 * var(--zaui-border-radius, 8px));
335
+ right: 0;
336
+ width: var(--zaui-border-radius, 8px);
337
+ height: var(--zaui-border-radius, 8px);
338
+ border-right: 1px solid rgb(235 236 238);
339
+ border-top-right-radius: var(--zaui-border-radius, 8px);
340
+ pointer-events: none;
341
+ }
342
+
343
+ // 遮住 ant-tabs-nav::before 横线的右端(圆角半径宽度),使其在圆弧起点处截止
344
+ &.tabs-visible.tabs-at-top::before {
345
+ content: '';
346
+ position: absolute;
347
+ bottom: 0;
348
+ right: 0;
349
+ width: var(--zaui-border-radius, 8px);
350
+ height: 2px;
351
+ background-color: #f7f9fd;
352
+ background-image: var(--header-bg-image);
353
+ background-repeat: no-repeat;
354
+ background-position: top center;
355
+ background-size: 100% auto;
356
+ background-attachment: fixed;
357
+ z-index: 1;
358
+ pointer-events: none;
359
+ }
328
360
  }
329
361
 
330
362
  /** 内容区 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "4.5.6-beta.1",
3
+ "version": "4.5.6-beta.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "es",