首页 > 编程语言 >Python实战项目4-首页搭建/git安装使用

Python实战项目4-首页搭建/git安装使用

时间:2023-03-01 15:01:58浏览次数:42  
标签:git Python res 文件夹 首页 版本 path data

前台主页功能

  • 首页页面组件
  • 头部组件(小组件)
<template>
    <div class="header">
        <div class="slogan">
            <p>老男孩IT教育 | 帮助有志向的年轻人通过努力学习获得体面的工作和生活</p>
        </div>
        <div class="nav">
            <ul class="left-part">
                <li class="logo">
                    <router-link to="/">
                        <img src="../assets/img/head-logo.svg" alt="">
                    </router-link>
                </li>
                <li class="ele">
                    <span @click="goPage('/free-course')" :class="{active: url_path === '/free-course'}">免费课</span>
                </li>
                <li class="ele">
                    <span @click="goPage('/actual-course')" :class="{active: url_path === '/actual-course'}">实战课</span>
                </li>
                <li class="ele">
                    <span @click="goPage('/light-course')" :class="{active: url_path === '/light-course'}">轻课</span>
                </li>
            </ul>

            <div class="right-part">
                <div>
                    <span>登录</span>
                    <span class="line">|</span>
                    <span>注册</span>
                </div>
      </div>
        </div>
    </div>

</template>

<script>

    export default {
        name: "Header",
        data() {
            return {
                // 当前所在路径,去sessionStorage取的,如果取不到,就是 /
                url_path: sessionStorage.url_path || '/',
            }
        },
        methods: {
            goPage(url_path) {
                // 已经是当前路由就没有必要重新跳转
                if (this.url_path !== url_path) {
                    this.$router.push(url_path);
                }
                sessionStorage.url_path = url_path;
            },
        },
        created() {
            // 组件加载万成,就取出当前的路径,存到sessionStorage  this.$route.path
            sessionStorage.url_path = this.$route.path;
            // 把url_path = 当前路径
            this.url_path = this.$route.path;
        }
    }
</script>

<style scoped>
    .header {
        background-color: white;
        box-shadow: 0 0 5px 0 #aaa;
    }

    .header:after {
        content: "";
        display: block;
        clear: both;
    }

    .slogan {
        background-color: #eee;
        height: 40px;
    }

    .slogan p {
        width: 1200px;
        margin: 0 auto;
        color: #aaa;
        font-size: 13px;
        line-height: 40px;
    }

    .nav {
        background-color: white;
        user-select: none;
        width: 1200px;
        margin: 0 auto;

    }

    .nav ul {
        padding: 15px 0;
        float: left;
    }

    .nav ul:after {
        clear: both;
        content: '';
        display: block;
    }

    .nav ul li {
        float: left;
    }

    .logo {
        margin-right: 20px;
    }

    .ele {
        margin: 0 20px;
    }

    .ele span {
        display: block;
        font: 15px/36px '微软雅黑';
        border-bottom: 2px solid transparent;
        cursor: pointer;
    }

    .ele span:hover {
        border-bottom-color: orange;
    }

    .ele span.active {
        color: orange;
        border-bottom-color: orange;
    }

    .right-part {
        float: right;
    }

    .right-part .line {
        margin: 0 10px;
    }

    .right-part span {
        line-height: 68px;
        cursor: pointer;
    }
</style>
  • 轮播图组件(小组件)
<template>
  <div class="banner">
    <el-carousel height="400px" :interval="5000" arrow="always">
      <el-carousel-item v-for="item in img_list" :key="item.id">
        <div v-if="item.link.indexOf('http')>-1">
          <a :href="item.link">
            <img :src="item.image" :alt="item.title">
          </a>
        </div>
        <div v-else>
          <router-link :to="item.link">
            <img :src="item.image" :alt="item.title">
          </router-link>
        </div>


      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
export default {
  name: "Banner",
  data() {
    return {
      img_list: []
    }
  },
  created() {
    this.$axios.get(this.$settings.BASE_URL + '/home/banner/').then(res => {
      console.log(res.data)
      if (res.data.code == 100) {
        this.img_list = res.data.data
      } else {
        this.$message(res.data.msg)
      }
    }).catch(res => {
      this.$message('轮播图服务器异常,请稍后再试')
    })
  }
}
</script>

<style scoped>
.el-carousel__item {
  height: 400px;
  min-width: 1200px;
}

