feat: 基础迁移完成了
This commit is contained in:
@@ -1,23 +1,87 @@
|
||||
import React from 'react';
|
||||
import logo from './logo.svg';
|
||||
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';
|
||||
|
||||
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">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.tsx</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
<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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user