Git Product home page Git Product logo

coach's Introduction

coach

Live deploy

notes:

使用了vue2/3 +vue/cli + vue-router+vuex +sass + firebase:database/auth/host

  1. 使用异步组件:
    const BaseDialog = defineAsyncComponent(() => import('@/components/BaseDialog.vue'))
    app.component('base-dialog',BaseDialog)
    

2.注册登录 调用firebase的auth接口,用户可通过邮箱注册为coach和登录验证,获取token和登录过期时间(过期失效通过settimeout设置) 测试账号:[email protected] 密码:123123 可登入查看接收到的requests

3.路由页面滚动位置控制 配置路由scrollBehavior属性

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
  scrollBehavior(to, _, _2) { 
    if (to.path.includes('contact')) { 
      return {
        top: 300,
        behavior:'smooth'
      }
    }
    }
  }
)
  1. 使用路由守卫+routes设置meta属性拦截页面跳转
     router.beforeEach(function (to, from, next) { 
    if (to.meta.requiredAuth && !store.getters.hasToken) {
      next('/auth')
    } else if (to.meta.unRequiredAuth && store.getters.hasToken) {
      next('/coaches')
    } else { 
      next()
    }
    

})

5.coachlist 选项过滤 filter筛选获取的数据

6.表单验证 通过设置valid属性和submit时执行validForm()验证表单,提示验证信息

  <template>
   <div class="form-control" :class="{invalid: !firstName.isValid}">
          <label for="firstname">FirstName:</label>
          <input type="text" id="firstname" v-model.trim="firstName.val" @blur="clearValidate('firstName')">
          <p v-if="!firstName.isValid">FirstName can not be empty!</p>
        </div>
   ...
  </template>
        ...
  
   <script>
     clearValidate(input){
        this[input].isValid = true
      },
      validForm(){
        this.formValid= true
        if(!this.firstName.val){
          this.formValid = false
          this.firstName.isValid = false
        }
      ...
      }
  
     submitForm(){
        this.validForm()
        if (!this.formValid){
          return
        }
     ...
     }
   </script>
        

7.回复request 点击发件人邮箱打开系统邮箱

<a :href="`mailto:${req.email}`">{{req.email}}</a>

8.通过vuex保存request和coach信息,设置更新数据请求间隔为1min,减少向后台调用数据

getters:{
shouldFetch(state) { 
      return (Date.now() - state.fetchTime)> 60*1000
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.