.el-carousel__item img {
  height: 400px;
  margin-left: calc(50% - 1920px / 2);
}
</style>
  • 尾部组件(小组件)
<template>
    <div class="footer">
        <ul>
            <li>关于我们</li>
            <li>联系我们</li>
            <li>商务合作</li>
            <li>帮助中心</li>
            <li>意见反馈</li>
            <li>新手指南</li>
        </ul>
        <p>Copyright © luffycity.com版权所有 | 京ICP备17072161号-1</p>
    </div>
</template>

<script>
    export default {
        name: "Footer"
    }
</script>

<style scoped>
    .footer {
        width: 100%;
        height: 128px;
        background: #25292e;
        color: #fff;
    }

    .footer ul {
        margin: 0 auto 16px;
        padding-top: 38px;
        width: 810px;
    }

    .footer ul li {
        float: left;
        width: 112px;
        margin: 0 10px;
        text-align: center;
        font-size: 14px;
    }

    .footer ul::after {
        content: "";
        display: block;
        clear: both;
    }

    .footer p {
        text-align: center;
        font-size: 12px;
    }
</style>

前台轮播图功能完成

  created() {
    this.$axios.get(this.$settings.BASE_URL + '/home/banner/').then(res => {
      console.log(res.data)
      if (res.data.code == 100) {
        this.img_list = res.data.data
      } else {
        this.$message(res.data.msg) 
      }
    }).catch(res => {
      this.$message('轮播图服务器异常,请稍后再试') # 前端捕获异常
    })
  }
<el-carousel height="400px" :interval="5000" arrow="always">
      <el-carousel-item v-for="item in img_list" :key="item.id">
        <div v-if="item.link.indexOf('http')>-1">
          <a :href="item.link">
            <img :src="item.image" :alt="item.title">
          </a>
        </div>
        <div v-else>
          <router-link :to="item.link">
            <img :src="item.image" :alt="item.title">
          </router-link>
        </div>


      </el-carousel-item>
    </el-carousel>

git介绍和安装

代码管理软件
git 
svn

功能:
	帮助开发者合并开发的代码
	如果出现冲突代码的合并,会提示后提交合并带啊吗的开发者,让其解决冲突
	代码版本管理
我们主要用来做代码管理[文件管理]
  • git是分布式管理,服务端挂掉本地还可以继续做版本管理,代码合并
  • svn为集成式管理,服务端挂掉就不能使用版本管理

git、gitee、github、gitlab区别

git:版本管理软件,装在操作系统上,又很多命令

gitee:远程仓库,开源代码,私有代码,有个网站,可以看到又那些开源代码,通过网站
做一些配置

软件安装一路下一步即可

image.png

image.png多出这两个东西就说明安装成功/cmd中输入git命令
image.png

git工作流程

git上有三个区
	工作区   存放文件的地方
	暂存区   工作区的变更,提交到暂存区
	版本库 	 暂存区的内容,提交到版本库

三个区需要进行相互操作,操作命令就是在操作这三个区

git常用命令

image.png
git管理文件 - git init

文件夹想要被git管理-文件夹作为仓库
	git init  #初始化仓库 当前文件夹 多出 .git文件夹
	不能删除.git文件夹,如果删除就不是git仓库了
	不要在跟路径下 初始化

git init '文件名' 自动在当前路径创建文件夹,并管理

文件--> 打开 gitbash --> git init

**查看文件变化 - ****git status**

查看文件变化
一定要在 .git 文件所在的文件夹下输入
git status

image.png

两种颜色:
红色:工作区变化了,但是没有提交到暂存区中
绿色:已经提交到暂存区,没有提交到版本库
无色:所有东西都在版本库中[意味着所有文件都被git管理起来了]

工作区变更提交到暂存区 -git add '文件名'

也可以编写 git add . 表示当前变更全部提交文件到暂存区

image.png
**暂存区 所有 内容提交到版本库 **- git commit -m '注释'

暂存区提交到版本库中的文件作为一个版本

设置作者(全局)

全局的意思是当前操作系统下所有仓库,提交到版本库时,都用这个作者
局部只针对当前仓库
git config --global user.email '[email protected]'
git config --global user.name 'suifengdd'

"""

注:在全局文件 C:\Users\用户文件夹\.gitconfig新建用户信息,在所有仓库下都可以使用
"""

设置作者(局部)


git config user.name '用户名'
	-- 用户名
git config user.email '用户邮箱'
	-- 用户邮箱
