mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 21:35:19 +00:00
refac
This commit is contained in:
parent
612a52d7bb
commit
b03529b006
2 changed files with 15 additions and 5 deletions
|
|
@ -233,7 +233,7 @@
|
||||||
{
|
{
|
||||||
label: 'Create a new note',
|
label: 'Create a new note',
|
||||||
onClick: async () => {
|
onClick: async () => {
|
||||||
await goto('/notes');
|
await goto(`/notes${query ? `?content=${query}` : ''}`);
|
||||||
show = false;
|
show = false;
|
||||||
onClose();
|
onClose();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { marked } from 'marked';
|
||||||
|
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import fileSaver from 'file-saver';
|
import fileSaver from 'file-saver';
|
||||||
import Fuse from 'fuse.js';
|
import Fuse from 'fuse.js';
|
||||||
|
|
@ -26,6 +28,7 @@
|
||||||
// Assuming $i18n.languages is an array of language codes
|
// Assuming $i18n.languages is an array of language codes
|
||||||
$: loadLocale($i18n.languages);
|
$: loadLocale($i18n.languages);
|
||||||
|
|
||||||
|
import { page } from '$app/stores';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { onMount, getContext, onDestroy } from 'svelte';
|
import { onMount, getContext, onDestroy } from 'svelte';
|
||||||
import { WEBUI_NAME, config, prompts as _prompts, user } from '$lib/stores';
|
import { WEBUI_NAME, config, prompts as _prompts, user } from '$lib/stores';
|
||||||
|
|
@ -42,7 +45,6 @@
|
||||||
import Tooltip from '../common/Tooltip.svelte';
|
import Tooltip from '../common/Tooltip.svelte';
|
||||||
import NoteMenu from './Notes/NoteMenu.svelte';
|
import NoteMenu from './Notes/NoteMenu.svelte';
|
||||||
import FilesOverlay from '../chat/MessageInput/FilesOverlay.svelte';
|
import FilesOverlay from '../chat/MessageInput/FilesOverlay.svelte';
|
||||||
import { marked } from 'marked';
|
|
||||||
import XMark from '../icons/XMark.svelte';
|
import XMark from '../icons/XMark.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
@ -97,7 +99,7 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const createNoteHandler = async () => {
|
const createNoteHandler = async (content?: string) => {
|
||||||
// $i18n.t('New Note'),
|
// $i18n.t('New Note'),
|
||||||
const res = await createNewNote(localStorage.token, {
|
const res = await createNewNote(localStorage.token, {
|
||||||
// YYYY-MM-DD
|
// YYYY-MM-DD
|
||||||
|
|
@ -105,8 +107,8 @@
|
||||||
data: {
|
data: {
|
||||||
content: {
|
content: {
|
||||||
json: null,
|
json: null,
|
||||||
html: '',
|
html: content ?? '',
|
||||||
md: ''
|
md: content ?? ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
meta: null,
|
meta: null,
|
||||||
|
|
@ -301,6 +303,14 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
if ($page.url.searchParams.get('content')) {
|
||||||
|
const content = $page.url.searchParams.get('content') ?? '';
|
||||||
|
if (content) {
|
||||||
|
createNoteHandler(content);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await init();
|
await init();
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue