157 lines
3.7 KiB
TypeScript
157 lines
3.7 KiB
TypeScript
/**
|
|
* 登录数据
|
|
*/
|
|
import { BaseData } from "./BaseData";
|
|
|
|
export class LoginData extends BaseData {
|
|
// 登录状态:0未登录 1登录中 2已登录
|
|
private _loginState = 0;
|
|
// token
|
|
private _token = "";
|
|
// refresh token
|
|
private _refreshToken = "";
|
|
// token 过期时间戳
|
|
private _expire = 0;
|
|
// 操作类型,1:登录界面;2:断线重连;3:其他
|
|
private _operateType = 1;
|
|
// 公网IP
|
|
private _ip = "";
|
|
// 机器设备名
|
|
private _machineIdentifier = "";
|
|
// sdk体系的UID
|
|
private _sdkUid = "";
|
|
// 上次登陆时间
|
|
private _lastLoginTime = "";
|
|
|
|
public reset(): void {
|
|
this._loginState = 0;
|
|
this._token = "";
|
|
this._refreshToken = "";
|
|
this._expire = 0;
|
|
this._operateType = 1;
|
|
this._ip = "";
|
|
this._machineIdentifier = "";
|
|
this._sdkUid = "";
|
|
this._lastLoginTime = "";
|
|
}
|
|
|
|
public clear(): void {
|
|
this._loginState = 0;
|
|
this._token = "";
|
|
this._refreshToken = "";
|
|
this._expire = 0;
|
|
this._operateType = 1;
|
|
this._ip = "";
|
|
this._machineIdentifier = "";
|
|
this._sdkUid = "";
|
|
this._lastLoginTime = "";
|
|
}
|
|
|
|
public destroy(): void {
|
|
super.destroy();
|
|
this._loginState = null;
|
|
this._token = null;
|
|
this._refreshToken = null;
|
|
this._expire = null;
|
|
this._operateType = null;
|
|
this._ip = null;
|
|
this._machineIdentifier = null;
|
|
this._sdkUid = null;
|
|
this._lastLoginTime = null;
|
|
}
|
|
|
|
/**是否已登录成功 */
|
|
public isLogin(): boolean {
|
|
return this._loginState === 2;
|
|
}
|
|
|
|
/** 设置登录状态 */
|
|
public set loginState(value: number) {
|
|
this._loginState = value;
|
|
}
|
|
|
|
/** 获取登录状态 */
|
|
public get loginState(): number {
|
|
return this._loginState;
|
|
}
|
|
|
|
/** 设置登录token */
|
|
public set token(value: string) {
|
|
this._token = value;
|
|
}
|
|
|
|
/** 获取登录token */
|
|
public get token(): string {
|
|
return this._token;
|
|
}
|
|
|
|
/** 设置登录refresh token */
|
|
public set refreshToken(value: string) {
|
|
this._refreshToken = value;
|
|
}
|
|
|
|
/** 获取登录refresh token */
|
|
public get refreshToken(): string {
|
|
return this._refreshToken;
|
|
}
|
|
|
|
/** 设置token 过期时间戳 */
|
|
public set expire(value: number) {
|
|
this._expire = value;
|
|
}
|
|
|
|
/** 获取token 过期时间戳 */
|
|
public get expire(): number {
|
|
return this._expire;
|
|
}
|
|
|
|
/** 设置操作类型 */
|
|
public set operateType(value: number) {
|
|
this._operateType = value;
|
|
}
|
|
|
|
/** 获取操作类型 */
|
|
public get operateType(): number {
|
|
return this._operateType;
|
|
}
|
|
|
|
/** 设置ip */
|
|
public set ip(value: string) {
|
|
this._ip = value;
|
|
}
|
|
|
|
/** 获取ip */
|
|
public get ip(): string {
|
|
return this._ip;
|
|
}
|
|
|
|
/** 设置机器设备名 */
|
|
public set machineIdentifier(value: string) {
|
|
this._machineIdentifier = value;
|
|
}
|
|
|
|
/** 获取机器设备名 */
|
|
public get machineIdentifier(): string {
|
|
return this._machineIdentifier;
|
|
}
|
|
|
|
/** 设置sdk体系的UID */
|
|
public set sdkUid(value: string) {
|
|
this._sdkUid = value;
|
|
}
|
|
|
|
/** 获取sdk体系的UID */
|
|
public get sdkUid(): string {
|
|
return this._sdkUid;
|
|
}
|
|
|
|
/** 设置上次登陆时间 */
|
|
public set lastLoginTime(value: string) {
|
|
this._lastLoginTime = value;
|
|
}
|
|
|
|
/** 获取上次登陆时间 */
|
|
public get lastLoginTime(): string {
|
|
return this._lastLoginTime;
|
|
}
|
|
} |