|
|
|
|
@ -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' && <Badge color={temp === "zone" ? "#466aff" : "#089f7f"} text="待审核" className='pass'/> }
|
|
|
|
|
{detail.auditStatus === '2' && <Badge color="#eb1212" text="未通过" className='failed'/> }
|
|
|
|
|
</div>
|
|
|
|
|
<div className='pb20' dangerouslySetInnerHTML={{ __html: detail.summary }} ></div>
|
|
|
|
|
{mdContents && Object.keys(mdContents).length > 0 ? <div className="md-preview-box">
|
|
|
|
|
{mdFiles.map((file) => (
|
|
|
|
|
<div key={file.fileId} className="pb20">
|
|
|
|
|
<RenderHtml className="editor-content-panel mt20 imageLayerParent" value={ mdContents[file.fileId] || '加载中...' } url={history.location}/>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div> : <div className='pb20' dangerouslySetInnerHTML={{ __html: detail.summary }} ></div>}
|
|
|
|
|
{
|
|
|
|
|
detail.fileList && detail.fileList.length > 0 &&
|
|
|
|
|
files && files.length > 0 &&
|
|
|
|
|
<ul className="files_box">
|
|
|
|
|
{
|
|
|
|
|
detail.fileList.map((i,k)=>{
|
|
|
|
|
files.map((i,k)=>{
|
|
|
|
|
return(
|
|
|
|
|
<li>
|
|
|
|
|
<img src={SourceFile} alt="" width="20px" className="mr12"/>
|
|
|
|
|
|