1
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
.back-navbar {
|
.back-navbar {
|
||||||
position: sticky;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
left: 0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
background: #ffffff;
|
background: transparent;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const BackNavbar: React.FC<BackNavbarProps> = ({
|
|||||||
style={{
|
style={{
|
||||||
paddingTop: `${statusBarHeight}px`,
|
paddingTop: `${statusBarHeight}px`,
|
||||||
height: `${totalHeight}px`,
|
height: `${totalHeight}px`,
|
||||||
backgroundColor: backgroundColor || "#fafafa"
|
backgroundColor: backgroundColor || "transparent"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
z-index: 99;
|
z-index: 99;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
// 背景颜色通过 style 动态设置,默认透明
|
// 背景颜色通过 style 动态设置,默认 #FAFAFA
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ const CustomNavbar = (props: IProps) => {
|
|||||||
<View
|
<View
|
||||||
className={styles.customerNavbar}
|
className={styles.customerNavbar}
|
||||||
style={{
|
style={{
|
||||||
height: `${navBarHeight}px`,
|
height: `${statusBarHeight + navBarHeight}px`,
|
||||||
paddingTop: `${statusBarHeight}px`,
|
paddingTop: `${statusBarHeight}px`,
|
||||||
backgroundColor: backgroundColor || '#fafafa'
|
backgroundColor: backgroundColor || 'transparent'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
.leftSection {
|
.leftSection {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-width: 60px;
|
gap: 8px;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.centerSection {
|
.centerSection {
|
||||||
@@ -27,6 +28,10 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rightSection {
|
.rightSection {
|
||||||
@@ -39,7 +44,8 @@
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #333;
|
color: #333;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.backIcon {
|
.backIcon {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ interface GeneralNavbarProps {
|
|||||||
showLeft?: boolean
|
showLeft?: boolean
|
||||||
onBack?: () => void
|
onBack?: () => void
|
||||||
className?: string
|
className?: string
|
||||||
|
titlePosition?: 'left' | 'center' // 标题位置:左侧或居中
|
||||||
}
|
}
|
||||||
|
|
||||||
const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
|
const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
|
||||||
@@ -22,11 +23,12 @@ const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
|
|||||||
titleStyle,
|
titleStyle,
|
||||||
titleClassName = '',
|
titleClassName = '',
|
||||||
leftContent,
|
leftContent,
|
||||||
backgroundColor = '#FAFAFA',
|
backgroundColor = 'transparent',
|
||||||
showBack = true,
|
showBack = true,
|
||||||
showLeft = true,
|
showLeft = true,
|
||||||
onBack,
|
onBack,
|
||||||
className = ''
|
className = '',
|
||||||
|
titlePosition = 'left' // 默认标题在左侧
|
||||||
}) => {
|
}) => {
|
||||||
const { statusNavbarHeightInfo } = useGlobalState() || {}
|
const { statusNavbarHeightInfo } = useGlobalState() || {}
|
||||||
const { statusBarHeight = 0, navBarHeight = 44, totalHeight = 98 } = statusNavbarHeightInfo || {}
|
const { statusBarHeight = 0, navBarHeight = 44, totalHeight = 98 } = statusNavbarHeightInfo || {}
|
||||||
@@ -35,7 +37,7 @@ const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
|
|||||||
if (onBack) {
|
if (onBack) {
|
||||||
onBack()
|
onBack()
|
||||||
} else {
|
} else {
|
||||||
Taro.navigateBack()
|
(Taro as any).navigateBack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,20 +84,23 @@ const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
|
|||||||
style={{
|
style={{
|
||||||
height: `${totalHeight}px`,
|
height: `${totalHeight}px`,
|
||||||
paddingTop: `${statusBarHeight}px`,
|
paddingTop: `${statusBarHeight}px`,
|
||||||
backgroundColor: backgroundColor || '#FAFAFA'
|
backgroundColor: backgroundColor || 'transparent'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View className={styles.navbarContent} style={{ height: `${navBarHeight}px` }}>
|
<View className={styles.navbarContent} style={{ height: `${navBarHeight}px` }}>
|
||||||
<View className={styles.leftSection}>
|
<View className={styles.leftSection}>
|
||||||
{renderLeftContent()}
|
{renderLeftContent()}
|
||||||
|
{titlePosition === 'left' && renderTitle()}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className={styles.centerSection}>
|
{titlePosition === 'center' && (
|
||||||
{renderTitle()}
|
<View className={styles.centerSection}>
|
||||||
</View>
|
{renderTitle()}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
<View className={styles.rightSection}>
|
<View className={styles.rightSection}>
|
||||||
{/* 右侧占位,保持标题居中 */}
|
{/* 右侧占位 */}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useState } from "react";
|
import { View, Text } from "@tarojs/components";
|
||||||
import { View, Text, Image } from "@tarojs/components";
|
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import img from "@/config/images";
|
import { redirectTo } from "@/utils/navigation";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
import PublishMenu from "../PublishMenu";
|
import PublishMenu from "../PublishMenu";
|
||||||
export type currentPageType = "games" | "message" | "personal";
|
export type currentPageType = "games" | "message" | "personal";
|
||||||
@@ -24,12 +23,6 @@ const GuideBar = (props) => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const handlePublish = () => {
|
|
||||||
Taro.navigateTo({
|
|
||||||
url: "/publish_pages/publishBall/index",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handlePageChange = (code: string) => {
|
const handlePageChange = (code: string) => {
|
||||||
if (code === currentPage) {
|
if (code === currentPage) {
|
||||||
return;
|
return;
|
||||||
@@ -52,7 +45,7 @@ const GuideBar = (props) => {
|
|||||||
if (code === "list") {
|
if (code === "list") {
|
||||||
url = "/game_pages/list/index"
|
url = "/game_pages/list/index"
|
||||||
}
|
}
|
||||||
Taro.redirectTo({
|
redirectTo({
|
||||||
url: url,
|
url: url,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
(Taro as any).pageScrollTo({
|
(Taro as any).pageScrollTo({
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useMemo } from "react";
|
|||||||
import img from "../../config/images";
|
import img from "../../config/images";
|
||||||
import { ListCardProps } from "../../../types/list/types";
|
import { ListCardProps } from "../../../types/list/types";
|
||||||
import { formatGameTime, calculateDuration } from "@/utils/timeUtils";
|
import { formatGameTime, calculateDuration } from "@/utils/timeUtils";
|
||||||
|
import { navigateTo } from "@/utils/navigation";
|
||||||
import images from '@/config/images'
|
import images from '@/config/images'
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleViewDetail = () => {
|
const handleViewDetail = () => {
|
||||||
Taro.navigateTo({
|
navigateTo({
|
||||||
url: `/game_pages/detail/index?id=${id || 1}&from=list`,
|
url: `/game_pages/detail/index?id=${id || 1}&from=list`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
EvaluateCallback,
|
EvaluateCallback,
|
||||||
EvaluateScene,
|
EvaluateScene,
|
||||||
} from "@/store/evaluateStore";
|
} from "@/store/evaluateStore";
|
||||||
|
import { navigateTo, redirectTo, navigateBack } from "@/utils/navigation";
|
||||||
import styles from "./index.module.scss";
|
import styles from "./index.module.scss";
|
||||||
import images from "@/config/images";
|
import images from "@/config/images";
|
||||||
import AiImportPopup from "@/publish_pages/publishBall/components/AiImportPopup";
|
import AiImportPopup from "@/publish_pages/publishBall/components/AiImportPopup";
|
||||||
@@ -46,7 +47,7 @@ const PublishMenu: React.FC<PublishMenuProps> = (props) => {
|
|||||||
setAiImportVisible(true);
|
setAiImportVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Taro.navigateTo({
|
navigateTo({
|
||||||
url: `/publish_pages/publishBall/index?type=${type}`,
|
url: `/publish_pages/publishBall/index?type=${type}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -58,16 +59,16 @@ const PublishMenu: React.FC<PublishMenuProps> = (props) => {
|
|||||||
if (flag) {
|
if (flag) {
|
||||||
handleMenuClick(type);
|
handleMenuClick(type);
|
||||||
} else if (type === "ai") {
|
} else if (type === "ai") {
|
||||||
Taro.navigateBack();
|
navigateBack();
|
||||||
setAiImportVisible(true);
|
setAiImportVisible(true);
|
||||||
} else {
|
} else {
|
||||||
Taro.redirectTo({
|
redirectTo({
|
||||||
url: `/publish_pages/publishBall/index?type=${type}`,
|
url: `/publish_pages/publishBall/index?type=${type}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCancel: () => {
|
onCancel: () => {
|
||||||
Taro.navigateBack();
|
navigateBack();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
@@ -81,7 +82,7 @@ const PublishMenu: React.FC<PublishMenuProps> = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleManualPublish = () => {
|
const handleManualPublish = () => {
|
||||||
Taro.navigateTo({
|
navigateTo({
|
||||||
url: "/publish_pages/publishBall/index?type=individual",
|
url: "/publish_pages/publishBall/index?type=individual",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -267,7 +267,8 @@ const OrderList = () => {
|
|||||||
>
|
>
|
||||||
<GeneralNavbar
|
<GeneralNavbar
|
||||||
title="订单列表"
|
title="订单列表"
|
||||||
backgroundColor="transparent"
|
backgroundColor="#FAFAFA"
|
||||||
|
titlePosition="left"
|
||||||
titleClassName={styles.titleClassName}
|
titleClassName={styles.titleClassName}
|
||||||
className={styles.navbar}
|
className={styles.navbar}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
|||||||
import { updateUserLocation } from "@/services/userService";
|
import { updateUserLocation } from "@/services/userService";
|
||||||
import { useUserActions } from "@/store/userStore";
|
import { useUserActions } from "@/store/userStore";
|
||||||
import { useDictionaryStore } from "@/store/dictionaryStore";
|
import { useDictionaryStore } from "@/store/dictionaryStore";
|
||||||
import { saveImage } from "@/utils";
|
import { saveImage, navigateTo } from "@/utils";
|
||||||
|
|
||||||
export interface ListPageContentProps {
|
export interface ListPageContentProps {
|
||||||
onNavStateChange?: (state: {
|
onNavStateChange?: (state: {
|
||||||
@@ -246,7 +246,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSearchClick = () => {
|
const handleSearchClick = () => {
|
||||||
(Taro as any).navigateTo({
|
navigateTo({
|
||||||
url: "/game_pages/search/index",
|
url: "/game_pages/search/index",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import noticeService from "@/services/noticeService";
|
|||||||
import { formatRelativeTime } from "@/utils/timeUtils";
|
import { formatRelativeTime } from "@/utils/timeUtils";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { useGlobalState } from "@/store/global";
|
import { useGlobalState } from "@/store/global";
|
||||||
|
import { navigateTo } from "@/utils/navigation";
|
||||||
import "@/other_pages/message/index.scss";
|
import "@/other_pages/message/index.scss";
|
||||||
|
|
||||||
interface MessageItem {
|
interface MessageItem {
|
||||||
@@ -59,14 +60,14 @@ const MessagePageContent = () => {
|
|||||||
|
|
||||||
const handleTabClick = (tab: MessageCategory) => {
|
const handleTabClick = (tab: MessageCategory) => {
|
||||||
if (tab === "comment") {
|
if (tab === "comment") {
|
||||||
(Taro as any).navigateTo({
|
navigateTo({
|
||||||
url: "/other_pages/comment_reply/index",
|
url: "/other_pages/comment_reply/index",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tab === "follow") {
|
if (tab === "follow") {
|
||||||
(Taro as any).navigateTo({
|
navigateTo({
|
||||||
url: "/other_pages/new_follow/index",
|
url: "/other_pages/new_follow/index",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -81,7 +82,7 @@ const MessagePageContent = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(Taro as any).navigateTo({
|
navigateTo({
|
||||||
url: message.jump_url,
|
url: message.jump_url,
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
(Taro as any).showToast({
|
(Taro as any).showToast({
|
||||||
|
|||||||
@@ -21,15 +21,19 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateX(100%);
|
transform: scale(0.98);
|
||||||
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
|
transition: opacity 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
|
||||||
|
transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
will-change: opacity, transform;
|
||||||
|
backface-visibility: hidden;
|
||||||
|
-webkit-backface-visibility: hidden;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateX(0);
|
transform: scale(1);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ const FollowPage: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<View className="follow_page">
|
<View className="follow_page">
|
||||||
{/* 自定义导航栏 */}
|
{/* 自定义导航栏 */}
|
||||||
<CustomNavbar>
|
<CustomNavbar backgroundColor="#FAFAFA">
|
||||||
<View className="navbar_content">
|
<View className="navbar_content">
|
||||||
<View className="navbar_back" onClick={() => Taro.navigateBack()}>
|
<View className="navbar_back" onClick={() => Taro.navigateBack()}>
|
||||||
<View className="back_icon" />
|
<View className="back_icon" />
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ export * from './routeUtil';
|
|||||||
export * from './share'
|
export * from './share'
|
||||||
export * from './genPoster'
|
export * from './genPoster'
|
||||||
export * from './wx_helper'
|
export * from './wx_helper'
|
||||||
|
export * from './navigation';
|
||||||
|
|||||||
115
src/utils/navigation.ts
Normal file
115
src/utils/navigation.ts
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import Taro from "@tarojs/taro";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导航工具函数 - 封装页面跳转,提供流畅的过渡效果
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface NavigateOptions {
|
||||||
|
url: string;
|
||||||
|
success?: (res: any) => void;
|
||||||
|
fail?: (err: any) => void;
|
||||||
|
complete?: (res: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导航到新页面(带过渡动画)
|
||||||
|
* 使用 Taro.navigateTo,系统会自动提供过渡动画
|
||||||
|
*/
|
||||||
|
export const navigateTo = (options: NavigateOptions): Promise<TaroGeneral.NavigateToSuccessCallbackResult> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
(Taro as any).navigateTo({
|
||||||
|
...options,
|
||||||
|
success: (res: any) => {
|
||||||
|
options.success?.(res);
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: (err: any) => {
|
||||||
|
options.fail?.(err);
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
complete: (res: any) => {
|
||||||
|
options.complete?.(res);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重定向到新页面(带过渡动画)
|
||||||
|
* 使用 Taro.redirectTo,系统会自动提供过渡动画
|
||||||
|
*/
|
||||||
|
export const redirectTo = (options: NavigateOptions): Promise<TaroGeneral.NavigateToSuccessCallbackResult> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
(Taro as any).redirectTo({
|
||||||
|
...options,
|
||||||
|
success: (res: any) => {
|
||||||
|
options.success?.(res);
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: (err: any) => {
|
||||||
|
options.fail?.(err);
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
complete: (res: any) => {
|
||||||
|
options.complete?.(res);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回上一页(带过渡动画)
|
||||||
|
*/
|
||||||
|
export const navigateBack = (options?: { delta?: number }): Promise<TaroGeneral.NavigateBackSuccessCallbackResult> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
(Taro as any).navigateBack({
|
||||||
|
delta: options?.delta || 1,
|
||||||
|
success: (res: any) => {
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: (err: any) => {
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切换到 tabBar 页面(无过渡动画,这是 tabBar 的特性)
|
||||||
|
*/
|
||||||
|
export const switchTab = (options: { url: string }): Promise<TaroGeneral.SwitchTabSuccessCallbackResult> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
Taro.switchTab({
|
||||||
|
...options,
|
||||||
|
success: (res: any) => {
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: (err: any) => {
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重新加载当前页面
|
||||||
|
*/
|
||||||
|
export const reLaunch = (options: NavigateOptions): Promise<TaroGeneral.ReLaunchSuccessCallbackResult> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
(Taro as any).reLaunch({
|
||||||
|
...options,
|
||||||
|
success: (res: any) => {
|
||||||
|
options.success?.(res);
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: (err: any) => {
|
||||||
|
options.fail?.(err);
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
complete: (res: any) => {
|
||||||
|
options.complete?.(res);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Reference in New Issue
Block a user