Commit 89a7a9cd by 岑成威

fix: 整理

1 parent 60c53226
<template>
<view class="app-navbar-root">
<!-- fixed 时占位,避免内容顶到屏幕最上(总高 = 安全区 + 导航条) -->
<view
v-if="fixed && placeholder"
class="app-navbar-placeholder"
:style="placeholderStyle"
></view>
<view class="app-navbar-shell" :class="shellClass" :style="shellStyle">
<view
v-if="safeAreaInsetTop"
class="app-navbar-safe-top"
:style="safeTopStyle"
></view>
<view
class="app-navbar-bar"
:class="barBorderClass"
:style="barRowStyle"
>
<view
v-if="showBack"
class="app-navbar-left"
@tap="onLeftTap"
>
<uni-icons
:color="leftIconColor"
:size="leftIconSizeNum"
:type="leftIcon"
></uni-icons>
<text
v-if="leftText != ''"
class="app-navbar-left-text"
>{{ leftText }}</text>
</view>
<view v-else class="app-navbar-left-spacer"></view>
<view class="app-navbar-center">
<slot name="center">
<text
v-if="title != ''"
class="app-navbar-title"
>{{ title }}</text>
</slot>
</view>
<view class="app-navbar-right">
<slot name="right"></slot>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { computed, onMounted, ref } from "vue"
import { calcWindowTopInsetPx } from "@/utils/safe-area.uts"
import { router } from "@/utils/router.uts"
type AppNavbarProps = {
title?: string
/** 是否显示左侧返回区(图标 ± 文案) */
showBack?: boolean
/** 为 true 时点击左侧默认 router.back()(与项目路由钩子一致) */
autoBack?: boolean
safeAreaInsetTop?: boolean
bgColor?: string
border?: boolean
fixed?: boolean
placeholder?: boolean
/** 导航条内容区高度(px),不含安全区 */
barHeight?: number
leftIcon?: string
leftIconColor?: string
leftIconSize?: number
leftText?: string
/** fixed 时壳层 z-index;不传默认 200(详情页全屏时可传 0 压低层级) */
zIndex?: number | null
}
const props = withDefaults(defineProps<AppNavbarProps>(), {
title: "",
showBack: true,
autoBack: true,
safeAreaInsetTop: true,
bgColor: "#ffffff",
border: false,
fixed: false,
placeholder: false,
barHeight: 48,
leftIcon: "left",
leftIconColor: "#000000",
leftIconSize: 20,
leftText: "",
zIndex: null
})
const emit = defineEmits<{
leftClick: []
}>()
const insetTopPx = ref(0)
function refreshInset(): void {
insetTopPx.value = calcWindowTopInsetPx(uni.getWindowInfo())
}
onMounted(() => {
refreshInset()
})
const barHeightPx = computed((): number => {
const h = props.barHeight
return h > 0 ? h : 48
})
const totalHeightPx = computed((): number => {
const safe = props.safeAreaInsetTop ? insetTopPx.value : 0
return safe + barHeightPx.value
})
const placeholderStyle = computed((): UTSJSONObject => {
return {
height: `${totalHeightPx.value}px`,
width: "100%"
} as UTSJSONObject
})
const shellClass = computed((): string => {
return props.fixed ? "app-navbar-shell--fixed" : ""
})
const shellStyle = computed((): UTSJSONObject => {
const style = {
backgroundColor: props.bgColor,
width: "100%"
} as UTSJSONObject
if (props.fixed) {
style["position"] = "fixed"
style["top"] = "0"
style["left"] = "0"
const zi = props.zIndex
style["zIndex"] = zi != null ? zi : 200
}
return style
})
const safeTopStyle = computed((): UTSJSONObject => {
return {
height: `${insetTopPx.value}px`,
width: "100%"
} as UTSJSONObject
})
const barRowStyle = computed((): UTSJSONObject => {
return {
height: `${barHeightPx.value}px`,
width: "100%"
} as UTSJSONObject
})
const barBorderClass = computed((): string => {
return props.border ? "app-navbar-bar--border" : ""
})
const leftIconSizeNum = computed((): number => {
const s = props.leftIconSize
return s > 0 ? s : 20
})
function onLeftTap(): void {
emit("leftClick")
if (props.autoBack) {
router.back(null)
}
}
</script>
<style>
.app-navbar-root {
width: 100%;
display: flex;
flex-direction: column;
}
.app-navbar-placeholder {
flex-shrink: 0;
}
.app-navbar-shell {
display: flex;
flex-direction: column;
flex-shrink: 0;
}
.app-navbar-shell--fixed {
width: 100%;
}
.app-navbar-safe-top {
flex-shrink: 0;
width: 100%;
}
.app-navbar-bar {
display: flex;
flex-direction: row;
flex-shrink: 0;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding-left: 4px;
padding-right: 8px;
}
.app-navbar-bar--border {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #eeeeee;
}
.app-navbar-left {
width: 48px;
height: 100%;
display: flex;
flex-direction: row;
flex-shrink: 0;
align-items: center;
justify-content: center;
}
.app-navbar-left-text {
margin-left: 2px;
font-size: 15px;
color: #000000;
}
.app-navbar-left-spacer {
width: 48px;
flex-shrink: 0;
height: 100%;
}
.app-navbar-center {
flex: 1;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
overflow: hidden;
padding-left: 8px;
padding-right: 8px;
}
.app-navbar-title {
font-size: 17px;
font-weight: 500;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
}
.app-navbar-right {
min-width: 48px;
height: 100%;
display: flex;
flex-direction: row;
flex-shrink: 0;
align-items: center;
justify-content: flex-end;
}
</style>
......@@ -94,7 +94,7 @@
<!-- 底部按钮 -->
<view class="popup-footer">
<view class="flex-1" style="margin-right: 12px;">
<view class="flex-1 popup-footer-item popup-footer-item-first">
<un-button :block="true"
round="8px"
size="large"
......@@ -554,8 +554,8 @@ defineExpose({ open, close });
}
.portrait-wrapper {
width: 100vw;
max-height: 85vh;
width: 100%;
height: 85%;
border-radius: 20px 20px 0 0;
}
......@@ -602,7 +602,6 @@ defineExpose({ open, close });
.content {
width: 100%;
min-height: 100%;
display: flex;
flex-direction: column;
padding-bottom: 20px;
......@@ -612,8 +611,7 @@ defineExpose({ open, close });
display: flex;
flex-direction: row;
padding: 16px 20px;
padding-bottom: calc(24px + env(safe-area-inset-bottom)); /* 确保无论是否有安全区,底部都留有24px的间隔 */
gap: 16px;
padding-bottom: 24px;
flex-shrink: 0;
align-items: center;
background: #ffffff;
......@@ -622,6 +620,14 @@ defineExpose({ open, close });
z-index: 2;
}
.popup-footer-item {
width: 0;
}
.popup-footer-item-first {
margin-right: 16px;
}
.pop-tips {
width: 100%;
background: rgba(44, 102, 247, 0.1);
......
<template>
<view class="layout-root" :class="[resolutionState.cssClass]">
<un-page class="layout-root layout-column-shell" :class="[resolutionState.cssClass]">
<slot />
</view>
</un-page>
</template>
<script setup lang="uts">
......@@ -11,8 +11,8 @@ import { resolutionState, useResolutionConfig } from "@/services/adapter/index.u
useResolutionConfig();
</script>
<style scoped>
.layout-root {
<style>
.layout-column-shell {
width: 100%;
height: 100%;
display: flex;
......
<template>
<view class="layout-root" :class="[modeClass, resolutionClass, adapterClass]" :style="styleObj">
<slot></slot>
</view>
</un-page>
</template>
<script setup lang="uts">
......@@ -79,8 +79,8 @@ onUnmounted(() => {
})
</script>
<style scoped>
.layout-root {
<style>
.layout-root-shell {
width: 100%;
height: 100%;
}
......
......@@ -171,7 +171,6 @@
background-size: cover;
background-repeat: no-repeat;
z-index: -1;
will-change: transform;
}
.skeleton-box {
......
......@@ -183,6 +183,5 @@ type TouchEvent = {
left: 0;
top: 0;
transform-origin: center center;
will-change: transform;
}
</style>
......@@ -759,6 +759,7 @@ defineExpose({
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
background: linear-gradient(180deg, rgba(240, 244, 255, 0.96), rgba(220, 230, 248, 0.92));
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
overflow: hidden;
......
......@@ -82,7 +82,8 @@
"^layout-root$": "@/components/LayoutRoot/index.uvue",
"^Layout$": "@/components/Layout/index.uvue",
"^segment-tab$": "@/pages/receptionCenter/SegmentTab.uvue",
"^reception-detail$": "@/pages/receptionCenter/receptionDetail.uvue"
"^reception-detail$": "@/pages/receptionCenter/receptionDetail.uvue",
"^app-navbar$": "@/components/AppNavbar/index.uvue",
}
},
"globalStyle": {
......
......@@ -331,7 +331,7 @@ defineExpose({
.swiper-name {
padding-top: var(--l-spacing-lg);
text-indent: 67px;
padding-left: 67px;
color: #333;
font-size: var(--l-font-base);
font-weight: 500;
......@@ -530,7 +530,7 @@ defineExpose({
.swiper-name {
padding-top: var(--l-spacing-lg);
text-indent: 67px;
padding-left: 67px;
color: #333;
font-size: var(--l-font-base);
font-weight: 500;
......
......@@ -124,10 +124,6 @@ const open = (): void => {
inputFocus.value = true;
};
const back = (): void => {
uni.navigateBack();
};
const setStep = (index: number): void => {
if (index == 2) return;
if (stepIndex.value > index) {
......@@ -189,6 +185,7 @@ const chooseMerchant = (userInfo: any): void => {
padding-top: 0;
padding-bottom: 0;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
display: flex;
......
......@@ -308,7 +308,6 @@
top: 0;
left: 0;
visibility: hidden;
will-change: transform;
}
.swipe-stack-show {
position: absolute;
......
......@@ -2,16 +2,13 @@
<layout-root>
<view :key="dateilKey"
class="detail-box">
<view class="nav-bar"
:style="{ 'z-index': backZindex }">
<view class="back"
@tap="back">
<uni-icons color="#000"
:size="20"
type="left">
</uni-icons>
</view>
</view>
<app-navbar fixed
:placeholder="false"
bg-color="transparent"
:border="false"
:auto-back="false"
:z-index="backZindex"
@left-click="back" />
<ModuleSwipeStack v-model:current-id="id"
:draw-status="drawStatus"
:items="moduleList"
......@@ -598,22 +595,6 @@ onBackPress((options: OnBackPressOptions) => {
height: 100%;
margin: 0 auto;
}
.nav-bar {
position: fixed;
width: 100%;
height: 48px;
left: 0;
top: 24px;
z-index: 9;
.back {
width: 48px;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
}
.pen-box {
position: fixed;
right: 20px;
......
......@@ -112,7 +112,7 @@ function onPlayRecord(): void {
<style scoped lang="scss">
.page {
width: 100%;
min-height: 100%;
height: 100%;
display: flex;
flex-direction: column;
background: #f5f7fa;
......
......@@ -1388,7 +1388,6 @@ defineExpose({
border-radius: 12px;
background-color: #ffffff;
background-image: linear-gradient(to bottom, #f0f6ff 0%, #ffffff 100%);
backdrop-filter: blur(8px);
box-shadow: inset 0 0 8px 0 #ffffff;
border-width: 1px;
border-style: solid;
......@@ -1428,7 +1427,6 @@ defineExpose({
font-size: 14px;
color: #9CA3AF;
margin-left: 8px;
text-decoration: underline;
}
.tag-row {
......@@ -1621,7 +1619,6 @@ defineExpose({
border-color: #FFFFFF;
opacity: 1;
background: #ffffff33;
backdrop-filter: blur(8px);
box-shadow: inset 0 0 8px 0 #ffffff;
overflow: hidden;
}
......@@ -1971,7 +1968,6 @@ defineExpose({
.bubble-text {
font-size: 14px;
color: #374151;
word-break: break-all;
}
.bubble-text-selected {
......@@ -2033,7 +2029,6 @@ defineExpose({
font-size: 12px;
color: #4B5563;
line-height: 1.5;
word-break: break-all;
}
/* ── 底部占位 ───────────────────────────────────────────────────────────────── */
......
......@@ -95,6 +95,14 @@ export function isEmpty(value: any): boolean {
*/
export const nullValues = [null, ""];
export function keys(object: any): string[] {
if (!isObject(object)) {
return [];
}
return UTSJSONObject.keys(object as UTSJSONObject);
}
/**
* 格式化日期时间
*/
......@@ -214,7 +222,8 @@ export function map<T, U>(array: T[], iteratee: (item: T, index: number) => U):
if (!isArray(array)) return result;
for (const [i, element] of array.entries()) {
for (let i = 0; i < array.length; i++) {
const element = array[i];
result.push(iteratee(element, i));
}
......@@ -233,7 +242,8 @@ export function reduce<T, U>(
if (!isArray(array)) return initialValue;
let accumulator: U = initialValue;
for (const [i, element] of array.entries()) {
for (let i = 0; i < array.length; i++) {
const element = array[i];
accumulator = iteratee(accumulator, element, i);
}
......@@ -247,7 +257,8 @@ export function reduce<T, U>(
export function every<T>(array: T[], predicate: (value: T, index: number) => boolean): boolean {
if (!isArray(array)) return true;
for (const [i, element] of array.entries()) {
for (let i = 0; i < array.length; i++) {
const element = array[i];
if (!predicate(element, i)) {
return false;
}
......@@ -263,7 +274,8 @@ export function every<T>(array: T[], predicate: (value: T, index: number) => boo
export function some<T>(array: T[], predicate: (value: T, index: number) => boolean): boolean {
if (!isArray(array)) return false;
for (const [i, element] of array.entries()) {
for (let i = 0; i < array.length; i++) {
const element = array[i];
if (predicate(element, i)) {
return true;
}
......@@ -446,7 +458,8 @@ export function remove<T>(array: T[], predicate: (value: T, index: number) => bo
const result: T[] = [];
for (const [i, element] of array.entries()) {
for (let i = 0; i < array.length; i++) {
const element = array[i];
if (!predicate(element, i)) {
result.push(element);
}
......@@ -463,7 +476,8 @@ export function forEach<T>(data: T[], iteratee: (value: T, index: number) => voi
if (isArray(data)) {
const array = data as T[];
for (const [i, element] of array.entries()) {
for (let i = 0; i < array.length; i++) {
const element = array[i];
if (element != null) {
iteratee(element, i);
}
......@@ -478,7 +492,8 @@ export function forEach<T>(data: T[], iteratee: (value: T, index: number) => voi
export function find<T>(array: T[], predicate: (value: T, index: number) => boolean): null | T {
if (!isArray(array)) return null;
for (const [i, element] of array.entries()) {
for (let i = 0; i < array.length; i++) {
const element = array[i];
if (predicate(element, i)) {
return element;
}
......
......@@ -80,16 +80,17 @@ PAGES.forEach((e) => {
});
// TABS 用于存储 tabBar 配置项
// export let TABS: TabBarItem[] = [];
export let TABS: TabBarItem[] = [];
// 如果 tabBar 配置存在且列表不为空,则初始化 TABS
// if (ctx.tabBar.list != null) {
// TABS = ctx.tabBar.list;
// Android 端静态初始化阶段,tabBar 可能为空,需先判空再访问 list
const tabBar = ctx.tabBar;
if (tabBar != null && tabBar.list != null) {
TABS = [...tabBar.list];
// // 确保每个 tabBar 页面的路径都以 "/" 开头
// TABS.forEach((e) => {
// if (!e.pagePath.startsWith("/")) {
// e.pagePath = "/" + e.pagePath;
// }
// });
// }
// 确保每个 tabBar 页面的路径都以 "/" 开头
TABS.forEach((e) => {
if (!e.pagePath.startsWith("/")) {
e.pagePath = "/" + e.pagePath;
}
});
}
......@@ -306,7 +306,15 @@ export class Router {
if (path == "/") {
path = this.defaultPath("home");
}
return !isNull(TABS.find((e) => path == e.pagePath));
for (let i = 0; i < TABS.length; i++) {
const tab = TABS[i];
if (path == tab.pagePath) {
return true;
}
}
return false;
}
// 判断是否为登录页
......
/**
* 与窗口安全区/状态栏对齐的顶部 inset(px),用于自定义导航栏占位。
* 优先 safeAreaInsets.top,其次 safeArea.top,最后 statusBarHeight。
*/
export function calcWindowTopInsetPx(info: GetWindowInfoResult): number {
let topInset = 0
const insets = info.safeAreaInsets
if (insets != null) {
const t = insets.top
if (t != null && t > 0) {
topInset = Math.round(t)
}
}
if (topInset <= 0) {
const safe = info.safeArea
if (safe != null) {
const st = safe.top
if (st != null && st > 0) {
topInset = Math.round(st)
}
}
}
if (topInset <= 0) {
const sb = info.statusBarHeight
if (sb != null && sb > 0) {
topInset = Math.round(sb)
}
}
return topInset
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!