From 8c4dd9d0a9c2d7b342c79d853b26ff0c4f318fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=83=E5=AE=87?= Date: Tue, 20 May 2025 09:44:52 +0800 Subject: [PATCH 1/5] =?UTF-8?q?wiki=E5=8E=86=E5=8F=B2=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/paths.js | 3 +- config/webpackDevServer.config.js | 4 + package.json | 1 - src/forge/Main/Detail.js | 10 +++ src/forge/Wiki/api.js | 18 +++++ src/forge/Wiki/fetch.js | 2 +- src/forge/Wiki/page/edit.jsx | 9 ++- src/forge/Wiki/page/historyList.jsx | 115 ++++++++++++++++++++++++++++ src/forge/Wiki/page/index.jsx | 1 + src/forge/Wiki/page/index.scss | 24 +++++- src/forge/Wiki/page/preview.jsx | 52 ++++++++----- src/setupProxy.js | 24 ++++++ src/ssrUrl.js | 3 +- 13 files changed, 240 insertions(+), 26 deletions(-) create mode 100644 src/forge/Wiki/page/historyList.jsx create mode 100644 src/setupProxy.js diff --git a/config/paths.js b/config/paths.js index c116b362a..c9e2c21fa 100644 --- a/config/paths.js +++ b/config/paths.js @@ -53,4 +53,5 @@ module.exports = { appNodeModules: resolveApp('node_modules'), publicUrl: getPublicUrl(resolveApp('package.json')), servedPath: getServedPath(resolveApp('package.json')), -}; + proxySetup: resolveApp('src/setupProxy.js'), +}; \ No newline at end of file diff --git a/config/webpackDevServer.config.js b/config/webpackDevServer.config.js index f12d31594..b1c2175b1 100644 --- a/config/webpackDevServer.config.js +++ b/config/webpackDevServer.config.js @@ -5,6 +5,7 @@ const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMi const ignoredFiles = require('react-dev-utils/ignoredFiles'); const config = require('./webpack.config.dev'); const paths = require('./paths'); +const fs = require('fs'); const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'; const host = process.env.HOST || '0.0.0.0'; @@ -90,6 +91,9 @@ module.exports = function(proxy, allowedHost) { // it used the same host and port. // https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432 app.use(noopServiceWorkerMiddleware()); + if (fs.existsSync(paths.proxySetup)) { + require(paths.proxySetup)(app); + } }, }; }; diff --git a/package.json b/package.json index 3d2d7daf5..53fff77af 100644 --- a/package.json +++ b/package.json @@ -202,7 +202,6 @@ "eslintConfig": { "extends": "react-app" }, - "proxy": "https://testforgeplus.trustie.net", "port": "3007", "devDependencies": { "@babel/core": "^7.23.6", diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 932372ded..ce033477c 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -135,6 +135,10 @@ const Wiki = Loadable({ loader: () => import('../Wiki/page/index'), loading: Loading, }); +const WikiHisList = Loadable({ + loader: () => import('../Wiki/page/historyList'), + loading: Loading, +}); const WikiEdit = Loadable({ loader: () => import('../Wiki/page/edit'), loading: Loading, @@ -817,6 +821,12 @@ class Detail extends Component { () => () } > + {/* wiki历史列表 */} + () + } + > {/* wiki */} { const {getFieldDecorator, validateFields, getFieldValue} = form; const wikiParams = {owner, repo: repoIdentifier, projectId: project_id}; let editType = pathname.split("/").pop(); //编辑wiki(addWiki addWikiBy${key} edit) + const sha = searchParams.get("sha") || ''; const [loading, setLoading] = useState(false); const [wikiPageInitDetail, setWikiPageInitDetail] = useState({}) @@ -42,9 +43,11 @@ export default Form.create()((props) => { const wikiName = searchParams.get("wiki") const sameNameWiki = findSamaNameWiki(wikiPages, wikiName) document.title = `${titleByEditType[editType]}${sameNameWiki.title}-维基-${projectAuthor && projectAuthor.name}/${projectName}`; - getWiki({ + const func = sha ? getPreviousWiki : getWiki + func({ ...wikiParams, - pageName: sameNameWiki.sub_url + pageName: sameNameWiki.sub_url, + sha }).then(res=>{ if(res && res.code === 200){ res.data.content = Base64.decode(res.data.content_base64) diff --git a/src/forge/Wiki/page/historyList.jsx b/src/forge/Wiki/page/historyList.jsx new file mode 100644 index 000000000..2e80f3dd3 --- /dev/null +++ b/src/forge/Wiki/page/historyList.jsx @@ -0,0 +1,115 @@ +import React, { useEffect, useState } from "react"; +import { Button, Table } from "antd"; +import { getWikiRevisions } from "../api"; + +import './index.scss'; + +export default (props) => { + const {project_id, match:{params:{owner, projectsId: repoIdentifier}}, projectDetail, history, location} = props; + const search = new URLSearchParams(location.search); + const pageName = search.get("wiki") || ''; + const title_sub = search.get("str") || ''; + const wikiParams = {owner, repo: repoIdentifier, projectId: project_id, pageName: title_sub}; + const permission = projectDetail && projectDetail.permission && projectDetail.permission !== "Reporter"; + const { author: projectAuthor, name: projectName} = projectDetail || {}; + + const [reload, setReload] = useState(); + const [loading, setLoading] = useState(); + const [ historyList, setHistoryList ] = useState([]); + + // 弹框编辑目录 + + useEffect(()=>{ + if(!project_id) return + document.title = `${pageName}历史版本-维基-${projectAuthor && projectAuthor.name}/${projectName}`; + getList() + // setWikiPageInitDetail({}) + // // 获取wiki 目录树、sidebar内容 + // getMenuListAndSidebarData(wikiParams).then(res=>{ + // setWikiPageInitDetail(res); + // }) + }, [project_id, reload]) + + function refush(){ + setReload(Math.random()) + } + + const getList = () => { + setLoading(true) + getWikiRevisions(wikiParams).then(res=>{ + setLoading(false) + if(res?.code === 200){ + setHistoryList(res.data?.commits); + } + }) + } + + const columns = [ + { + title: '修改时间', + dataIndex: ['author','date'], + }, + { + title: '修改记录', + dataIndex: 'message', + key: "message", + ellipsis: true, + }, + { + title: '修改人', + dataIndex: 'author', + key: "author", + ellipsis: true, + render:(value)=>{ + return( +
+ + {value?.name} +
+ ) + } + }, + { + title: '操作', + dataIndex: 'sha', + key: 'sha', + render: (text, record) => { + return
+ +
+ +
+ } + } + ]; + + + return
+
+
历史版本
+ +
+ +
+ record.id} + loading={loading} + >
+
+
+} \ No newline at end of file diff --git a/src/forge/Wiki/page/index.jsx b/src/forge/Wiki/page/index.jsx index b4f7c77b8..9d0496a5c 100644 --- a/src/forge/Wiki/page/index.jsx +++ b/src/forge/Wiki/page/index.jsx @@ -126,6 +126,7 @@ export default (props) => { {wikiDetail.userName} 上次修改于{wikiDetail.last_commit ? timeAgo(wikiDetail.last_commit.author.date) : '刚刚'} + 历史版本 {permission &&
diff --git a/src/forge/Wiki/page/index.scss b/src/forge/Wiki/page/index.scss index 0f98f10ee..92b2e9fef 100644 --- a/src/forge/Wiki/page/index.scss +++ b/src/forge/Wiki/page/index.scss @@ -112,7 +112,7 @@ display: flex; justify-content: space-between; align-items: center; - padding: 0 12rem 0 2rem; + padding: 0 2rem 0 2rem; width: 100%; height: 8vh; background: rgb(39, 47, 76); @@ -125,4 +125,26 @@ flex:none } } +} +.history { + .wiki-title { + font-weight: 700; + color: #202d40; + font-size: 17px; + } + .ant-table-thead > tr > th{ + background-color: #fff; + } + .ant-table-column-title { + color: #202d40; + font-size: 16px; + } + .divider { + opacity: 24%; + width: 0px; + height: 7px; + border-right: 1px solid; + border-color: #72748e; + display: inline-block; + } } \ No newline at end of file diff --git a/src/forge/Wiki/page/preview.jsx b/src/forge/Wiki/page/preview.jsx index ef859e248..52d391a2d 100644 --- a/src/forge/Wiki/page/preview.jsx +++ b/src/forge/Wiki/page/preview.jsx @@ -1,8 +1,8 @@ import React, { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { Base64 } from 'js-base64'; -import { Divider } from 'antd'; -import { getWiki, getMenuListAndSidebarData, findNodeByFirstOrContrastName, } from '../api'; +import { Divider, Button } from 'antd'; +import { getWiki, getMenuListAndSidebarData, findNodeByFirstOrContrastName, getPreviousWiki } from '../api'; import RenderHtml from '../../../components/render-html'; import TreeByWikiSidebar from '../components/treeByWikiSidebar'; import Clone from '../components/clone'; @@ -15,6 +15,7 @@ export default (props) => { const search = new URLSearchParams(location.search); const projectName = search.get("name") || ''; const wikiBySearch = search.get("wiki") || ''; + const sha = search.get("sha") || ''; const [wikiPageInitDetail, setWikiPageInitDetail] = useState({}) const [checkItem, setCheckItem] = useState({}); @@ -24,12 +25,13 @@ export default (props) => { useEffect(()=>{ if(checkItem && checkItem.name){ - document.title = `${checkItem.name}-维基预览` + document.title = `${checkItem.name || wikiBySearch}-维基预览` } }, [checkItem]) useEffect(()=>{ + if (sha) return // 获取wiki 目录树、sidebar内容 getMenuListAndSidebarData(wikiParams).then(res=>{ setWikiPageInitDetail(res); @@ -49,11 +51,13 @@ export default (props) => { setCheckItem(node); }, [menuList, wikiBySearch]) - useEffect(() => { - document.title = `${checkItem && checkItem.titleStr}-维基预览` - checkItem.title_sub && getWiki({ + useEffect(() => { + document.title = `${checkItem && checkItem.titleStr || wikiBySearch}-维基预览` + const func = sha ? getPreviousWiki : getWiki + func({ ...wikiParams, - pageName: checkItem.title_sub + pageName: checkItem.title_sub || wikiBySearch, + sha }).then(res => { if(res && res.code === 200){ setItemDetail(res.data); @@ -71,23 +75,35 @@ export default (props) => { {projectName}
-
克隆地址
- - + { + sha ? : <> +
克隆地址
+ + + + }
-
- {/* 读sidebar转换成目录树 */} - { - history.push(`${location.pathname}?name=${projectName}&wiki=${encodeURIComponent(node.titleStr)}`) - }}/> -
- + { + !sha &&
+ {/* 读sidebar转换成目录树 */} + { + history.push(`${location.pathname}?name=${projectName}&wiki=${encodeURIComponent(node.titleStr)}`) + }}/> +
+ } +
-

{checkItem.titleStr}

+

{itemDetail.title}

{itemDetail && itemDetail.content_base64 && }
diff --git a/src/setupProxy.js b/src/setupProxy.js new file mode 100644 index 000000000..567aed980 --- /dev/null +++ b/src/setupProxy.js @@ -0,0 +1,24 @@ +// src/setupProxy.js +const { createProxyMiddleware } = require('http-proxy-middleware'); + +module.exports = function(app) { + app.use( + '/api/wiki', + createProxyMiddleware({ + target: 'http://172.20.32.201:8000/', + changeOrigin: true, + logLevel: 'debug', // 开启 http-proxy-middleware 的日志 + // pathRewrite: { '^/api/wiki': '' }, // 根据需要取消注释和修改 + }) + ); + + app.use( + '/api', + createProxyMiddleware({ + target: 'http://172.20.32.201:4000/', + changeOrigin: true, + logLevel: 'debug', // 开启 http-proxy-middleware 的日志 + // pathRewrite: { '^/api': '' }, // 根据需要取消注释和修改 + }) + ); +}; diff --git a/src/ssrUrl.js b/src/ssrUrl.js index 4bf99bf81..df1d4b10e 100644 --- a/src/ssrUrl.js +++ b/src/ssrUrl.js @@ -1,4 +1,5 @@ -export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'https://testforgeplus.trustie.net' +// export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'https://testforgeplus.trustie.net' +export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'http://172.20.32.201:4000/' export const zoneUrl = process.env.NODE_ENV === 'production' ? 'https://gateway.gitlink.org.cn' : 'https://testgetway.trustie.net' export const host = process.env.NODE_ENV === 'production' ? 'www.gitlink.org.cn' : 'testforgeplus.trustie.net' From 74408d0ec3f37884605effe2105b094fe806e021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=83=E5=AE=87?= Date: Mon, 26 May 2025 10:55:44 +0800 Subject: [PATCH 2/5] wiki cont. --- src/forge/Wiki/fetch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/forge/Wiki/fetch.js b/src/forge/Wiki/fetch.js index 10413a169..ddfb54d1e 100644 --- a/src/forge/Wiki/fetch.js +++ b/src/forge/Wiki/fetch.js @@ -1,7 +1,7 @@ import javaFetch from '../javaFetch'; let settings = JSON.parse(localStorage.chromesetting); -let actionUrl = window.location.hostname === "localhost" ? settings && settings.common.wiki : ''; +let actionUrl = window.location.hostname !== "localhost" ? settings && settings.common.wiki : ''; const service = javaFetch(actionUrl); export const httpUrl = actionUrl; From bc9dca588ebdfd6568edf3e43d74f3a59d17f2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=83=E5=AE=87?= Date: Thu, 19 Jun 2025 15:27:14 +0800 Subject: [PATCH 3/5] =?UTF-8?q?testforge=20=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssrUrl.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ssrUrl.js b/src/ssrUrl.js index df1d4b10e..05df5203e 100644 --- a/src/ssrUrl.js +++ b/src/ssrUrl.js @@ -1,5 +1,4 @@ -// export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'https://testforgeplus.trustie.net' -export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'http://172.20.32.201:4000/' +export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'https://testforgeplus.trustie.net' export const zoneUrl = process.env.NODE_ENV === 'production' ? 'https://gateway.gitlink.org.cn' : 'https://testgetway.trustie.net' export const host = process.env.NODE_ENV === 'production' ? 'www.gitlink.org.cn' : 'testforgeplus.trustie.net' From e8d8f3ce7843fc333675a541e670f5180566e6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=83=E5=AE=87?= Date: Thu, 19 Jun 2025 20:14:08 +0800 Subject: [PATCH 4/5] =?UTF-8?q?wiki=E5=8E=86=E5=8F=B2=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Wiki/page/preview.jsx | 5 +++-- src/services/project.js | 14 +++++++------- src/setupProxy.js | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/forge/Wiki/page/preview.jsx b/src/forge/Wiki/page/preview.jsx index 52d391a2d..78571940f 100644 --- a/src/forge/Wiki/page/preview.jsx +++ b/src/forge/Wiki/page/preview.jsx @@ -16,6 +16,7 @@ export default (props) => { const projectName = search.get("name") || ''; const wikiBySearch = search.get("wiki") || ''; const sha = search.get("sha") || ''; + const str = search.get("str") || ''; const [wikiPageInitDetail, setWikiPageInitDetail] = useState({}) const [checkItem, setCheckItem] = useState({}); @@ -53,10 +54,10 @@ export default (props) => { useEffect(() => { document.title = `${checkItem && checkItem.titleStr || wikiBySearch}-维基预览` - const func = sha ? getPreviousWiki : getWiki + const func = sha ? getPreviousWiki : getWiki func({ ...wikiParams, - pageName: checkItem.title_sub || wikiBySearch, + pageName: checkItem.title_sub || str, sha }).then(res => { if(res && res.code === 200){ diff --git a/src/services/project.js b/src/services/project.js index 1aa9345f1..ea2f62e5a 100644 --- a/src/services/project.js +++ b/src/services/project.js @@ -15,13 +15,13 @@ const axiosInstance = axios.create({ }); axiosInstance.interceptors.request.use( config => { - if (window.location.port === "3007") { - if (config.url.indexOf('?') === -1) { - config.url = `${config.url}?debug=admin`; - } else { - config.url = `${config.url}&debug=admin`; - } - } + // if (window.location.port === "3007") { + // if (config.url.indexOf('?') === -1) { + // config.url = `${config.url}?debug=admin`; + // } else { + // config.url = `${config.url}&debug=admin`; + // } + // } return config; }, err => { diff --git a/src/setupProxy.js b/src/setupProxy.js index 567aed980..2b1f845c4 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -5,7 +5,7 @@ module.exports = function(app) { app.use( '/api/wiki', createProxyMiddleware({ - target: 'http://172.20.32.201:8000/', + target: 'http://testgetway.trustie.net/', changeOrigin: true, logLevel: 'debug', // 开启 http-proxy-middleware 的日志 // pathRewrite: { '^/api/wiki': '' }, // 根据需要取消注释和修改 @@ -15,7 +15,7 @@ module.exports = function(app) { app.use( '/api', createProxyMiddleware({ - target: 'http://172.20.32.201:4000/', + target: 'http://testforgeplus.trustie.net/', changeOrigin: true, logLevel: 'debug', // 开启 http-proxy-middleware 的日志 // pathRewrite: { '^/api': '' }, // 根据需要取消注释和修改 From 48a84d8c12b4659e428623c006da4b7c8be35b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=83=E5=AE=87?= Date: Fri, 20 Jun 2025 09:10:52 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96cont.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Wiki/page/preview.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/forge/Wiki/page/preview.jsx b/src/forge/Wiki/page/preview.jsx index 78571940f..a41d43003 100644 --- a/src/forge/Wiki/page/preview.jsx +++ b/src/forge/Wiki/page/preview.jsx @@ -57,7 +57,7 @@ export default (props) => { const func = sha ? getPreviousWiki : getWiki func({ ...wikiParams, - pageName: checkItem.title_sub || str, + pageName: str, sha }).then(res => { if(res && res.code === 200){