This commit is contained in:
hupeng
2023-10-11 11:27:47 +08:00
commit d0b337c596
659 changed files with 67106 additions and 0 deletions

View File

@ -0,0 +1,17 @@
## 1.0.72023-08-16
1. 修复ios可能存在点击返回按钮点不到的情况
## 1.0.62023-08-07
1. 修复nvue在ios端可能存在背景图样式错乱的BUG
## 1.0.52023-08-04
1. bgColor设置背景图片增加imgMode属性
## 1.0.42023-08-01
1. bgColor属性支持背景图片在线图片或base64图片都可以
## 1.0.32023-07-03
去除插槽判断避免某些平台不显示的BUG
## 1.0.22023-06-05
1. 兼容渐变背景色
## 1.0.12023-05-16
1. 优化组件依赖,修改后无需全局引入,组件导入即可使用
2. 优化部分功能
## 1.0.02023-05-10
uv-navbar 自定义导航栏

View File

@ -0,0 +1,89 @@
export default {
props: {
// 是否开启顶部安全区适配
safeAreaInsetTop: {
type: Boolean,
default: true
},
// 固定在顶部时,是否生成一个等高元素,以防止塌陷
placeholder: {
type: Boolean,
default: false
},
// 是否固定在顶部
fixed: {
type: Boolean,
default: true
},
// 是否显示下边框
border: {
type: Boolean,
default: false
},
// 左边的图标
leftIcon: {
type: String,
default: 'arrow-left'
},
// 左边的提示文字
leftText: {
type: String,
default: ''
},
// 左右的提示文字
rightText: {
type: String,
default: ''
},
// 右边的图标
rightIcon: {
type: String,
default: ''
},
// 标题
title: {
type: [String, Number],
default: ''
},
// 背景颜色
bgColor: {
type: String,
default: '#ffffff'
},
imgMode: {
type: String,
default: 'aspectFill'
},
// 标题的宽度
titleWidth: {
type: [String, Number],
default: '400rpx'
},
// 导航栏高度
height: {
type: [String, Number],
default: '44px'
},
// 左侧返回图标的大小
leftIconSize: {
type: [String, Number],
default: 20
},
// 左侧返回图标的颜色
leftIconColor: {
type: String,
default: '#303133'
},
// 点击左侧区域(返回图标),是否自动返回上一页
autoBack: {
type: Boolean,
default: false
},
// 标题的样式,对象或字符串
titleStyle: {
type: [String, Object],
default: ''
},
...uni.$uv?.props?.navbar
}
}

View File

