import React, { useEffect } from 'react'
import { Routes, Route } from 'react-router-dom'
import Layout from './components/Layout'
import HomePage from './pages/HomePage'
import EditorPage from './pages/EditorPage'
import AIVideoPage from './pages/AIVideoPage'
import SettingsPage from './pages/SettingsPage'
import TemplateManagePage from './pages/TemplateManagePage'
import TemplateDetailPage from './pages/TemplateDetailPage'
import ResourceCategoryPage from './pages/ResourceCategoryPage'
import ProjectManagePage from './pages/ProjectManagePage'
import ProjectDetailPage from './pages/ProjectDetailPage'
import ModelManagePage from './pages/ModelManagePage'
import AudioLibraryPage from './pages/AudioLibraryPage'
import MediaLibraryPage from './pages/MediaLibraryPage'
import KVTestPage from './pages/KVTestPage'
import TextVideoGeneratorPage from './pages/TextVideoGeneratorPage'
import PythonCoreTestPage from './pages/PythonCoreTestPage'
import PythonEnvManagerPage from './pages/PythonEnvManagerPage'
import * as path from '@tauri-apps/api/path';
import { convertFileSrc } from '@tauri-apps/api/core'
async function testPath() {
  const appDataDirPath = await path.appDataDir();
  const filePath = await path.join(appDataDirPath, 'assets/video.mp4');
  const assetUrl = convertFileSrc(filePath);
  const path2 = `C:\\Users\\imeep\\.mixvideo\\temp\\video_storage\\0af48d09-7b7f-4453-84e6-e7b2b33f7726.mp4`
  const assetUrl2 = convertFileSrc(path2, 'file');

  console.log({ filePath, assetUrl, assetUrl2, path2 })
}
function App() {

  useEffect(() => {
    testPath()
  }, [])
  return (
    <Routes>
      {/* 项目详情页 - 无侧边栏布局 */}
      <Route path="/projects/:projectId" element={<ProjectDetailPage />} />

      {/* 其他页面 - 带侧边栏布局 */}
      <Route path="/*" element={
        <Layout>
          <Routes>
            <Route path="/" element={<HomePage />} />
            <Route path="/editor" element={<EditorPage />} />
            <Route path="/ai-video" element={<AIVideoPage />} />
            <Route path="/text-video-generator" element={<TextVideoGeneratorPage />} />
            <Route path="/python-core-test" element={<PythonCoreTestPage />} />
            <Route path="/python-env-manager" element={<PythonEnvManagerPage />} />
            <Route path="/templates" element={<TemplateManagePage />} />
            <Route path="/templates/:templateId" element={<TemplateDetailPage />} />
            <Route path="/resource-categories" element={<ResourceCategoryPage />} />
            <Route path="/projects" element={<ProjectManagePage />} />
            <Route path="/models" element={<ModelManagePage />} />
            <Route path="/audio" element={<AudioLibraryPage />} />
            <Route path="/media" element={<MediaLibraryPage />} />
            <Route path="/kv-test" element={<KVTestPage />} />
            <Route path="/settings" element={<SettingsPage />} />
          </Routes>
        </Layout>
      } />
    </Routes>
  )
}

export default App
