mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
This commit is contained in:
parent
358ad8ef20
commit
f9d374810d
@ -504,9 +504,10 @@
|
|||||||
|
|
||||||
let reader = new FileReader();
|
let reader = new FileReader();
|
||||||
reader.onload = async (event) => {
|
reader.onload = async (event) => {
|
||||||
|
try {
|
||||||
let suggestions = JSON.parse(event.target.result);
|
let suggestions = JSON.parse(event.target.result);
|
||||||
|
|
||||||
promptSuggestions = suggestions.map((s) => {
|
suggestions = suggestions.map((s) => {
|
||||||
if (typeof s.title === 'string') {
|
if (typeof s.title === 'string') {
|
||||||
s.title = [s.title, ''];
|
s.title = [s.title, ''];
|
||||||
} else if (!Array.isArray(s.title)) {
|
} else if (!Array.isArray(s.title)) {
|
||||||
@ -515,14 +516,23 @@
|
|||||||
|
|
||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
promptSuggestions = [...promptSuggestions, ...suggestions];
|
||||||
|
} catch (error) {
|
||||||
|
toast.error($i18n.t('Invalid JSON file'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
reader.readAsText(files[0]);
|
reader.readAsText(files[0]);
|
||||||
|
|
||||||
|
e.target.value = ''; // Reset the input value
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
|
type="button"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
const input = document.getElementById('prompt-suggestions-import-input');
|
const input = document.getElementById('prompt-suggestions-import-input');
|
||||||
if (input) {
|
if (input) {
|
||||||
@ -553,6 +563,7 @@
|
|||||||
{#if promptSuggestions.length}
|
{#if promptSuggestions.length}
|
||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
|
type="button"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
let blob = new Blob([JSON.stringify(promptSuggestions)], {
|
let blob = new Blob([JSON.stringify(promptSuggestions)], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
|
Loading…
Reference in New Issue
Block a user