十分钟,用AI开发了官网首页

一、原版

大家好,我是小码哥,喜欢折腾AI的人,访问过xmgai.cn的网站都知道,首页还是比较low的,今天准备重新设计一下,在UI方面,我是不太擅长的,所以这次,还是借助AI来帮我完成官网首页的开发。先来看看我原来的官网,比较low,更多是图片效果的展示。

然后点击图片,跳转登录页面

1、通过媒体自适应移动端

2、源码

<template>
  <div class="container">

    <el-row>
      <el-col :span="24" class="oneTitle">
        <span>小码哥AI</span>
      </el-col>
    </el-row>
    <el-row :gutter="10" class="image-row">
      <el-col :span="12" class="pc-col" v-for="(item, index) in pageList" :key="index">
        <div class="imageCla">
          <el-image
            class="dialog-image"
            :src="item.previewImg"
            fit="cover"
            @click="handleHome(item)"
          />
          <div class="image-description">{{ item.name }}</div>
        </div>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24" class="oneTitle">
        <span>AI头像(登录制作)</span>
      </el-col>
    </el-row>
    <el-row :gutter="10" class="image-row">
      <el-col :span="6" class="pc-col" v-for="(item, index) in headPicList" :key="index">
        <div class="imageCla">
          <el-image
            class="dialog-image"
            :src="item.previewImg"
            fit="cover"
            @click="handleHome(item)"
          />
          <div class="image-description">{{ item.name }}</div>
        </div>
      </el-col>
    </el-row>

    
    <el-row>
      <el-col :span="24" class="oneTitle">
        <span>AI绘画(登录制作)</span>
      </el-col>
    </el-row>
    <el-row :gutter="10" class="image-row">
      <el-col :span="6" class="pc-col" v-for="(item, index) in aiPicList" :key="index">
        <div class="imageCla">
          <el-image
            class="dialog-image"
            :src="item.previewImg"
            fit="cover"
            @click="handleHome(item)"
          />
          <div class="image-description">{{ item.name }}</div>
        </div>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24" class="oneTitle">
        <span>独一无二的艺术二维码(40多种模板)</span>
      </el-col>
    </el-row>
    <el-row :gutter="10" class="image-row">
      <el-col :span="6" class="pc-col" v-for="(item, index) in claasifyList" :key="index">
        <div class="imageCla">
          <el-image
            class="dialog-image"
            :src="item.previewImg"
            fit="cover"
            @click="handleHome(item)"
          />
          <div class="image-description">{{ item.name }}</div>
        </div>
      </el-col>
    </el-row>
    
    <el-row>
      <el-col :span="24" class="oneTitle">
        <span>AI换脸</span>
      </el-col>
    </el-row>
    <el-row :gutter="10" class="image-row">
      <el-col :span="8" v-for="(item, index) in faceImages" :key="index">
        <div class="imageCla">
          <el-image
            class="faceimage"
            :src="item.src"
            fit="cover"
            @click="handleHome(item)"
          />
          <div class="image-description">{{ item.description }}</div>
        </div>
      </el-col>
    </el-row>

    
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
const router = useRouter(); // 路由对象

const handleHome = () => {
  router.push({
    path: '/login',
  });
};

const faceImages = ref([
  { src: "http://aipic.xmgai.cn/faceswap/11.png", description: "原图" },
  { src: "http://aipic.xmgai.cn/faceswap/22.jpg", description: "目标图" },
  { src: "http://aipic.xmgai.cn/faceswap/33.jpg", description: "成果" },
  { src: "http://aipic.xmgai.cn/faceswap/1.jpg", description: "原图" },
  { src: "http://aipic.xmgai.cn/faceswap/2.jpg", description: "目标图" },
  { src: "http://aipic.xmgai.cn/faceswap/3.jpg", description: "成果" }
]);

const claasifyList = ref([
  { previewImg: "http://aipic.xmgai.cn/model/5.png", name: "国风写实" },
  { previewImg: "http://aipic.xmgai.cn/model/23.png", name: "迷雾城堡" },
  { previewImg: "http://aipic.xmgai.cn/model/67.png", name: "薰衣草" },
  { previewImg: "http://aipic.xmgai.cn/model/2.png", name: "墨莲" },
  { previewImg: "http://aipic.xmgai.cn/model/97.png", name: "桃花" },
  { previewImg: "http://aipic.xmgai.cn/model/53.png", name: "怦然心动" },
  { previewImg: "http://aipic.xmgai.cn/model/6.png", name: "花嫁" },
  { previewImg: "http://aipic.xmgai.cn/model/4.png", name: "蝴蝶仙子" },
]);

const headPicList = ref([
  { previewImg: "http://aipic.xmgai.cn/headpic/1-1.PNG", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/1-2.PNG", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/2-1.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/2-2.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/3-1.PNG", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/3-2.PNG", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/3-3.PNG", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/3-4.PNG", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/5-1.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/5-2.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/5-3.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/headpic/5-4.png", name: "点击图片制作" },

]);

