修复bug
parent
fef17e59e4
commit
5d41339c4a
|
|
@ -1,13 +1,27 @@
|
|||
import { useState } from 'react'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Layout } from 'antd'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import AppSider from './AppSider'
|
||||
import AppHeader from './AppHeader'
|
||||
import './MainLayout.css'
|
||||
|
||||
const { Content } = Layout
|
||||
|
||||
// 项目详情页路由(浏览 / 编辑)
|
||||
const isProjectDetailPath = (pathname) => {
|
||||
return /^\/projects\/[^/]+\/(docs|editor)(\/|$)/.test(pathname)
|
||||
}
|
||||
|
||||
function MainLayout({ children }) {
|
||||
const [collapsed, setCollapsed] = useState(true)
|
||||
const location = useLocation()
|
||||
|
||||
// 进入项目详情页时,若左侧主菜单栏处于展开状态则自动收起
|
||||
useEffect(() => {
|
||||
if (isProjectDetailPath(location.pathname)) {
|
||||
setCollapsed(true)
|
||||
}
|
||||
}, [location.pathname])
|
||||
|
||||
const toggleCollapsed = () => {
|
||||
setCollapsed(!collapsed)
|
||||
|
|
|
|||
|
|
@ -28,33 +28,6 @@
|
|||
height: 100%;
|
||||
}
|
||||
|
||||
/* 侧栏收起时:左侧悬浮展开按钮 */
|
||||
.docs-sider-expand-btn {
|
||||
position: fixed;
|
||||
left: 12px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 30;
|
||||
width: 32px;
|
||||
height: 48px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--header-bg);
|
||||
color: var(--text-color-secondary);
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
||||
transition: color 0.2s ease, border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.docs-sider-expand-btn:hover {
|
||||
color: var(--link-color);
|
||||
border-color: var(--link-color);
|
||||
}
|
||||
|
||||
.docs-sider-header {
|
||||
padding: 12px 10px 12px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useState, useEffect, useRef, useMemo } from 'react'
|
||||
import { useParams, useNavigate, useSearchParams } from 'react-router-dom'
|
||||
import { Layout, Spin, Button, Tooltip, Modal, Input, Space, Dropdown, Empty, Switch, Select, TreeSelect, Radio, Alert } from 'antd'
|
||||
import { ShareAltOutlined, FileTextOutlined, FolderOutlined, FolderOpenOutlined, FilePdfOutlined, CopyOutlined, CloudDownloadOutlined, CloudUploadOutlined, ArrowLeftOutlined, ReloadOutlined, VerticalAlignTopOutlined, MenuUnfoldOutlined } from '@ant-design/icons'
|
||||
import { ShareAltOutlined, FileTextOutlined, FolderOutlined, FolderOpenOutlined, FilePdfOutlined, CopyOutlined, CloudDownloadOutlined, CloudUploadOutlined, ArrowLeftOutlined, ReloadOutlined, VerticalAlignTopOutlined } from '@ant-design/icons'
|
||||
import ReactMarkdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import rehypeRaw from 'rehype-raw'
|
||||
|
|
@ -61,7 +61,6 @@ function DocumentPage() {
|
|||
const [pdfUrl, setPdfUrl] = useState('')
|
||||
const [pdfFilename, setPdfFilename] = useState('')
|
||||
const [viewMode, setViewMode] = useState('markdown')
|
||||
const [siderCollapsed, setSiderCollapsed] = useState(false)
|
||||
const [gitRepos, setGitRepos] = useState([])
|
||||
// Git 同步范围弹窗状态
|
||||
const [gitSyncModalVisible, setGitSyncModalVisible] = useState(false)
|
||||
|
|
@ -132,7 +131,6 @@ function DocumentPage() {
|
|||
setMarkdownContent('')
|
||||
setTocItems([])
|
||||
setViewMode('folder')
|
||||
setSiderCollapsed(true)
|
||||
expandParentFolders(`${folderPath}/placeholder`)
|
||||
|
||||
// 从内容区点击进入子文件夹时,同时展开自身,保证与左侧文件树同步
|
||||
|
|
@ -151,7 +149,6 @@ function DocumentPage() {
|
|||
setMarkdownContent('')
|
||||
setTocItems([])
|
||||
setViewMode('folder')
|
||||
setSiderCollapsed(true)
|
||||
setOpenKeys([])
|
||||
|
||||
if (syncUrl) {
|
||||
|
|
@ -1262,7 +1259,7 @@ function DocumentPage() {
|
|||
<div className="project-docs-page">
|
||||
<Layout className="docs-layout">
|
||||
{/* 左侧目录 */}
|
||||
<Sider width={280} className="docs-sider" theme="light" collapsed={siderCollapsed} collapsedWidth={0}>
|
||||
<Sider width={280} className="docs-sider" theme="light">
|
||||
<div className="docs-sider-header">
|
||||
<div className="docs-sider-title-row">
|
||||
<button
|
||||
|
|
@ -1342,19 +1339,6 @@ function DocumentPage() {
|
|||
/>
|
||||
</Sider>
|
||||
|
||||
{/* 侧栏收起时:悬浮展开按钮 */}
|
||||
{siderCollapsed && (
|
||||
<button
|
||||
type="button"
|
||||
className="docs-sider-expand-btn"
|
||||
onClick={() => setSiderCollapsed(false)}
|
||||
aria-label="展开目录"
|
||||
title="展开目录"
|
||||
>
|
||||
<MenuUnfoldOutlined />
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* 右侧内容区 */}
|
||||
<Layout className="docs-content-layout">
|
||||
<Content className="docs-content" ref={contentRef}>
|
||||
|
|
|
|||
|
|
@ -44,10 +44,13 @@ function ProjectList({ type = 'my' }) {
|
|||
const [unreadByProject, setUnreadByProject] = useState({})
|
||||
const pageSize = 8
|
||||
|
||||
// 角色字段统一小写(兼容历史数据中的大小写差异)
|
||||
const normalizeRole = (role) => String(role || '').trim().toLowerCase()
|
||||
|
||||
// 参与项目角色 -> 显示名称
|
||||
const projectRoleLabel = (role) => {
|
||||
const roleMap = { admin: '管理员', editor: '编辑者', viewer: '查看者' }
|
||||
return roleMap[role] || role || '查看者'
|
||||
return roleMap[normalizeRole(role)] || role || '查看者'
|
||||
}
|
||||
|
||||
// 成员管理弹窗角色显示名
|
||||
|
|
@ -112,13 +115,14 @@ function ProjectList({ type = 'my' }) {
|
|||
const cardRoleClass = (project) => {
|
||||
if (type === 'my') return 'role-owner'
|
||||
const roleMap = { admin: 'role-admin', editor: 'role-editor', viewer: 'role-viewer' }
|
||||
return roleMap[project.user_role] || 'role-viewer'
|
||||
return roleMap[normalizeRole(project.user_role)] || 'role-viewer'
|
||||
}
|
||||
|
||||
// 卡片角色徽章图标
|
||||
const cardRoleIcon = (project) => {
|
||||
if (type === 'my' || project.user_role === 'admin') return <SafetyOutlined />
|
||||
if (project.user_role === 'editor') return <FormOutlined />
|
||||
const role = normalizeRole(project.user_role)
|
||||
if (type === 'my' || role === 'admin') return <SafetyOutlined />
|
||||
if (role === 'editor') return <FormOutlined />
|
||||
return <ReadOutlined />
|
||||
}
|
||||
|
||||
|
|
@ -1183,7 +1187,7 @@ function ProjectList({ type = 'my' }) {
|
|||
return (
|
||||
<Select
|
||||
size="small"
|
||||
value={role}
|
||||
value={normalizeRole(role)}
|
||||
style={{ width: 110 }}
|
||||
onChange={(newRole) => handleChangeMemberRole(record, newRole)}
|
||||
options={[
|
||||
|
|
|
|||
Loading…
Reference in New Issue