Allow browsing before mini login

This commit is contained in:
stu2not
2026-06-30 14:11:31 +08:00
parent be036ea7fe
commit ec390113ad
11 changed files with 436 additions and 53 deletions
+40 -2
View File
@@ -135,6 +135,7 @@ export default function Location() {
const [emptyState, setEmptyState] = useState<{ title: string; desc: string; actionText: string; actionUrl: string } | null>(
null
)
const [isGuest, setIsGuest] = useState(false)
useDidShow(() => {
void loadLocation(true)
@@ -144,10 +145,18 @@ export default function Location() {
const targetMode = nextMode || trajectoryMode
if (!getToken()) {
Taro.reLaunch({ url: '/pages/login/index' })
setDeviceLocation(null)
setTrajectory([])
setSelectedPoint(null)
setCoordinates(DEFAULT_COORDINATES)
setEmptyState(null)
setLocationNotice(null)
setIsGuest(true)
setLoading(false)
return
}
setIsGuest(false)
if (showToast) {
Taro.showLoading({ title: '刷新中...' })
}
@@ -372,7 +381,36 @@ export default function Location() {
<Text className='page-title'>设备定位</Text>
</View>
{emptyState ? (
{isGuest ? (
<>
<View className='map-section guest-map-section'>
<Map
className='map'
latitude={DEFAULT_COORDINATES.latitude}
longitude={DEFAULT_COORDINATES.longitude}
scale={11}
onError={(event) => {
console.error('[location] guest map error:', event.detail)
}}
/>
</View>
<View className='location-empty-shell'>
<View className='location-empty-card'>
<Text className='location-empty-title'>设备定位与轨迹</Text>
<Text className='location-empty-desc'>绑定设备后,可在这里查看孩子设备的位置、更新时间和定位精度。</Text>
<View
className='location-empty-action'
onClick={() => {
Taro.setStorageSync('postLoginRedirect', '/pages/location/index')
Taro.navigateTo({ url: '/pages/login/index' })
}}
>
<Text className='location-empty-action-text'>登录后查看</Text>
</View>
</View>
</View>
</>
) : emptyState ? (
<View className='location-empty-shell'>
<View className='location-empty-card'>
<Text className='location-empty-title'>{emptyState.title}</Text>