fei.wang
6 天以前 ae7b22322555448d95fd56f505bafa325c167a26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>横屏适配测试</title>
    <style>
        body {
            margin: 0;
            padding: 20px;
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
        }
        
        .test-container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        .orientation-info {
            background: #e8f4fd;
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 20px;
            border-left: 4px solid #2196F3;
        }
        
        .canvas-simulation {
            width: 300px;
            height: 300px;
            border: 3px solid #333;
            border-radius: 50%;
            margin: 20px auto;
            position: relative;
            background: #f9f9f9;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .controls-simulation {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
            margin: 20px 0;
        }
        
        .button {
            padding: 15px 25px;
            background: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            min-width: 120px;
        }
        
        .button:hover {
            background: #0056b3;
        }
        
        .landscape-layout {
            display: flex;
            align-items: flex-start;
            gap: 40px;
        }
        
        .landscape-layout .canvas-simulation {
            margin: 0;
            flex-shrink: 0;
        }
        
        .landscape-layout .controls-simulation {
            flex: 1;
            flex-direction: column;
            align-items: flex-start;
        }
        
        .test-buttons {
            margin-top: 20px;
            text-align: center;
        }
        
        .test-button {
            margin: 5px;
            padding: 10px 20px;
            background: #28a745;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        
        .test-button:hover {
            background: #218838;
        }
        
        .status {
            margin-top: 20px;
            padding: 10px;
            background: #d4edda;
            border-radius: 5px;
            border-left: 4px solid #28a745;
        }
        
        @media (orientation: landscape) {
            .test-container {
                padding: 30px;
            }
            
            .canvas-simulation {
                width: 400px;
                height: 400px;
            }
            
            .button {
                padding: 20px 30px;
                font-size: 18px;
                min-width: 150px;
            }
        }
        
        @media (min-width: 1024px) {
            .button {
                padding: 25px 35px;
                font-size: 20px;
                min-width: 180px;
            }
        }
    </style>
</head>
<body>
    <div class="test-container">
        <h1>横屏适配测试页面</h1>
        
        <div class="orientation-info">
            <h3>当前屏幕信息</h3>
            <p><strong>屏幕尺寸:</strong> <span id="screenSize">检测中...</span></p>
            <p><strong>方向:</strong> <span id="orientation">检测中...</span></p>
            <p><strong>设备类型:</strong> <span id="deviceType">检测中...</span></p>
        </div>
        
        <div id="layoutContainer">
            <!-- 画布模拟 -->
            <div class="canvas-simulation">
                <div style="text-align: center;">
                    <div style="width: 80px; height: 80px; background: #ddd; border-radius: 50%; margin: 0 auto 10px;"></div>
                    <div>车辆监控画布</div>
                    <div style="font-size: 12px; color: #666;">300x300px</div>
                </div>
            </div>
            
            <!-- 控制按钮模拟 -->
            <div class="controls-simulation">
                <h3>控制区域</h3>
                <div style="margin-bottom: 15px;">
                    <h4>红色层扇形控制</h4>
                    <div style="display: flex; gap: 5px; flex-wrap: wrap;">
                        <button class="button" style="background: #dc3545;">扇形1</button>
                        <button class="button" style="background: #dc3545;">扇形2</button>
                        <button class="button" style="background: #dc3545;">扇形3</button>
                        <button class="button" style="background: #dc3545;">扇形4</button>
                    </div>
                </div>
                
                <div style="margin-bottom: 15px;">
                    <h4>黄色层扇形控制</h4>
                    <div style="display: flex; gap: 5px; flex-wrap: wrap;">
                        <button class="button" style="background: #ffc107; color: #000;">扇形1</button>
                        <button class="button" style="background: #ffc107; color: #000;">扇形2</button>
                        <button class="button" style="background: #ffc107; color: #000;">扇形3</button>
                        <button class="button" style="background: #ffc107; color: #000;">扇形4</button>
                    </div>
                </div>
                
                <div style="margin-bottom: 15px;">
                    <h4>绿色层扇形控制</h4>
                    <div style="display: flex; gap: 5px; flex-wrap: wrap;">
                        <button class="button" style="background: #28a745;">扇形1</button>
                        <button class="button" style="background: #28a745;">扇形2</button>
                        <button class="button" style="background: #28a745;">扇形3</button>
                        <button class="button" style="background: #28a745;">扇形4</button>
                    </div>
                </div>
                
                <div style="margin-top: 20px;">
                    <button class="button" style="background: #6c757d;">还原</button>
                    <button class="button" style="background: #17a2b8;">开始</button>
                    <button class="button" style="background: #6f42c1;">设置</button>
                </div>
            </div>
        </div>
        
        <div class="test-buttons">
            <button class="test-button" onclick="toggleLayout()">切换布局模式</button>
            <button class="test-button" onclick="simulateOrientationChange()">模拟方向变化</button>
            <button class="test-button" onclick="testResponsive()">测试响应式</button>
        </div>
        
        <div class="status" id="status">
            状态: 正常
        </div>
    </div>
 
    <script>
        let isLandscape = false;
        let isLayoutMode = false;
        
        function updateScreenInfo() {
            const width = window.innerWidth;
            const height = window.innerHeight;
            isLandscape = width > height;
            
            document.getElementById('screenSize').textContent = `${width} x ${height}`;
            document.getElementById('orientation').textContent = isLandscape ? '横屏' : '竖屏';
            
            let deviceType = '手机';
            if (width >= 1024 || height >= 1024) {
                deviceType = '平板';
            }
            if (width >= 1366 || height >= 1366) {
                deviceType = '大屏设备';
            }
            document.getElementById('deviceType').textContent = deviceType;
            
            updateLayout();
        }
        
        function updateLayout() {
            const container = document.getElementById('layoutContainer');
            if (isLandscape || isLayoutMode) {
                container.className = 'landscape-layout';
                document.getElementById('status').textContent = '状态: 横屏布局模式';
            } else {
                container.className = '';
                document.getElementById('status').textContent = '状态: 竖屏布局模式';
            }
        }
        
        function toggleLayout() {
            isLayoutMode = !isLayoutMode;
            updateLayout();
        }
        
        function simulateOrientationChange() {
            // 模拟方向变化
            const container = document.querySelector('.test-container');
            container.style.transform = 'rotate(90deg)';
            setTimeout(() => {
                container.style.transform = 'rotate(0deg)';
                updateScreenInfo();
            }, 1000);
        }
        
        function testResponsive() {
            // 测试响应式
            const buttons = document.querySelectorAll('.button');
            buttons.forEach(button => {
                button.style.animation = 'pulse 0.5s';
            });
            setTimeout(() => {
                buttons.forEach(button => {
                    button.style.animation = '';
                });
            }, 500);
        }
        
        // 监听窗口大小变化
        window.addEventListener('resize', updateScreenInfo);
        
        // 监听方向变化
        window.addEventListener('orientationchange', () => {
            setTimeout(updateScreenInfo, 100);
        });
        
        // 初始化
        updateScreenInfo();
        
        // 添加CSS动画
        const style = document.createElement('style');
        style.textContent = `
            @keyframes pulse {
                0% { transform: scale(1); }
                50% { transform: scale(1.05); }
                100% { transform: scale(1); }
            }
        `;
        document.head.appendChild(style);
    </script>
</body>
</html>