index.ts 1.43 KB
Newer Older
1
import { APP_NAME } from '$lib/constants';
2
import { writable, derived } from 'svelte/store';
3

4
// Backend
5
export const WEBUI_NAME = writable(APP_NAME);
6
7
export const config = writable(undefined);
export const user = writable(undefined);
8
9

// Frontend
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const rawThemeSetting = writable('system');
export const theme = derived(rawThemeSetting, ($rawThemeSetting) => {
	if ($rawThemeSetting === 'system') {
		return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
	}
	return $rawThemeSetting;
});

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
	rawThemeSetting.update((currentTheme) => {
		if (currentTheme === 'system') {
			return e.matches ? 'dark' : 'light';
		}
		return currentTheme;
	});
});

export function setTheme(theme){
	rawThemeSetting.set(theme);
	localStorage.setItem('theme', theme);
}
Timothy J. Baek's avatar
Timothy J. Baek committed
31

32
export const chatId = writable('');
Timothy J. Baek's avatar
Timothy J. Baek committed
33

34
export const chats = writable([]);
Timothy J. Baek's avatar
Timothy J. Baek committed
35
export const tags = writable([]);
36
export const models = writable([]);
Timothy J. Baek's avatar
Timothy J. Baek committed
37

38
export const modelfiles = writable([]);
Timothy J. Baek's avatar
Timothy J. Baek committed
39
export const prompts = writable([]);
Timothy J. Baek's avatar
Timothy J. Baek committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
export const documents = writable([
	{
		collection_name: 'collection_name',
		filename: 'filename',
		name: 'name',
		title: 'title'
	},
	{
		collection_name: 'collection_name1',
		filename: 'filename1',
		name: 'name1',
		title: 'title1'
	}
]);
Timothy J. Baek's avatar
Timothy J. Baek committed
54

55
56
export const settings = writable({});
export const showSettings = writable(false);
57
export const showChangelog = writable(false);