Commit 2fccb697 authored by wuyongsheng's avatar wuyongsheng

feat: 添加当前用户项目缓存

parent e9493716
/*
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-07-11 11:49:55
* @LastEditors: 吴永生 15770852798@163.com
* @LastEditTime: 2022-08-23 16:46:45
* @FilePath: /bkunyun/src/store/modules/currentProject.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
type projectInfo = { type projectInfo = {
id?: string; id?: string;
...@@ -12,14 +20,22 @@ type productInfo = { ...@@ -12,14 +20,22 @@ type productInfo = {
name?: string; name?: string;
}; };
const sessionStorageCurrentProjectInfo = JSON.parse( /** 用户信息 */
sessionStorage.getItem("currentProjectInfo") || "{}" let userInfo: any;
try {
userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}");
} catch {
console.error("获取用户信息 出错");
}
const localStorageCurrentProjectInfo = JSON.parse(
localStorage.getItem(`currentProjectInfo_${userInfo.name}`) || "{}"
); );
const sessionStorageCurrentProductInfo = JSON.parse( const localStorageCurrentProductInfo = JSON.parse(
sessionStorage.getItem("currentProductInfo") || "{}" localStorage.getItem(`currentProductInfo_${userInfo.name}`) || "{}"
); );
const sessionStorageProjectList = JSON.parse( const localStorageProjectList = JSON.parse(
sessionStorage.getItem("projectList") || "[]" localStorage.getItem(`projectList_${userInfo.name}`) || "[]"
); );
class currentProject { class currentProject {
...@@ -28,22 +44,22 @@ class currentProject { ...@@ -28,22 +44,22 @@ class currentProject {
} }
// 选中的项目 // 选中的项目
currentProjectInfo: projectInfo = sessionStorageCurrentProjectInfo; currentProjectInfo: projectInfo = localStorageCurrentProjectInfo;
// 选中的产品下的项目列表 // 选中的产品下的项目列表
projectList: Array<projectInfo> = sessionStorageProjectList; projectList: Array<projectInfo> = localStorageProjectList;
// 选中的产品 // 选中的产品
currentProductInfo: productInfo = sessionStorageCurrentProductInfo; currentProductInfo: productInfo = localStorageCurrentProductInfo;
setProjectList = (list: Array<projectInfo>) => { setProjectList = (list: Array<projectInfo>) => {
this.projectList = list; this.projectList = list;
sessionStorage.setItem("projectList", JSON.stringify(list)); localStorage.setItem(`projectList_${userInfo.name}`, JSON.stringify(list));
}; };
changeProject = (project: projectInfo) => { changeProject = (project: projectInfo) => {
this.currentProjectInfo = project; this.currentProjectInfo = project;
sessionStorage.setItem("currentProjectInfo", JSON.stringify(project)); localStorage.setItem(`currentProjectInfo_${userInfo.name}`, JSON.stringify(project));
}; };
changeProductInfo = (productInfo: productInfo) => { changeProductInfo = (productInfo: productInfo) => {
this.currentProductInfo = productInfo; this.currentProductInfo = productInfo;
sessionStorage.setItem("currentProductInfo", JSON.stringify(productInfo)); localStorage.setItem(`currentProductInfo_${userInfo.name}`, JSON.stringify(productInfo));
}; };
} }
......
...@@ -125,7 +125,7 @@ const SeeDataset = observer((props: ISeeDatasetProps) => { ...@@ -125,7 +125,7 @@ const SeeDataset = observer((props: ISeeDatasetProps) => {
"sdf", "sdf",
"sdf2d", "sdf2d",
"sdf3d", "sdf3d",
"smiles", // "smiles",
].includes(item) ].includes(item)
) { ) {
arr.push({ label: item, value: item }); arr.push({ label: item, value: item });
......
...@@ -50,7 +50,6 @@ const BatchOperatorFlow = (props: IProps) => { ...@@ -50,7 +50,6 @@ const BatchOperatorFlow = (props: IProps) => {
showVersion = false, showVersion = false,
...other ...other
} = props; } = props;
console.log(tasks);
/** 自定义的节点类型 */ /** 自定义的节点类型 */
const nodeTypes = useMemo(() => { const nodeTypes = useMemo(() => {
return { batchNode: BatchNode, flowNode: FlowNode }; return { batchNode: BatchNode, flowNode: FlowNode };
......
...@@ -11,7 +11,7 @@ import ReactFlow, { ...@@ -11,7 +11,7 @@ import ReactFlow, {
import { useCallback, useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { uuid } from "@/utils/util"; import { uuid } from "@/utils/util";
import { IEdge, IParameter, ITask } from "../../ProjectSubmitWork/interface"; import { IParameter, ITask } from "../../ProjectSubmitWork/interface";
import { ILine } from "./interface"; import { ILine } from "./interface";
import BatchNode from "./components/BatchNode"; import BatchNode from "./components/BatchNode";
import FlowNode from "./components/FlowNode"; import FlowNode from "./components/FlowNode";
...@@ -61,7 +61,7 @@ const Flow = (props: IProps) => { ...@@ -61,7 +61,7 @@ const Flow = (props: IProps) => {
showControls = true, showControls = true,
...other ...other
} = props; } = props;
console.log(tasks);
/** 自定义的节点类型 */ /** 自定义的节点类型 */
const nodeTypes = useMemo(() => { const nodeTypes = useMemo(() => {
return { batchNode: BatchNode, flowNode: FlowNode }; return { batchNode: BatchNode, flowNode: FlowNode };
...@@ -221,7 +221,7 @@ const Flow = (props: IProps) => { ...@@ -221,7 +221,7 @@ const Flow = (props: IProps) => {
// const nodesInputAndOutputStatus = useCallback( // const nodesInputAndOutputStatus = useCallback(
// (id: string) => { // (id: string) => {
// /** 所有的连线 */ // /** 所有的连线 */
// const lineArr: IEdge[] = []; // const lineArr: ] = [];
// tasks?.length && // tasks?.length &&
// tasks.forEach((item) => { // tasks.forEach((item) => {
// item.edges?.length && lineArr.push(...item.edges); // item.edges?.length && lineArr.push(...item.edges);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment