修复bug

main
mula.liu 2026-08-31 18:32:09 +08:00
parent fef17e59e4
commit 5d41339c4a
4 changed files with 26 additions and 51 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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}>

View File

@ -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={[