feat: v1.0
This commit is contained in:
@@ -1,89 +1,51 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import './App.css';
|
||||
import { fetchDeviceList } from '@/api/devices';
|
||||
import { fetchWechatAccountList } from '@/api/wechat-accounts';
|
||||
import { fetchScenes } from '@/api/scenarios';
|
||||
import TestComponent from '@/components/TestComponent';
|
||||
import type { Device } from '@/types/device';
|
||||
import type { WechatFriend } from '@/types/wechat';
|
||||
import React from 'react';
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||
import Home from './pages/Home';
|
||||
import Login from './pages/login/Login';
|
||||
import Devices from './pages/devices/Devices';
|
||||
import DeviceDetail from './pages/devices/DeviceDetail';
|
||||
import WechatAccounts from './pages/wechat-accounts/WechatAccounts';
|
||||
import WechatAccountDetail from './pages/wechat-accounts/WechatAccountDetail';
|
||||
import Workspace from './pages/workspace/Workspace';
|
||||
import AutoGroupDetail from './pages/workspace/auto-group/Detail';
|
||||
import MomentsSync from './pages/workspace/moments-sync/MomentsSync';
|
||||
import MomentsSyncDetail from './pages/workspace/moments-sync/Detail';
|
||||
import TrafficDistribution from './pages/workspace/traffic-distribution/TrafficDistribution';
|
||||
import TrafficDistributionDetail from './pages/workspace/traffic-distribution/Detail';
|
||||
import Scenarios from './pages/scenarios/Scenarios';
|
||||
import Profile from './pages/profile/Profile';
|
||||
import Plans from './pages/plans/Plans';
|
||||
import Orders from './pages/orders/Orders';
|
||||
import TrafficPool from './pages/traffic-pool/TrafficPool';
|
||||
import ContactImport from './pages/contact-import/ContactImport';
|
||||
import Content from './pages/content/Content';
|
||||
|
||||
function App() {
|
||||
const [devices, setDevices] = useState<any[]>([]);
|
||||
const [wechatAccounts, setWechatAccounts] = useState<any[]>([]);
|
||||
const [scenes, setScenes] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const testAPIs = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
// 测试设备API
|
||||
const deviceResponse = await fetchDeviceList(1, 5);
|
||||
console.log('设备API响应:', deviceResponse);
|
||||
setDevices(deviceResponse.data?.list || []);
|
||||
|
||||
// 测试微信账号API
|
||||
const wechatResponse = await fetchWechatAccountList({ page: 1, limit: 5 });
|
||||
console.log('微信账号API响应:', wechatResponse);
|
||||
setWechatAccounts(wechatResponse.data?.list || []);
|
||||
|
||||
// 测试场景API
|
||||
const sceneResponse = await fetchScenes({ page: 1, limit: 5 });
|
||||
console.log('场景API响应:', sceneResponse);
|
||||
setScenes(sceneResponse.data || []);
|
||||
|
||||
} catch (error) {
|
||||
console.error('API测试失败:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// 页面加载时自动测试API
|
||||
testAPIs();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<h1>nkebao2 - 基础文件迁移测试</h1>
|
||||
<p>这是一个测试页面,用于验证从Cunkebao迁移过来的基础文件是否正常工作</p>
|
||||
|
||||
<TestComponent
|
||||
title="路径别名测试"
|
||||
className="mb-4 bg-blue-50"
|
||||
/>
|
||||
|
||||
<button onClick={testAPIs} disabled={loading}>
|
||||
{loading ? '测试中...' : '重新测试API'}
|
||||
</button>
|
||||
|
||||
<div style={{ marginTop: '20px', textAlign: 'left', maxWidth: '800px' }}>
|
||||
<h3>测试结果:</h3>
|
||||
|
||||
<div style={{ marginBottom: '20px' }}>
|
||||
<h4>设备API (共 {devices.length} 条):</h4>
|
||||
<pre style={{ fontSize: '12px', background: '#f5f5f5', padding: '10px', borderRadius: '4px' }}>
|
||||
{JSON.stringify(devices.slice(0, 2), null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: '20px' }}>
|
||||
<h4>微信账号API (共 {wechatAccounts.length} 条):</h4>
|
||||
<pre style={{ fontSize: '12px', background: '#f5f5f5', padding: '10px', borderRadius: '4px' }}>
|
||||
{JSON.stringify(wechatAccounts.slice(0, 2), null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: '20px' }}>
|
||||
<h4>场景API (共 {scenes.length} 条):</h4>
|
||||
<pre style={{ fontSize: '12px', background: '#f5f5f5', padding: '10px', borderRadius: '4px' }}>
|
||||
{JSON.stringify(scenes.slice(0, 2), null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/devices" element={<Devices />} />
|
||||
<Route path="/devices/:id" element={<DeviceDetail />} />
|
||||
<Route path="/wechat-accounts" element={<WechatAccounts />} />
|
||||
<Route path="/wechat-accounts/:id" element={<WechatAccountDetail />} />
|
||||
<Route path="/workspace" element={<Workspace />} />
|
||||
<Route path="/workspace/auto-group/:id" element={<AutoGroupDetail />} />
|
||||
<Route path="/workspace/moments-sync" element={<MomentsSync />} />
|
||||
<Route path="/workspace/moments-sync/:id" element={<MomentsSyncDetail />} />
|
||||
<Route path="/workspace/traffic-distribution" element={<TrafficDistribution />} />
|
||||
<Route path="/workspace/traffic-distribution/:id" element={<TrafficDistributionDetail />} />
|
||||
<Route path="/scenarios" element={<Scenarios />} />
|
||||
<Route path="/profile" element={<Profile />} />
|
||||
<Route path="/plans" element={<Plans />} />
|
||||
<Route path="/orders" element={<Orders />} />
|
||||
<Route path="/traffic-pool" element={<TrafficPool />} />
|
||||
<Route path="/contact-import" element={<ContactImport />} />
|
||||
<Route path="/content" element={<Content />} />
|
||||
{/* 你可以继续添加更多路由 */}
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user