Back to blocks

照片排名系统

4.0
en技术照片排名用户选择元数据

Prompt

a photo ranking system using pairwise choices, where user chooses from 2 side ny side images, photos have associasted metadata and multiple users

Résultat Généré

import React, { useState, useEffect } from 'react';

const App = () => {
  const [photos, setPhotos] = useState([]);
  const [currentPair, setCurrentPair] = useState([]);
  const [ranking, setRanking] = useState({});

  useEffect(() => {
    fetchPhotos();
  }, []);

  const fetchPhotos = () => {
    // Mock data for photos with metadata
    const mockPhotos = [
      { id: 1, url: 'https://placehold.co/300X300', metadata: { title: 'Photo 1', description: 'Description for Photo 1' } },
      { id: 2, url: 'https://placehold.co/300X300', metadata: { title: 'Photo 2', description: 'Description for Photo 2' } },
      { id: 3, url: 'https://placehold.co/300X300', metadata: { title: 'Photo 3', description: 'Description for Photo 3' } }
    ];
    setPhotos(mockPhotos);
    setCurrentPair([mockPhotos[0], mockPhotos[1]]);
  };

  const handleChoice = (chosenId) => {
    const newRanking = { ...ranking };
    const [photoA, photoB] = currentPair;

    if (!newRanking[photoA.id]) newRanking[photoA.id] = 0;
    if (!newRanking[photoB.id]) newRanking[photoB.id] = 0;

    if (chosenId === photoA.id) {
      newRanking[photoA.id] += 1;
    } else {
      newRanking[photoB.id] += 1;
    }

    setRanking(newRanking);
    selectNextPair();
  };

  const selectNextPair = () => {
    const nextPair = photos.slice(2, 4);
    if (nextPair.length === 2) {
      setCurrentPair(nextPair);
    } else {
      // End of ranking or shuffle for more rounds
      setCurrentPair([photos[0], photos[1]]);
    }
  };

  return (
    <div className='flex flex-col items-center justify-center min-h-screen bg-gray-100'>
      <h1 className='text-3xl font-bold mb-8'>Photo Ranking System</h1>
      <div className='flex space-x-8'>
        {currentPair.map((photo) => (
          <div key={photo.id} className='flex flex-col items-center'>
            <img src={photo.url} alt={photo.metadata.title} className='w-64 h-64 object-cover rounded-lg shadow-lg' />
            <h2 className='text-xl mt-4'>{photo.metadata.title}</h2>
            <p className='text-gray-600'>{photo.metadata.description}</p>
            <button
              onClick={() => handleChoice(photo.id)}
              className='mt-4 px-6 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition duration-200'
            >
              Choose
            </button>
          </div>
        ))}
      </div>
      <div className='mt-8'>
        <h2 className='text-2xl font-bold mb-4'>Ranking</h2>
        <ul>
          {Object.entries(ranking).map(([id, score]) => (
            <li key={id} className='text-lg'>{`Photo ${id}: ${score} votes`}</li>
          ))}
        </ul>
      </div>
    </div>
  );
};

export default App;

Plus de Recommandations

Voir Tout

程序展示

技术en
4.0

https://68crg2.csb.app show the program

程序展示应用03/04/2025

AI生成器应用描述模板

技术en
4.0

Here’s a polished and engaging app description template you can customize based on your app’s purpose: --- **AI generator: [ai generator **Tagline:** [Short, catchy phrase – e.g., "Simplify your life in seconds!"] **Description:** [Your App Name] is the ultimate [category, e.g., productivity/health/gaming] app designed to [core benefit, e.g., "boost your focus, organize tasks effortlessly, or connect with friends seamlessly"]. Whether you’re a [target audience, e.g., busy professional, fitness enthusiast, or casual gamer], our app helps you [key feature, e.g., "track progress, save time, or unlock new experiences"] with an intuitive, user-friendly interface. **Key Features:** ✔ **[Feature 1]** – [Brief detail, e.g., "AI-powered task prioritization"] ✔ **[Feature 2]** – [e.g., "Real-time collaboration with teammates"] ✔ **[Feature 3]** – [e.g., "Customizable reminders & smart alerts"] ✔ **[Feature 4]** – [e.g., "Offline access for on-the-go use"] **Why Choose [Your App Name]?** - 🚀 [Unique selling point, e.g., "Backed by science for maximum productivity"] - 🌎 [Another USP, e.g., "Used by 1M+ users worldwide"] - 🔒 [Trust factor, e.g., "Secure, private, and ad-free"] Download now and [call to action, e.g., "transform your daily routine today!"] --- **Tips to Enhance:** 1. **Be concise** – Focus on benefits, not just features. 2. **Use keywords** – Improve app store visibility (e.g., "fitness tracker," "time saver"). 3. **Add social proof** – Include ratings or awards if available (*"Rated 4.9/5 by 10K users!"*). Let me know your app’s category/goals, and I can refine this further! 🚀

AI生成器应用描述SEO优化02/04/2025

生成应用工具

技术en
4.0

Generate me app

应用生成工具开发02/04/2025

AI视频生成器

技术en
4.0

Web application Ai video generator Text to video

Web应用文本转视频AI工具02/04/2025

免费克隆黑箱AI

技术en
4.0

make a clone of black box ai but in this clone make every thing free

AI克隆免费工具技术开发30/03/2025