mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac: clone
This commit is contained in:
parent
8464b30485
commit
3578b5e337
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getContext, createEventDispatcher } from 'svelte';
|
import { getContext, createEventDispatcher, onMount } from 'svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -12,6 +12,7 @@
|
|||||||
let loading = false;
|
let loading = false;
|
||||||
|
|
||||||
export let edit = false;
|
export let edit = false;
|
||||||
|
export let clone = false;
|
||||||
|
|
||||||
export let id = '';
|
export let id = '';
|
||||||
export let name = '';
|
export let name = '';
|
||||||
@ -20,7 +21,7 @@
|
|||||||
};
|
};
|
||||||
export let content = '';
|
export let content = '';
|
||||||
|
|
||||||
$: if (name && !edit) {
|
$: if (name && !edit && !clone) {
|
||||||
id = name.replace(/\s+/g, '_').toLowerCase();
|
id = name.replace(/\s+/g, '_').toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
|
|
||||||
|
let clone = false;
|
||||||
let tool = null;
|
let tool = null;
|
||||||
|
|
||||||
const saveHandler = async (data) => {
|
const saveHandler = async (data) => {
|
||||||
@ -34,6 +35,7 @@
|
|||||||
if (sessionStorage.tool) {
|
if (sessionStorage.tool) {
|
||||||
tool = JSON.parse(sessionStorage.tool);
|
tool = JSON.parse(sessionStorage.tool);
|
||||||
sessionStorage.removeItem('tool');
|
sessionStorage.removeItem('tool');
|
||||||
|
clone = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -43,6 +45,7 @@
|
|||||||
name={tool?.name ?? ''}
|
name={tool?.name ?? ''}
|
||||||
meta={tool?.meta ?? { description: '' }}
|
meta={tool?.meta ?? { description: '' }}
|
||||||
content={tool?.content ?? ''}
|
content={tool?.content ?? ''}
|
||||||
|
{clone}
|
||||||
on:save={(e) => {
|
on:save={(e) => {
|
||||||
saveHandler(e.detail);
|
saveHandler(e.detail);
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user