dsh-db-tool 1.5.1 → 1.5.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.
Files changed (2) hide show
  1. package/client/client.js +18 -6
  2. package/package.json +1 -1
package/client/client.js CHANGED
@@ -1345,8 +1345,18 @@ window.__ModuleLoader__.load({
1345
1345
  if (closeRef.current) closeRef.current.focus();
1346
1346
  }, []);
1347
1347
 
1348
- // 拖动定位:初始停靠视口右上(宽度按 1100 常量估算,.dbt-browse-dialog 为 max-width:1400 的自适应宽)
1349
- const [pos, setPos] = React.useState(() => ({ top: 72, left: Math.max(12, (window.innerWidth || 1200) - 1100 - 24) }));
1348
+ // 拖动定位:首帧给个保守值,mount 后按浮窗实测尺寸居中(侧栏 iframe 视口窄,常量估宽会错位)
1349
+ const dialogRef2 = React.useRef(null);
1350
+ const [pos, setPos] = React.useState(() => ({ top: 72, left: 12 }));
1351
+ React.useEffect(() => {
1352
+ const el = dialogRef2.current;
1353
+ if (!el) return;
1354
+ const w = window.innerWidth || 1200, h = window.innerHeight || 800;
1355
+ setPos({
1356
+ top: Math.max(0, Math.round((h - el.offsetHeight) / 2)),
1357
+ left: Math.max(0, Math.round((w - el.offsetWidth) / 2)),
1358
+ });
1359
+ }, []);
1350
1360
  const draggingRef = React.useRef(null); // {dx, dy}
1351
1361
  const [dragging, setDragging] = React.useState(false);
1352
1362
  function stopDrag() { draggingRef.current = null; setDragging(false); }
@@ -1360,12 +1370,13 @@ window.__ModuleLoader__.load({
1360
1370
  function onHeaderPointerMove(e) {
1361
1371
  if (!draggingRef.current) return;
1362
1372
  const h = window.innerHeight || 800, w = window.innerWidth || 1200;
1363
- // 垂直 clamp 用浮窗实际高度:整体保持在视口内(视觉审查:底部分页栏不得溢出被裁);
1364
- // 水平放宽到至少留 120px 可抓回(允许左右拖出一半)
1365
- const dlgH = (e.currentTarget.parentElement && e.currentTarget.parentElement.offsetHeight) || 720;
1373
+ // clamp 全部用浮窗实测尺寸:整体保持在视口内(窄视口下常量估宽会把窗拖丢)
1374
+ const dlg = e.currentTarget.parentElement;
1375
+ const dlgH = (dlg && dlg.offsetHeight) || 720;
1376
+ const dlgW = (dlg && dlg.offsetWidth) || 1100;
1366
1377
  setPos({
1367
1378
  top: Math.min(Math.max(e.clientY - draggingRef.current.dy, 0), Math.max(0, h - dlgH)),
1368
- left: Math.min(Math.max(e.clientX - draggingRef.current.dx, -(1100 - 120)), w - 120),
1379
+ left: Math.min(Math.max(e.clientX - draggingRef.current.dx, 0), Math.max(0, w - dlgW)),
1369
1380
  });
1370
1381
  }
1371
1382
 
@@ -1419,6 +1430,7 @@ window.__ModuleLoader__.load({
1419
1430
  "div",
1420
1431
  {
1421
1432
  className: "dbt-browse-root dbt-browse-dialog" + (dragging ? " dragging" : ""),
1433
+ ref: dialogRef2,
1422
1434
  style: { position: "fixed", top: pos.top, left: pos.left },
1423
1435
  role: "dialog", "aria-labelledby": "dbt-browse-title",
1424
1436
  onKeyDown: (e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-db-tool",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "DSH community plugin: chat-operated multi-database admin tool with sidebar management, project-scoped grants, ro/rw modes and dangerous-operation confirmation",
5
5
  "type": "module",
6
6
  "license": "MIT",