添加用户、组织主页

This commit is contained in:
黄心宇 2024-04-17 17:12:30 +08:00
parent b4b9b60aee
commit 3d00be91ff
5 changed files with 28 additions and 5 deletions

View File

@ -37,5 +37,13 @@ export const deepRoutes = [
key: "detail",
path: "/:owner/:projectsId",
// component: Detail,
},
{
key: "owner",
path: "/:owner",
// component: Detail,
}
]
]
// 不进行组织或个人判断
export const specialRoute = ["explore", "settings", "setting", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search", "organize", "login", "register", "resetPassword", "aboutus","educoder", "glcc","bindlogin", "softbot","zone", "undefined"]

View File

@ -28,7 +28,7 @@ const proxy = createProxyMiddleware(options('http://localhost:8081'));
// });
// 设置代理
app.use(['/api', '/images', '/system', '/favicon', '/robots.txt', '/sitemap*.xml', '/sitemap*.txt'], (req, res) => {
app.use(['/api', '/images', '/system', '/favicon', '/robots.txt', '/sitemap*.xml', '/sitemap*.txt', '/favicon.ico'], (req, res) => {
proxy(req, res);
});

View File

@ -3,7 +3,7 @@ import {renderToString} from "react-dom/server";
import {StaticRouter, matchPath} from "react-router-dom";
import {renderRoutes} from "react-router-config";
import Routes, { deepRoutes } from "../Routes";
import Routes, { deepRoutes, specialRoute } from "../Routes";
import { Provider } from "react-redux";
import { serverStore } from "../src/redux/stores/configureStore";
import App from "../src/App";
@ -50,7 +50,7 @@ export const render = async (req,res)=>{
code: 200,
};
if (_route) {
if (_route && !specialRoute.includes(_match.url && _match.url.replace('/', ''))) {
await changeHead(_route, _match.params)
} else {
return false

View File

@ -1,6 +1,6 @@
// 兜底方案先改head
import { setDefaultMeta, setSeoMeta } from '../src/common/UrlTool'
import { getProjectDetailFunc, getMainInfos, getNewsDetail } from '../src/services/project'
import { getProjectDetailFunc, getMainInfos, getNewsDetail, getOwnerInfo } from '../src/services/project'
export const changeHead = async ({ key }, params) => {
let res
@ -29,6 +29,15 @@ export const changeHead = async ({ key }, params) => {
setSeoMeta(`${data.name}`, data.name, data.subTitle || '', `/zone/${params.deptId}`)
}
break;
case 'owner':
console.log(params);
res = await getOwnerInfo(params.owner);
data = res.data
const name = data.nickname || data.username
if (data) {
setSeoMeta(`${name}`, name, data.description || '', `/${params.owner}`)
}
break;
default:
break;
}

View File

@ -37,6 +37,12 @@ export async function getProjectReadMe (owner, projectsId, branch) {
return axios.get(url, {params: { ref: branch }});
}
export async function getOwnerInfo (owner) {
const url = `${baseUrl}/owners/${owner}.json`;
return axios.get(url);
}
export async function getMainInfos (deptId) {
const url = `${baseZoneUrl}/zone/open/zoneKey/${deptId}`;
return axios.get(url);