From 6aec8a8bea63c65b0b12ca52a3f909c716f9f7dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= Date: Fri, 3 Apr 2026 16:16:24 +0800 Subject: [PATCH] =?UTF-8?q?nscc=E4=B8=93=E5=8C=BA=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E9=99=84=E4=BB=B6:=E8=8B=A5=E4=B8=BAmd=E7=B1=BB=E5=9E=8B,?= =?UTF-8?q?=E5=88=99=E6=B8=B2=E6=9F=93md=E5=86=85=E5=AE=B9=E4=B8=BA?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Information/Pages/sourceDetail.jsx | 67 +++++++++++++++++--- src/forge/Information/api.js | 8 +++ src/forge/Information/index.scss | 3 + 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/src/forge/Information/Pages/sourceDetail.jsx b/src/forge/Information/Pages/sourceDetail.jsx index 775df358f..1a6c7d0f2 100644 --- a/src/forge/Information/Pages/sourceDetail.jsx +++ b/src/forge/Information/Pages/sourceDetail.jsx @@ -1,7 +1,7 @@ import React , { useEffect , useState } from 'react'; import { Badge, Breadcrumb } from 'antd'; import SourceFile from '../img/sourceFile.png'; -import { getSourceDetail } from '../api'; +import { getFileByZone, getSourceDetail } from '../api'; import { Link } from 'react-router-dom'; import { httpUrl } from '../fetch'; import { AlignCenter, FlexAJ } from '../../Component/layout'; @@ -9,11 +9,17 @@ import SourceIcon from '../img/sourceIcon.png'; import { addMeta, setSeoMeta } from 'educoder'; import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils'; import {setZoneVisits} from '../api' +import axios from 'axios'; +import RenderHtml from '../../../components/render-html'; function SourceDetail(props){ const { deptId , sourceid } = props.match.params; const [ detail , setDetail ] = useState(undefined); + const [files, setFiles] = useState([]); + const [mdFiles, setMdFiles] = useState([]); + const [mdContents, setMdContents] = useState(undefined); + const zonedetail = props.data; const {temp} = props; @@ -51,12 +57,51 @@ function SourceDetail(props){ } } - function getDetails(){ - getSourceDetail(sourceid).then(response=>{ - if(response){ + function getDetails() { + getSourceDetail(sourceid).then(response => { + if (response) { setDetail(response.data.data); + const { fileList } = response.data.data; + if (deptId === "NSCC") { + initMDContent(fileList) + }else{ + setFiles(fileList); + } + } - }).catch(error=>{}) + }).catch(error => { }) + } + + async function initMDContent(fileList) { + const mdFileList = fileList.filter(item => + item.fileOriginName && item.fileOriginName.toLowerCase().endsWith('.md') + ); + + const nonMdFiles = fileList.filter(item => + !item.fileOriginName || !item.fileOriginName.toLowerCase().endsWith('.md') + ); + setFiles(nonMdFiles); + + if (mdFileList.length > 0) { + setMdFiles(mdFileList); + + try { + const contents = await Promise.all( + mdFileList.map(async (file) => { + const res = await axios.get(`${httpUrl}/file/open/download/${file.fileId}`, { + responseType: 'text' + }); + return { [file.fileId]: res.data }; + }) + ); + + // 合并所有结果为单个对象 + setMdContents(contents.reduce((acc, item) => ({ ...acc, ...item }), {})); + + } catch (error) { + console.error('获取 md 文件失败:', error); + } + } } return( @@ -84,12 +129,18 @@ function SourceDetail(props){ {detail.auditStatus === '0' && } {detail.auditStatus === '2' && } -
+ {mdContents && Object.keys(mdContents).length > 0 ?
+ {mdFiles.map((file) => ( +
+ +
+ ))} +
:
} { - detail.fileList && detail.fileList.length > 0 && + files && files.length > 0 &&
    { - detail.fileList.map((i,k)=>{ + files.map((i,k)=>{ return(
  • diff --git a/src/forge/Information/api.js b/src/forge/Information/api.js index 84ec12934..132732774 100644 --- a/src/forge/Information/api.js +++ b/src/forge/Information/api.js @@ -5,6 +5,14 @@ export function getImage(identifier) { return `${ httpUrl }/file/open/downloadByIdentifier/${ identifier }` } +export function getFileByZone(fileId) { + return fetch({ + url: `${ httpUrl }/file/open/download/${ fileId }`, + method: 'get', + params + }); +} + /**入口页接口***/ export function getMainInfos(deptId, params) { return fetch({ diff --git a/src/forge/Information/index.scss b/src/forge/Information/index.scss index 4ce42df7e..0400f8d21 100644 --- a/src/forge/Information/index.scss +++ b/src/forge/Information/index.scss @@ -2069,6 +2069,8 @@ border: none; } &.zone_source_box .sources .source_left_ul{ + width: 272px; + align-items: flex-start; border-right: 1px solid rgba(76, 88, 118, 0.1); } &.zone_source_box .sources .source_left_ul li.active{ @@ -2092,6 +2094,7 @@ } } &.zone_source_box .sources .source_lists .source_lists_card{ + width: 280px; background-image: url('./img/sourceCardBack1.png'); background-color: transparent; }