mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 21:42:58 +00:00
feat: onboarding screen
This commit is contained in:
parent
cfe255bb95
commit
194b924a96
@ -2216,11 +2216,16 @@ async def get_app_config(request: Request):
|
|||||||
if data is not None and "id" in data:
|
if data is not None and "id" in data:
|
||||||
user = Users.get_user_by_id(data["id"])
|
user = Users.get_user_by_id(data["id"])
|
||||||
|
|
||||||
|
user_count = 0
|
||||||
|
if user is None:
|
||||||
|
user_count = Users.get_num_users()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"status": True,
|
"status": True,
|
||||||
"name": WEBUI_NAME,
|
"name": WEBUI_NAME,
|
||||||
"version": VERSION,
|
"version": VERSION,
|
||||||
"default_locale": str(DEFAULT_LOCALE),
|
"default_locale": str(DEFAULT_LOCALE),
|
||||||
|
**({"onboarding": True} if user_count is 0 else {}),
|
||||||
"oauth": {
|
"oauth": {
|
||||||
"providers": {
|
"providers": {
|
||||||
name: config.get("name", name)
|
name: config.get("name", name)
|
||||||
|
63
src/lib/components/OnBoarding.svelte
Normal file
63
src/lib/components/OnBoarding.svelte
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<script>
|
||||||
|
import { getContext } from 'svelte';
|
||||||
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
import Marquee from './common/Marquee.svelte';
|
||||||
|
import SlideShow from './common/SlideShow.svelte';
|
||||||
|
import ArrowRightCircle from './icons/ArrowRightCircle.svelte';
|
||||||
|
|
||||||
|
export let show = true;
|
||||||
|
export let getStartedHandler = () => {};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if show}
|
||||||
|
<div class="w-full h-screen max-h-[100dvh] text-white relative">
|
||||||
|
<SlideShow duration={5000} />
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="w-full h-full absolute top-0 left-0 bg-gradient-to-t dark:from-black dark:to-black/60"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<div class="w-full h-full absolute top-0 left-0 backdrop-blur-xl"></div>
|
||||||
|
|
||||||
|
<div class="relative bg-transparent w-full min-h-screen flex z-10">
|
||||||
|
<div class="flex flex-col justify-center w-full items-center pb-10 text-center">
|
||||||
|
<div class="text-5xl lg:text-7xl font-secondary">
|
||||||
|
<Marquee
|
||||||
|
duration={5000}
|
||||||
|
words={[
|
||||||
|
$i18n.t('Explore the cosmos'),
|
||||||
|
$i18n.t('Unlock mysteries'),
|
||||||
|
$i18n.t('Chart new frontiers'),
|
||||||
|
$i18n.t('Dive into knowledge'),
|
||||||
|
$i18n.t('Discover wonders'),
|
||||||
|
$i18n.t('Ignite curiosity'),
|
||||||
|
$i18n.t('Forge new paths'),
|
||||||
|
$i18n.t('Unravel secrets'),
|
||||||
|
$i18n.t('Pioneer insights'),
|
||||||
|
$i18n.t('Embark on adventures')
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="mt-0.5">{$i18n.t(`wherever you are`)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="absolute bottom-12 left-0 right-0 w-full">
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<div class="flex flex-col justify-center items-center">
|
||||||
|
<button
|
||||||
|
class="relative z-20 flex p-1 rounded-full bg-white/5 hover:bg-white/10 transition font-medium text-sm"
|
||||||
|
on:click={() => {
|
||||||
|
getStartedHandler();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ArrowRightCircle className="size-6" />
|
||||||
|
</button>
|
||||||
|
<div class="mt-1.5 font-primary text-base font-medium">{$i18n.t(`Get started`)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
30
src/lib/components/common/Marquee.svelte
Normal file
30
src/lib/components/common/Marquee.svelte
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { fade, fly } from 'svelte/transition';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
let idx = 0;
|
||||||
|
|
||||||
|
export let className = '';
|
||||||
|
export let words = ['lorem', 'ipsum'];
|
||||||
|
export let duration = 4000;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
setInterval(async () => {
|
||||||
|
if (idx === words.length - 1) {
|
||||||
|
idx = 0;
|
||||||
|
} else {
|
||||||
|
idx = idx + 1;
|
||||||
|
}
|
||||||
|
}, duration);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class={className}>
|
||||||
|
<div>
|
||||||
|
{#key idx}
|
||||||
|
<div class=" marquee-item" in:fly={{ y: '30%', duration: 1000 }}>
|
||||||
|
{words.at(idx)}
|
||||||
|
</div>
|
||||||
|
{/key}
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
selectedImageIdx = (selectedImageIdx + 1) % 5;
|
selectedImageIdx = (selectedImageIdx + 1) % (imageUrls.length - 1);
|
||||||
}, duration);
|
}, duration);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
19
src/lib/components/icons/ArrowRightCircle.svelte
Normal file
19
src/lib/components/icons/ArrowRightCircle.svelte
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let className = 'size-4';
|
||||||
|
export let strokeWidth = '1.5';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width={strokeWidth}
|
||||||
|
stroke="currentColor"
|
||||||
|
class={className}
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="m12.75 15 3-3m0 0-3-3m3 3h-7.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
@ -10,6 +10,7 @@
|
|||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { getBackendConfig } from '$lib/apis';
|
import { getBackendConfig } from '$lib/apis';
|
||||||
import SlideShow from '$lib/components/common/SlideShow.svelte';
|
import SlideShow from '$lib/components/common/SlideShow.svelte';
|
||||||
|
import OnBoarding from '$lib/components/OnBoarding.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -87,6 +88,8 @@
|
|||||||
await setSessionUser(sessionUser);
|
await setSessionUser(sessionUser);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let onboarding = false;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($user !== undefined) {
|
if ($user !== undefined) {
|
||||||
await goto('/');
|
await goto('/');
|
||||||
@ -96,6 +99,7 @@
|
|||||||
if (($config?.features.auth_trusted_header ?? false) || $config?.features.auth === false) {
|
if (($config?.features.auth_trusted_header ?? false) || $config?.features.auth === false) {
|
||||||
await signInHandler();
|
await signInHandler();
|
||||||
}
|
}
|
||||||
|
onboarding = $config?.onboarding ?? false;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -105,15 +109,17 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
|
<OnBoarding
|
||||||
|
bind:show={onboarding}
|
||||||
|
getStartedHandler={() => {
|
||||||
|
onboarding = false;
|
||||||
|
mode = 'signup';
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<div class="w-full h-screen max-h-[100dvh] text-white relative">
|
<div class="w-full h-screen max-h-[100dvh] text-white relative">
|
||||||
<div class="w-full h-full absolute top-0 left-0 bg-white dark:bg-black"></div>
|
<div class="w-full h-full absolute top-0 left-0 bg-white dark:bg-black"></div>
|
||||||
|
|
||||||
<!-- <div
|
|
||||||
class="w-full h-full absolute top-0 left-0 bg-gradient-to-t dark:from-black dark:to-black/60"
|
|
||||||
></div> -->
|
|
||||||
|
|
||||||
<!-- <div class="w-full h-full absolute top-0 left-0 backdrop-blur-xl bg-black/50"></div> -->
|
|
||||||
|
|
||||||
{#if loaded}
|
{#if loaded}
|
||||||
<div class="fixed m-10 z-50">
|
<div class="fixed m-10 z-50">
|
||||||
<div class="flex space-x-2">
|
<div class="flex space-x-2">
|
||||||
|
Loading…
Reference in New Issue
Block a user