refactor: 代码架构重构 - 提取组件、统一状态管理和数据访问层

- 新增布局组件(SidebarBrand、SidebarUser、SidebarNavItem)
- 新增通用UI组件(EmptyState、StatusBadge、TagInput、SearchBar)
- 新增全局状态管理(UserContext)
- 新增自定义Hooks(usePageState、useNavigation)
- 新增统一数据访问层(src/services/api.js)
- 新增常量配置(constants/pages.js、constants/storageKeys.js)
- 样式文件模块化,拆分页面特定样式
- 更新README文档,添加组件和使用说明
- 同步OpenSpec规范到主specs目录
This commit is contained in:
2026-03-20 10:19:31 +08:00
parent f2e0ec047e
commit 56c08a34ff
27 changed files with 1812 additions and 199 deletions

View File

@@ -6,7 +6,10 @@
@use 'base' as *;
@use 'components' as *;
@use 'layout' as *;
@use 'pages' as *;
@use 'pages/console' as *;
@use 'pages/admin' as *;
@use 'pages/developer' as *;
@use 'pages/home' as *;
/* ============================================
原始样式内容(待进一步拆分)

View File

@@ -0,0 +1,142 @@
/* ============ 管理台页面样式 ============ */
/* 本文件包含管理台Admin相关的所有页面样式 */
/* 管理台侧边栏 */
.admin-sidebar {
width: 240px;
background: var(--color-bg-1);
border-right: 1px solid var(--color-border-2);
display: flex;
flex-direction: column;
flex-shrink: 0;
height: 100%;
}
.admin-sidebar-header {
padding: 16px;
border-bottom: 1px solid var(--color-border-2);
}
.admin-sidebar-nav {
flex: 1;
overflow-y: auto;
padding: 12px;
}
.admin-nav-item {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 12px;
border-radius: var(--radius-md);
cursor: pointer;
transition: background 0.2s;
color: var(--color-text-2);
font-size: 14px;
font-weight: 500;
margin-bottom: 2px;
}
.admin-nav-item:hover {
background: var(--color-bg-2);
color: var(--color-text-1);
}
.admin-nav-item.active {
background: var(--color-primary-light);
color: var(--color-primary);
}
.admin-nav-icon {
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.admin-nav-text {
flex: 1;
}
.admin-sidebar-user {
display: flex;
align-items: center;
gap: 12px;
padding: 16px;
border-top: 1px solid var(--color-border-2);
background: var(--color-bg-2);
cursor: pointer;
transition: background 0.2s;
}
.admin-sidebar-user:hover {
background: var(--color-bg-3);
}
.admin-sidebar-user-info {
flex: 1;
min-width: 0;
}
.admin-sidebar-user-name {
font-size: 14px;
font-weight: 600;
color: var(--color-text-1);
margin-bottom: 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.admin-sidebar-user-role {
font-size: 12px;
color: var(--color-text-3);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* 成员选择样式 */
.member-selection {
border: 1px solid var(--color-border-3);
border-radius: var(--radius-md);
max-height: 240px;
overflow-y: auto;
}
.member-checkbox-item,
.member-radio-item {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 14px;
cursor: pointer;
transition: background 0.15s;
border-bottom: 1px solid var(--color-border-2);
}
.member-checkbox-item:last-child,
.member-radio-item:last-child {
border-bottom: none;
}
.member-checkbox-item:hover,
.member-radio-item:hover {
background: var(--color-bg-2);
}
.member-checkbox-avatar {
width: 32px;
height: 32px;
border-radius: 50%;
background: linear-gradient(135deg, var(--color-primary) 0%, #8B5CF6 100%);
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
font-size: 13px;
font-weight: 600;
flex-shrink: 0;
}

View File

@@ -0,0 +1,73 @@
/* ============ 工作台页面样式 ============ */
/* 本文件包含工作台Console相关的所有页面样式 */
/* 聊天布局 */
.chat-layout {
display: flex;
flex-direction: column;
height: 100%;
background: var(--color-bg-1);
}
/* 聊天顶部栏 */
.chat-header {
height: var(--header-height);
background: var(--color-bg-1);
border-bottom: 1px solid var(--color-border-2);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
}
/* 聊天侧边栏 */
.chat-sidebar {
width: 260px;
background: var(--color-bg-2);
border-right: 1px solid var(--color-border-2);
display: flex;
flex-direction: column;
flex-shrink: 0;
height: 100%;
overflow: hidden;
}
/* 聊天内容区 */
.chat-content {
flex: 1;
display: flex;
flex-direction: column;
background: var(--color-bg-1);
}
/* 聊天消息区 */
.chat-messages {
flex: 1;
overflow-y: auto;
padding: 24px;
min-height: 0;
}
/* 会话项 */
.conversation-item {
padding: 12px 14px;
border-radius: var(--radius-md);
cursor: pointer;
margin-bottom: 4px;
transition: all var(--transition);
border: 1px solid transparent;
}
.conversation-item:hover {
background: var(--color-bg-1);
border-color: var(--color-border-2);
}
.conversation-item.active {
background: var(--color-bg-1);
border-color: var(--color-primary);
box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
}
/* 更多工作台样式请参考 global.scss 中的对应部分 */
/* 包括chat-input-wrapper, message-thinking, instance-stopped 等 */

View File

@@ -0,0 +1,91 @@
/* ============ 开发台页面样式 ============ */
/* 本文件包含开发台Developer相关的所有页面样式 */
/* 开发台复用了大量工作台的样式(如 .chat-sidebar 等) */
/* 开发台特有样式 */
.dev-detail-header {
display: flex;
gap: 20px;
align-items: flex-start;
}
.dev-detail-icon {
width: 72px;
height: 72px;
border-radius: 16px;
background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 32px;
flex-shrink: 0;
}
.dev-detail-main {
flex: 1;
}
.dev-detail-tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: 12px 0;
}
.dev-detail-tag {
padding: 4px 12px;
background: #F1F5F9;
border-radius: 999px;
font-size: 13px;
color: #64748B;
}
.dev-detail-stats {
display: flex;
gap: 24px;
color: #64748B;
font-size: 14px;
}
.dev-detail-section {
margin-top: 24px;
padding-top: 24px;
border-top: 1px solid #E2E8F0;
}
.dev-detail-section h3 {
font-size: 16px;
font-weight: 700;
margin-bottom: 12px;
}
.dev-info-row {
display: flex;
margin-bottom: 16px;
}
.dev-info-label {
width: 100px;
flex-shrink: 0;
color: #64748B;
font-size: 14px;
font-weight: 500;
}
.dev-info-value {
flex: 1;
color: #1E293B;
font-size: 14px;
}
/* 开发台返回按钮样式 */
.dev-back-btn {
display: inline-flex;
align-items: center;
gap: 6px;
cursor: pointer;
color: #3B82F6;
font-weight: 600;
margin-bottom: 16px;
}

222
src/styles/pages/_home.scss Normal file
View File

@@ -0,0 +1,222 @@
/* ============ 首页样式 ============ */
/* 本文件包含首页Home相关的所有页面样式 */
.home-layout {
min-height: 100vh;
display: flex;
flex-direction: column;
background: linear-gradient(180deg, #F8FAFC 0%, #FFFFFF 100%);
position: relative;
overflow: hidden;
}
.home-layout::before {
content: '';
position: absolute;
top: -30%;
right: -20%;
width: 800px;
height: 800px;
background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 60%);
pointer-events: none;
}
.home-layout::after {
content: '';
position: absolute;
bottom: -20%;
left: -10%;
width: 600px;
height: 600px;
background: radial-gradient(circle, rgba(139, 92, 246, 0.06) 0%, transparent 60%);
pointer-events: none;
}
.home-header {
padding: 0 48px;
height: 68px;
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
z-index: 1;
border-bottom: 1px solid var(--color-border-2);
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(12px);
}
.home-logo {
font-size: 18px;
font-weight: 800;
color: var(--color-text-1);
display: flex;
align-items: center;
gap: 10px;
letter-spacing: -0.3px;
}
.home-nav {
display: flex;
gap: 6px;
}
.home-nav a {
color: var(--color-text-2);
text-decoration: none;
padding: 9px 16px;
border-radius: 8px;
font-weight: 600;
font-size: 14px;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
align-items: center;
gap: 6px;
}
.home-nav a:hover {
color: var(--color-text-1);
background: var(--color-bg-2);
}
.home-main {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 48px 24px;
text-align: center;
position: relative;
z-index: 1;
}
.home-badge {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 14px;
background: var(--color-primary-light);
border: 1px solid rgba(59, 130, 246, 0.2);
border-radius: 999px;
color: var(--color-primary);
font-size: 13px;
font-weight: 700;
margin-bottom: 28px;
}
.home-badge-dot {
width: 8px;
height: 8px;
background: var(--color-success);
border-radius: 50%;
}
.home-title {
font-size: 56px;
font-weight: 800;
color: var(--color-text-1);
margin-bottom: 14px;
line-height: 1.15;
letter-spacing: -1.2px;
}
.home-title span {
background: linear-gradient(90deg, #3B82F6 0%, #8B5CF6 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.home-desc {
font-size: 18px;
color: var(--color-text-3);
margin-bottom: 44px;
max-width: 640px;
line-height: 1.7;
}
.home-buttons {
display: flex;
gap: 14px;
}
.home-btn {
padding: 13px 30px;
font-size: 15px;
font-weight: 700;
border-radius: 10px;
cursor: pointer;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 8px;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.home-btn.primary {
background: linear-gradient(135deg, #3B82F6 0%, #60A5FA 100%);
color: #FFFFFF;
border: none;
box-shadow: 0 8px 24px rgba(59, 130, 246, 0.25);
}
.home-btn.primary:hover {
transform: translateY(-2px);
box-shadow: 0 12px 32px rgba(59, 130, 246, 0.35);
}
.home-features {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
max-width: 860px;
margin-top: 64px;
}
.home-feature {
padding: 24px;
background: #FFFFFF;
border: 1px solid var(--color-border-2);
border-radius: 14px;
text-align: left;
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.home-feature:hover {
border-color: var(--color-border-3);
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
transform: translateY(-2px);
}
.home-feature-icon {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12px;
}
.home-feature-title {
font-size: 16px;
font-weight: 800;
color: var(--color-text-1);
margin-bottom: 8px;
}
.home-feature-desc {
font-size: 14px;
color: var(--color-text-3);
line-height: 1.6;
}
.home-footer {
padding: 28px;
text-align: center;
color: var(--color-text-4);
font-size: 13px;
font-weight: 500;
position: relative;
z-index: 1;
}