"""
注:在当前仓库下的config新建用户信息,只能在当前仓库下使用
注:一个仓库有局部用户,优先使用局部用户,没有配置再找全局用户
"""

**查看版本库信息 **git log** ****git reflog**

查看版本库信息
git log
	详细一些

git reflog 
	精简一些

**工作区的变更回退 **git checkout .

变更的内容,还原

**暂存区拉回工作区[由红变绿] ****git reset HEAD**
**回到某个版本 ****git reset --hard 版本号**

只要被'版本管理',可以回退到任意版本
  • 1)有红色信息(工作区有内容),就执行 add
  • 2)全绿信息(内容全部在暂存区),才执行 commit
  • 3)只有被版本库控制的代码,才能被监听,所以可以回滚到任何一个版本

空文件夹不会被git 记录

git忽略文件

咱们项目中有些文件,或文件夹不想被git管理
	使用步骤:
	1.在仓库目录下,git 目录下 新建 .gitignore
	2.在.gitignore中写文件名  
    	 mode_models
        .idea
        *.pyc
        *.log
	3.写的就会被忽略
	4.已经被管理过的不会被忽略

# 忽略文件写法
文件或文件夹名:代表所有目录下的同名文件或文件夹都被过滤
/文件或文件夹名:代表仓库根目录下的文件或文件夹被过滤

例如:
a.txt:项目中所有a.txt文件和文件夹都会被过滤
/a.txt:项目中只有根目录下a.txt文件和文件夹会被过滤
/b/a.txt:项目中只有根目录下的b文件夹下的a.txt文件和文件夹会被过滤
*x*:名字中有一个x的都会被过滤(*代表0~n个任意字符)
空文件夹不会被提交,空包会被提交,包可以被提交(包中有一个init空文件)

标签:git,Python,res,文件夹,首页,版本,path,data
From: https://www.cnblogs.com/ddsuifeng/p/17168176.html

相关文章

  • Git推送报错:unable to access 'https://github.com/xxxxxxxxxxxx.git/': Recv failure
    Git推送到新分支报错:unabletoaccess'https://github.com/xxxxxxxxxxxx.git/':Recvfailure:Connectionwasreset 原因:连接没有释放 解决方案:1、在git中执行......
  • Python eval代码函数示例
    描述eval()函数用来执行一个字符串表达式,并返回表达式的值。语法以下是eval()方法的语法:eval(expression[,globals[,locals]])参数expression--表达式。globals--变......
  • Python file 函数代码示例
    描述file() 函数用于创建一个file对象,它有一个别名叫 ​​open()​​,更形象一些,它们是内置函数。参数是以字符串的形式传递的。更多文件操作可参考:​​Python文件I/O​......
  • python的应用
    Python是一种开源的、跨平台的编程语言,可以被用于多种应用领域。它可以用来开发Web应用程序、移动应用程序、脚本、数据库、网络爬虫、机器学习、数据分析和自动化任务等......
  • Python 图片转PDF
    直接给接口吧↓用到的库:fpdf,PyPDF2importfpdfdefpicture2pdf(pic_path,output_path,vertical=False,format='A4'):#生成只有一页且铺满源图片的PDFp......
  • Python读取温度矩阵数据
    importcv2,structimportnumpyasnpimportmatplotlib.pyplotaspltclassTempMatrix():def__init__(self):passdefread_temp_matrix_img(......
  • 爬虫代码中Python中random模块的方法整理
    1、random产生0~1之间的随机小数。2、randrange在前两个参数范围内产生一个数字。不包括第二个参数,第三个参数是步长。3、randint在两个参数之间产生一个数字,左右两个参数都......
  • 爬虫代码中Python中time模块的方法整理
    1、时间戳time.time当前时间。2、time.sleep程序暂停三秒钟。3、time.ctime当前时间。年月日时分秒。4、time.localtime()将时间戳转换成元组。显示当前时间的详细信息。tim......
  • Python解析器如何在爬虫代码里搜索模块位置
    1、先找到当前目录。2、如果不在当前目录中,Python将在shell变量PYTHONPATH下搜索每个目录。3、如果找不到,Python会查看默认路径。在UNIX下,默认路径一般为/user/local/lib/py......
  • pod install&ndash;verbose 出错 仓库拉不下来 https://github.com/CocoaPods/Specs.g
    发布过unity+admobiOS包的开发者应该都有体会,构建版本时unity会很长时间卡在podinstall这个过程中,特别是在第一次执行构建xcode项目时,可能整个过程耗时要一个下午!在这个......