From fbc0904eb3ec27406ceb7f01ea6644346202915f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=83=E5=AE=87?= Date: Fri, 16 Jun 2023 15:14:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E5=88=B6=E4=B8=93=E5=8C=BA=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E8=B7=AF=E5=BE=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 10 +---- src/forge/Information/Component/hot.jsx | 2 +- src/forge/Information/Component/newsBox.jsx | 8 ++-- .../Information/Component/publicBanner.jsx | 14 +++--- src/forge/Information/Pages/headerPage.jsx | 11 +++-- .../Information/Pages/headerPageZone1.jsx | 11 +++-- src/forge/Information/Pages/main.jsx | 19 ++++---- src/forge/Information/Pages/newsDetail.jsx | 6 +-- src/forge/Information/Pages/newsList.jsx | 10 ++--- src/forge/Information/Pages/projectSource.jsx | 8 ++-- src/forge/Information/Pages/zoneVIP.jsx | 9 ++-- src/forge/Information/index.jsx | 43 +++++++++++-------- src/forge/Information/tempInfo.js | 4 ++ 13 files changed, 77 insertions(+), 78 deletions(-) diff --git a/src/App.js b/src/App.js index eb6985bae..d1c049dc0 100644 --- a/src/App.js +++ b/src/App.js @@ -160,7 +160,7 @@ const Topic = 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","zone1"]; +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"]; class App extends Component { constructor(props) { @@ -388,14 +388,6 @@ class App extends Component { } }> - { - return () - } - }> - {k+1} - {i.name} + {i.name} ) }) diff --git a/src/forge/Information/Component/newsBox.jsx b/src/forge/Information/Component/newsBox.jsx index 43e5b44ad..9bab62d8f 100644 --- a/src/forge/Information/Component/newsBox.jsx +++ b/src/forge/Information/Component/newsBox.jsx @@ -14,14 +14,14 @@ function PublicBanner(props){
- {newsList[0].name} + {newsList[0].name}

{newsList[0].summary}

{newsList[0].publishTime}

- 查看详情 + 查看详情

    @@ -29,14 +29,14 @@ function PublicBanner(props){ newsList.map((i,k)=>{ return( k > 0 &&
  • - {i.name} + {i.name}

    {i.summary}

    {i.publishTime} - 查看详情 + 查看详情

  • ) diff --git a/src/forge/Information/Component/publicBanner.jsx b/src/forge/Information/Component/publicBanner.jsx index 50ee32583..e77a19036 100644 --- a/src/forge/Information/Component/publicBanner.jsx +++ b/src/forge/Information/Component/publicBanner.jsx @@ -10,9 +10,7 @@ function PublicBanner(props){ const [ key , setKey ] = useState("1"); const { deptId } = props.match.params; const { pathname } = props.history.location; - const { data , adminUrl } = props; - const temp = props.pathName - + const { data , adminUrl, temp } = props; useEffect(()=>{ if(pathname){ @@ -20,7 +18,7 @@ function PublicBanner(props){ const infodetail = /[A-Za-z0-9]{0,}\/newdetail/g; const project = /[A-Za-z0-9]{0,}\/projects/g; const vip = /[A-Za-z0-9]{0,}\/VIP/g; - if(pathname === `/${temp}/${deptId}`){ + if(pathname === `/zone/${deptId}`){ setKey("1"); } else if(project.test(pathname)){ @@ -46,12 +44,12 @@ function PublicBanner(props){ }
    - 首页 - 开源项目 + 首页 + 开源项目 {/* 资源发布 */} - { tempConfig[temp].mainTitle } + { tempConfig[temp].mainTitle } {/* Sig小组 */} - { tempConfig[temp].member } + { tempConfig[temp].member } { adminUrl && {window.location.href=adminUrl}}>后台管理 }
    diff --git a/src/forge/Information/Pages/headerPage.jsx b/src/forge/Information/Pages/headerPage.jsx index ef34b4b14..a69f77b92 100644 --- a/src/forge/Information/Pages/headerPage.jsx +++ b/src/forge/Information/Pages/headerPage.jsx @@ -15,8 +15,7 @@ function HeaderPage(props){ const [ newsList, setNewsList ] = useState(undefined); const [ partnerList, setParterList ] = useState(undefined); const { deptId } = props.match.params; - const { data, id } = props; - const temp = props.pathName + const { data, id, temp } = props; useEffect(()=>{ if(id){ @@ -90,14 +89,14 @@ function HeaderPage(props){
    - {newsList[0].name} + {newsList[0].name}

    {newsList[0].summary}

    {newsList[0].publishTime}

    - 查看详情 + 查看详情

      @@ -105,14 +104,14 @@ function HeaderPage(props){ newsList.map((i,k)=>{ return( k > 0 &&
    • - {i.name} + {i.name}

      {i.summary}

      {i.publishTime} - 查看详情 + 查看详情

    • ) diff --git a/src/forge/Information/Pages/headerPageZone1.jsx b/src/forge/Information/Pages/headerPageZone1.jsx index 23d38e472..dd7aef2a9 100644 --- a/src/forge/Information/Pages/headerPageZone1.jsx +++ b/src/forge/Information/Pages/headerPageZone1.jsx @@ -29,8 +29,7 @@ function HeaderPage(props){ const [ newsList, setNewsList ] = useState(undefined); const [ partnerList, setParterList ] = useState(undefined); const { deptId } = props.match.params; - const { data, id } = props; - const temp = props.pathName + const { data, id, temp } = props; const vision = [ {imageUrl: vision0, title: '促进技术创新和应用', content: '通过开源硬件社区的建设,可以让更多的人参与到硬件开发中来,激发大众的创造力和创新精神,从而推动硬件领域的技术创新和实际应用。'}, @@ -154,7 +153,7 @@ function HeaderPage(props){

      1 - {newsList[0].name} + {newsList[0].name}

      {newsList[0].summary}

      @@ -162,7 +161,7 @@ function HeaderPage(props){ {newsList[0].publishTime} - 查看更多 + 查看更多

        @@ -170,11 +169,11 @@ function HeaderPage(props){ newsList.map((i,k)=>{ return( k > 0 && - +
      • {k + 1} - {i.name} + {i.name}

        {i.summary}

        diff --git a/src/forge/Information/Pages/main.jsx b/src/forge/Information/Pages/main.jsx index 89c38d930..398658fa9 100644 --- a/src/forge/Information/Pages/main.jsx +++ b/src/forge/Information/Pages/main.jsx @@ -11,7 +11,7 @@ import liulan from '../img/liulan.png'; import emptydata from '../../Images/nodata.png'; import DefaultImg from '../Component/defaultImg'; import { httpUrl } from '../fetch'; -import { tempConfig } from '../tempInfo'; +import { tempConfig, tempEnum } from '../tempInfo'; function Main(props){ const [ key , setKey ] = useState("1"); @@ -22,14 +22,13 @@ function Main(props){ const [ isSpin , setIsSpin ] = useState(true); const [ newCateId , setNewCateId ] = useState(undefined); const { deptId , cateId } = props.match.params; - const { id } = props; - const temp = props.pathName + const { id, temp } = props; useEffect(()=>{ if(id) { setIsSpin(true); - if (temp === 'zone') { + if (temp === tempEnum.zone) { getMainList(); } else { getCateList(); @@ -50,7 +49,7 @@ function Main(props){ if(result){ let rows = result.data.rows; setMainList(rows); - if (temp !== 'zone') { + if (temp !== tempEnum.zone) { selectCate(rows[0].id) } setTimeout(() => { @@ -71,7 +70,7 @@ function Main(props){ if(result){ let rows = result.data.rows; setMainList(rows); - if (temp !== 'zone') { + if (temp !== tempEnum.zone) { selectCate(rows[0].id) } setIsSpin(false); @@ -103,7 +102,7 @@ function Main(props){ function selectCate(id) { setNewCateId(id) - props.history.push(`/${temp}/${deptId}/news/${id}`) + props.history.push(`/zone/${deptId}/news/${id}`) } return( @@ -114,13 +113,13 @@ function Main(props){ { mainList && mainList.length>0 && ( - temp === 'zone' ? + temp === tempEnum.zone ?

        - 全部 + 全部 { mainList.map((i,k)=>{ return( - {i.name} + {i.name} ) }) } diff --git a/src/forge/Information/Pages/newsDetail.jsx b/src/forge/Information/Pages/newsDetail.jsx index d7c00fbb4..68633125e 100644 --- a/src/forge/Information/Pages/newsDetail.jsx +++ b/src/forge/Information/Pages/newsDetail.jsx @@ -12,7 +12,7 @@ function NewsDetail(props){ const [ detail , setDetail ] = useState(undefined); const [ cmsDir , setCmsDir ] = useState(undefined); const [ content , setContent]=useState(undefined); - const temp = props.pathName + const temp = props.temp useEffect(()=>{ if(id){ @@ -38,8 +38,8 @@ function NewsDetail(props){ detail &&
        - {tempConfig[temp].mainTitle} - { cmsDir && {cmsDir.name} } + {tempConfig[temp].mainTitle} + { cmsDir && {cmsDir.name} } 正文
        diff --git a/src/forge/Information/Pages/newsList.jsx b/src/forge/Information/Pages/newsList.jsx index ab7b49a49..67a84e154 100644 --- a/src/forge/Information/Pages/newsList.jsx +++ b/src/forge/Information/Pages/newsList.jsx @@ -11,6 +11,7 @@ import emptydata from '../../Images/nodata.png'; import nodata from '../img/nodata.png'; import { Link } from 'react-router-dom'; import { httpUrl } from '../fetch'; +import { tempEnum } from '../tempInfo'; function NewsList(props){ const { deptId , cateId } = props.match.params; @@ -22,8 +23,7 @@ function NewsList(props){ const [ mainList , setMainList ] = useState(undefined); const [ details , setDetails ] = useState(undefined); const [ menuSpin , setMenuSpin ] = useState(true); - const { id } = props; - const temp = props.pathName + const { id, temp } = props; useEffect(()=>{ @@ -121,7 +121,7 @@ function NewsList(props){ mainList && mainList.length>0 && mainList.map((i,k)=>{ return( -
        {props.history.push(`/${temp}/${deptId}/newdetail/${i.id}`)}} key={k}> +
        {props.history.push(`/zone/${deptId}/newdetail/${i.id}`)}} key={k}> { i.headImg ? @@ -129,7 +129,7 @@ function NewsList(props){ }
        - {i.name} + {i.name}

        {i.summary}

        @@ -145,7 +145,7 @@ function NewsList(props){ { mainList && mainList.length === 0 &&
        - +

        暂无数据~

        } diff --git a/src/forge/Information/Pages/projectSource.jsx b/src/forge/Information/Pages/projectSource.jsx index aebf94159..781284375 100644 --- a/src/forge/Information/Pages/projectSource.jsx +++ b/src/forge/Information/Pages/projectSource.jsx @@ -7,6 +7,7 @@ import Nodata from '../../Nodata'; import axios from 'axios'; import { httpUrl } from '../fetch'; import nodata from '../img/nodata.png'; +import { tempEnum } from '../tempInfo'; const { Search } = Input; @@ -21,8 +22,7 @@ function ProjectSource(props){ const [ searchName , setSearchName ] = useState(undefined); const [ value , setValue ] = useState(undefined); const [ loading , setLoading ] = useState(false); - const { id } = props; - const temp = props.pathName + const { id, temp } = props; useEffect(()=>{ if(id){ @@ -84,7 +84,7 @@ function ProjectSource(props){ {/* */}

        开源项目

        - { temp === 'zone1' &&

        聚合开源特色项目,搭建硬件开源服务桥梁

        } + { temp === tempEnum.zone1 &&

        聚合开源特色项目,搭建硬件开源服务桥梁

        }
        • 项目分类
        • @@ -166,7 +166,7 @@ function ProjectSource(props){ :"" } { - lists && lists.length === 0 && (temp === 'zone1' ? : ) + lists && lists.length === 0 && (temp === tempEnum.zone1 ? : ) }
        diff --git a/src/forge/Information/Pages/zoneVIP.jsx b/src/forge/Information/Pages/zoneVIP.jsx index b3d522d66..e5dcdda91 100644 --- a/src/forge/Information/Pages/zoneVIP.jsx +++ b/src/forge/Information/Pages/zoneVIP.jsx @@ -3,7 +3,7 @@ import Crown from '../img/crown.png'; import Nodata from '../../Nodata'; import { Link } from 'react-router-dom'; import { Spin, Button, Icon } from 'antd'; -import { tempConfig } from '../tempInfo' +import { tempConfig, tempEnum } from '../tempInfo' import MemberApply from '../Component/memberApply'; import { getVIPLists, getAuditStatus, applyJoin } from '../api'; import nodata from '../img/nodata.png'; @@ -22,8 +22,7 @@ function ZoneVIP(props){ const [ isSpin , setIsSpin ] = useState(true); const [ applyVisible , setApplyVisible ] = useState(false); const [ memberStatus , setMemberStatus] = useState(memberStatusEnum.notMember); - const { id, showNotification, checkIfLogin, showLoginDialog } = props; - const temp = props.pathName + const { id, showNotification, checkIfLogin, showLoginDialog, temp } = props; useEffect(()=>{ if(id){ @@ -95,7 +94,7 @@ function ZoneVIP(props){
        {i.typeName}
        - { temp === 'zone1' &&
        {i.typeName}
        } + { temp === tempEnum.zone1 &&
        {i.typeName}
        }

        {i.typeIntroduction}

        @@ -121,7 +120,7 @@ function ZoneVIP(props){
      : ( - temp === 'zone1' ? : + temp === tempEnum.zone1 ? : ) }
    diff --git a/src/forge/Information/index.jsx b/src/forge/Information/index.jsx index 056bc1f78..29d3fcd79 100644 --- a/src/forge/Information/index.jsx +++ b/src/forge/Information/index.jsx @@ -13,6 +13,7 @@ import PublicBanner from "./Component/publicBanner"; import './index.scss'; import "slick-carousel/slick/slick.css"; import "slick-carousel/slick/slick-theme.css"; +import { tempEnum } from "./tempInfo"; const VIP = Loadable({ loader: () => import("./Pages/zoneVIP"), @@ -51,7 +52,7 @@ function Index(props){ const [ adminUrl , setAdminUrl ] = useState(undefined); const { deptId } = props.match.params; const [ id , setId ] = useState(undefined); - const temp = props.pathName + const [ temp , setTemp ] = useState(tempEnum.zone); useEffect(()=>{ if(deptId){ @@ -59,21 +60,29 @@ function Index(props){ } },[deptId]) + useEffect(() => { + setTheme() + }, [temp]) + function setTheme() { document.getElementsByTagName("html")[0].dataset.theme = temp; } setTheme() function getDetail(){ - getMainInfos(deptId, { template: temp }).then(result=>{ + getMainInfos(deptId).then(result=>{ if(result){ if (result.code === 404) { props.history.push('/nopage'); return - } + } + let data = result.data; + if (data.template) { + setTemp( data.template ) + } setData(data); - document.title= data&& data.name; + document.title= data && data.name; setId(data.id); if(data.id){ getAdminUrl(data.id); @@ -93,42 +102,42 @@ function Index(props){ } return(
    - + { id && } ( -
    +
    )} > ( - + )} > ( - + )} > ( - + )} > ( -
    +
    )} > ( - temp === 'zone' ? : + temp === tempEnum.zone ? : )} > diff --git a/src/forge/Information/tempInfo.js b/src/forge/Information/tempInfo.js index 3ae2fe698..595b0fa67 100644 --- a/src/forge/Information/tempInfo.js +++ b/src/forge/Information/tempInfo.js @@ -1,3 +1,7 @@ +export const tempEnum = { + zone: 'zone', + zone1: 'zone1' +} export const tempConfig = { zone: { mainTitle: '领域资讯',