|
@@ -2,71 +2,52 @@
|
|
|
<view :class="classes">
|
|
<view :class="classes">
|
|
|
<view class="nut-navbar__left">
|
|
<view class="nut-navbar__left">
|
|
|
<nut-icon v-if="leftShow" color="#979797" name="left" @click="handleLeft"></nut-icon>
|
|
<nut-icon v-if="leftShow" color="#979797" name="left" @click="handleLeft"></nut-icon>
|
|
|
|
|
+ <slot name="left"></slot>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="nut-navbar__title">
|
|
<view class="nut-navbar__title">
|
|
|
- <view v-if="title" class="text__title" @click="handleCenter">{{ title }}</view>
|
|
|
|
|
|
|
+ <view v-if="title" @click="handleCenter">{{ title }}</view>
|
|
|
<nut-icon v-if="titIcon" class="icon" :name="titIcon" @click="handleCenterIcon"></nut-icon>
|
|
<nut-icon v-if="titIcon" class="icon" :name="titIcon" @click="handleCenterIcon"></nut-icon>
|
|
|
<slot name="content"></slot>
|
|
<slot name="content"></slot>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="nut-navbar__right" v-if="desc || icon">
|
|
|
|
|
- <view v-if="desc" @click="handleClear">{{ desc }}</view>
|
|
|
|
|
- <template v-if="icon">
|
|
|
|
|
- <view @click="handleSends">
|
|
|
|
|
- <slot name="icons"></slot>
|
|
|
|
|
- </view>
|
|
|
|
|
- </template>
|
|
|
|
|
- <view>
|
|
|
|
|
- <nut-icon v-if="icon" class="rightIcon" :name="icon" @click="handleSend"></nut-icon>
|
|
|
|
|
- </view>
|
|
|
|
|
|
|
+
|
|
|
|
|
+ <view class="nut-navbar__right">
|
|
|
|
|
+ <view v-if="desc" class="right_text" @click="handleRight">{{ desc }}</view>
|
|
|
|
|
+ <slot name="right"></slot>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
|
-import { computed, ref } from 'vue';
|
|
|
|
|
|
|
+import { computed, toRefs } from 'vue';
|
|
|
import { createComponent } from '../../utils/create';
|
|
import { createComponent } from '../../utils/create';
|
|
|
const { componentName, create } = createComponent('navbar');
|
|
const { componentName, create } = createComponent('navbar');
|
|
|
export default create({
|
|
export default create({
|
|
|
props: {
|
|
props: {
|
|
|
- leftShow: { type: Boolean, default: true }, //左侧 是否显示返回
|
|
|
|
|
|
|
+ leftShow: { type: Boolean, default: true }, //左侧 是否显示返回icon
|
|
|
title: { type: String, default: '' }, //中间 文字标题
|
|
title: { type: String, default: '' }, //中间 文字标题
|
|
|
titIcon: { type: String, default: '' }, //中间 标题icon
|
|
titIcon: { type: String, default: '' }, //中间 标题icon
|
|
|
- icon: { type: String, default: '' }, //右侧 按钮图标
|
|
|
|
|
desc: { type: String, default: '' }, //右侧 按钮文字
|
|
desc: { type: String, default: '' }, //右侧 按钮文字
|
|
|
- defaultIndex: {
|
|
|
|
|
- type: Number,
|
|
|
|
|
- default: 0
|
|
|
|
|
|
|
+ fixed: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: false
|
|
|
|
|
+ },
|
|
|
|
|
+ safeAreaInsetTop: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- emits: [
|
|
|
|
|
- 'click',
|
|
|
|
|
- 'on-click-back',
|
|
|
|
|
- 'on-click-title',
|
|
|
|
|
- 'on-click-right',
|
|
|
|
|
- 'on-click-desc',
|
|
|
|
|
- 'on-click-icon',
|
|
|
|
|
- 'on-click-more',
|
|
|
|
|
- 'on-click-clear',
|
|
|
|
|
- 'on-click-send',
|
|
|
|
|
- 'on-click-slot',
|
|
|
|
|
- 'on-click-slot-send',
|
|
|
|
|
- 'switch-tab'
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ emits: ['click', 'on-click-back', 'on-click-title', 'on-click-icon', 'on-click-right'],
|
|
|
setup(props, { emit }) {
|
|
setup(props, { emit }) {
|
|
|
- const activeIndex = ref(props.defaultIndex);
|
|
|
|
|
|
|
+ const { fixed, safeAreaInsetTop } = toRefs(props);
|
|
|
const classes = computed(() => {
|
|
const classes = computed(() => {
|
|
|
const prefixCls = componentName;
|
|
const prefixCls = componentName;
|
|
|
return {
|
|
return {
|
|
|
- [prefixCls]: true
|
|
|
|
|
|
|
+ [prefixCls]: true,
|
|
|
|
|
+ [`${prefixCls}--fixed`]: fixed.value,
|
|
|
|
|
+ [`${prefixCls}--safe-area-inset-top`]: safeAreaInsetTop.value
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- function switchTitle(id: number, name: string) {
|
|
|
|
|
- activeIndex.value = id;
|
|
|
|
|
- // console.log(id);
|
|
|
|
|
- emit('switch-tab', activeIndex.value, name);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function handleLeft() {
|
|
function handleLeft() {
|
|
|
emit('on-click-back');
|
|
emit('on-click-back');
|
|
|
}
|
|
}
|
|
@@ -78,24 +59,8 @@ export default create({
|
|
|
emit('on-click-icon');
|
|
emit('on-click-icon');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function handleClear() {
|
|
|
|
|
- emit('on-click-clear');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function handleMore() {
|
|
|
|
|
- emit('on-click-more');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function handleSend() {
|
|
|
|
|
- emit('on-click-send');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function handleSlot() {
|
|
|
|
|
- emit('on-click-slot');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function handleSends() {
|
|
|
|
|
- emit('on-click-slot-send');
|
|
|
|
|
|
|
+ function handleRight() {
|
|
|
|
|
+ emit('on-click-right');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
@@ -103,12 +68,7 @@ export default create({
|
|
|
handleLeft,
|
|
handleLeft,
|
|
|
handleCenter,
|
|
handleCenter,
|
|
|
handleCenterIcon,
|
|
handleCenterIcon,
|
|
|
- handleClear,
|
|
|
|
|
- handleSend,
|
|
|
|
|
- handleSlot,
|
|
|
|
|
- handleSends,
|
|
|
|
|
- switchTitle,
|
|
|
|
|
- activeIndex
|
|
|
|
|
|
|
+ handleRight
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|