mirror of
https://github.com/open-webui/open-webui
synced 2025-06-25 09:47:41 +00:00
Merge pull request #13832 from Ithanil/svelte_versioning
feat: Handle frontend updates according to Svelte docs
This commit is contained in:
commit
4959e91fa7
@ -26,6 +26,9 @@ ARG BUILD_HASH
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# to store git revision in build
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
|
@ -49,6 +49,16 @@
|
|||||||
import AppSidebar from '$lib/components/app/AppSidebar.svelte';
|
import AppSidebar from '$lib/components/app/AppSidebar.svelte';
|
||||||
import { chatCompletion } from '$lib/apis/openai';
|
import { chatCompletion } from '$lib/apis/openai';
|
||||||
|
|
||||||
|
import { beforeNavigate } from '$app/navigation';
|
||||||
|
import { updated } from '$app/state';
|
||||||
|
|
||||||
|
// handle frontend updates (https://svelte.dev/docs/kit/configuration#version)
|
||||||
|
beforeNavigate(({ willUnload, to }) => {
|
||||||
|
if (updated.current && !willUnload && to?.url) {
|
||||||
|
location.href = to.url.href;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setContext('i18n', i18n);
|
setContext('i18n', i18n);
|
||||||
|
|
||||||
const bc = new BroadcastChannel('active-tab-channel');
|
const bc = new BroadcastChannel('active-tab-channel');
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import adapter from '@sveltejs/adapter-static';
|
import adapter from '@sveltejs/adapter-static';
|
||||||
|
import * as child_process from 'node:child_process';
|
||||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||||
|
|
||||||
/** @type {import('@sveltejs/kit').Config} */
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
@ -14,7 +15,12 @@ const config = {
|
|||||||
pages: 'build',
|
pages: 'build',
|
||||||
assets: 'build',
|
assets: 'build',
|
||||||
fallback: 'index.html'
|
fallback: 'index.html'
|
||||||
})
|
}),
|
||||||
|
// poll for new version name every 60 seconds (to trigger reload mechanic in +layout.svelte)
|
||||||
|
version: {
|
||||||
|
name: child_process.execSync('git rev-parse HEAD').toString().trim(),
|
||||||
|
pollInterval: 60000
|
||||||
|
}
|
||||||
},
|
},
|
||||||
vitePlugin: {
|
vitePlugin: {
|
||||||
// inspector: {
|
// inspector: {
|
||||||
|
Loading…
Reference in New Issue
Block a user