feat(menu): add new menu web control

This commit is contained in:
2026-03-16 11:09:22 +07:00
parent b1d8d8bc9a
commit 986026c3af
3 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
import React, { useState, useEffect, memo } from 'react';
import { useNavigate } from 'react-router-dom';
import { Button, Typography } from 'antd';
import { useBreadcrumb } from '../../layout/LayoutBreadcrumb';
const { Text } = Typography;
const IndexWebControl = memo(function IndexWebControl() {
const navigate = useNavigate();
const { setBreadcrumbItems } = useBreadcrumb();
const [isPlaying, setIsPlaying] = useState(false);
const url = "https://117.102.231.130:9529";
const handlePlay = () => {
setIsPlaying(true);
};
const handleReset = () => {
setIsPlaying(false);
};
useEffect(() => {
const token = localStorage.getItem('token');
if (token) {
setBreadcrumbItems([
{
title: (
<Text strong style={{ fontSize: '14px' }}>
Web Control Panel
</Text>
),
},
]);
} else {
navigate('/signin');
}
}, []);
return (
<div style={{ padding: '20px' }}>
<div style={{ marginBottom: 20 }}>
<Button type="primary" onClick={handlePlay} style={{ marginRight: 10 }}>
Play
</Button>
<Button danger onClick={handleReset}>
🔄 Reset
</Button>
</div>
<div
style={{
border: '1px solid #ddd',
height: '500px',
background: '#fafafa',
}}
>
{isPlaying ? (
<iframe
src={url}
title="Web Preview"
style={{
width: '100%',
height: '100%',
border: 'none',
}}
/>
) : (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100%',
color: '#888',
}}
>
Klik Play untuk menjalankan web
</div>
)}
</div>
</div>
);
});
export default IndexWebControl;