mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
refac
This commit is contained in:
parent
b364cf43d3
commit
282c541427
1 changed files with 5 additions and 7 deletions
|
|
@ -378,14 +378,13 @@
|
||||||
let isResizing = false;
|
let isResizing = false;
|
||||||
|
|
||||||
let startWidth = 0;
|
let startWidth = 0;
|
||||||
let startX = 0;
|
let startClientX = 0;
|
||||||
let endX = 0;
|
|
||||||
|
|
||||||
const resizeStartHandler = (e: MouseEvent) => {
|
const resizeStartHandler = (e: MouseEvent) => {
|
||||||
if ($mobile) return;
|
if ($mobile) return;
|
||||||
isResizing = true;
|
isResizing = true;
|
||||||
|
|
||||||
startX = e.clientX;
|
startClientX = e.clientX;
|
||||||
startWidth = $sidebarWidth ?? 260;
|
startWidth = $sidebarWidth ?? 260;
|
||||||
|
|
||||||
document.body.style.userSelect = 'none';
|
document.body.style.userSelect = 'none';
|
||||||
|
|
@ -399,8 +398,8 @@
|
||||||
localStorage.setItem('sidebarWidth', String($sidebarWidth));
|
localStorage.setItem('sidebarWidth', String($sidebarWidth));
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyResize = () => {
|
const resizeSidebarHandler = (endClientX) => {
|
||||||
const dx = endX - startX;
|
const dx = endClientX - startClientX;
|
||||||
const newSidebarWidth = Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, startWidth + dx));
|
const newSidebarWidth = Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, startWidth + dx));
|
||||||
|
|
||||||
sidebarWidth.set(newSidebarWidth);
|
sidebarWidth.set(newSidebarWidth);
|
||||||
|
|
@ -622,8 +621,7 @@
|
||||||
<svelte:window
|
<svelte:window
|
||||||
on:mousemove={(e) => {
|
on:mousemove={(e) => {
|
||||||
if (!isResizing) return;
|
if (!isResizing) return;
|
||||||
endX = e.clientX;
|
resizeSidebarHandler(e.clientX);
|
||||||
applyResize();
|
|
||||||
}}
|
}}
|
||||||
on:mouseup={() => {
|
on:mouseup={() => {
|
||||||
resizeEndHandler();
|
resizeEndHandler();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue