refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,17 @@
|
||||
const PAGE_PATH = '/pages/uni-ui/nav-bar/nav-bar'
|
||||
|
||||
describe('nav-bar', () => {
|
||||
let page
|
||||
|
||||
beforeEach(async () => {
|
||||
page = await program.reLaunch(PAGE_PATH)
|
||||
await page.waitFor('scroll-view')
|
||||
})
|
||||
|
||||
it('nav-bar snapshot', async () => {
|
||||
const image = await program.screenshot({
|
||||
fullPage: true
|
||||
})
|
||||
expect(image).toSaveImageSnapshot()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle"></uni-nav-bar>
|
||||
<scroll-view style="flex: 1;padding-bottom: var(--uni-safe-area-inset-bottom);" :class="state.isDarkMode ? 'theme-dark' : 'theme-light'">
|
||||
<!-- 正常使用场景应把uni-nav-bar放在template的根节点,本示例为了演示多种导航栏效果把导航栏组件放到了scroll-view里了 -->
|
||||
<uni-nav-bar navigationBarTextStyle="black" title="黑色标题"></uni-nav-bar>
|
||||
<uni-nav-bar navigationBarTextStyle="white" title="青色背景白色标题" style="background-color: cyan;"></uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle" title="下边带灰线" style="border-bottom: 0.5px #ccc solid;"></uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle" hideDefaultBack title="隐藏左侧返回箭头"></uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle" title="标题居左" mid-class="left-title"></uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle" title="右边有按钮">
|
||||
<template #right>
|
||||
<text class="txt-button" @click="clickButton">⋯</text>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle" title="右边有2个按钮" right-class="two-buttons">
|
||||
<template #right>
|
||||
<text class="txt-button" @click="clickButton">+</text>
|
||||
<text class="txt-button" @click="clickButton">⋯</text>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle" title="左边有按钮">
|
||||
<template #left>
|
||||
<text class="txt-button" @click="clickButton">+</text>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle" title="左右各1个按钮">
|
||||
<template #left>
|
||||
<text class="txt-button" @click="clickButton">+</text>
|
||||
</template>
|
||||
<template #right>
|
||||
<text class="txt-button" @click="clickButton">⋯</text>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle">
|
||||
<template #mid>
|
||||
<text :style="{ color: navigationBarTextStyle }">插槽右箭头可以点</text>
|
||||
<text style="padding: 3px;font-size: 10px;" class="uni-theme-text" @click="clickButton">▼</text>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
<uni-nav-bar :navigationBarTextStyle="navigationBarTextStyle">
|
||||
<template #left>
|
||||
<text class="txt-button" @click="clickButton">+</text>
|
||||
</template>
|
||||
<template #mid>
|
||||
<input placeholder="左中右都是插槽,中间是input" style="border: #ccc 0.5px solid;"/>
|
||||
</template>
|
||||
<template #right>
|
||||
<text class="txt-button" @click="clickButton">⋯</text>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { state } from '@/store/index';
|
||||
|
||||
const navigationBarTextStyle = ref('black')
|
||||
|
||||
function clickButton() {
|
||||
uni.showToast({
|
||||
title: '点击了按钮'
|
||||
});
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
// Android平台如果在onShow前调用API,会设置上一个页面的导航栏颜色,所以放在onShow里设置颜色
|
||||
// #ifdef APP-ANDROID
|
||||
if (state.isDarkMode) {
|
||||
navigationBarTextStyle.value = 'white'
|
||||
// 本示例中导航栏的背景色和通用背景色不同,前景色无法遵守theme.json的设置,需要单独设颜色
|
||||
uni.setNavigationBarColor({
|
||||
"frontColor":"#ffffff",
|
||||
"backgroundColor":"#000000" //微信规范不可为空
|
||||
})
|
||||
} else {
|
||||
navigationBarTextStyle.value = 'black'
|
||||
// 本示例中导航栏的背景色和通用背景色不同,前景色无法遵守theme.json的设置,需要单独设颜色
|
||||
uni.setNavigationBarColor({
|
||||
"frontColor":"#000000",
|
||||
"backgroundColor":"#ffffff" //微信规范不可为空
|
||||
})
|
||||
}
|
||||
// #endif
|
||||
})
|
||||
|
||||
watch((): boolean => state.isDarkMode, (newVal: boolean) => {
|
||||
if (newVal) {
|
||||
navigationBarTextStyle.value = 'white'
|
||||
// 本示例中导航栏的背景色和通用背景色不同,前景色无法遵守theme.json的设置,需要单独设颜色
|
||||
uni.setNavigationBarColor({
|
||||
"frontColor":"#ffffff",
|
||||
"backgroundColor":"#000000" //微信规范不可为空
|
||||
})
|
||||
} else {
|
||||
navigationBarTextStyle.value = 'black'
|
||||
// 本示例中导航栏的背景色和通用背景色不同,前景色无法遵守theme.json的设置,需要单独设颜色
|
||||
uni.setNavigationBarColor({
|
||||
"frontColor":"#000000",
|
||||
"backgroundColor":"#ffffff" //微信规范不可为空
|
||||
})
|
||||
}
|
||||
}
|
||||
// #ifndef APP-ANDROID
|
||||
// TODO Android在设置页面导航栏颜色后,后退页面,上一层页面的导航栏也被改了!原因是这个代码执行太早,activity还没创建好
|
||||
, { immediate: true }
|
||||
// #endif
|
||||
)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.left-title{
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.two-buttons{
|
||||
width: 88px;
|
||||
}
|
||||
.txt-button{
|
||||
font-weight: bold;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
text-align: center;
|
||||
color: var(--text-color);
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户