返回代码库

智能家居控制面板

4.0
zh技术开发智能家居ReactAI建议

提示语

// SmartHomeDashboard.js
import React, { useState, useEffect } from "react";
import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import { Camera } from "lucide-react";

export default function SmartHomeDashboard() {
  const [deviceData, setDeviceData] = useState({
    temperature: "25°C",
    voltage: "230V",
    power: "100W",
    current: "0.5A",
    load: "20%",
  });

  const [deviceOn, setDeviceOn] = useState(true);
  const [scannedBarcode, setScannedBarcode] = useState("");
  const [showScanner, setShowScanner] = useState(false);
  const [suggestions, setSuggestions] = useState([]);
  const [alerts, setAlerts] = useState([]);
  const [deviceList, setDeviceList] = useState(["Device#1234", "Device#5678"]);

  useEffect(() => {
    // Simulate AI-based suggestions
    setSuggestions([
      "Consider replacing Device#1234 with a more efficient model.",
      "Schedule auto power-off for idle hours.",
      "Reduce device usage during peak load times."
    ]);

    // Simulate alerts
    setAlerts([
      "High power consumption detected in Device#1234.",
      "Temperature nearing threshold: 25°C."
    ]);
  }, []);

  const handleToggle = () => {
    setDeviceOn(!deviceOn);
  };

  const handleBarcodeScan = (event) => {
    const file = event.target.files[0];
    if (file) {
      setScannedBarcode("SCANNED: Device#1234");
      setDeviceList((prev) => [...new Set([...prev, "Device#1234"])]);
    }
  };

  const githubThemeStyle = "bg-[#0d1117] text-white border border-[#30363d]";

  return (
    <div className="p-6 grid gap-4 md:grid-cols-2 lg:grid-cols-3">
      {/* Device Monitoring Cards */}
      {Object.entries(deviceData).map(([key, value]) => (
        <Card key={key} className={`rounded-2xl shadow-xl ${githubThemeStyle}`}>
          <CardContent className="p-4">
            <h2 className="text-xl font-semibold capitalize">{key}</h2>
            <p className="text-2xl mt-2">{value}</p>
          </CardContent>
        </Card>
      ))}

      {/* Device Control */}
      <Card className={`col-span-1 rounded-2xl shadow-xl ${githubThemeStyle}`}>
        <CardContent className="p-4 flex flex-col gap-4">
          <h2 className="text-xl font-semibold">Smart Control</h2>
          <div className="flex items-center justify-between">
            <span>Device Status</span>
            <Switch checked={deviceOn} onCheckedChange={handleToggle} />
          </div>
          <div className="flex flex-col gap-2">
            <p className="text-sm text-muted-foreground">Barcode Scanner</p>
            <Input type="file" accept="image/*" onChange={handleBarcodeScan} />
            <p className="text-green-400 font-semibold">{scannedBarcode}</p>
          </div>
        </CardContent>
      </Card>

      {/* AI-based Suggestions */}
      <Card className={`col-span-1 rounded-2xl shadow-xl ${githubThemeStyle}`}>
        <CardContent className="p-4">
          <h2 className="text-xl font-semibold mb-2">AI Suggestions</h2>
          <ul className="list-disc pl-5 space-y-1 text-gray-300">
            {suggestions.map((tip, index) => (
              <li key={index} className="text-sm">{tip}</li>
            ))}
          </ul>
        </CardContent>
      </Card>

      {/* Real-Time Alerts */}
      <Card className={`col-span-1 rounded-2xl shadow-xl ${githubThemeStyle}`}>
        <CardContent className="p-4">
          <h2 className="text-xl font-semibold mb-2 text-red-500">Real-Time Alerts</h2>
          <ul className="list-disc pl-5 space-y-1">
            {alerts.map((alert, index) => (
              <li key={index} className="text-sm text-red-400">{alert}</li>
            ))}
          </ul>
        </CardContent>
      </Card>

      {/* Device List */}
      <Card className={`col-span-1 rounded-2xl shadow-xl ${githubThemeStyle}`}>
        <CardContent className="p-4">
          <h2 className="text-xl font-semibold mb-2">Connected Devices</h2>
          <ul className="list-disc pl-5 space-y-1 text-gray-300">
            {deviceList.map((device, idx) => (
              <li key={idx} className="text-sm">{device}</li>
            ))}
          </ul>
        </CardContent>
      </Card>
    </div>
  );
}

