mirror of
https://github.com/open-webui/open-webui
synced 2025-04-25 08:48:21 +00:00
feat: import/export community
This commit is contained in:
parent
bc5e39d31b
commit
0e7db89117
@ -43,8 +43,26 @@
|
|||||||
|
|
||||||
let showDeleteConfirm = false;
|
let showDeleteConfirm = false;
|
||||||
|
|
||||||
const shareHandler = async (tool) => {
|
const shareHandler = async (item) => {
|
||||||
console.log(tool);
|
toast.success($i18n.t('Redirecting you to OpenWebUI Community'));
|
||||||
|
|
||||||
|
const url = 'https://openwebui.com';
|
||||||
|
|
||||||
|
const tab = await window.open(`${url}/tools/create`, '_blank');
|
||||||
|
|
||||||
|
// Define the event handler function
|
||||||
|
const messageHandler = (event) => {
|
||||||
|
if (event.origin !== url) return;
|
||||||
|
if (event.data === 'loaded') {
|
||||||
|
tab.postMessage(JSON.stringify(item), '*');
|
||||||
|
|
||||||
|
// Remove the event listener after handling the message
|
||||||
|
window.removeEventListener('message', messageHandler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('message', messageHandler, false);
|
||||||
|
console.log(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
const cloneHandler = async (func) => {
|
const cloneHandler = async (func) => {
|
||||||
|
@ -39,8 +39,26 @@
|
|||||||
|
|
||||||
let showDeleteConfirm = false;
|
let showDeleteConfirm = false;
|
||||||
|
|
||||||
const shareHandler = async (tool) => {
|
const shareHandler = async (item) => {
|
||||||
console.log(tool);
|
toast.success($i18n.t('Redirecting you to OpenWebUI Community'));
|
||||||
|
|
||||||
|
const url = 'https://openwebui.com';
|
||||||
|
|
||||||
|
const tab = await window.open(`${url}/tools/create`, '_blank');
|
||||||
|
|
||||||
|
// Define the event handler function
|
||||||
|
const messageHandler = (event) => {
|
||||||
|
if (event.origin !== url) return;
|
||||||
|
if (event.data === 'loaded') {
|
||||||
|
tab.postMessage(JSON.stringify(item), '*');
|
||||||
|
|
||||||
|
// Remove the event listener after handling the message
|
||||||
|
window.removeEventListener('message', messageHandler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('message', messageHandler, false);
|
||||||
|
console.log(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
const cloneHandler = async (tool) => {
|
const cloneHandler = async (tool) => {
|
||||||
|
@ -36,6 +36,18 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
window.addEventListener('message', async (event) => {
|
||||||
|
if (
|
||||||
|
!['https://openwebui.com', 'https://www.openwebui.com', 'http://localhost:9999'].includes(
|
||||||
|
event.origin
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
func = JSON.parse(event.data);
|
||||||
|
console.log(func);
|
||||||
|
});
|
||||||
|
|
||||||
if (sessionStorage.function) {
|
if (sessionStorage.function) {
|
||||||
func = JSON.parse(sessionStorage.function);
|
func = JSON.parse(sessionStorage.function);
|
||||||
sessionStorage.removeItem('function');
|
sessionStorage.removeItem('function');
|
||||||
|
@ -33,6 +33,18 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
window.addEventListener('message', async (event) => {
|
||||||
|
if (
|
||||||
|
!['https://openwebui.com', 'https://www.openwebui.com', 'http://localhost:9999'].includes(
|
||||||
|
event.origin
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tool = JSON.parse(event.data);
|
||||||
|
console.log(tool);
|
||||||
|
});
|
||||||
|
|
||||||
if (sessionStorage.tool) {
|
if (sessionStorage.tool) {
|
||||||
tool = JSON.parse(sessionStorage.tool);
|
tool = JSON.parse(sessionStorage.tool);
|
||||||
sessionStorage.removeItem('tool');
|
sessionStorage.removeItem('tool');
|
||||||
|
Loading…
Reference in New Issue
Block a user