Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import {
} from './refactor'
import { PathPlanningPage } from './refactor/pages/PathPlanning'
import { CourseContentPage } from './refactor/pages/CourseContent'
import { PathActivationDebugPage } from './refactor/pages/PathActivationDebug'

// CodeRunner重构版本 (使用refactor目录下的)
import { IntegratedCodeRunner } from './refactor/components/features/CodeRunner'

type AppView = 'landing' | 'profile' | 'dashboard' | 'profile-settings' |
'refactor-assessment' | 'refactor-goal-management' | 'refactor-path-planning' |
'refactor-course-content' | 'refactor-code-runner' | 'refactor-data-management' |
'refactor-path-activation-debug'
'refactor-course-content' | 'refactor-code-runner' | 'refactor-data-management'

const App = () => {
const [currentView, setCurrentView] = useState<AppView>('landing')
Expand Down Expand Up @@ -204,22 +202,9 @@ const App = () => {
</Layout>
)

case 'refactor-path-activation-debug':
return (
<Layout
title="🧪 路径激活调试"
onBack={handleBackToDashboard}
onHome={handleGoHome}
onLogout={handleLogout}
onProfileSwitch={handleProfileSwitch}
>
<PathActivationDebugPage onNavigate={handleRefactorNavigate} />
</Layout>
)

default:
return <LandingPage
onGetStarted={handleGetStarted}
return <LandingPage
onGetStarted={handleGetStarted}
onLogin={handleProfileLogin}
onDashboard={handleBackToDashboard}
onProfileSwitch={handleProfileSwitch}
Expand Down
40 changes: 18 additions & 22 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,28 @@
*/

// 导出API实例
export { learningApi } from './learningApi'
// 默认导出使用新版 Learning API v2
export { learningApiV2 as learningApi } from './learningApi_v2'
export { simpleApi } from './simpleApi'

// 导出核心类型
export type { APIResponse } from './learningApi'
export type {
LearningSystemStatus,
AgentInteraction,
GoalCategory,
GoalRecommendation,
SkillGapAnalysis,
PathGenerationConfig,
ContentGenerationConfig,
Exercise,
ProjectTemplate,
LearningGoal,
LearningPath,
export type { APIResponse } from './learningApi_v2'
export type {
SystemStatus,
LearningGoal,
LearningPath,
CourseUnit,
AbilityAssessment,
AssessmentInput,
GoalFormData,
PathProgressStats,
AbilitySummary,
ActivationResult,
GoalActivationStats
} from './learningApi'
AbilityProfile,
CreateGoalData,
CreatePathData,
SyncResult,
Profile,
CreateProfileInput,
UpdateProfileInput,
UpdateSettingsInput,
ProfileStats,
ProfileSettings
} from './learningApi_v2'

/**
* API使用工具函数
Expand Down
16 changes: 1 addition & 15 deletions src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AppleProfileSwitcher from './AppleProfileSwitcher'

interface DashboardProps {
onLogout: () => void
onNavigate: (view: 'refactor-assessment' | 'refactor-goal-management' | 'refactor-path-planning' | 'refactor-course-content' | 'refactor-code-runner' | 'refactor-data-management' | 'refactor-path-activation-debug' | 'profile-settings') => void
onNavigate: (view: 'refactor-assessment' | 'refactor-goal-management' | 'refactor-path-planning' | 'refactor-course-content' | 'refactor-code-runner' | 'refactor-data-management' | 'profile-settings') => void
onHome: () => void
}

Expand Down Expand Up @@ -209,20 +209,6 @@ const Dashboard: React.FC<DashboardProps> = ({ onLogout, onNavigate, onHome }) =
status: '数据工具',
available: true
},
{
id: 'path-activation-debug',
view: 'refactor-path-activation-debug' as const,
title: '🧪 路径激活调试',
description: '测试和验证路径激活、冻结功能是否正常工作',
icon: (
<svg className="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z" />
</svg>
),
color: 'from-yellow-500 to-orange-500',
status: '调试工具',
available: true
}
]

return (
Expand Down
41 changes: 20 additions & 21 deletions src/refactor/pages/DataManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ import { Alert, toast } from '../components/ui/Alert/Alert'
import { ConfirmModal, Modal } from '../components/ui/Modal/Modal'
import { Loading } from '../components/ui/Loading/Loading'
import { ProgressBar } from '../components/ui/ProgressBar/ProgressBar'
import { learningApiV2 } from '../../api/learningApi_v2'
import { learningApi } from '../../api'
// 使用any类型暂时解决类型问题
type LearningPath = any
import { getCurrentProfile } from '../../utils/profile'
import { LearningAPI } from '../../api/learningApi'
import {
Button as UiButton,
Alert as UiAlert,
Expand Down Expand Up @@ -75,7 +74,7 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
setLoading(true)
try {
// 获取当前Profile
const profileResponse = learningApiV2.getCurrentProfile()
const profileResponse = learningApi.getCurrentProfile()
if (!profileResponse.success || !profileResponse.data) {
toast.error('无法获取当前Profile')
return
Expand All @@ -85,8 +84,8 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
setCurrentProfile(profile)

// 获取学习数据 - 使用v2 API分别获取
const goalsResponse = await learningApiV2.getAllGoals()
const pathsResponse = await learningApiV2.getAllPaths()
const goalsResponse = await learningApi.getAllGoals()
const pathsResponse = await learningApi.getAllPaths()

const learningDataV2 = {
goals: goalsResponse.data || [],
Expand Down Expand Up @@ -160,8 +159,8 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
const handleExport = async () => {
try {
// v2版本暂时手动构建导出数据
const goalsResponse = await learningApiV2.getAllGoals()
const pathsResponse = await learningApiV2.getAllPaths()
const goalsResponse = await learningApi.getAllGoals()
const pathsResponse = await learningApi.getAllPaths()

const exportDataV2 = {
goals: goalsResponse.data || [],
Expand Down Expand Up @@ -193,10 +192,10 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga

switch (deleteConfirm.type) {
case 'goal':
result = await learningApiV2.deleteGoal(deleteConfirm.id)
result = await learningApi.deleteGoal(deleteConfirm.id)
break
case 'path':
result = await learningApiV2.deletePath(deleteConfirm.id)
result = await learningApi.deletePath(deleteConfirm.id)
break
case 'unit':
// v2暂时不支持,返回失败
Expand Down Expand Up @@ -258,7 +257,7 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga

for (const path of learningData.paths) {
try {
const result = await learningApiV2.deletePath(path.id)
const result = await learningApi.deletePath(path.id)
if (result.success) {
successCount++
} else {
Expand Down Expand Up @@ -286,8 +285,8 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
const handleActivatePath = async (path: LearningPath) => {
console.log('🔥 [DataManagement] 激活路径操作开始:', path.id, path.title, path.status)
try {
console.log('🔥 [DataManagement] 调用learningApiV2.updatePath')
const result = await learningApiV2.updatePath(path.id, { status: 'active' })
console.log('🔥 [DataManagement] 调用learningApi.updatePath')
const result = await learningApi.updatePath(path.id, { status: 'active' })
console.log('🔥 [DataManagement] 激活路径API结果:', result)

if (result.success) {
Expand All @@ -308,8 +307,8 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
const handleFreezePath = async (path: LearningPath) => {
console.log('❄️ [DataManagement] 冻结路径操作开始:', path.id, path.title, path.status)
try {
console.log('❄️ [DataManagement] 调用learningApiV2.updatePath')
const result = await learningApiV2.updatePath(path.id, { status: 'frozen' })
console.log('❄️ [DataManagement] 调用learningApi.updatePath')
const result = await learningApi.updatePath(path.id, { status: 'frozen' })
console.log('❄️ [DataManagement] 冻结路径API结果:', result)

if (result.success) {
Expand All @@ -330,8 +329,8 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
const handleArchivePath = async (path: LearningPath) => {
console.log('📦 [DataManagement] 归档路径操作开始:', path.id, path.title, path.status)
try {
console.log('📦 [DataManagement] 调用learningApiV2.updatePath')
const result = await learningApiV2.updatePath(path.id, { status: 'archived' })
console.log('📦 [DataManagement] 调用learningApi.updatePath')
const result = await learningApi.updatePath(path.id, { status: 'archived' })
console.log('📦 [DataManagement] 归档路径API结果:', result)

if (result.success) {
Expand Down Expand Up @@ -972,7 +971,7 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
variant="secondary"
size="sm"
onClick={() => {
const allContent = LearningAPI.getInstance().getAllCourseContent()
const allContent = learningApi.getAllCourseContent()
if (allContent.success) {
copyToClipboard(allContent.data)
}
Expand Down Expand Up @@ -1016,7 +1015,7 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
{/* 课程内容列表 */}
<div className="space-y-3">
{(() => {
const allContent = LearningAPI.getInstance().getAllCourseContent()
const allContent = learningApi.getAllCourseContent()
if (!allContent.success || !allContent.data) return null

return allContent.data.slice(0, 5).map((content: any) => (
Expand Down Expand Up @@ -1054,7 +1053,7 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
onClick={async () => {
const confirmed = window.confirm(`确定要删除课程内容 "${content.title}" 吗?`)
if (confirmed) {
const result = await LearningAPI.getInstance().deleteCourseContent(content.id)
const result = await learningApi.deleteCourseContent(content.id)
if (result.success) {
toast.success('课程内容已删除')
await refreshData()
Expand All @@ -1074,7 +1073,7 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga

{/* 显示更多内容 */}
{(() => {
const allContent = LearningAPI.getInstance().getAllCourseContent()
const allContent = learningApi.getAllCourseContent()
if (!allContent.success || !allContent.data || allContent.data.length <= 5) return null

return (
Expand All @@ -1097,7 +1096,7 @@ export const DataManagementPage: React.FC<DataManagementPageProps> = ({ onNaviga
</summary>
<pre className="mt-3 p-4 bg-gray-100 rounded-lg text-xs overflow-auto max-h-64">
{(() => {
const allContent = LearningAPI.getInstance().getAllCourseContent()
const allContent = learningApi.getAllCourseContent()
return JSON.stringify(allContent.success ? allContent.data : [], null, 2)
})()}
</pre>
Expand Down
Loading