cont.
This commit is contained in:
parent
96475ab739
commit
771a2ba19a
|
@ -30,9 +30,9 @@ const terserPlugin = new TerserWebpackPlugin({
|
|||
terserOptions: {
|
||||
compress: {
|
||||
warnings: false,
|
||||
drop_console: false,
|
||||
drop_console: true,
|
||||
drop_debugger: true,
|
||||
// pure_funcs: ['console.log'] //移除console
|
||||
pure_funcs: ['console.log'] //移除console
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -145,6 +145,7 @@
|
|||
"scripts": {
|
||||
"start": "node scripts/start.js",
|
||||
"build": "cross-env NODE_ENV=production babel-node --max_old_space_size=15360 scripts/build.js",
|
||||
"build:server": "cross-env NODE_ENV=production webpack --config config/webpack.server.js",
|
||||
"build:dll": "webpack --config=./config/webpack.dll.config.js",
|
||||
"test-build": "cross-env NODE_ENV=testBuild node --max_old_space_size=15360 scripts/build.js",
|
||||
"pre-build": "NODE_ENV=preBuild node --max_old_space_size=15360 scripts/build.js",
|
||||
|
|
|
@ -35,7 +35,6 @@ function excludePath(req, res, next) {
|
|||
app.use(excludePath);
|
||||
|
||||
app.get('*',function (req,res) {
|
||||
console.log('render', req.url)
|
||||
render(req,res);
|
||||
})
|
||||
|
||||
|
|
|
@ -9,14 +9,13 @@ import { getPathType } from './service'
|
|||
import { serverStore } from "../src/redux/stores/configureStore";
|
||||
import App from "../src/App";
|
||||
import { Route } from 'react-router-dom';
|
||||
import { setDefaultMeta } from '../src/common/UrlTool'
|
||||
|
||||
export const render = async (req,res)=>{
|
||||
let _route = null,
|
||||
_match = null;
|
||||
|
||||
const pathData = await getPathType('Eeeros')
|
||||
const store = serverStore();
|
||||
|
||||
let store = serverStore();
|
||||
|
||||
function matchSubRoutes(routes, url) {
|
||||
for (const route of routes) {
|
||||
|
@ -66,9 +65,11 @@ export const render = async (req,res)=>{
|
|||
</Provider>
|
||||
))
|
||||
|
||||
|
||||
// 注入state
|
||||
|
||||
if (!content) {
|
||||
// 未匹配到详情页恢复默认header
|
||||
setDefaultMeta()
|
||||
} else {
|
||||
// 匹配到服务端渲染页面注入state
|
||||
let script = domObj.window.document.getElementById('initState')
|
||||
if (!script) {
|
||||
script = domObj.window.document.createElement('script')
|
||||
|
@ -77,13 +78,16 @@ export const render = async (req,res)=>{
|
|||
script.textContent = `window.__initState__ = ${ JSON.stringify(store.getState()) }`
|
||||
|
||||
domObj.window.document.head.appendChild(script);
|
||||
}
|
||||
|
||||
|
||||
let html = domObj.serialize()
|
||||
|
||||
|
||||
const prepHTML=(data,rootString)=>{
|
||||
data=data.replace('<div id="root" class="page -layout-v -fit widthunit"></div>',`<div id="root" class="page -layout-v -fit widthunit">${rootString}</div>`);
|
||||
return data;
|
||||
}
|
||||
res.send(prepHTML(html, content))
|
||||
|
||||
store = null
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import { SnackbarHOC } from 'educoder';
|
|||
import { initAxiosInterceptors } from './AppConfig'
|
||||
import cookie from 'react-cookies';
|
||||
import InfosIndex from './forge/users/Index'
|
||||
import OrganizeIndex from './forge/Team/Index'
|
||||
|
||||
window.marked = marked;
|
||||
const theme = createMuiTheme({
|
||||
|
@ -80,10 +81,10 @@ const http500 = Loadable({
|
|||
// loading: Loading,
|
||||
// })
|
||||
// 组织
|
||||
const OrganizeIndex = Loadable({
|
||||
loader: () => import('./forge/Team/Index'),
|
||||
loading: Loading,
|
||||
})
|
||||
// const OrganizeIndex = Loadable({
|
||||
// loader: () => import('./forge/Team/Index'),
|
||||
// loading: Loading,
|
||||
// })
|
||||
|
||||
const Search = Loadable({
|
||||
loader: () => import('./modules/search/'),
|
||||
|
|
|
@ -349,12 +349,9 @@ export function setSeoMeta(keyWords, title, description, url, owner, projectId)
|
|||
if(projectId)keyStatement += `/${projectId}`;
|
||||
|
||||
if (domObj) {
|
||||
console.log('==================domObj===================')
|
||||
document = domObj.window.document
|
||||
console.log('==================document===================', document.querySelector(`meta[property='og:title']`).content)
|
||||
}
|
||||
document.querySelector(`meta[property='og:title']`).content = title + keyStatement + ' for gitlink' + keyStatement + ' for git';
|
||||
console.log('==================document===================', document.querySelector(`meta[property='og:title']`).content)
|
||||
document.querySelector(`meta[property='og:url']`).content = window.location.origin + url;
|
||||
document.querySelector(`meta[property='og:description']`).content = description + ' - ' + title + ' for gitlink' + keyStatement + ' for git';
|
||||
document.querySelector(`meta[property='og:image:alt']`).content = description + ' - ' + title + ' for gitlink' + keyStatement + ' for git';
|
||||
|
@ -374,3 +371,23 @@ export function setSeoMeta(keyWords, title, description, url, owner, projectId)
|
|||
domObj.window.document.querySelector('meta[name="Keywords"]')
|
||||
}
|
||||
}
|
||||
|
||||
export function setDefaultMeta() {
|
||||
|
||||
if (domObj) {
|
||||
document = domObj.window.document
|
||||
}
|
||||
document.querySelector(`meta[property='og:title']`).content = 'GitLink | 确实开源';
|
||||
document.querySelector(`meta[property='og:url']`).content = 'https://gitlink.org.cn/';
|
||||
document.querySelector(`meta[property='og:description']`).content = 'GitLink,新一代开源创新服务平台 分布式协作开发 一站式过程管理 高效流水线运维 多层次代码分析 多维度用户画像 分布式协作开发 基于Git打造分布式代码托管环境';
|
||||
document.querySelector(`meta[property='og:image:alt']`).content = 'GitLink | 确实开源';
|
||||
document.querySelector('meta[name="Keywords"]').content= 'gitLink,GitLink,gitlink,git,trustie,trustieforge,forge,开源,确实开源,代码托管,Git,开源,内源,项目管理,版本控制,开源代码,代码分享,项目协作,开源项目托管,免费代码托管,Git代码托管,Git托管服务,确实让创建更美好,协同开发平台';
|
||||
document.querySelector(`meta[name='description']`).content = 'GitLink,新一代开源创新服务平台 分布式协作开发 一站式过程管理 高效流水线运维 多层次代码分析 多维度用户画像 分布式协作开发 基于Git打造分布式代码托管环境';
|
||||
document.querySelector(`meta[name='go-import']`).content ='gitlink.org.cn git https://gitlink.org.cn';
|
||||
document.querySelector(`meta[name='octolytics-dimension-user_login']`).content = 'GitLink';
|
||||
document.querySelector(`meta[name='octolytics-dimension-repository_nwo']`).content = 'GitLink';
|
||||
document.querySelector(`meta[name='octolytics-dimension-repository_network_root_nwo']`).content = 'GitLink';
|
||||
document.querySelector(`meta[name='twitter:title']`).content = 'GitLink | 确实开源';
|
||||
document.querySelector(`meta[name='twitter:description']`).content = 'GitLink,新一代开源创新服务平台 分布式协作开发 一站式过程管理 高效流水线运维 多层次代码分析 多维度用户画像 分布式协作开发 基于Git打造分布式代码托管环境';
|
||||
document.querySelector(`link[rel='canonical']`).href = 'https://gitlink.org.cn';
|
||||
}
|
|
@ -105,7 +105,6 @@ export default ({
|
|||
rs = dompurify.sanitize(rs.replace(/▁/g, "▁▁▁"))
|
||||
rs = rs.replaceAll('<img ', `<img onerror="javascript:this.src='${ imgError }';"`)
|
||||
resetMathExpressions()
|
||||
console.log('==========================rs=====================', rs)
|
||||
return rs
|
||||
}, [str,issues]);
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import RenderHtml from '../../components/render-html';
|
|||
function CoderDepot(props){
|
||||
// const [ projectDetail , setProjectDetail ]= useState(undefined);
|
||||
let { platform , mirror_status , bannerList , projectDetail, projectEntries, projectReadMe } = props ;
|
||||
console.log('==================projectReadMe=========', projectReadMe)
|
||||
|
||||
projectDetail = props.defaultDetail || projectDetail || {}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ const $ = window.$;
|
|||
|
||||
function CoderDepotReadme({ operate , history , readme , ChangeFile }){
|
||||
const [ menuList ,setMenuList ] = useState(undefined);
|
||||
const [ content ,setContent ] = useState(undefined);
|
||||
const [ content ,setContent ] = useState( (readme && readme.replace_content) || undefined );
|
||||
|
||||
useEffect(()=>{
|
||||
if(readme && readme.replace_content){
|
||||
|
|
|
@ -186,7 +186,6 @@ const getBannerFunc = (owner, projectsId, isServer = false) => {
|
|||
class Detail extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
console.log('=================defaultDetail================', props.defaultDetail)
|
||||
this.state = {
|
||||
projectDetail: props.defaultDetail || undefined,
|
||||
isManager: false,
|
||||
|
@ -255,12 +254,10 @@ class Detail extends Component {
|
|||
|
||||
if (!this.props.projectBase) {
|
||||
const data = await getProjectFunc(owner, projectsId);
|
||||
console.log('======================getProjectFunc==============')
|
||||
if (data.data) {
|
||||
this.getProject(data.data)
|
||||
}
|
||||
} else {
|
||||
console.log('======================this.props.projectBase==============')
|
||||
this.getProject(this.props.projectBase)
|
||||
}
|
||||
}
|
||||
|
@ -305,18 +302,14 @@ class Detail extends Component {
|
|||
secondSync: false,
|
||||
mirror_status:0
|
||||
})
|
||||
console.log('==================projectMenu=========', this.props.projectMenu)
|
||||
this.getBanner(this.props.projectMenu)
|
||||
let projectdata
|
||||
if (this.props.defaultDetail) {
|
||||
console.log('========================this.props.defaultDetail=================')
|
||||
projectdata = this.props.defaultDetail
|
||||
} else {
|
||||
console.log('========================getDetailFunc=================')
|
||||
projectdata = await getDetailFunc(owner, projectsId, !window.location.host).data;
|
||||
}
|
||||
if (projectdata) {
|
||||
console.log('========================projectdata=================')
|
||||
this.getDetail(projectdata)
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +405,6 @@ class Detail extends Component {
|
|||
data = res.data
|
||||
}
|
||||
}
|
||||
console.log('=============data==============')
|
||||
if (data) {
|
||||
if (data.status === 404) {
|
||||
if (window.location.pathname.includes('/invite')) {
|
||||
|
|
|
@ -39,7 +39,7 @@ const ProjectDetail = Loadable({
|
|||
loader: () => import("../Main/Detail"),
|
||||
loading: Loading,
|
||||
});
|
||||
export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(
|
||||
const team = CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(
|
||||
((props)=>{
|
||||
|
||||
console.log(456)
|
||||
|
@ -117,4 +117,8 @@ export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(
|
|||
</div>
|
||||
)
|
||||
})
|
||||
))))
|
||||
)))
|
||||
|
||||
team.preFetch = ProjectDetail.preFetch
|
||||
|
||||
export default withRouter(team)
|
|
@ -6,16 +6,15 @@ import { withRouter } from "react-router";
|
|||
import { SnackbarHOC } from "educoder";
|
||||
import { CNotificationHOC } from "../../modules/courses/common/CNotificationHOC";
|
||||
import { TPMIndexHOC } from "../../modules/tpm/TPMIndexHOC";
|
||||
import ProjectDetail from "../Main/Detail";
|
||||
const Infos = Loadable({
|
||||
loader: () => import("./Infos"),
|
||||
loading: Loading,
|
||||
});
|
||||
// // forge项目详情
|
||||
// const ProjectDetail = Loadable({
|
||||
// loader: () => import("../Main/Detail"),
|
||||
// loading: Loading,
|
||||
// });
|
||||
// forge项目详情
|
||||
const ProjectDetail = Loadable({
|
||||
loader: () => import("../Main/Detail"),
|
||||
loading: Loading,
|
||||
});
|
||||
|
||||
class DetailTop extends Component {
|
||||
constructor(props) {
|
||||
|
|
|
@ -61,8 +61,13 @@ export function TPMIndexHOC(WrappedComponent) {
|
|||
window.removeEventListener('keyup', this.keyupListener)
|
||||
}
|
||||
componentWillMount() {
|
||||
// console.log(123)
|
||||
// this.fetchUsers();
|
||||
if (!__SERVER__) {
|
||||
this.fetchUsers();
|
||||
} else {
|
||||
this.setState({
|
||||
current_user: {}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -166,7 +171,7 @@ export function TPMIndexHOC(WrappedComponent) {
|
|||
publicNav:false
|
||||
})
|
||||
}
|
||||
let url = `/api/users/get_user_info.json`;
|
||||
let url = `/users/get_user_info.json`;
|
||||
axios.get(url).then((response) => {
|
||||
if (response && response.data) {
|
||||
this.initCommonState(response.data)
|
||||
|
@ -289,6 +294,7 @@ export function TPMIndexHOC(WrappedComponent) {
|
|||
};
|
||||
let path =this.props.location.pathname;
|
||||
let pathCheck = path.indexOf("/zone")>-1 && path.indexOf("/newdetail")>-1 && IsPC();
|
||||
console.log('+++++++++++++++++++++++++++++++fdsafgsda++++++++++++++')
|
||||
return (
|
||||
<div className="indexHOC">
|
||||
<SystemNotice
|
||||
|
@ -318,7 +324,7 @@ export function TPMIndexHOC(WrappedComponent) {
|
|||
<div className="newContainer newContainers">
|
||||
{!publicNav && <div style={{height:"58px"}}></div> }
|
||||
{
|
||||
// current_user &&
|
||||
current_user &&
|
||||
<WrappedComponent initCommonState={(user) => this.initCommonState(user)}
|
||||
{...this.props} {...this.state} {...common} >
|
||||
</WrappedComponent>
|
||||
|
|
|
@ -4,7 +4,6 @@ const baseUrl = 'https://www.gitlink.org.cn/api'
|
|||
|
||||
//
|
||||
export async function getProjectFunc (owner, projectsId) {
|
||||
console.log('4444444444444444444444444')
|
||||
const url = `${baseUrl}/${owner}/${projectsId}/simple.json`;
|
||||
return axios.get(url);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue