diff --git a/package-lock.json b/package-lock.json index 1cb3733d3..6f4ada7df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5068,11 +5068,11 @@ } }, "echarts": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/echarts/-/echarts-4.7.0.tgz", - "integrity": "sha512-NlOTdUcAsIyCCG+N4uh0ZEvXtrPW2jvcuqf03RyqYeCKzyPbiOQ4I3MdKXMhxG3lBdqQNdNXVT71SB4KTQjN0A==", + "version": "4.9.0", + "resolved": "https://registry.nlark.com/echarts/download/echarts-4.9.0.tgz", + "integrity": "sha1-qbm6oD8Doqcx5jQMVb77V6nhNH0=", "requires": { - "zrender": "4.3.0" + "zrender": "4.3.2" } }, "editor.md": { @@ -9898,6 +9898,11 @@ "esprima": "^4.0.0" } }, + "js2wordcloud": { + "version": "1.1.12", + "resolved": "https://registry.npm.taobao.org/js2wordcloud/download/js2wordcloud-1.1.12.tgz", + "integrity": "sha1-8BdC2k5qyzAAsoY1dmQWjvn8o64=" + }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", @@ -14030,7 +14035,7 @@ }, "qr.js": { "version": "0.0.0", - "resolved": "https://registry.npm.taobao.org/qr.js/download/qr.js-0.0.0.tgz", + "resolved": "https://registry.npmjs.org/qr.js/-/qr.js-0.0.0.tgz", "integrity": "sha1-ys6GOG9ZoNuAUPqQ2baw6IoeNk8=" }, "qrcode.react": { @@ -20538,9 +20543,9 @@ } }, "zrender": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/zrender/-/zrender-4.3.0.tgz", - "integrity": "sha512-Dii6j2bDsPkxQayuVf2DXJeruIB/mKVxxcGRZQ9GExiBd4c3w7+oBuvo1O/JGHeFeA1nCmSDVDs/S7yKZG1nrA==" + "version": "4.3.2", + "resolved": "https://registry.npm.taobao.org/zrender/download/zrender-4.3.2.tgz", + "integrity": "sha1-7HQy+UFcgsc1hLa3uMR+GwFiCcY=" } } } diff --git a/package.json b/package.json index dbd948e0b..f69e3af90 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dompurify": "^2.0.15", "dotenv": "4.0.0", "dotenv-expand": "4.2.0", - "echarts": "^4.7.0", + "echarts": "^4.9.0", "editor.md": "^1.5.0", "eslint": "4.10.0", "eslint-config-react-app": "^2.1.0", @@ -47,6 +47,7 @@ "install": "^0.12.2", "jest": "20.0.4", "js-base64": "^2.5.2", + "js2wordcloud": "^1.1.12", "katex": "^0.11.1", "lodash": "^4.17.15", "loglevel": "^1.6.8", diff --git a/src/components/render-html.jsx b/src/components/render-html.jsx index 3601ea323..b24fc092a 100644 --- a/src/components/render-html.jsx +++ b/src/components/render-html.jsx @@ -46,18 +46,18 @@ export default ({ let id = decodeURIComponent(u.split("#")[1]); let ele = document.getElementById(id); if(ele){ - window.scrollTo(0, ele.offsetTop + 220); + window.scrollTo(0, ele.offsetTop + 120); } } } - },[url]) + },[url,html]) const el = useRef(); function onAncherHandler(e) { - let target = e.target + let target = e.target; if (target.tagName.toUpperCase() === 'A') { - let ancher = target.getAttribute('href') - if (ancher.startsWith('#')) { + let ancher = target.getAttribute('href'); + if (ancher && ancher.startsWith('#')) { e.preventDefault() let viewEl = document.getElementById(ancher.replace('#', '')) if (viewEl) { diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index 9b13e8c3d..56ea54fae 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -45,7 +45,8 @@ function CoderDepot(props){ const [ desc , setDesc ] = useState(undefined); const [ website , setWebsite ] = useState(undefined); const [ lesson_url , setLessonUrl ] = useState(undefined); - const [ readme , setReadme ] = useState(undefined) + const [ readme , setReadme ] = useState(undefined); + const [ defaultBranch , setDefaultBranch ] = useState(undefined) const owner = props.match.params.owner; const projectsId = props.match.params.projectsId; @@ -59,6 +60,7 @@ function CoderDepot(props){ setDesc(details.description); setWebsite(details.website); setLessonUrl(details.lesson_url); + setDefaultBranch(details.default_branch); } },[details]) @@ -72,17 +74,17 @@ function CoderDepot(props){ useEffect(()=>{ - if (projectsId && owner){ + if (projectsId && owner && defaultBranch){ if(pathname.indexOf(`/projects/${owner}/${projectsId}`) > -1 && pathname.indexOf(`/tree/${branchName}/`) > -1) { let url = pathname.split(`/tree/${branchName}/`)[1]; setTreeValue(url); getFileInfo(url,branchName); }else{ setTreeValue(undefined); - getDirInfo(branchName ||(projectDetail && projectDetail.default_branch)); + getDirInfo(branchName || defaultBranch); } } - },[projectsId,owner,pathname]) + },[projectsId,owner,pathname,defaultBranch]) // 获取主目录列表 function getDirInfo(branch){ @@ -159,8 +161,8 @@ function CoderDepot(props){ // 文件相关的下拉项 const fileMenu =(
) @@ -176,7 +178,7 @@ function CoderDepot(props){ // 页面地址返回到主目录 function returnMain(){ setTreeValue(undefined); - let branch = branchName || (projectDetail && projectDetail.default_branch); + let branch = branchName || defaultBranch; props.history.push(`/projects/${owner}/${projectsId}/tree/${branch}`); }; // 子目录路径返回链接 @@ -186,7 +188,7 @@ function CoderDepot(props){ // 点击跳转到子目录 function goToSubRoot(path,type,filename){ setType(type); - props.history.push(`/projects/${owner}/${projectsId}${`/tree/${branchName || (projectDetail && projectDetail.default_branch)}`}${path?`/${path}`:""}`); + props.history.push(`/projects/${owner}/${projectsId}${`/tree/${branchName || defaultBranch}`}${path?`/${path}`:""}`); } function onEdit(readOnly){ @@ -194,7 +196,7 @@ function CoderDepot(props){ } function ChangeFile(path, readOnly){ //点击直接跳转页面 加载一次路由 - props.history.push(`/projects/${owner}/${projectsId}/tree/${branchName || (projectDetail && projectDetail.default_branch)}/${path}`); + props.history.push(`/projects/${owner}/${projectsId}/tree/${branchName || defaultBranch}/${path}`); setType("file"); setReadOnly(readOnly); }; @@ -253,7 +255,7 @@ function CoderDepot(props){ owner={owner} projectsId={projectsId} name={projectDetail && projectDetail.name} - branch={branchName || (projectDetail && projectDetail.default_branch)} + branch={branchName || defaultBranch} visible={visible} onClose={()=>setVisible(false)} list = {mainFlag ? dirInfo : undefined} @@ -278,14 +280,14 @@ function CoderDepot(props){