diff --git a/src/App.js b/src/App.js index 4662cc13..84f4e114 100644 --- a/src/App.js +++ b/src/App.js @@ -87,6 +87,7 @@ const Search = Loadable({ loader: () => import('./modules/search/'), loading: Loading, }) + const WikiPreview = Loadable({ loader: () => import('./forge/Wiki/Preview'), loading: Loading, @@ -139,6 +140,11 @@ const WebIDE = Loadable({ loader: () => import('./forge/Newfile/webIDE'), loading: Loading, }); + +const Badge = Loadable({ + loader: () => import('./forge/Badge/Index'), + loading: Loading, +}) // const CreateMerge = Loadable({ // loader: () => import('./forge/Merge/NewMerge'), // loading: Loading, @@ -328,6 +334,13 @@ class App extends Component { } } /> + {/* svg */} + { + return () + } + } /> + {/* webIDE */} { + const url = `/${owner}/${projectsId}/detail.json`; + axios.get(url).then((result) => { + if (result && result.data) { + if (result.data.status === 404) { + this.props.history.push('/nopage'); + } else { + setProjectDetail(result.data); + // seo优化设置 + let keyWords = `${owner},${projectsId},${result.data.author.name},`; + let title = `${owner}/${projectsId}${result.data.description ? ':' + result.data.description : ''}`; + setSeoMeta(keyWords, title, result.data.description, `/${owner}/${projectsId}`, owner, projectsId); + } + } + }).catch((error) => { }) + }, [projectsId, owner]); + + useEffect(() => { + if (projectDetail) { + if (type === "watch.svg") { + setText(`${coutTranslate(projectDetail.watchers_count)} 关注数`); + } else if (type === "star.svg") { + setText(`${coutTranslate(projectDetail.praises_count)} 点赞数`); + } else if (type === "fork.svg") { + setText(`${coutTranslate(projectDetail.forked_count)} Fork数`); + } + } + }, [type, projectDetail]); + + function coutTranslate(num) { + if (num < 1000) { + return num; + } else if (num >= 1000 & num < 10000) { + return (num / 1000).toFixed(1) + 'k'; + } else { + return (num / 1000).toFixed(0) + 'k'; + } + } + + return + + + + + + + + + + + + + + + + + + + + + + + + + + + -1 ? (text.length - 1.5) : text.length) + (text.includes('k ') && 0.5))} + x={64 + 6 * (7.5 - (text.indexOf("Fork") > -1 ? (text.length - 1.5) : text.length) + (text.includes('k ') && 0.5))} + y="30" lengthAdjust="spacing" transform="scale(.9)" weight="bold"> + {text} + + + + + + + + + + + +} + +export default Badge; \ No newline at end of file