feat: + 面板改为右侧弹出悬浮窗(遮罩点击关闭,320px 适配内容)

This commit is contained in:
Aisland
2026-08-17 01:23:29 +08:00
parent 573eea3be9
commit 81e63f376a
4 changed files with 27 additions and 4 deletions
+11 -1
View File
@@ -242,6 +242,7 @@ function WorktableSection(props: any) {
const [bottomInset, setBottomInset] = useState(0)
const bottomInsetRef = useRef(0)
const [floatGeo, setFloatGeo] = useState<{ left: number; width: number | null } | null>(null)
const [sidebarRight, setSidebarRight] = useState<number | null>(null)
const [activeSplitId, setActiveSplitId] = useState<string | null>(() =>
splitStore.active && splitStore.spec ? splitStore.spec.id : null,
)
@@ -325,6 +326,7 @@ function WorktableSection(props: any) {
const padRight = parseFloat(cs.paddingRight) || 0
const margin = 20
const width = rect.width - padLeft - padRight - margin * 2
setSidebarRight(Math.round(rect.right))
if (width > 0) {
setFloatGeo({ left: Math.round(rect.left + padLeft + margin), width: Math.round(width) })
} else {
@@ -636,6 +638,13 @@ function WorktableSection(props: any) {
const dockedStyle = !isFloat && bottomInset > 0 ? { marginBottom: bottomInset } : undefined
// + 弹窗:向右弹出、锚定 sidebar 右边缘与工作台区块顶部(视口内钳制)
const sectionTop = rootRef.current?.getBoundingClientRect().top ?? 100
const popLeft = sidebarRight != null
? Math.min(sidebarRight + 8, Math.max(16, window.innerWidth - 344))
: 16
const popTop = clamp(sectionTop, MIN_TOP, Math.max(MIN_TOP, window.innerHeight - 540))
if (!wide) {
const projectIcons = registeredIds.map((id) => metas[id]?.icon ?? '📦')
const shortcutIcons = projects.shortcuts.map((s) => s.icon)
@@ -727,8 +736,9 @@ function WorktableSection(props: any) {
</div>
)}
{addOpen && <div className="dsh-wt_popBackdrop" onClick={() => setAddOpen(false)} />}
{addOpen && (
<div className="dsh-wt_menu dsh-wt_add">
<div className="dsh-wt_menu dsh-wt_add dsh-wt_pop" style={{ position: 'fixed', left: popLeft, top: popTop, width: 320, zIndex: 80 }}>
<span className="dsh-wt_menuLabel">{t('add.chooseLayout')}</span>
<div className="dsh-wt_presets">
{PRESET_DEFS.map((def) => (
+3
View File
@@ -122,4 +122,7 @@ export const css = [
'.dsh-wt_paneWipText{font-size:11px}',
'.dsh-wt_splitFlip{flex:none;display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font-size:13px;cursor:pointer}',
'.dsh-wt_splitFlip:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}',
// + 右侧弹出面板
'.dsh-wt_popBackdrop{position:fixed;left:0;top:0;right:0;bottom:0;z-index:79;background:transparent}',
'.dsh-wt_pop{max-height:min(540px,calc(100vh - 32px));overflow:auto;box-shadow:var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4))}',
].join('\n')