enh: offline mode

This commit is contained in:
Timothy Jaeryang Baek 2025-06-30 15:20:41 +04:00
parent 2748fc1e4d
commit 71d550dd26
4 changed files with 29 additions and 20 deletions

View file

@ -1546,6 +1546,7 @@ async def get_app_config(request: Request):
"name": app.state.WEBUI_NAME, "name": app.state.WEBUI_NAME,
"version": VERSION, "version": VERSION,
"default_locale": str(DEFAULT_LOCALE), "default_locale": str(DEFAULT_LOCALE),
"offline_mode": OFFLINE_MODE,
"oauth": { "oauth": {
"providers": { "providers": {
name: config.get("name", name) name: config.get("name", name)

View file

@ -90,7 +90,9 @@
}; };
onMount(async () => { onMount(async () => {
if (!$config?.offline_mode) {
checkForVersionUpdates(); checkForVersionUpdates();
}
await Promise.all([ await Promise.all([
(async () => { (async () => {
@ -160,6 +162,7 @@
</button> </button>
</div> </div>
{#if !$config?.offline_mode}
<button <button
class=" text-xs px-3 py-1.5 bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-lg font-medium" class=" text-xs px-3 py-1.5 bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-lg font-medium"
type="button" type="button"
@ -169,6 +172,7 @@
> >
{$i18n.t('Check for updates')} {$i18n.t('Check for updates')}
</button> </button>
{/if}
</div> </div>
</div> </div>

View file

@ -38,7 +38,9 @@
return ''; return '';
}); });
if (!$config?.offline_mode) {
checkForVersionUpdates(); checkForVersionUpdates();
}
}); });
</script> </script>
@ -80,6 +82,7 @@
</button> </button>
</div> </div>
{#if $config?.offline_mode}
<button <button
class=" text-xs px-3 py-1.5 bg-gray-100 hover:bg-gray-200 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-lg font-medium" class=" text-xs px-3 py-1.5 bg-gray-100 hover:bg-gray-200 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-lg font-medium"
on:click={() => { on:click={() => {
@ -88,6 +91,7 @@
> >
{$i18n.t('Check for updates')} {$i18n.t('Check for updates')}
</button> </button>
{/if}
</div> </div>
</div> </div>

View file

@ -228,7 +228,7 @@
} }
// Check for version updates // Check for version updates
if ($user?.role === 'admin') { if ($user?.role === 'admin' && !$config?.offline_mode) {
// Check if the user has dismissed the update toast in the last 24 hours // Check if the user has dismissed the update toast in the last 24 hours
if (localStorage.dismissedUpdateToast) { if (localStorage.dismissedUpdateToast) {
const dismissedUpdateToast = new Date(Number(localStorage.dismissedUpdateToast)); const dismissedUpdateToast = new Date(Number(localStorage.dismissedUpdateToast));