Compare commits
3 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
87bc88600e | |
|
|
6409ad6940 | |
|
|
5aae70e4c7 |
|
|
@ -56,4 +56,4 @@ export const deepRoutes = [
|
||||||
]
|
]
|
||||||
|
|
||||||
// 不进行组织或个人判断
|
// 不进行组织或个人判断
|
||||||
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", "admins", "oauth", "competitions", "hiagent","sf", "development", "governance"]
|
export const specialRoute = ["ossRepo", "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", "admins", "oauth", "competitions", "hiagent","sf", "development", "governance","explore"]
|
||||||
20
src/App.js
20
src/App.js
|
|
@ -236,6 +236,11 @@ const GovernanceIframe = Loadable({
|
||||||
loading: Loading,
|
loading: Loading,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const OssRepoIframe = Loadable({
|
||||||
|
loader: () => import("./forge/ossRepoIframe"),
|
||||||
|
loading: Loading,
|
||||||
|
});
|
||||||
|
|
||||||
const Forums = Loadable({
|
const Forums = Loadable({
|
||||||
loader: () => import("./forums"),
|
loader: () => import("./forums"),
|
||||||
loading: Loading,
|
loading: Loading,
|
||||||
|
|
@ -252,7 +257,7 @@ const AI = Loadable({
|
||||||
});
|
});
|
||||||
|
|
||||||
// 此处仅维护前端可能的一级路由,不用进行项目或者组织判断的字段。
|
// 此处仅维护前端可能的一级路由,不用进行项目或者组织判断的字段。
|
||||||
const keyWord = ["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", "hiagent","sf", "development", "governance", "forums", "news", "exploreStore", "factory", "zoneAdmin", "ai"];
|
const keyWord = ["ossRepo", "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", "hiagent","sf", "development", "governance", "explore","forums", "news", "exploreStore", "factory", "zoneAdmin", "ai"];
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
@ -636,7 +641,7 @@ class App extends Component {
|
||||||
<Route path="/search" component={Search} mygetHelmetapi={mygetHelmetapi} />
|
<Route path="/search" component={Search} mygetHelmetapi={mygetHelmetapi} />
|
||||||
|
|
||||||
{/* 项目标签列表页 */}
|
{/* 项目标签列表页 */}
|
||||||
<Route path="/explore/topic/:id/:name" component={Topic} mygetHelmetapi={mygetHelmetapi} />
|
<Route path="/ossRepo/topic/:id/:name" component={Topic} mygetHelmetapi={mygetHelmetapi} />
|
||||||
|
|
||||||
<Route path={"/:OIdentifier/enterprise"}
|
<Route path={"/:OIdentifier/enterprise"}
|
||||||
render={
|
render={
|
||||||
|
|
@ -723,7 +728,7 @@ class App extends Component {
|
||||||
<Projects {...this.props} {...props} />
|
<Projects {...this.props} {...props} />
|
||||||
)}
|
)}
|
||||||
></Route>
|
></Route>
|
||||||
<Route exact path="/explore"
|
<Route exact path="/ossRepo"
|
||||||
render={
|
render={
|
||||||
(props) => (
|
(props) => (
|
||||||
<Projects {...this.props} {...props} {...this.state}/>
|
<Projects {...this.props} {...props} {...this.state}/>
|
||||||
|
|
@ -745,6 +750,15 @@ class App extends Component {
|
||||||
}>
|
}>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<Route
|
||||||
|
path={"/explore"}
|
||||||
|
render={
|
||||||
|
(props) => {
|
||||||
|
return (<OssRepoIframe {...this.props} {...props} {...this.state} />)
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
</Route>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path={"/factory"}
|
path={"/factory"}
|
||||||
render={
|
render={
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import fetch from './fetch';
|
import fetch from './fetch';
|
||||||
|
import fetchLogin from './fetchLogin';
|
||||||
|
|
||||||
/**智能体分类列表***/
|
/**智能体分类列表***/
|
||||||
export function getAgentTypeList(params) {
|
export function getAgentTypeList(params) {
|
||||||
|
|
@ -16,4 +17,13 @@ export function getAgentList(params) {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params
|
params
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**智能体登录***/
|
||||||
|
export function agentLogin(data) {
|
||||||
|
return fetchLogin({
|
||||||
|
url: `/api/login/oauth/access_token`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ import { withRouter } from "react-router";
|
||||||
import { httpUrl } from '../../ai/fetch';
|
import { httpUrl } from '../../ai/fetch';
|
||||||
import cookie from 'react-cookies';
|
import cookie from 'react-cookies';
|
||||||
import { aiAgentLogin } from "../../forge/Information/api";
|
import { aiAgentLogin } from "../../forge/Information/api";
|
||||||
|
import { agentLogin } from "../api";
|
||||||
|
|
||||||
function Agent(props) {
|
function Agent(props) {
|
||||||
const { match, current_user, history, showLoginDialog } = props;
|
const { match, current_user, history, showLoginDialog } = props;
|
||||||
|
|
@ -30,15 +31,21 @@ function Agent(props) {
|
||||||
|
|
||||||
if (!agentCookie) {
|
if (!agentCookie) {
|
||||||
// Cookie中agent没有值,调用登录接口
|
// Cookie中agent没有值,调用登录接口
|
||||||
const res = await aiAgentLogin();
|
const res = await agentLogin({
|
||||||
|
grant_type: 'password',
|
||||||
|
client_id: '4b25ca036879216a020a',
|
||||||
|
username: 'hnxjy',
|
||||||
|
password: '123456',
|
||||||
|
scope: 'profile'
|
||||||
|
});
|
||||||
|
|
||||||
if (res && res.data && res.data.data) {
|
if (res && res.data && res.data) {
|
||||||
const { accessToken, expiresAt, expiresIn } = res.data.data;
|
const { access_token, expires_in } = res.data;
|
||||||
// expiresAt是开始时间,加上expiresIn(毫秒)得到过期时间
|
// 用当前时间 + expires_in(秒)计算过期时间
|
||||||
const expiryDate = new Date(expiresAt + expiresIn);
|
const expiryDate = new Date(Date.now() + (expires_in) * 1000);
|
||||||
|
|
||||||
// 将完整的token数据存储在agent Cookie中
|
// 将完整的token数据存储在agent Cookie中
|
||||||
currentTokenData = accessToken;
|
currentTokenData = access_token;
|
||||||
cookie.save('agent', currentTokenData, { expires: expiryDate, path: '/' });
|
cookie.save('agent', currentTokenData, { expires: expiryDate, path: '/' });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
import axios from 'axios';
|
||||||
|
import { message , notification } from 'antd';
|
||||||
|
import cookie from 'react-cookies';
|
||||||
|
|
||||||
|
function beforeFetch(actionUrl){
|
||||||
|
if (window.location.href.indexOf('localhost') < 0) {
|
||||||
|
axios.defaults.withCredentials = true;
|
||||||
|
}
|
||||||
|
const config = {
|
||||||
|
// headers:{Authorization:"Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjo0NCwidXNlcl9rZXkiOiI3NWY3MmJmYmE2NGU4N2U3NWVjNWMwZDk2OThkMDFiN2EyODE0YjYwIiwidXNlcm5hbWUiOiJpbm5vdiJ9.IviAyZQjPFc4rT3ejAKfJYx3_QgS78RCKHx1XS-A4uI_mrc7_l6wK76HVIoPCEvP0Qimzyc6dpeVW4cE2fILZw"},
|
||||||
|
baseURL: actionUrl,
|
||||||
|
timeout: 1800000, // 请求超时时间
|
||||||
|
}
|
||||||
|
|
||||||
|
const service = axios.create(config);
|
||||||
|
|
||||||
|
service.interceptors.request.use(request => {
|
||||||
|
// let deptId = sessionStorage.getItem('deptId')
|
||||||
|
// request.headers.Authorization = cookie.load('autologin_trustie')
|
||||||
|
// if (deptId) {
|
||||||
|
// // 用于权限区分
|
||||||
|
// request.headers['Dept-Id'] = deptId
|
||||||
|
// }
|
||||||
|
return request
|
||||||
|
})
|
||||||
|
|
||||||
|
service.interceptors.response.use(
|
||||||
|
response => {
|
||||||
|
const res = response||{};
|
||||||
|
if(res && res.data && res.data.code === 404){
|
||||||
|
message.error("错误链接!");
|
||||||
|
window.location.href = '/nopage';
|
||||||
|
return Promise.reject('error');
|
||||||
|
}else if(res && res.data && res.data.code === 500){
|
||||||
|
message.error(res.data.msg);
|
||||||
|
return Promise.reject('error');
|
||||||
|
}else{
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log(error);
|
||||||
|
// notification.open({
|
||||||
|
// message: "提示",
|
||||||
|
// description: error.message,
|
||||||
|
// });
|
||||||
|
// return Promise.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
let settings = localStorage.chromesetting&& localStorage.chromesetting !=="undefined"&& JSON.parse(localStorage.chromesetting);
|
||||||
|
// 根据当前IP判断使用哪个zone配置
|
||||||
|
const isSpecificIP = window.location.hostname.startsWith('27.');
|
||||||
|
// let actionUrl = settings && (isSpecificIP ? settings.common.zone : settings.common.zone_local) + '/zoneAdmin/api';
|
||||||
|
|
||||||
|
let actionUrl = settings && settings.common && settings.common.agent_login;
|
||||||
|
|
||||||
|
const service = beforeFetch(actionUrl);
|
||||||
|
export const httpUrl = actionUrl;
|
||||||
|
export default service;
|
||||||
|
|
@ -249,10 +249,12 @@ function List(props) {
|
||||||
if (res && res.data && res.data.rows) {
|
if (res && res.data && res.data.rows) {
|
||||||
setList(res.data.rows.map(row => {
|
setList(res.data.rows.map(row => {
|
||||||
const { projectProperties, id } = row;
|
const { projectProperties, id } = row;
|
||||||
|
const imageUrl = projectProperties.authorImageUrl.split(':4000/') && projectProperties.authorImageUrl.split(':4000/')[1]
|
||||||
|
const authorImageUrl = imageUrl ? `${window.location.origin}/${imageUrl}` : projectProperties.authorImageUrl
|
||||||
return {
|
return {
|
||||||
id: id,
|
id: id,
|
||||||
name: projectProperties.fromOwner === "AI-RESOURCE" ? projectProperties.name.split("/").pop() : projectProperties.name,
|
name: projectProperties.fromOwner === "AI-RESOURCE" ? projectProperties.name.split("/").pop() : projectProperties.name,
|
||||||
image: projectProperties.authorImageUrl,
|
image: authorImageUrl,
|
||||||
isNew: false,
|
isNew: false,
|
||||||
url: projectProperties.fullName,
|
url: projectProperties.fullName,
|
||||||
desc: projectProperties.description,
|
desc: projectProperties.description,
|
||||||
|
|
@ -398,9 +400,9 @@ function List(props) {
|
||||||
{list.map((model) => (
|
{list.map((model) => (
|
||||||
<ActionItem key={`${type}-${model.id}`} className="ai_home_card" padding="1px" borderRadius="12px">
|
<ActionItem key={`${type}-${model.id}`} className="ai_home_card" padding="1px" borderRadius="12px">
|
||||||
{type === "agents" ? <div>
|
{type === "agents" ? <div>
|
||||||
<div>
|
<div className="df">
|
||||||
<img src={model.image ? model.image : require(`../image/${model.id}.png`).default} width={46} className="mr15" style={{ borderRadius: '8px' }} />
|
<img src={model.image ? model.image : require(`../image/${model.id}.png`).default} width={46} className="mr15" style={{ borderRadius: '8px' }} />
|
||||||
<span className="font-18 font-bd">{model.name}</span>
|
<span className="font-18 font-bd task-hide">{model.name}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="color3f4 mt15 task-hide-2" style={{minHeight: 56}}>{model.desc}</div>
|
<div className="color3f4 mt15 task-hide-2" style={{minHeight: 56}}>{model.desc}</div>
|
||||||
<div className="btn-Box">
|
<div className="btn-Box">
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ class NewHeader extends Component {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "开源软件仓库",
|
"name": "开源软件仓库",
|
||||||
"link": "/explore",
|
"link": "/ossRepo",
|
||||||
"index": "2",
|
"index": "2",
|
||||||
"hidden": false
|
"hidden": false
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class Index extends Component {
|
||||||
></Route>
|
></Route>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path="/explore"
|
path="/ossRepo"
|
||||||
render={(props) => (
|
render={(props) => (
|
||||||
<ProjectHome {...this.props} {...props} />
|
<ProjectHome {...this.props} {...props} />
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC";
|
||||||
|
import loadingGIf from "./Images/loading.gif";
|
||||||
|
function OssRepo(props) {
|
||||||
|
const {current_user, mygetHelmetapi} = props;
|
||||||
|
const {admin, user_id} = current_user || {}
|
||||||
|
const {common} = mygetHelmetapi || {};
|
||||||
|
const {ossRepo="http://27.122.114.160:3001"} = common || {};
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
document.title = '开源软件仓库';
|
||||||
|
// document.body.style.background = '#fff';
|
||||||
|
return () => {
|
||||||
|
document.body.style.background = '';
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const url = `${ossRepo}/?uid=${user_id === 2 ? undefined : user_id}`
|
||||||
|
// const url = "http://localhost:3007/"
|
||||||
|
|
||||||
|
return <div className="" style={{border: "none"}}>
|
||||||
|
{loading && <div className="center" style={{minHeight: '60vh', marginTop: '30vh'}}>
|
||||||
|
<img src={loadingGIf} width={250}/>
|
||||||
|
<div className="font-16" style={{position: 'relative', top: '-40px', color: '#091221', opacity: '0.6'}}>加载中,请耐心等待</div>
|
||||||
|
</div>}
|
||||||
|
<iframe title={`ossRepoIframe`} src={url} id={`ossRepoIframe`} frameBorder="0" name={`ossRepoIframe`} width="100%" style={{height: '100vh', border: 'none'}} onLoad={()=>{setLoading(false)}}></iframe>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TPMIndexHOC(OssRepo);
|
||||||
|
|
@ -26,7 +26,9 @@ function ForumList({title="最新帖子", forumList, LIMIT, page, setPage, total
|
||||||
</div>
|
</div>
|
||||||
<div className="forums-list4-box pt5">
|
<div className="forums-list4-box pt5">
|
||||||
{forumList.map((item, index) => {
|
{forumList.map((item, index) => {
|
||||||
const orderIndex = index+LIMIT*(page-1)
|
const orderIndex = index+LIMIT*(page-1);
|
||||||
|
const imageUrl = item.image_url.split(':4000/') && item.image_url.split(':4000/')[1]
|
||||||
|
const authorImageUrl = imageUrl ? `${window.location.origin}/${imageUrl}` : item.image_url
|
||||||
return <div className="forums-list4-item">
|
return <div className="forums-list4-item">
|
||||||
<div className="pr80 AlignCenter">
|
<div className="pr80 AlignCenter">
|
||||||
{orderIndex < 3 ? <img src={sortImg1[orderIndex]} width={24} className="mr10"/> : <span className="font-bd font-20 mr10">{orderIndex + 1}</span>}
|
{orderIndex < 3 ? <img src={sortImg1[orderIndex]} width={24} className="mr10"/> : <span className="font-bd font-20 mr10">{orderIndex + 1}</span>}
|
||||||
|
|
@ -39,7 +41,7 @@ function ForumList({title="最新帖子", forumList, LIMIT, page, setPage, total
|
||||||
<i className="iconfont icon-jiantou21 font-16"></i>
|
<i className="iconfont icon-jiantou21 font-16"></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="opacity8 mt15 forums-list4-item-bottom">
|
<div className="opacity8 mt15 forums-list4-item-bottom">
|
||||||
<img src={item.image_url} alt="" className="user-img" />
|
<img src={authorImageUrl} alt="" className="user-img" />
|
||||||
{item.username}
|
{item.username}
|
||||||
<span className="ml10">{item.published_time}</span>
|
<span className="ml10">{item.published_time}</span>
|
||||||
<Divider type="vertical" />
|
<Divider type="vertical" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue