!1412 优化:注销关闭图纸

pull/1412/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 46396163c7
commit f8bdc94ddc

@ -12,6 +12,8 @@ import { appCache } from '../../../Common/AppCache';
import { userConfig } from '../../../Editor/UserConfig';
import { app } from '../../../ApplicationServices/Application';
import { AppToaster } from '../Toaster';
import { AppConfirm } from '../Common/Confirm';
import { FileServer } from '../../../DatabaseServices/FileServer';
interface ILoginState
{
@ -53,7 +55,8 @@ export default class Login extends React.Component<{ store?: TopPanelStore; }, I
handleLogin = async () =>
{
if (this.isLoginIng) return;
if (!this.state.user_name.trim() || !this.state.pass_word.trim())
let userName = this.state.user_name.trim();
if (!userName || !this.state.pass_word.trim())
{
AppToaster.show({
message: "用户名和密码不能为空",
@ -63,6 +66,26 @@ export default class Login extends React.Component<{ store?: TopPanelStore; }, I
return;
}
let oldName = localStorage.getItem(StoreageKeys.UserName);
let oldPhone = localStorage.getItem(StoreageKeys.UserPhone);
if (oldName !== userName && oldPhone !== userName)
{
// 切换账号
if (!app.Saved)
{
let status = await AppConfirm.show({
message: "图纸还未保存,切换账号将清空图纸,确定切换?"
});
if (status)
{
app.Saved = true;
let server = FileServer.GetInstance() as FileServer;
await server.AddNewFile();
}
else return;
}
}
this.isLoginIng = true;
let data = await PostJson(SignUrl.login, this.state);
if (data.err_code === RequestStatus.Ok)

@ -4,7 +4,6 @@ import * as React from 'react';
import { app } from '../../ApplicationServices/Application';
import { SignUrl } from '../../Common/HostUrl';
import { Post, RequestStatus } from '../../Common/Request';
import { FileServer } from '../../DatabaseServices/FileServer';
import { commandMachine } from '../../Editor/CommandMachine';
import { CommandState } from '../../Editor/CommandState';
import { SnapMenuFixed } from '../../Editor/SnapMenuFixed';
@ -18,6 +17,7 @@ import { userConfigStore } from '../Store/UserConfigStore';
import { TempEditor } from '../../Editor/TempEditor';
import { Log } from '../../Common/Log';
import { Entity } from '../../DatabaseServices/Entity/Entity';
import { AppConfirm } from './Common/Confirm';
interface TopPanelState
{
@ -76,8 +76,11 @@ export class TopPanel extends React.Component<{ store?: TopPanelStore; }, {}>
};
handleLoginOut = async () =>
{
if (!FileServer.GetInstance().isSave && !confirm("您当前图纸还未保存,是否继续"))
return;
if (!app.Saved)
{
let status = await AppConfirm.show({ message: "您当前图纸还未保存,是否继续?" });
if (!status) return;
}
this.props.store.isLogin = false;
let data = await Post(SignUrl.loginOut);
if (data.err_code === RequestStatus.Ok)

Loading…
Cancel
Save