mirror of
https://github.com/open-webui/open-webui
synced 2025-05-24 06:44:24 +00:00
refac: code block
This commit is contained in:
parent
60095598ec
commit
a22d1d5410
@ -5,7 +5,14 @@
|
|||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import { getContext, getAllContexts, onMount, tick, createEventDispatcher } from 'svelte';
|
import {
|
||||||
|
getContext,
|
||||||
|
getAllContexts,
|
||||||
|
onMount,
|
||||||
|
tick,
|
||||||
|
createEventDispatcher,
|
||||||
|
onDestroy
|
||||||
|
} from 'svelte';
|
||||||
import { copyToClipboard } from '$lib/utils';
|
import { copyToClipboard } from '$lib/utils';
|
||||||
|
|
||||||
import 'highlight.js/styles/github-dark.min.css';
|
import 'highlight.js/styles/github-dark.min.css';
|
||||||
@ -31,6 +38,8 @@
|
|||||||
export let editorClassName = '';
|
export let editorClassName = '';
|
||||||
export let stickyButtonsClassName = 'top-8';
|
export let stickyButtonsClassName = 'top-8';
|
||||||
|
|
||||||
|
let pyodideWorker = null;
|
||||||
|
|
||||||
let _code = '';
|
let _code = '';
|
||||||
$: if (code) {
|
$: if (code) {
|
||||||
updateCode();
|
updateCode();
|
||||||
@ -138,7 +147,7 @@
|
|||||||
|
|
||||||
console.log(packages);
|
console.log(packages);
|
||||||
|
|
||||||
const pyodideWorker = new PyodideWorker();
|
pyodideWorker = new PyodideWorker();
|
||||||
|
|
||||||
pyodideWorker.postMessage({
|
pyodideWorker.postMessage({
|
||||||
id: id,
|
id: id,
|
||||||
@ -280,6 +289,12 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
if (pyodideWorker) {
|
||||||
|
pyodideWorker.terminate();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user