@ -0,0 +1,254 @@
<template>
<view class="uv-navbar">
<view
class="uv-navbar__placeholder"
v-if="fixed && placeholder"
:style="{
height: $uv.addUnit($uv.getPx(height) + $uv.sys().statusBarHeight, 'px'),
}"
></view>
<view :class="[fixed && 'uv-navbar--fixed']">
<image
class="uv-navbar--bgimg"
:src="bgColor"
:mode="imgMode"
v-if="isImg"
:style="[bgImgStyle]"
></image>
<uv-status-bar
v-if="safeAreaInsetTop"
:bgColor="getStatusbgColor"
></uv-status-bar>
<view
class="uv-navbar__content"
:class="[border && 'uv-border-bottom']"
:style="[{
height: $uv.addUnit(height)
}, getBgColor]"
>
<view
class="uv-navbar__content__left"
hover-class="uv-navbar__content__left--hover"
hover-start-time="150"
@tap="leftClick"
>
<slot name="left">
<uv-icon
v-if="leftIcon"
:name="leftIcon"
:size="leftIconSize"
:color="leftIconColor"
></uv-icon>
<text
v-if="leftText"
:style="{
color: leftIconColor
}"
class="uv-navbar__content__left__text"
>{{ leftText }}</text>
</slot>
</view>
<slot name="center">
<text
class="uv-line-1 uv-navbar__content__title"
:style="[{
width: $uv.addUnit(titleWidth),
flex: '0 1 auto'
}, $uv.addStyle(titleStyle)]"
>{{ title }}</text>
</slot>
<view
class="uv-navbar__content__right"
@tap="rightClick"
>
<slot name="right">
<uv-icon
v-if="rightIcon"
:name="rightIcon"
size="20"
></uv-icon>
<text
v-if="rightText"
class="uv-navbar__content__right__text"
>{{ rightText }}</text>
</slot>
</view>
</view>
</view>
</view>
</template>
<script>
import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
import props from './props.js';
/**
* Navbar 自定义导航栏
* @description 此组件一般用于在特殊情况下需要自定义导航栏的时候用到一般建议使用uni-app带的导航栏。
* @tutorial https://www.uvui.cn/components/navbar.html
* @property {Boolean} safeAreaInsetTop 是否开启顶部安全区适配 (默认 true
* @property {Boolean} placeholder 固定在顶部时,是否生成一个等高元素,以防止塌陷 (默认 false
* @property {Boolean} fixed 导航栏是否固定在顶部 (默认 false
* @property {Boolean} border 导航栏底部是否显示下边框 (默认 false
* @property {String} leftIcon 左边返回图标的名称只能为uvui自带的图标 (默认 'arrow-left'
* @property {String} leftText 左边的提示文字
* @property {String} rightText 右边的提示文字
* @property {String} rightIcon 右边返回图标的名称只能为uvui自带的图标
* @property {String} title 导航栏标题,如设置为空字符,将会隐藏标题占位区域
* @property {String} bgColor 导航栏背景设置 (默认 '#ffffff'
* @property {String | Number} titleWidth 导航栏标题的最大宽度,内容超出会以省略号隐藏 (默认 '400rpx'
* @property {String | Number} height 导航栏高度(不包括状态栏高度在内,内部自动加上)(默认 '44px'
* @property {String | Number} leftIconSize 左侧返回图标的大小(默认 20px
* @property {String | Number} leftIconColor 左侧返回图标的颜色(默认 #303133
* @property {Boolean} autoBack 点击左侧区域(返回图标),是否自动返回上一页(默认 false
* @property {Object | String} titleStyle 标题的样式,对象或字符串
* @event {Function} leftClick 点击左侧区域
* @event {Function} rightClick 点击右侧区域
* @example<uv-navbar
:fixed="false" title="剑未配妥,出门已是江湖" left-text="返回" right-text="帮助" @click-left="onClickBack" @click-right="onClickRight"></uv-navbar>
*/
export default {
name: 'uv-navbar',
mixins: [mpMixin, mixin, props],
data() {
return {
}
},
computed: {
getBgColor() {
const style = {};
if (this.bgColor) {
if (this.bgColor.indexOf("gradient") > -1) {// 渐变色
style.backgroundImage = this.bgColor;
} else if (this.isImg) {
style.background = 'transparent';
} else {
style.background = this.bgColor;
}
}
return style;
},
getStatusbgColor() {
if (this.bgColor) {
if (this.isImg) {
return 'transparent';
} else {
return this.bgColor;
}
}
},
// 判断传入的bgColor属性是否图片路径只要带有"/"均认为是图片形式
isImg() {
const isBase64 = this.bgColor.indexOf('data:') > -1 && this.bgColor.indexOf('base64') > -1;
return this.bgColor.indexOf('/') !== -1 || isBase64;
},
bgImgStyle() {
const style = {};
if (this.safeAreaInsetTop) {
style.height = this.$uv.addUnit(this.$uv.sys().statusBarHeight + 44, 'px');
} else {
style.height = '44px';
}
return style;
}
},
methods: {
// 点击左侧区域
leftClick() {
// 如果配置了autoBack自动返回上一页
this.$emit('leftClick')
if (this.autoBack) {
uni.navigateBack()
}
},
// 点击右侧区域
rightClick() {
this.$emit('rightClick')
}
}
}
</script>
<style lang="scss" scoped>
$show-border: 1;
$show-border-bottom: 1;
$show-lines: 1;
@import '@/uni_modules/uv-ui-tools/libs/css/variable.scss';
@import '@/uni_modules/uv-ui-tools/libs/css/components.scss';
@import '@/uni_modules/uv-ui-tools/libs/css/color.scss';
.uv-navbar {
position: relative;
&--fixed {
position: fixed;
left: 0;
right: 0;
top: 0;
z-index: 11;
}
&--bgimg {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
/* #ifndef APP-NVUE */
width: 100%;
height: 100%;
/* #endif */
/* #ifdef APP-NVUE */
width: 750rpx;
/* #endif */
}
&__content {
@include flex(row);
align-items: center;
height: 44px;
background-color: #9acafc;
position: relative;
justify-content: center;
&__left,
&__right {
padding: 0 13px;
position: absolute;
top: 0;
bottom: 0;
@include flex(row);
align-items: center;
}
&__left {
left: 0;
&--hover {
opacity: 0.7;
}
&__text {
font-size: 15px;
margin-left: 3px;
}
}
&__title {
text-align: center;
font-size: 16px;
color: $uv-main-color;
}
&__right {
right: 0;
&__text {
font-size: 15px;
margin-left: 3px;
}
}
}
}
</style>

View File

@ -0,0 +1,89 @@
{
"id": "uv-navbar",
"displayName": "uv-navbar 自定义导航栏 全面兼容vue3+2、app、h5、小程序等多端",
"version": "1.0.7",
"description": "uv-navbar 此组件一般用于在特殊情况下,需要自定义导航栏的时候用到,一般建议使用自带的原生导航栏。",
"keywords": [
"uv-navbar",
"uvui",
"uv-ui",
"navbar",
"自定义导航栏"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "插件不采集任何数据",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [
"uv-ui-tools",
"uv-icon",
"uv-status-bar"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}

View File

@ -0,0 +1,19 @@
## Navbar 自定义导航栏
> **组件名uv-navbar**
此组件一般用于在特殊情况下,需要自定义导航栏的时候用到,一般建议使用自带的原生导航栏,支持渐变色、透明色、图片背景。
# <a href="https://www.uvui.cn/components/navbar.html" target="_blank">查看文档</a>
## [下载完整示例项目](https://ext.dcloud.net.cn/plugin?name=uv-ui) <small>(请不要 下载插件ZIP</small>
### [更多插件请关注uv-ui组件库](https://ext.dcloud.net.cn/plugin?name=uv-ui)
<a href="https://ext.dcloud.net.cn/plugin?name=uv-ui" target="_blank">
![image](https://mp-a667b617-c5f1-4a2d-9a54-683a67cff588.cdn.bspapp.com/uv-ui/banner.png)
</a>
#### 如使用过程中有任何问题反馈或者您对uv-ui有一些好的建议欢迎加入uv-ui官方交流群<a href="https://www.uvui.cn/components/addQQGroup.html" target="_blank">官方QQ群</a>