mirror of
https://github.com/open-webui/open-webui
synced 2024-11-07 17:19:53 +00:00
refac
This commit is contained in:
parent
8381346378
commit
c3c15cbb7e
@ -1,9 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext, afterUpdate } from 'svelte';
|
import { getContext, tick } from 'svelte';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { models, settings, user } from '$lib/stores';
|
import { models, settings, user } from '$lib/stores';
|
||||||
|
import { updateUserSettings } from '$lib/apis/users';
|
||||||
import { getModels as _getModels } from '$lib/apis';
|
import { getModels as _getModels } from '$lib/apis';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
import Modal from '../common/Modal.svelte';
|
import Modal from '../common/Modal.svelte';
|
||||||
import Account from './Settings/Account.svelte';
|
import Account from './Settings/Account.svelte';
|
||||||
@ -14,8 +15,6 @@
|
|||||||
import Chats from './Settings/Chats.svelte';
|
import Chats from './Settings/Chats.svelte';
|
||||||
import User from '../icons/User.svelte';
|
import User from '../icons/User.svelte';
|
||||||
import Personalization from './Settings/Personalization.svelte';
|
import Personalization from './Settings/Personalization.svelte';
|
||||||
import { updateUserSettings } from '$lib/apis/users';
|
|
||||||
import { goto } from '$app/navigation';
|
|
||||||
import Valves from './Settings/Valves.svelte';
|
import Valves from './Settings/Valves.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
@ -36,30 +35,35 @@
|
|||||||
let selectedTab = 'general';
|
let selectedTab = 'general';
|
||||||
|
|
||||||
// Function to handle sideways scrolling
|
// Function to handle sideways scrolling
|
||||||
const handleSidewaysScroll = (event) => {
|
const scrollHandler = (event) => {
|
||||||
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
||||||
if (settingsTabsContainer) {
|
if (settingsTabsContainer) {
|
||||||
event.preventDefault(); // Prevent default vertical scrolling
|
event.preventDefault(); // Prevent default vertical scrolling
|
||||||
settingsTabsContainer.scrollLeft += event.deltaY; // Scroll sideways
|
settingsTabsContainer.scrollLeft += event.deltaY; // Scroll sideways
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Use afterUpdate to add the event listener after the modal is confirmed to be visible
|
const addScrollListener = async () => {
|
||||||
// and remove it when the modal is closed
|
await tick();
|
||||||
afterUpdate(() => {
|
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
||||||
if (show) {
|
if (settingsTabsContainer) {
|
||||||
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
settingsTabsContainer.addEventListener('wheel', scrollHandler);
|
||||||
if (settingsTabsContainer) {
|
|
||||||
settingsTabsContainer.addEventListener('wheel', handleSidewaysScroll);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
|
||||||
if (settingsTabsContainer) {
|
|
||||||
settingsTabsContainer.removeEventListener('wheel', handleSidewaysScroll);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
const removeScrollListener = async () => {
|
||||||
|
await tick();
|
||||||
|
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
||||||
|
if (settingsTabsContainer) {
|
||||||
|
settingsTabsContainer.removeEventListener('wheel', scrollHandler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$: if (show) {
|
||||||
|
addScrollListener();
|
||||||
|
} else {
|
||||||
|
removeScrollListener();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:show>
|
<Modal bind:show>
|
||||||
|
Loading…
Reference in New Issue
Block a user