生成结果

export default function App() {
  return (
    <pre style={{ whiteSpace: 'pre-wrap', padding: 24, fontFamily: 'monospace' }}>"import React, { useState, useEffect } from \"react\";\n\nconst SmartHomeDashboard = () => {\n  const [deviceData, setDeviceData] = useState({\n    temperature: \"25°C\",\n    voltage: \"230V\",\n    power: \"100W\",\n    current: \"0.5A\",\n    load: \"20%\",\n  });\n\n  const [deviceOn, setDeviceOn] = useState(true);\n  const [scannedBarcode, setScannedBarcode] = useState(\"\");\n  const [suggestions, setSuggestions] = useState([]);\n  const [alerts, setAlerts] = useState([]);\n  const [deviceList, setDeviceList] = useState([\"Device#1234\", \"Device#5678\"]);\n\n  useEffect(() => {\n    setSuggestions([\n      \"Consider replacing Device#1234 with a more efficient model.\",\n      \"Schedule auto power-off for idle hours.\",\n      \"Reduce device usage during peak load times.\"\n    ]);\n    setAlerts([\n      \"High power consumption detected in Device#1234.\",\n      \"Temperature nearing threshold: 25°C.\"\n    ]);\n  }, []);\n\n  const handleToggle = () => setDeviceOn(!deviceOn);\n\n  const handleBarcodeScan = (event) => {\n    const file = event.target.files[0];\n    if (file) {\n      setScannedBarcode(\"SCANNED: Device#1234\");\n      setDeviceList((prev) => [...new Set([...prev, \"Device#1234\"])]);\n    }\n  };\n\n  return (\n    <div className=\"p-6 grid gap-4 md:grid-cols-2 lg:grid-cols-3\">\n      {Object.entries(deviceData).map(([key, value]) => (\n        <div key={key} className=\"rounded-2xl shadow-xl bg-gray-800 text-white\">\n          <div className=\"p-4\">\n            <h2 className=\"text-xl font-semibold capitalize\">{key}</h2>\n            <p className=\"text-2xl mt-2\">{value}</p>\n          </div>\n        </div>\n      ))}\n      <div className=\"col-span-1 rounded-2xl shadow-xl bg-gray-800 text-white\">\n        <div className=\"p-4 flex flex-col gap-4\">\n          <h2 className=\"text-xl font-semibold\">Smart Control</h2>\n          <div className=\"flex items-center justify-between\">\n            <span>Device Status</span>\n            <button onClick={handleToggle} className={`relative w-12 h-6 bg-gray-700 rounded-full p-1 transition-colors duration-300 ${deviceOn ? 'bg-green-500' : 'bg-gray-500'}`}>\n              <span className={`block w-4 h-4 bg-white rounded-full shadow-md transform transition-transform duration-300 ${deviceOn ? 'translate-x-6' : 'translate-x-0'}`}></span>\n            </button>\n          </div>\n          <div className=\"flex flex-col gap-2\">\n            <p className=\"text-sm text-gray-400\">Barcode Scanner</p>\n            <input type=\"file\" accept=\"image/*\" onChange={handleBarcodeScan} className=\"text-sm text-gray-200 bg-gray-700 px-3 py-2 rounded-lg outline-none border border-gray-600 focus:border-gray-500\" />\n            <p className=\"text-green-400 font-semibold\">{scannedBarcode}</p>\n          </div>\n        </div>\n      </div>\n      <div className=\"col-span-1 rounded-2xl shadow-xl bg-gray-800 text-white\">\n        <div className=\"p-4\">\n          <h2 className=\"text-xl font-semibold mb-2\">AI Suggestions</h2>\n          <ul className=\"list-disc pl-5 space-y-1 text-gray-300\">\n            {suggestions.map((tip, index) => (\n              <li key={index} className=\"text-sm\">{tip}</li>\n            ))}\n          </ul>\n        </div>\n      </div>\n      <div className=\"col-span-1 rounded-2xl shadow-xl bg-gray-800 text-white\">\n        <div className=\"p-4\">\n          <h2 className=\"text-xl font-semibold mb-2 text-red-500\">Real-Time Alerts</h2>\n          <ul className=\"list-disc pl-5 space-y-1\">\n            {alerts.map((alert, index) => (\n              <li key={index} className=\"text-sm text-red-400\">{alert}</li>\n            ))}\n          </ul>\n        </div>\n      </div>\n      <div className=\"col-span-1 rounded-2xl shadow-xl bg-gray-800 text-white\">\n        <div className=\"p-4\">\n          <h2 className=\"text-xl font-semibold mb-2\">Connected Devices</h2>\n          <ul className=\"list-disc pl-5 space-y-1 text-gray-300\">\n            {deviceList.map((device, idx) => (\n              <li key={idx} className=\"text-sm\">{device}</li>\n            ))}\n          </ul>\n        </div>\n      </div>\n    </div>\n  );\n};\n\nexport default SmartHomeDashboard;"</pre>
  )

更多推荐

查看全部

Chrome扩展自动刷新

技术开发zh
4.0

我想做一个 chrome 扩展。定期自动刷新特定搜索结果, 保持画面一直更新最新状态

Chrome扩展自动刷新网页更新2025/6/21

创建AI安卓应用

技术开发en
4.0

Create applications ai for android the name app is a aw ai.eg the app can make photo and video the ai He must be smart and ai can speak Arabic

AI应用安卓开发智能助手2025/6/20

Archive.org 电影搜索

技术开发en
4.0

make a app that find all full popular movies on https://archive.org/

电影搜索Archive.org应用开发2025/6/19

打造任务管理应用

技术开发en
4.0

create task management app like ticktick.com

任务管理应用开发TickTick2025/6/18

专业应用设计指南

技术开发en
4.0

Design a professional application that remembers all the information, which is the customer's phone number and all the tasks you have performed, with dates and alerts when the time is completed and the customer must be contacted.

应用设计任务管理客户联系2025/6/17

全面《古兰经》应用开发指南

技术开发zh
4.0

Act like a senior mobile app developer and UX/UI designer with deep experience in Islamic applications. Your objective is to create a full concept and specification document for a comprehensive "Quran Kareem" mobile application. The app must offer a complete Quran experience and include everything a devout Muslim would expect from a high-end Islamic digital product. Step-by-step, provide: Step 1: A detailed overview of the app’s purpose and target audience. Step 2: A full breakdown of the app's features, which must include: - Full Quran text in Arabic with Uthmani script. - Multiple high-quality audio recitations by famous Qaris such as Abdul Basit, Al-Afasy, Al-Hudhaify, and Mishary Rashid. - Option to download Surahs for offline listening. - Verse-by-verse audio playback. - Translation and tafsir in multiple languages. - Tafsir sources like Ibn Kathir and Al-Jalalayn. - Bookmarking, tagging, and note-taking. - Search functionality by Surah, Ayah, or keyword. - Prayer times and Qibla direction. - Daily Islamic reminders and verse of the day. - A section for Islamic nasheeds (vocal-only), categorized by theme or artist. - Night mode and adjustable font sizes. - User profiles and sync between devices. - Push notifications for prayer and reading goals. Step 3: A visual layout plan, describing the home screen and the navigation structure. Include a list of all major tabs or sections in the bottom navigation bar. Step 4: Technical requirements including platform (iOS/Android), preferred frameworks (e.g., Flutter, React Native), API suggestions for prayer times and Qibla, and audio streaming/storage management. Step 5: A strict note that every interactive element (button, slider, tab, menu item) must be fully functional and tested before app release. This includes all audio players, search bars, bookmarks, and toggle switches. Step 6: Conclude with ideas for monetization (if any), and how to keep the app ad-free or with optional donations/subscription for premium features. Take a deep breath and work on this problem step-by-step. Add to Arabic

古兰经应用移动开发伊斯兰软件2025/6/14