From d1448cb0ef10f358bb7bddb4e1ec268515e0b787 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 15 七月 2025 11:46:57 +0800
Subject: [PATCH] 项目初始化

---
 uni_modules/uview-ui/components/u-navbar/u-navbar.vue |  186 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 186 insertions(+), 0 deletions(-)

diff --git a/uni_modules/uview-ui/components/u-navbar/u-navbar.vue b/uni_modules/uview-ui/components/u-navbar/u-navbar.vue
new file mode 100644
index 0000000..2b206b7
--- /dev/null
+++ b/uni_modules/uview-ui/components/u-navbar/u-navbar.vue
@@ -0,0 +1,186 @@
+<template>
+	<view class="u-navbar">
+		<view
+			class="u-navbar__placeholder"
+			v-if="fixed && placeholder"
+			:style="{
+				height: $u.addUnit($u.getPx(height) + $u.sys().statusBarHeight,'px'),
+			}"
+		></view>
+		<view :class="[fixed && 'u-navbar--fixed']">
+			<u-status-bar
+				v-if="safeAreaInsetTop"
+				:bgColor="bgColor"
+			></u-status-bar>
+			<view
+				class="u-navbar__content"
+				:class="[border && 'u-border-bottom']"
+				:style="{
+					height: $u.addUnit(height),
+					backgroundColor: bgColor,
+				}"
+			>
+				<view
+					class="u-navbar__content__left"
+					hover-class="u-navbar__content__left--hover"
+					hover-start-time="150"
+					@tap="leftClick"
+				>
+					<slot name="left">
+						<u-icon
+							v-if="leftIcon"
+							:name="leftIcon"
+							:size="leftIconSize"
+							:color="leftIconColor"
+						></u-icon>
+						<text
+							v-if="leftText"
+							:style="{
+								color: leftIconColor
+							}"
+							class="u-navbar__content__left__text"
+						>{{ leftText }}</text>
+					</slot>
+				</view>
+				<slot name="center">
+					<text
+						class="u-line-1 u-navbar__content__title"
+						:style="[{
+							width: $u.addUnit(titleWidth),
+						}, $u.addStyle(titleStyle)]"
+					>{{ title }}</text>
+				</slot>
+				<view
+					class="u-navbar__content__right"
+					v-if="$slots.right || rightIcon || rightText"
+					@tap="rightClick"
+				>
+					<slot name="right">
+						<u-icon
+							v-if="rightIcon"
+							:name="rightIcon"
+							size="20"
+						></u-icon>
+						<text
+							v-if="rightText"
+							class="u-navbar__content__right__text"
+						>{{ rightText }}</text>
+					</slot>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import props from './props.js';
+	/**
+	 * Navbar 鑷畾涔夊鑸爮
+	 * @description 姝ょ粍浠朵竴鑸敤浜庡湪鐗规畩鎯呭喌涓嬶紝闇�瑕佽嚜瀹氫箟瀵艰埅鏍忕殑鏃跺�欑敤鍒帮紝涓�鑸缓璁娇鐢╱ni-app甯︾殑瀵艰埅鏍忋��
+	 * @tutorial https://www.uviewui.com/components/navbar.html
+	 * @property {Boolean}			safeAreaInsetTop	鏄惁寮�鍚《閮ㄥ畨鍏ㄥ尯閫傞厤  锛堥粯璁� true 锛�
+	 * @property {Boolean}			placeholder			鍥哄畾鍦ㄩ《閮ㄦ椂锛屾槸鍚︾敓鎴愪竴涓瓑楂樺厓绱狅紝浠ラ槻姝㈠闄� 锛堥粯璁� false 锛�
+	 * @property {Boolean}			fixed				瀵艰埅鏍忔槸鍚﹀浐瀹氬湪椤堕儴 锛堥粯璁� false 锛�
+	 * @property {Boolean}			border				瀵艰埅鏍忓簳閮ㄦ槸鍚︽樉绀轰笅杈规 锛堥粯璁� false 锛�
+	 * @property {String}			leftIcon			宸﹁竟杩斿洖鍥炬爣鐨勫悕绉帮紝鍙兘涓簎View鑷甫鐨勫浘鏍� 锛堥粯璁� 'arrow-left' 锛�
+	 * @property {String}			leftText			宸﹁竟鐨勬彁绀烘枃瀛�
+	 * @property {String}			rightText			鍙宠竟鐨勬彁绀烘枃瀛�
+	 * @property {String}			rightIcon			鍙宠竟杩斿洖鍥炬爣鐨勫悕绉帮紝鍙兘涓簎View鑷甫鐨勫浘鏍�
+	 * @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 <u-navbar title="鍓戞湭閰嶅Ε锛屽嚭闂ㄥ凡鏄睙婀�" left-text="杩斿洖" right-text="甯姪" @click-left="onClickBack" @click-right="onClickRight"></u-navbar>
+	 */
+	export default {
+		name: 'u-navbar',
+		mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
+		data() {
+			return {
+
+			}
+		},
+		methods: {
+			// 鐐瑰嚮宸︿晶鍖哄煙
+			leftClick() {
+				// 濡傛灉閰嶇疆浜哸utoBack锛岃嚜鍔ㄨ繑鍥炰笂涓�椤�
+				this.$emit('leftClick')
+				if(this.autoBack) {
+					uni.navigateBack()
+				}
+			},
+			// 鐐瑰嚮鍙充晶鍖哄煙
+			rightClick() {
+				this.$emit('rightClick')
+			},
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	@import "../../libs/css/components.scss";
+
+	.u-navbar {
+
+		&--fixed {
+			position: fixed;
+			left: 0;
+			right: 0;
+			top: 0;
+			z-index: 11;
+		}
+
+		&__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: $u-main-color;
+			}
+
+			&__right {
+				right: 0;
+
+				&__text {
+					font-size: 15px;
+					margin-left: 3px;
+				}
+			}
+		}
+	}
+</style>

--
Gitblit v1.9.3