ChatGPT快速建站,原来是这样玩的?

2023-08-0211:12:55网站建设与开发Comments1,900 views字数 5417阅读模式

二月份美国教育部停止学生在校使用ChatGPT完成作业以来,ChatGPT这个话题越来越火爆,与此同时关于ChatGPT在各个领域的应用的文章层出不穷。作为一名编程爱好者,该如何使用ChatGPT建立自己的个人网站呢?本文将以对话形式向各位展示如何快速建站。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

 文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

ChatGPT快速建站,原来是这样玩的?

 文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

下面是一个使用 Vue 3 编写的课程导航栏页面的示例代码:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

<template>
  <div class="course-navigation">
    <Header /> <!-- Use the Header component -->
    <!-- 内容区域 -->
    <div class="content">
      <!-- 课程分类导航栏 -->
      <LeftSidebar />
      <!-- 轮播图 -->
      <RightSidebar :carouselData="carouselData" />
    </div>
    <div class="background-image">
      <img alt="" style="width: 1600px;height: 250px" :src="img" />
    </div>
    <div style="font-size: 30px; text-align: center; margin-top: 30px;">课程列表</div>
    <!-- 课程详情区域 -->
    <CourseList :courses="courses" />
    <Footer />
  </div>
</template>

<script>
import Swiper from 'swiper';
import { Navigation, Pagination } from 'swiper/modules';
// import Swiper and modules styles
import 'swiper/css';
import 'swiper/css/navigation';
import 'swiper/css/pagination';
import Header from './Header.vue'; // Import the Header component
import Footer from './Footer.vue'; // Import the Footer component
import CourseList from './CourseList.vue'; // Import the CourseList component
import LeftSidebar from './LeftSidebar.vue'; // Import the LeftSidebar component
import RightSidebar from './RightSidebar.vue'; // Import the RightSidebar component


export default {
  name: "CourseNavigation",
  components: {
    Header, // Register the Header component
    Footer, // Register the Footer component
    CourseList, // Register the CourseList component
    LeftSidebar,
    RightSidebar,
    // ... Rest of your components ...
  },
  data() {
    return {
      activeMenu: "home", // 默认选中首页
      courses: [], // 所有课程数据,从后端获取或静态定义
      swiperOptions: {
        pagination: {
          el: ".swiper-pagination",
        },
        loop: true,
        autoplay: {
          delay: 3000,
        },
      },
      carouselData: [
        {
          id: 1,
          image: "https://csdn-blog-picture.oss-cn-guangzhou.aliyuncs.com/img/image-20230709183838817.png",
        },
        {
          id: 2,
          image: "https://via.placeholder.com/800x300?text=Slide%202",
        },
        {
          id: 3,
          image: "https://via.placeholder.com/800x300?text=Slide%203",
        },
        // 更多轮播图数据
      ],
      img: require("@/assets/background.jpg"),
    };
  },
  computed: {
    courseRows() {
      // 将所有课程按每行4个进行分组
      const rows = [];
      for (let i = 0; i < this.courses.length; i += 4) {
        rows.push(this.courses.slice(i, i + 4));
      }
      return rows;
    },
  },
  created() {
    this.getCourses();
    this.getFiveCourse();
  },
  methods: {
    handleMenuSelect(index) {
      this.activeMenu = index; // 更新选中的菜单项
      // 可根据不同的菜单项进行相应的页面跳转或其他操作
    },
    getCourses() {
      this.$axios.get('/sourceCourse/list'
        // ,
        //     {
        //         headers: {
        //             "Authorization": this.$store.getters.getToken
        //         }
        //     }
      ).then(response => {
        const courses = response.data.result;
        console.log(response)
        this.courses = courses;
        // this.$message({
        //     type: 'success',
        //     message: response.data.message
        // });
        console.log(this.courses)
      })
    },
    getFiveCourse() {
      this.$axios.get('/sourceCourse/getFiveCourse'
        // ,
        //     {
        //         headers: {
        //             "Authorization": this.$store.getters.getToken
        //         }
        //     }
      ).then(response => {
        const courses = response.data.result;
        console.log(response)
        this.carouselData = courses;
        // this.$message({
        //     type: 'success',
        //     message: response.data.message
        // });
        console.log(this.courses)
      })
    },
  },
  mounted() {
    // Initialize Swiper
    const swiper = new Swiper('.swiper', {
      modules: [Navigation, Pagination],
      direction: 'horizontal', // Change back to horizontal
      loop: true,
      autoplay: {
        delay: 3000, // Set the delay between slide transitions in milliseconds (3 seconds in this example)
        disableOnInteraction: false, // Allow auto play to continue even when the user interacts with Swiper
      },

      // If we need pagination
      pagination: {
        el: '.swiper-pagination',
        clickable: true, // Allow pagination bullets to be clickable
      },

      // Navigation arrows
      navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
      },

      // And if we need scrollbar
      scrollbar: {
        el: '.swiper-scrollbar',
      },

      // Add the loopedSlides option to control how many slides are looped
      loopedSlides: this.carouselData.length, // Set it to the total number of slides

      // Add the slideChange event handler for looping
      on: {
        slideChange: () => {
          if (swiper.realIndex === swiper.slides.length - 1) {
            // If it reaches the last slide, manually go to the first slide
            swiper.slideTo(0, 0, true); // Set the third parameter (boolean) to false for instant transition
          }
        },
      },
    });

    // Now you can use the 'swiper' variable to interact with the Swiper instance if needed
    // swiper.slideNext(); // Example: Go to the next slide programmatically
  },


};
</script>

<style>
.index {
  background-color: #E9EEF3;
}

/* 添加样式 */
.course-navigation {
  max-width: 1600px;
  margin: 0 auto;
}

.menu {
  display: flex;
  justify-content: center;
}

.menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu li {
  display: inline-block;
  padding: 0 20px;
  cursor: pointer;
}

.menu li.active {
  color: #ffd04b;
  border-bottom: 2px solid #ffd04b;
}

.content {
  display: flex;
  flex-wrap: wrap;
  /* Wrap the sidebar and swiper to next row if necessary */
}

.left-sidebar {
  width: 20%;
  padding: 20px;
  background-color: #f0f0f0;
}

.left-sidebar h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.left-sidebar ul {
  list-style: none;
  padding: 0;
}

.left-sidebar li {
  margin-bottom: 10px;
  cursor: pointer;
}

.right-sidebar {
  flex: 1;
  padding: 20px;
  min-width: 300px;
  /* Set a minimum width for the sidebar */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Add the following CSS styles */

.swiper-pagination {
  display: flex;
  justify-content: center;
  margin-top: 10px;
  /* Add some margin between carousel and pagination */
}

.swiper-pagination-bullet {
  width: 10px;
  height: 10px;
  background-color: #ccc;
  border-radius: 50%;
  margin: 0 5px;
  /* Adjust the space between bullets as needed */
}

.swiper-pagination-bullet-active {
  background-color: #555;
}
  /* 背景图片样式 */
.background-image {
  width: 1600px;
  height: 250px;
  margin-top: 50px;
}


.swiper-container {
  width: 100%;
  height: 300px;
  margin-bottom: 20px;
  position: relative;
  /* 添加以下样式以实现水平排列 */
  display: flex;
}

.swiper-slide img {
  width: 100%;
  height: 100%;
}


</style>

在上述示例代码中,我们创建了一个名为 CourseNavigation 的组件,其中包含了头部菜单栏、左侧课程分类导航栏、右侧轮播图以及课程详情区域。课程详情区域采用每行5个课程框的方式展示,可以根据实际情况调整课程数据和样式。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

需要注意的是,该示例代码只是一个简单的示例,实际项目中可能涉及到更复杂的业务逻辑和样式设计。你可以根据项目的需求进一步完善和定制该页面。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

下面就是生成的网站效果图啦,欢迎各位欣赏由ChatGPT编写的网站。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

 文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html

ChatGPT快速建站,原来是这样玩的?
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/52170.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/cms/52170.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定