修正new命令无法触发的问题

pull/532/MERGE
ChenX 5 years ago
parent 60f2491d04
commit 244ec12d9a

@ -43,20 +43,34 @@ export class Save implements Command
export class New implements Command
{
NoHistory = true;
async exec()
{
let server = FileServer.GetInstance() as FileServer;
if (server.m_CurFileId)
if (server.m_CurFileId === undefined) //TODO: 或者 如果图纸未保存则提醒保存
{
server.m_CurFileId = undefined;
app.CreateDocument();
RightPanelStore.GetInstance().lightStore.InitScene();
let res = await app.Editor.GetKeyWords({
Msg: "当前图纸未保存,是否放弃当前图纸继续新建?",
KeyWordList: [
{ key: "Y", msg: "是" },
{ key: "N", msg: "否" },
],
Default: "N"
});
if (res.StringResult !== "Y")
return;
}
server.m_CurFileId = undefined;
app.CreateDocument();
RightPanelStore.GetInstance().lightStore.InitScene();
}
}
export class SaveAs implements Command
{
NoHistory = true;
async exec()
{
let fileData = app.FileOut().Data;
@ -66,6 +80,7 @@ export class SaveAs implements Command
export class SaveAsBinary implements Command
{
NoHistory = true;
async exec()
{
let fileData = app.FileOut2().Data;

@ -91,7 +91,14 @@ export class GetKeyWordsServices implements EditorService
//初始化状态
this.keywordList = prompt.KeyWordList;
this.UpdateContextMenuPosition();
this.selectIndex = 0;
if (prompt.Default)
{
let index = this.keywordList.findIndex(k => k.key === prompt.Default);
if (index === -1) index = 0;
this.selectIndex = index;
}
else
this.selectIndex = 0;
this.ed.InputState |= InputState.GetKeyWord;
this.IsReady = true;
this.prompt = prompt.Msg;

Loading…
Cancel
Save