Fix: 修复在线版python_pyodide板卡本地文件管理下文件编辑后无法保存
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -22,6 +22,7 @@ class WebAccessFSExt extends WebAccessFS {
|
|||||||
|
|
||||||
export default class FileSystemFS extends FS {
|
export default class FileSystemFS extends FS {
|
||||||
#fs_ = null;
|
#fs_ = null;
|
||||||
|
#encoder_ = new TextEncoder();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@@ -68,7 +69,8 @@ export default class FileSystemFS extends FS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async writeFile(path, data) {
|
async writeFile(path, data) {
|
||||||
return this.#fs_.writeFile(path, data, 'utf8');
|
const encodedArray = this.#encoder_.encode(data);
|
||||||
|
return this.#fs_.writeFile(path, encodedArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
async isFile(path) {
|
async isFile(path) {
|
||||||
|
|||||||
@@ -330,10 +330,13 @@ export default class StatusBarFileSystem extends PageBase {
|
|||||||
this.#fileTree_.showProgress();
|
this.#fileTree_.showProgress();
|
||||||
const id = this.#fileTree_.getSelectedNodeId();
|
const id = this.#fileTree_.getSelectedNodeId();
|
||||||
const fs = this.#fileTree_.getFS();
|
const fs = this.#fileTree_.getFS();
|
||||||
const [error,] = await fs.writeFile(id, this.#editor_.getValue());
|
try {
|
||||||
this.#fileTree_.hideProgress();
|
await fs.writeFile(id, this.#editor_.getValue());
|
||||||
if (!error) {
|
|
||||||
this.setStatus(false);
|
this.setStatus(false);
|
||||||
|
} catch (error) {
|
||||||
|
Debug.error(error);
|
||||||
|
} finally {
|
||||||
|
this.#fileTree_.hideProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user