From 43857594d282bf7aae287a9ade4ceef440ee6e2d Mon Sep 17 00:00:00 2001 From: km2025 Date: Wed, 4 Feb 2026 15:35:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E5=88=86=E6=94=AF=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B9=B6=E5=9C=A8=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E4=B8=8A=E6=98=BE=E7=A4=BA=E7=89=88=E6=9C=AC=E5=8F=B7=E5=92=8C?= =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/auth.tsx | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/app/auth.tsx b/app/auth.tsx index a2c8d22..7955413 100644 --- a/app/auth.tsx +++ b/app/auth.tsx @@ -1,11 +1,12 @@ import { Ionicons } from '@expo/vector-icons' import { Block, Input, Text, Toast } from '@share/components' import { router } from 'expo-router' +import * as Updates from 'expo-updates' import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { TextInput } from 'react-native' import { KeyboardAwareScrollView } from 'react-native-keyboard-controller' -import { APP_VERSION } from '@/app.config' +import { APP_VERSION, VERSION } from '@/app.config' import BannerSection from '@/components/BannerSection' import { getSession, phoneNumber, setAuthToken, signIn } from '@/lib/auth' import { isValidPhone } from '@/utils' @@ -29,8 +30,55 @@ export default function Auth() { const [loading, setLoading] = useState(false) const [countdown, setCountdown] = useState(0) const [agreed, setAgreed] = useState(false) + const [currentBranch, setCurrentBranch] = useState('unknown') const countdownTimerRef = useRef | null>(null) + // 获取当前分支信息 + useEffect(() => { + const getBranchInfo = async () => { + try { + if (!Updates.isEnabled) { + setCurrentBranch('development') + return + } + + // 方法1: 使用 Updates.manifest (同步) + const manifest = Updates.manifest + + // 方法2: 或者尝试从更新中获取 + let branch = 'production' // 默认值 + + if (manifest?.extra?.eas?.branch) { + branch = manifest.extra.eas.branch + } else if (manifest?.metadata?.branchName) { + branch = manifest.metadata.branchName + } else if (Updates.channel) { + branch = Updates.channel + } + + // 方法3: 尝试获取当前运行的更新信息 + try { + const currentlyRunning = await Updates.fetchUpdateAsync() + if (currentlyRunning.manifest?.extra?.eas?.branch) { + branch = currentlyRunning.manifest.extra.eas.branch + } + } catch (e) { + console.log('Failed to fetch current update:', e) + } + + setCurrentBranch(branch) + console.log('Current branch:', branch) + console.log('Updates.channel:', Updates.channel) + console.log('Manifest:', manifest) + } catch (error) { + console.warn('Failed to get branch info:', error) + setCurrentBranch('unknown') + } + } + + getBranchInfo() + }, []) + const canSendCode = useMemo(() => { return isValidPhone(phone) && countdown === 0 }, [phone, countdown]) @@ -451,7 +499,9 @@ export default function Auth() { © 2025 LOOMART. All rights reserved. - 当前版本号: {APP_VERSION} + + 版本号: {VERSION} - {APP_VERSION} - {currentBranch} +