+
+ Wiki 编辑页面
+
+
+
+
标题
+ {helper(
+ "",
+ "name",
+ [
+ { required: true, message: "请输入标题" },
+ // { pattern: /[^`\[\]\/:*?''<>|%-+_]/g, message: '不允许部分特殊字符' }
+ ],
+
+ )}
+
+
+
+ {getFieldDecorator('content', {
+ rules: [{ required: true, message: "请输入wiki内容" }],
+ validateFirst: true
+ })()}
+
+
+ 添加模版
+
+
+ 周报
+ 月报
+
+
+
+
+ {permission &&
}
+
+
+ )
+})
\ No newline at end of file
diff --git a/src/forge/Wiki/Index.jsx b/src/forge/Wiki/Index.jsx
new file mode 100644
index 000000000..ed5c48996
--- /dev/null
+++ b/src/forge/Wiki/Index.jsx
@@ -0,0 +1,298 @@
+import React, { useEffect, useCallback, useState } from 'react';
+import { Button, Dropdown, Icon, Input, Menu, Tooltip, Select, Upload, message, Spin } from 'antd';
+import { getImageUrl, timeAgo } from 'educoder';
+import cookie from 'react-cookies';
+// import Loading from "../../Loading";
+import DelModal from './components/ModalFun';
+import Welcome from './Welcome';
+import { wikiPages, getWiki, deleteWiki } from './api';
+import { httpUrl, TokenKey } from './fetch';
+import './Index.scss';
+import { isArray } from 'lodash';
+const Search = Input.Search;
+const InputGroup = Input.Group;
+const { Option } = Select;
+
+export default (props) => {
+ const { match, current_user, history, showNotification, project, projectDetail } = props;
+ // const permission = projectDetail && projectDetail.permission !== "Reporter";
+ const permission = projectDetail && projectDetail.permission && projectDetail.permission !== "Reporter";
+
+ let projectsId = match.params.projectsId;
+ let owner = match.params.owner;
+
+ console.log(project);
+
+ const [fileArrInit, setFileArrInit] = useState(null);
+ const [checkItem, setCheckItem] = useState({});
+ const [itemDetail, setItemDetail] = useState({});
+
+ const [fileArr, setFileArr] = useState([]);
+ const [reload, setReload] = useState();
+
+ const [urlType, setUrlType] = useState('HTTPS');
+
+ // 加载wiki列表
+ useEffect(() => {
+ project && wikiPages({
+ owner: owner,
+ repo: projectsId,
+ projectId: project.id
+ }).then(res => {
+ if (res && res.message === "200" && isArray(res.data)) {
+ setFileArr(res.data);
+ setFileArrInit(res.data);
+ if (res.data.length) {
+ setCheckItem(res.data[0]);
+ };
+ } else {
+ setFileArr([]);
+ setFileArrInit([]);
+ }
+ });
+ }, [project, reload])
+
+ // 加载单个wiki详情,参数尽量用驼峰,此处由于后端太麻烦所以不标准
+ useEffect(() => {
+ project && checkItem.name && getWiki({
+ owner: owner,
+ repo: projectsId,
+ pagename: checkItem.name,
+ projectId: project.id
+ }).then(res => {
+ if (res && res.message === "200") {
+ setItemDetail(res.data);
+ } else {
+ showNotification("加载失败")
+ }
+ });
+ }, [project, checkItem]);
+
+ function changeSearchValue(e) {
+ let value = e.target.value;
+ let newFileArr = [];
+ for (const item of fileArrInit) {
+ if (item.name.indexOf(value) > -1) {
+ newFileArr.push(item);
+ }
+ }
+ setFileArr(newFileArr);
+ }
+
+ // 删除wiki模态框
+ function deleteFileModal(e, item) {
+ e.stopPropagation();
+ DelModal({
+ title: '删除页面',
+ contentTitle: `您确定要删除“${item.name}”此页面吗?`,
+ content: '此操作将删除该页面,请进行确认以防文件的丢失。',
+ onOk: () => {
+ deleteWiki({
+ owner: owner,
+ repo: projectsId,
+ pagename: item.name,
+ projectId: project.id
+ }).then(res => {
+ if (res && res.message === "200") {
+ message.success('删除成功');
+ setReload(Math.random());
+ } else {
+ message.error('删除失败');
+ }
+ });
+ }
+ });
+ }
+
+
+ function goUser(login) {
+ window.location.href = `/users/${login}`;
+ }
+
+ // 复制链接
+ const copyUrl = useCallback(() => {
+ let wikiUrl = document.getElementById("wikiUrl");
+ wikiUrl.select();
+ if (document.execCommand('copy')) {
+ document.execCommand('copy');
+ }
+ message.success('复制成功');
+ wikiUrl.blur();
+ }, [])
+
+ function addFile() {
+ history.push(`/projects/${owner}/${projectsId}/wiki/add`);
+ }
+
+ function goEdit() {
+ history.push(`/projects/${owner}/${projectsId}/wiki/edit/${encodeURI(checkItem.name)}`);
+ }
+
+ function preview() {
+ window.open(`/projects/${owner}/${projectsId}/wiki/preview/${encodeURI(project.name)}/${project.id}`);
+ }
+
+ // 支持 Markdown,Html,Pdf格式文件
+ const menu = (
+