Skip to content

Commit f03ee42

Browse files
author
Marty
committed
fix bug: run pyodide
1 parent 9cad874 commit f03ee42

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

prod/coms/wa-run-python.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
html,
44
css,
55
} from "https://cdn.jsdelivr.net/gh/lit/dist@2/all/lit-all.min.js";
6-
import MQTTAppV2 from "../js/py-mqtt-v2.js";
76

87
/**
98
* filename:wa-run-python.js
@@ -50,18 +49,9 @@ export class RunPython extends LitElement {
5049

5150
async runPythonCode(code) {
5251
try {
53-
window.mqtt = MQTTAppV2;
54-
mqtt.disconnectAll();
55-
56-
let lines = code.split('\n');
57-
for (let line of lines) {
58-
line = line.trim();
59-
if (line) {
60-
await this.pyodide.runPythonAsync(line);
61-
}
62-
}
63-
return null;
52+
return await this.pyodide.runPythonAsync(code);
6453
} catch (err) {
54+
console.error("整體執行錯誤:", err);
6555
if (this.pyodide && err.constructor.name === 'PythonError') {
6656
var errMsg = err.message.split("\n").slice(-3).join(" ");
6757
var result = errMsg.replace(/(line )(\d+)/, function (match, p1, p2) {

0 commit comments

Comments
 (0)