mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-14 04:35:56 +08:00
enh: notificationSoundAlways option
This commit is contained in:
parent
8fcad1df4e
commit
f4de3b4c45
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
@ -73,4 +73,4 @@
|
|||||||
|
|
||||||
### Contributor License Agreement
|
### Contributor License Agreement
|
||||||
|
|
||||||
By submitting this pull request, I confirm that I have read and fully agree to the [CONTRIBUTOR_LICENSE_AGREEMENT](CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
|
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
// Interface
|
// Interface
|
||||||
let defaultModelId = '';
|
let defaultModelId = '';
|
||||||
let showUsername = false;
|
let showUsername = false;
|
||||||
|
|
||||||
let notificationSound = true;
|
let notificationSound = true;
|
||||||
|
let notificationSoundAlways = false;
|
||||||
|
|
||||||
let detectArtifacts = true;
|
let detectArtifacts = true;
|
||||||
|
|
||||||
@ -117,6 +119,11 @@
|
|||||||
saveSettings({ notificationSound: notificationSound });
|
saveSettings({ notificationSound: notificationSound });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleNotificationSoundAlways = async () => {
|
||||||
|
notificationSoundAlways = !notificationSoundAlways;
|
||||||
|
saveSettings({ notificationSoundAlways: notificationSoundAlways });
|
||||||
|
};
|
||||||
|
|
||||||
const toggleShowChangelog = async () => {
|
const toggleShowChangelog = async () => {
|
||||||
showChangelog = !showChangelog;
|
showChangelog = !showChangelog;
|
||||||
saveSettings({ showChangelog: showChangelog });
|
saveSettings({ showChangelog: showChangelog });
|
||||||
@ -294,7 +301,8 @@
|
|||||||
chatDirection = $settings.chatDirection ?? 'auto';
|
chatDirection = $settings.chatDirection ?? 'auto';
|
||||||
userLocation = $settings.userLocation ?? false;
|
userLocation = $settings.userLocation ?? false;
|
||||||
|
|
||||||
notificationSound = $settings.notificationSound ?? true;
|
notificationSound = $settings?.notificationSound ?? true;
|
||||||
|
notificationSoundAlways = $settings?.notificationSoundAlways ?? false;
|
||||||
|
|
||||||
hapticFeedback = $settings.hapticFeedback ?? false;
|
hapticFeedback = $settings.hapticFeedback ?? false;
|
||||||
ctrlEnterToSend = $settings.ctrlEnterToSend ?? false;
|
ctrlEnterToSend = $settings.ctrlEnterToSend ?? false;
|
||||||
@ -477,6 +485,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if notificationSound}
|
||||||
|
<div>
|
||||||
|
<div class=" py-0.5 flex w-full justify-between">
|
||||||
|
<div class=" self-center text-xs">
|
||||||
|
{$i18n.t('Always Play Notification Sound')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="p-1 px-3 text-xs flex rounded-sm transition"
|
||||||
|
on:click={() => {
|
||||||
|
toggleNotificationSoundAlways();
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{#if notificationSoundAlways === true}
|
||||||
|
<span class="ml-2 self-center">{$i18n.t('On')}</span>
|
||||||
|
{:else}
|
||||||
|
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if $user?.role === 'admin'}
|
{#if $user?.role === 'admin'}
|
||||||
<div>
|
<div>
|
||||||
<div class=" py-0.5 flex w-full justify-between">
|
<div class=" py-0.5 flex w-full justify-between">
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
isLastActiveTab,
|
isLastActiveTab,
|
||||||
isApp,
|
isApp,
|
||||||
appInfo,
|
appInfo,
|
||||||
toolServers
|
toolServers,
|
||||||
|
playingNotificationSound
|
||||||
} from '$lib/stores';
|
} from '$lib/stores';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
@ -259,6 +260,16 @@
|
|||||||
const { done, content, title } = data;
|
const { done, content, title } = data;
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
|
if ($settings?.notificationSoundAlways ?? false) {
|
||||||
|
playingNotificationSound.set(true);
|
||||||
|
|
||||||
|
const audio = new Audio(`/audio/notification.mp3`);
|
||||||
|
audio.play().finally(() => {
|
||||||
|
// Ensure the global state is reset after the sound finishes
|
||||||
|
playingNotificationSound.set(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if ($isLastActiveTab) {
|
if ($isLastActiveTab) {
|
||||||
if ($settings?.notificationEnabled ?? false) {
|
if ($settings?.notificationEnabled ?? false) {
|
||||||
new Notification(`${title} | Open WebUI`, {
|
new Notification(`${title} | Open WebUI`, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user