mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 21:05:19 +00:00
refac
This commit is contained in:
parent
45e1c72613
commit
d7c54d92b5
1 changed files with 25 additions and 14 deletions
|
|
@ -152,7 +152,16 @@
|
||||||
console.log('importHandler', json);
|
console.log('importHandler', json);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(json);
|
let data = JSON.parse(json);
|
||||||
|
// validate data
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
if (data.length === 0) {
|
||||||
|
toast.error($i18n.t('Please select a valid JSON file'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data = data[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (data.type) type = data.type;
|
if (data.type) type = data.type;
|
||||||
if (data.url) url = data.url;
|
if (data.url) url = data.url;
|
||||||
|
|
||||||
|
|
@ -184,23 +193,25 @@
|
||||||
|
|
||||||
const exportHandler = async () => {
|
const exportHandler = async () => {
|
||||||
// export current connection as json file
|
// export current connection as json file
|
||||||
const json = JSON.stringify({
|
const json = JSON.stringify([
|
||||||
type,
|
{
|
||||||
url,
|
type,
|
||||||
|
url,
|
||||||
|
|
||||||
spec_type,
|
spec_type,
|
||||||
spec,
|
spec,
|
||||||
path,
|
path,
|
||||||
|
|
||||||
auth_type,
|
auth_type,
|
||||||
key,
|
key,
|
||||||
|
|
||||||
info: {
|
info: {
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
description: description
|
description: description
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
]);
|
||||||
|
|
||||||
const blob = new Blob([json], {
|
const blob = new Blob([json], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue