Update: 在线版title栏自动显示已打开文件的文件名
This commit is contained in:
@@ -1580,6 +1580,7 @@
|
|||||||
"path",
|
"path",
|
||||||
"Blockly",
|
"Blockly",
|
||||||
"Mixly.MFile",
|
"Mixly.MFile",
|
||||||
|
"Mixly.Title",
|
||||||
"Mixly.LayerExt",
|
"Mixly.LayerExt",
|
||||||
"Mixly.Msg",
|
"Mixly.Msg",
|
||||||
"Mixly.Workspace"
|
"Mixly.Workspace"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.loadJs('web', () => {
|
|||||||
goog.require('path');
|
goog.require('path');
|
||||||
goog.require('Blockly');
|
goog.require('Blockly');
|
||||||
goog.require('Mixly.MFile');
|
goog.require('Mixly.MFile');
|
||||||
|
goog.require('Mixly.Title');
|
||||||
goog.require('Mixly.LayerExt');
|
goog.require('Mixly.LayerExt');
|
||||||
goog.require('Mixly.Msg');
|
goog.require('Mixly.Msg');
|
||||||
goog.require('Mixly.Workspace');
|
goog.require('Mixly.Workspace');
|
||||||
@@ -51,6 +52,7 @@ File.open = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File.parseData(extname, await fileInfo.text());
|
File.parseData(extname, await fileInfo.text());
|
||||||
|
Title.updateTitle(obj.name + ' - ' + Title.title);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
@@ -60,6 +62,7 @@ File.open = async () => {
|
|||||||
let { data, filename } = fileObj;
|
let { data, filename } = fileObj;
|
||||||
const extname = path.extname(filename);
|
const extname = path.extname(filename);
|
||||||
File.parseData(extname, data);
|
File.parseData(extname, data);
|
||||||
|
Title.updateTitle(filename + ' - ' + Title.title);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,6 +134,7 @@ File.saveAs = async () => {
|
|||||||
}
|
}
|
||||||
File.obj = obj;
|
File.obj = obj;
|
||||||
File.save();
|
File.save();
|
||||||
|
Title.updateTitle(obj.name + ' - ' + Title.title);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
@@ -148,12 +152,14 @@ File.new = async () => {
|
|||||||
workspaceToCode = generator.workspaceToCode(blockEditor) || '';
|
workspaceToCode = generator.workspaceToCode(blockEditor) || '';
|
||||||
if (!blocksList.length && workspaceToCode === code) {
|
if (!blocksList.length && workspaceToCode === code) {
|
||||||
layer.msg(Msg.Lang['代码区已清空'], { time: 1000 });
|
layer.msg(Msg.Lang['代码区已清空'], { time: 1000 });
|
||||||
|
Title.updateTitle(Title.title);
|
||||||
File.obj = null;
|
File.obj = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!blocksList.length) {
|
if (!blocksList.length) {
|
||||||
layer.msg(Msg.Lang['工作区已清空'], { time: 1000 });
|
layer.msg(Msg.Lang['工作区已清空'], { time: 1000 });
|
||||||
|
Title.updateTitle(Title.title);
|
||||||
File.obj = null;
|
File.obj = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -177,6 +183,7 @@ File.new = async () => {
|
|||||||
blockEditor.scrollCenter();
|
blockEditor.scrollCenter();
|
||||||
Blockly.hideChaff();
|
Blockly.hideChaff();
|
||||||
codeEditor.setValue(generator.workspaceToCode(blockEditor) || '', -1);
|
codeEditor.setValue(generator.workspaceToCode(blockEditor) || '', -1);
|
||||||
|
Title.updateTitle(Title.title);
|
||||||
File.obj = null;
|
File.obj = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user