首页 > 编程语言 >直播app源码,默认显示搜索框 保留搜索条件

直播app源码,默认显示搜索框 保留搜索条件

时间:2023-11-22 14:11:23浏览次数:28  
标签:search title app 源码 搜索 router routes path

直播app源码,默认显示搜索框 保留搜索条件

<template>
  <div :class="{'show':show}">
    <svg-icon class-name="search-icon" icon-class="search" @click.stop="click" />
    <el-select
      ref="headerSearchSelect"
      v-model="search"
      :remote-method="querySearch"
      filterable
      default-first-option
      remote
      placeholder="菜单快捷搜索"
     
      @change="change"
    >
      <el-option v-for="option in options" :key="option.item.path" :value="option.item" :label="option.item.title.join(' > ')" />
    </el-select>
  </div>
</template>
 
<script>
// fuse is a lightweight fuzzy-search module
// make search results more in line with expectations
import Fuse from 'fuse.js/dist/fuse.min.js'
import path from 'path'
 
export default {
  name: 'HeaderSearch',
  data() {
    return {
      search: '',
      options: [],
      searchPool: [],
      show: true,//右上角搜索框 默认开启
      fuse: undefined
    }
  },
  computed: {
    routes() {
      return this.$store.getters.permission_routes
    }
  },
  watch: {
    routes() {
      this.searchPool = this.generateRoutes(this.routes)
    },
    searchPool(list) {
      this.initFuse(list)
    },
    show(value) {
      if (value) {
        document.body.addEventListener('click', this.close)
      } else {
        document.body.removeEventListener('click', this.close)
      }
    }
  },
  mounted() {
    this.searchPool = this.generateRoutes(this.routes)
  },
  methods: {
    click() {
      this.show = !this.show
      if (this.show) {
        this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus()
      }
    },
    close() {
      this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur()
      // this.options = [] //清空搜索结果;注释掉:保留上一次的搜索结果
      //this.show = false //false 关闭搜索框;注释掉:搜索框停留
    },
    change(val) {
      const path = val.path;
      if(this.ishttp(val.path)) {
        // http(s):// 路径新窗口打开
        const pindex = path.indexOf("http");
        window.open(path.substr(pindex, path.length), "_blank");
      } else {
        this.$router.push(val.path)
      }
      //this.search = '' //清空搜索词;注释掉:保留上一次的搜索词
      //this.options = [] //清空搜索结果;注释掉:保留上一次的搜索结果
      this.$nextTick(() => {
        //this.show = false //false 关闭搜索框;注释掉:搜索框停留
      })
    },
    initFuse(list) {
      this.fuse = new Fuse(list, {
        shouldSort: true,
        threshold: 0.4,
        location: 0,
        distance: 100,
        minMatchCharLength: 1,
        keys: [{
          name: 'title',
          weight: 0.7
        }, {
          name: 'path',
          weight: 0.3
        }]
      })
    },
    // Filter out the routes that can be displayed in the sidebar
    // And generate the internationalized title
    generateRoutes(routes, basePath = '/', prefixTitle = []) {
      let res = []
 
      for (const router of routes) {
        // skip hidden router
        if (router.hidden) { continue }
 
        const data = {
          path: !this.ishttp(router.path) ? path.resolve(basePath, router.path) : router.path,
          title: [...prefixTitle]
        }
 
        if (router.meta && router.meta.title) {
          data.title = [...data.title, router.meta.title]
 
          if (router.redirect !== 'noRedirect') {
            // only push the routes with title
            // special case: need to exclude parent router without redirect
            res.push(data)
          }
        }
 
        // recursive child routes
        if (router.children) {
          const tempRoutes = this.generateRoutes(router.children, data.path, data.title)
          if (tempRoutes.length >= 1) {
            res = [...res, ...tempRoutes]
          }
        }
      }
      return res
    },
    querySearch(query) {
      if (query !== '') {
        this.options = this.fuse.search(query)
      } else {
        this.options = []
      }
    },
    ishttp(url) {
      return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1
    }
  }
}
</script>
 
<style scoped>
.header-search {
  font-size: 0 !important;
 
  .search-icon {
    cursor: pointer;
    font-size: 18px;
    vertical-align: middle;
  }
 
  .header-search-select {
    font-size: 18px;
    transition: width 0.2s;
    width: 0;
    overflow: hidden;
    background: transparent;
    border-radius: 0;
    display: inline-block;
    vertical-align: middle;
 
    ::v-deep .el-input__inner {
      border-radius: 0;
      border: 0;
      padding-left: 0;
      padding-right: 0;
      box-shadow: none !important;
      border-bottom: 1px solid #d9d9d9;
      vertical-align: middle;
    }
  }
 
  &.show {
    .header-search-select {
      width: 210px;
      margin-left: 10px;
    }
  }
}
</style>

