Merge branch 'feat/liujie'
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import Taro, { useDidShow } from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { View } from '@tarojs/components'
|
import { View } from '@tarojs/components'
|
||||||
import { check_login_status } from '@/services/loginService'
|
import { check_login_status } from '@/services/loginService'
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ export function getCurrentFullPath(): string {
|
|||||||
const currentPage = pages.at(-1)
|
const currentPage = pages.at(-1)
|
||||||
|
|
||||||
if (currentPage) {
|
if (currentPage) {
|
||||||
|
console.log(currentPage, 'currentPage get')
|
||||||
const route = currentPage.route
|
const route = currentPage.route
|
||||||
const options = currentPage.options || {}
|
const options = currentPage.options || {}
|
||||||
|
|
||||||
@@ -25,7 +26,6 @@ export function getCurrentFullPath(): string {
|
|||||||
export default function withAuth<P extends object>(WrappedComponent: React.ComponentType<P>) {
|
export default function withAuth<P extends object>(WrappedComponent: React.ComponentType<P>) {
|
||||||
const ComponentWithAuth: React.FC<P> = (props: P) => {
|
const ComponentWithAuth: React.FC<P> = (props: P) => {
|
||||||
const [authed, setAuthed] = useState(false)
|
const [authed, setAuthed] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const is_login = check_login_status()
|
const is_login = check_login_status()
|
||||||
setAuthed(is_login)
|
setAuthed(is_login)
|
||||||
@@ -34,14 +34,14 @@ export default function withAuth<P extends object>(WrappedComponent: React.Compo
|
|||||||
const currentPage = getCurrentFullPath()
|
const currentPage = getCurrentFullPath()
|
||||||
Taro.redirectTo({
|
Taro.redirectTo({
|
||||||
url: `/pages/login/index/index${
|
url: `/pages/login/index/index${
|
||||||
currentPage ? `?redirect=${currentPage}` : ''
|
currentPage ? `?redirect=${encodeURIComponent(currentPage)}` : ''
|
||||||
}`,
|
}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
if (!authed) {
|
if (!authed) {
|
||||||
return <View /> // 空壳,避免 children 渲染出错
|
return <View style={{ width: '100vh', height: '100vw', backgroundColor: 'white', position: 'fixed', top: 0, left: 0, zIndex: 999 }} /> // 空壳,避免 children 渲染出错
|
||||||
}
|
}
|
||||||
|
|
||||||
return <WrappedComponent {...props} />
|
return <WrappedComponent {...props} />
|
||||||
|
|||||||
@@ -367,13 +367,25 @@ function Index() {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
function handleBack() {
|
||||||
|
const pages = Taro.getCurrentPages()
|
||||||
|
if (pages.length <= 1) {
|
||||||
|
Taro.redirectTo({
|
||||||
|
url: '/pages/list/index',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Taro.navigateBack()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log('detail', detail)
|
console.log('detail', detail)
|
||||||
return (
|
return (
|
||||||
<View className='detail-page'>
|
<View className='detail-page'>
|
||||||
{/* custom navbar */}
|
{/* custom navbar */}
|
||||||
<view className="custom-navbar">
|
<view className="custom-navbar">
|
||||||
<View className='detail-navigator'>
|
<View className='detail-navigator'>
|
||||||
<View className='detail-navigator-back' onClick={() => { Taro.navigateBack() }}>
|
<View className='detail-navigator-back' onClick={handleBack}>
|
||||||
<Image className='detail-navigator-back-icon' src={img.ICON_ARROW_LEFT} />
|
<Image className='detail-navigator-back-icon' src={img.ICON_ARROW_LEFT} />
|
||||||
</View>
|
</View>
|
||||||
<View className='detail-navigator-icon'>
|
<View className='detail-navigator-icon'>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const LoginPage: React.FC = () => {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
|
console.log('redirect:', decodeURIComponent(redirect))
|
||||||
Taro.redirectTo({ url: decodeURIComponent(redirect) });
|
Taro.redirectTo({ url: decodeURIComponent(redirect) });
|
||||||
} else {
|
} else {
|
||||||
Taro.redirectTo({ url: '/pages/list/index' });
|
Taro.redirectTo({ url: '/pages/list/index' });
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ export const fetchUserProfile = async (): Promise<ApiResponse<UserInfoType>> =>
|
|||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
|
export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
|
||||||
try {
|
try {
|
||||||
const response = await httpService.post('api/user/update', payload);
|
const response = await httpService.post('/user/update', payload);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('更新用户信息失败:', error);
|
console.error('更新用户信息失败:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user