const aiPicList = ref([
  { previewImg: "http://aipic.xmgai.cn/aipic/1-1.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/aipic/1-2.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/aipic/1-3.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/aipic/1-4.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/aipic/2-1.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/aipic/2-2.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/aipic/2-3.png", name: "点击图片制作" },
  { previewImg: "http://aipic.xmgai.cn/aipic/2-4.png", name: "点击图片制作" },

]);

const pageList = ref([
  { previewImg: "http://aipic.xmgai.cn/page/1.png", name: "AI绘画" },
  { previewImg: "http://aipic.xmgai.cn/page/2.png", name: "AI头像制作" },
  { previewImg: "http://aipic.xmgai.cn/page/3.png", name: "AI图生文" },
  { previewImg: "http://aipic.xmgai.cn/page/4.png", name: "AI换脸" },
  { previewImg: "http://aipic.xmgai.cn/page/5.png", name: "AI专属二维码" },

]);
</script>

<style scoped>
.container {
  width: 100%;
  margin: 0 auto;
  padding: 20px 0; /* 修改这里 */
  box-sizing: border-box;
}

.image-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dialog-image, .faceimage {
  margin-bottom: 10px;
  width: 100%;
  height: auto;
  object-fit: cover;
  cursor: pointer;
  border-radius: 8px;
  transition: transform 0.3s, box-shadow 0.3s;
}

.dialog-image:hover, .faceimage:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.imageCla {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f9f9f9;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s, box-shadow 0.3s;
}