​以上就是直播app源码,默认显示搜索框 保留搜索条件, 更多内容欢迎关注之后的文章

 

标签:search,title,app,源码,搜索,router,routes,path
From: https://www.cnblogs.com/yunbaomengnan/p/17848881.html

相关文章

  • VS2022下nuget包同步失败,提示: PackageSourceMapping 已启用,未考虑以下源: **
    随着Net8的发布,顺带VS2022升级到17.8后,发现nuget还原恢复多了一些配置: 有问题的时候,会提示未找到映射源,此时编译会报错,如下示例: 严重性代码说明项目文件行禁止显示状态错误NU1100无法解析net7.0-android33.0的“HarfBuzzSharp.NativeAssets.Linux(>=2.8.2.3)”......
  • Maybatis-Plus 数据库查询 lambdaQuery和mapper中EQ、NE、GT、LT、GE、LE、select、li
    Maybatis-PluslambdaQuery和mapper中EQ、NE、GT、LT、GE、LE的用法及详解实体当前实体如下,后续代码示例都用该实体;@Data@TableName("user_info")@ApiModel(value="UserInfo对象",description="")publicclassUserInfoimplementsSerializable{privatesta......
  • 【Java】乡镇卫生院、社区卫生服务中心云HIS源码
    云HIS采用云端SaaS服务的方式提供,用户通过浏览器即能访问,无需关注系统的部署、维护、升级等问题,系统充分考虑了模板化、配置化、智能化、扩展化等设计方法,覆盖了基层医院机构的主要工作流程,能够与监管系统有序对接,并能满足系统后期扩展的需要。一、医保数据上传医保数据上传是将......
  • uniapp app上传图片并设置超过10m进行图片压缩
    组件页面<template>   <viewclass="upload-wrapper">      <viewv-if="pictureUrl.length">         <viewclass="preview"v-for="(item,index)inpictureUrl":key='index'>        ......
  • 报错:Invalid bound statement (not found): com.ljxx.pts.dao.SitePriceMapper.select
    如果你是Mybatis的话请注意yml或者properties文件里面的组件扫描#指定mapper.xml的位置mybatis.mapperLocations=classpath*:mapper/**/*Mapper.xmlmybatis.configuration.map-underscore-to-camel-case=true注意:由于上面指定的是Mapper.xml,故xml文件不要携程Dao.xml......
  • 面试必刷TOP101:30、二叉搜索树与双向链表
    题目题解/*思路:首先根节点以及其左右子树,左子树的左子树和右子树的右子树相同*左子树的右子树和右子树的左子树相同即可,采用递归*非递归也可,采用栈或队列存取各级子树根节点*/publicclassSolution{ booleanisSymmetrical(TreeNodepRoot) { if(pRoot==null){ re......
  • app检测
    magisk检测检测方式为:1.遍历maps文件,找到app_process模块的内存,遍历app_process内存,查找magisk和MAGISK字符串。2.从给定的变量v282开始,进行栈残留检查,从当前位置检查至栈底,查找magisk和MAGISK字符串。3.在/proc/self/mounts文件中查找magisk字符串检查模拟器检查方法为......
  • Java的Integer.bitCount()源码分析
    本文部分参考:https://blog.csdn.net/weixin_42092787/article/details/106607426常规解法对于统计一个32位的二进制数值当中1的数量这个问题,常规解法如下:publicinthammingWeight(intn){intcount=0;for(inti=0;i<32;i++){n......
  • 免费AI换脸app72写真使用感受
    使用72写真app后,我对它的使用体验有一些深刻的感受。选择喜欢的封面图,点击一键生成一款写真,等待15秒会生成1张用户的写真,点击写真可以下载到手机相册,写真是根据用户上传的头像生成,因此上传更清晰的正面的无遮挡的大头照会更像苹果应用商店(AppStore)预览链接:https://apps.ap......
  • 弹钢琴 app,Android 开发实战
    A.项目描述本项目主要实现了【钢琴键盘的模拟】、【弹奏引导】以及【乐曲库】等功能。钢琴键盘模拟:提供全尺寸键盘,并且根据用户的喜好来调整键盘的颜色样式。弹奏引导:用户可以根据键盘上的提示符号......