|
- import { parseJsonText } from './index';
-
- export default class SessionStorage {
- // 用于新建镜像
- static readonly mirrorNameKey = 'mirror-name';
- // 模型部署服务
- static readonly serviceInfoKey = 'service-info';
- // 模型部署服务版本
- static readonly serviceVersionInfoKey = 'service-version-info';
- // 编辑器 url
- static readonly editorUrlKey = 'editor-url';
- // 客户端信息
- static readonly clientInfoKey = 'client-info';
- // 自动机器学习记录ID
- static readonly autoMLRecordIDKey = 'auto-ml-record-id';
-
- static getItem(key: string, isObject: boolean = false) {
- const jsonStr = sessionStorage.getItem(key);
- if (!isObject) {
- return jsonStr;
- }
- if (jsonStr) {
- return parseJsonText(jsonStr);
- }
- return null;
- }
-
- static setItem(key: string, state?: any, isObject: boolean = false) {
- if (state) {
- sessionStorage.setItem(key, isObject ? JSON.stringify(state) : state);
- }
- }
-
- static removeItem(key: string) {
- sessionStorage.removeItem(key);
- }
- }
|