Commit 2c758df2 authored by chenshouchao's avatar chenshouchao

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

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