增加测试命令reopen

pull/556/MERGE
ChenX 5 years ago
parent 974136b833
commit a508c4acbe

@ -1,3 +1,4 @@
import { StoreageKeys } from "../Common/StoreageKeys";
import { FileServer } from "../DatabaseServices/FileServer";
import { Command } from "../Editor/CommandMachine";
@ -5,7 +6,7 @@ export class Open implements Command
{
async exec()
{
let fid = localStorage.getItem('lastfid');
let fid = localStorage.getItem(StoreageKeys.LastOpenFileId);
if (fid)
(FileServer.GetInstance() as FileServer).OpenFile(fid);
}

@ -0,0 +1,32 @@
import { Command } from "../Editor/CommandMachine";
import { FileServer } from "../DatabaseServices/FileServer";
import { app } from "../ApplicationServices/Application";
import { IsDev } from "../Common/Deving";
export class ReOpen implements Command
{
async exec()
{
if (!IsDev() && !app.Saved)
{
let res = await app.Editor.GetKeyWords({
Msg: "当前图纸未保存,是否放弃当前图纸继续新建?",
KeyWordList: [
{ key: "Y", msg: "是" },
{ key: "N", msg: "否" },
],
Default: "N"
});
if (res.StringResult !== "Y")
return;
}
let fileServer = FileServer.GetInstance() as FileServer;
if (fileServer.m_CurFileId)
{
let id = fileServer.m_CurFileId;
app.CreateDocument();
fileServer.m_CurFileId = undefined;
fileServer.OpenFile(id);
}
}
}

@ -3,6 +3,7 @@ import { app } from '../ApplicationServices/Application';
import { FileSystem } from '../Common/FileSystem';
import { RequestStatus, uploadLogo } from '../Common/Request';
import { deflate, GetCurrentViewPreViewImage } from '../Common/SerializeMaterial';
import { StoreageKeys } from "../Common/StoreageKeys";
import { FileServer } from '../DatabaseServices/FileServer';
import { Command } from '../Editor/CommandMachine';
@ -34,6 +35,7 @@ export class Save implements Command
if (data.err_code === RequestStatus.Ok)
{
fileServer.m_CurFileId = data.files.file_id;
localStorage.setItem(StoreageKeys.LastOpenFileId, fileServer.m_CurFileId);
}
}

@ -8,4 +8,5 @@ export enum StoreageKeys
ConfigName = "configName_",
IsNewErp = "isNewErp",
RoomName = "roomName",
LastOpenFileId = "lastfid",
}

@ -5,6 +5,7 @@ import { FileUrls } from "../Common/HostUrl";
import { DirectoryId, PostJson, RequestStatus } from "../Common/Request";
import { inflate } from "../Common/SerializeMaterial";
import { Singleton } from "../Common/Singleton";
import { StoreageKeys } from "../Common/StoreageKeys";
import { IDirectoryProps } from "../UI/Components/SourceManage/CommonPanel";
import { CADFiler } from "./CADFiler";
@ -148,6 +149,6 @@ export class FileServer extends Singleton
{
if (fileInfo.name)
this.currentFileInfo.name = fileInfo.name;
localStorage.setItem('lastfid', fileInfo.file_id || "");
localStorage.setItem(StoreageKeys.LastOpenFileId, fileInfo.file_id || "");
}
}

@ -99,6 +99,7 @@ import { PasteClip } from "../Add-on/PasteClip";
import { Pedit } from "../Add-on/Pedit";
import { Command_PLTest } from "../Add-on/polytest";
import { Command_Purge } from "../Add-on/Purge";
import { ReOpen } from "../Add-on/ReOpen";
import { Command_RestoreColor } from "../Add-on/RestoreColor";
import { Command_Reverse } from "../Add-on/Reverse";
import { Command_Rotate } from "../Add-on/Rotate";
@ -207,6 +208,7 @@ export function registerCommand()
commandMachine.RegisterCommand("new", new New());
commandMachine.RegisterCommand("open", new Open());
commandMachine.RegisterCommand("reopen", new ReOpen());
commandMachine.RegisterCommand("arc", new DrawArc());

@ -4,6 +4,7 @@ import { inject, observer } from 'mobx-react';
import * as React from 'react';
import { IsDev } from '../../../Common/Deving';
import { CURRENT_HOST, ResourcesCDN_HOST } from '../../../Common/HostUrl';
import { StoreageKeys } from '../../../Common/StoreageKeys';
import { FileServer } from '../../../DatabaseServices/FileServer';
import { TopPanelStore } from '../../Store/TopPanelStore';
import { Carousel } from '../Carousel';
@ -33,7 +34,7 @@ export class ContentComponent extends React.Component<{ store?: TopPanelStore; }
{
this.props.store.openMain = false;
this.props.store.editoring = true;
let fid = localStorage.getItem('lastfid');
let fid = localStorage.getItem(StoreageKeys.LastOpenFileId);
if (fid)
(FileServer.GetInstance() as FileServer).OpenFile(fid);
return;

@ -4,9 +4,10 @@ import { inject, observer } from 'mobx-react';
import * as React from 'react';
import { app } from '../../../ApplicationServices/Application';
import { FileSystem } from '../../../Common/FileSystem';
import { FileUrls, CURRENT_HOST } from '../../../Common/HostUrl';
import { CURRENT_HOST, FileUrls } from '../../../Common/HostUrl';
import { DirectoryId } from '../../../Common/Request';
import { deflate } from '../../../Common/SerializeMaterial';
import { StoreageKeys } from '../../../Common/StoreageKeys';
import { FileFormatReg } from '../../../Common/Utils';
import { FileServer } from '../../../DatabaseServices/FileServer';
import { TopPanelStore } from '../../Store/TopPanelStore';
@ -127,9 +128,9 @@ export class FilePanel extends React.Component<{ store?: TopPanelStore; }, {}>
let server = FileServer.GetInstance() as FileServer;
if (data.file_ids.includes(server.m_CurFileId))
this.handleAddNewFile("新文件", this.commonPanel['currentDir']);
let lastFid = localStorage.getItem('lastfid');
if (data.file_ids.includes(lastFid))
localStorage.setItem('lastfid', "");
let lastFileId = localStorage.getItem(StoreageKeys.LastOpenFileId);
if (data.file_ids.includes(lastFileId))
localStorage.setItem(StoreageKeys.LastOpenFileId, "");
};
renderNav = () =>
{

Loading…
Cancel
Save