Commit 2c758df2 authored by chenshouchao's avatar chenshouchao

feat: 文件服务器指向配置完成

parent 88a07105
......@@ -34,8 +34,13 @@ const API = function () {
// 文件服务器指向
const APIOPTION = function () {
// todo isPrivatization
const raysyncAddr = getLoaclStorageOfKey("raysyncAddr");
return raysyncAddr.fileServerEndPoint || "";
let fileServerEndPoint = localStorage.getItem("fileServerEndPoint");
if (fileServerEndPoint) {
return fileServerEndPoint;
} else {
const raysyncAddr = getLoaclStorageOfKey("raysyncAddr");
return raysyncAddr.fileServerEndPoint || "";
}
};
// api端口号
......
import { useStores } from "@/store/index";
import { elements } from "@/router";
import { current, } from "@/api/demo_api";
import { current } from "@/api/demo_api";
import { product } from "@/api/project_api";
import localStorageKey from "@/utils/localStorageKey";
......@@ -8,6 +8,7 @@ import NotFound from "@/views/404";
import useMyRequest from "@/hooks/useMyRequest";
import { useEffect } from "react";
import { menu } from "@/api/routes_api";
import { setFileServerEndPointLocalStorage } from "@/views/Project/project";
const useMyRouter = () => {
const { permissionStore, menuStore, currentProjectStore } = useStores();
......@@ -51,6 +52,7 @@ const useMyRouter = () => {
} else {
currentProjectStore.setProjectList(list);
currentProjectStore.changeProject(list[0]);
setFileServerEndPointLocalStorage(list[0].zoneId);
}
}
......
......@@ -28,6 +28,7 @@ import Loading from "@/views/Loading";
import MyDialog from "@/components/mui/MyDialog";
import { getProjectList } from "../../project";
import { checkIsNumberLetterChinese } from "@/utils/util";
import { setFileServerEndPointLocalStorage } from "@/views/Project/project";
type zoneIdOption = {
id: string;
......@@ -147,6 +148,7 @@ const BaseInfo = observer(() => {
const projectList = await getProjectList();
currentProjectStore.setProjectList(projectList);
currentProjectStore.changeProject(projectList[0]);
setFileServerEndPointLocalStorage(projectList[0].zoneId);
setProjectInfo(projectList[0]);
},
}
......
......@@ -7,6 +7,7 @@ import ProjectListPopper from "../ProjectListPopper";
import React, { useEffect, useState } from "react";
import { observer } from "mobx-react-lite";
import AddProject from "../AddProject";
import { setFileServerEndPointLocalStorage } from "@/views/Project/project";
const CurrentProject = observer(() => {
const { currentProjectStore } = useStores();
......@@ -31,6 +32,7 @@ const CurrentProject = observer(() => {
const id = canBeOpen ? "spring-popper" : undefined;
const handleChangeCurrentProject = (project: any) => {
currentProjectStore.changeProject(project);
setFileServerEndPointLocalStorage(project.zoneId);
setProjectListOpen(!projectListOpen);
};
......
import { product } from "@/api/project_api"
import { product, hpczone } from "@/api/project_api";
export const getProjectList = async () => {
const res = await product({product: "CADD",})
return res.data
}
\ No newline at end of file
const res = await product({ product: "CADD" });
return res.data;
};
export const setFileServerEndPointLocalStorage = async (zoneId: string) => {
const res = await hpczone();
console.log(res);
let fileServerEndPoint = "";
if (Array.isArray(res)) {
res.forEach((item: any) => {
if (item.id === zoneId) {
fileServerEndPoint = item.storageConfig.fileServerEndPoint;
}
});
localStorage.setItem("fileServerEndPoint", fileServerEndPoint);
}
};
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