.imageCla:hover {
  transform: translateY(3px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.image-description {
  text-align: center;
  margin-top: 8px;
  font-size: 14px;
  color: #333;
}

.oneTitle {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  font-size: 20px;
  text-align: center;
  margin: 10px 0;
  font-weight: bolder;
  background-image: linear-gradient(135deg, #eb7ace, #2f41e6, #bdd631, #eb7ace);
  background-size: 200% 100%;
  animation: GenerateButton_gradient 10s cubic-bezier(.62, .28, .23, .99) infinite;
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  transition: all 0.3s ease-in-out;
}

@keyframes GenerateButton_gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 15px 0; /* 修改这里 */
  }
  .el-col {
    margin-bottom: 10px;
  }
  .oneTitle {
    font-size: 18px;
  }
  .pc-col {
    flex: 0 0 50%; /* 移动端一行两列 */
    max-width: 50%;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 10px 0; /* 修改这里 */
  }
  .el-col {
    margin-bottom: 5px;
  }
  .oneTitle {
    font-size: 16px;
  }
  .image-description {
    font-size: 12px;
  }
  .pc-col {
    flex: 0 0 50%; /* 移动端一行两列 */
    max-width: 50%;
  }
}
</style>

二、升级版

1、效果

移动端

2、代码如下:

<template>
  <div class="ai-website">
    <!-- Logo -->
    <div class="logo">
      <img src="https://via.placeholder.com/150x50?text=AI+Logo" alt="AI Logo" />
    </div>

    <!-- 左侧时间轴 -->
    <div class="timeline">
      <div
        v-for="(item, index) in timelineItems"
        :key="index"
        class="timeline-item"
        :class="{ active: activeSection === item.id }"
        @click="scrollToSection(item.id)"
      >
        <div class="timeline-dot"></div>
        <div class="timeline-label">{{ item.label }}</div>
      </div>
    </div>

    <!-- 右侧内容区域 -->
    <div class="content">
      <!-- AI 内容创作 -->
      <section id="content-creation" class="section">
        <h1 class="section-title">AI 内容创作</h1>
        <div class="feature-grid">
          <div
            v-for="(item, index) in contentFeatures"
            :key="index"
            class="feature-card"
            @click="handleFeatureClick(item)"
          >
            <h2>{{ item.title }}</h2>
            <p>{{ item.description }}</p>
          </div>
        </div>
      </section>

      <!-- AI 绘画 -->
      <section id="ai-painting" class="section">
        <h1 class="section-title">AI 绘画</h1>
        <div class="feature-grid">
          <div
            v-for="(item, index) in paintingFeatures"
            :key="index"
            class="feature-card"
            @click="handleFeatureClick(item)"
          >
            <h2>{{ item.title }}</h2>
            <p>{{ item.description }}</p>
          </div>
        </div>
      </section>

      <!-- AI 探索 -->
      <section id="ai-exploration" class="section">
        <h1 class="section-title">AI 探索</h1>
        <div class="feature-grid">
          <div
            v-for="(item, index) in explorationFeatures"
            :key="index"
            class="feature-card"
            @click="handleFeatureClick(item)"
          >
            <h2>{{ item.title }}</h2>
            <p>{{ item.description }}</p>
          </div>
        </div>
      </section>
    </div>

    <!-- 登录模态框 -->
    <el-dialog v-model="showLoginModal" title="登录" width="30%" center>
      <Login @login-success="handleLoginSuccess" />
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import Login from '@/views/Login/Login.vue';

// 时间轴数据
const timelineItems = ref([
  { id: 'content-creation', label: 'AI 内容创作' },
  { id: 'ai-painting', label: 'AI 绘画' },
  { id: 'ai-exploration', label: 'AI 探索' }
]);

// 当前激活的区域
const activeSection = ref('content-creation');

// AI 内容创作功能列表
const contentFeatures = ref([
  { title: '长文创作', description: '生成高质量的长篇文章' },
  { title: '创作灵感', description: '获取创作灵感和思路' }
]);

// AI 绘画功能列表
const paintingFeatures = ref([
  { title: '文生图', description: '根据文字描述生成图像' },
  { title: '图生图', description: '根据图像生成新的图像' },
  { title: '二维码制作', description: '生成个性化的二维码' },
  { title: '艺术字', description: '生成艺术字体' },
  { title: '百家姓', description: '生成百家姓艺术字' },
  { title: '百变头像', description: '生成个性化头像' }
]);

// AI 探索功能列表
const explorationFeatures = ref([
  { title: 'AI 实验室', description: '探索最新的 AI 技术' },
  { title: 'AI 社区', description: '加入 AI 爱好者社区' },
  { title: 'AI 新闻', description: '了解 AI 领域的最新动态' }
]);

// 是否显示登录模态框
const showLoginModal = ref(false);

// 处理功能点击
const handleFeatureClick = (item) => {
  const token = localStorage.getItem('token');
  if (!token) {
    showLoginModal.value = true; // 显示登录模态框
  } else {
    alert(`跳转到: ${item.title}`); // 模拟跳转
  }
};

// 处理登录成功
const handleLoginSuccess = () => {
  showLoginModal.value = false;
  alert('登录成功,可以访问功能了!');
};

// 滚动到指定区域
const scrollToSection = (id) => {
  const section = document.getElementById(id);
  if (section) {
    section.scrollIntoView({ behavior: 'smooth' });
    activeSection.value = id; // 更新当前激活的区域
  }
};

// 监听滚动事件,更新激活的区域
const handleScroll = () => {
  const sections = timelineItems.value.map((item) => document.getElementById(item.id));
  const scrollPosition = window.scrollY + 100; // 偏移量

  for (let i = sections.length - 1; i >= 0; i--) {
    if (sections[i].offsetTop <= scrollPosition) {
      activeSection.value = timelineItems.value[i].id;
      break;
    }
  }
};

onMounted(() => {
  window.addEventListener('scroll', handleScroll);
});

onUnmounted(() => {
  window.removeEventListener('scroll', handleScroll);
});
</script>

<style lang="scss" scoped>
.ai-website {
  display: flex;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e1e2f, #2a2a40);
  color: white;
  font-family: Arial, sans-serif;
  position: relative;

  .logo {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;

    img {
      width: 150px;
      height: auto;
    }
  }
}

.timeline {
  width: 200px;
  padding: 20px;
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start; /* 左对齐 */

  .timeline-item {
    display: flex;
    align-items: center;
    margin: 20px 0;
    cursor: pointer;
    transition: all 0.3s;

    &:hover {
      opacity: 0.8;
    }

    &.active {
      .timeline-dot {
        background: #409EFF;
        box-shadow: 0 0 10px #409EFF;
      }
      .timeline-label {
        color: #409EFF;
        font-weight: bold;
      }
    }

    .timeline-dot {
      width: 12px;
      height: 12px;
      background: white;
      border-radius: 50%;
      margin-right: 10px;
      transition: all 0.3s;
    }

    .timeline-label {
      font-size: 16px;
      transition: all 0.3s;
      text-align: left; /* 文字左对齐 */
    }
  }
}

.content {
  margin-left: 200px;
  flex: 1;
  padding: 20px;

  .section {
    margin-bottom: 100px;

    .section-title {
      font-size: 32px;
      margin-bottom: 40px;
      text-align: center;
      color: #409EFF;
    }

    .feature-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
      gap: 20px;

      .feature-card {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        padding: 20px;
        cursor: pointer;
        transition: all 0.3s;

        &:hover {
          transform: scale(1.05);
          box-shadow: 0 0 20px rgba(64, 158, 255, 0.5);
        }

        h2 {
          font-size: 20px;
          margin-bottom: 10px;
        }

        p {
          color: #aaa;
        }
      }
    }
  }
}

/* 移动端适配 */
@media (max-width: 768px) {
  .ai-website {
    flex-direction: column;

    .logo {
      position: static;
      text-align: center;
      margin-top: 20px;
    }

    .timeline {
      width: 100%;
      height: auto;
      position: static;
      flex-direction: row;
      justify-content: center;
      padding: 10px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);

      .timeline-item {
        margin: 0 10px;
      }
    }

    .content {
      margin-left: 0;
      padding: 10px;

      .section {
        margin-bottom: 50px;

        .section-title {
          font-size: 24px;
        }

        .feature-grid {
          grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        }
      }
    }
  }
}
</style>

文末点击名片,欢迎交流AI副业搞钱。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小码哥(xmgcode88)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值