Allow manual version info edit

Make the version info card editable via text boxes.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-18 14:24:10 +00:00
parent 450e57fe50
commit 73ff9e7886
3 changed files with 134 additions and 60 deletions

View File

@@ -1,5 +1,7 @@
{
"versionCode": 1,
"versionName": "1.0.0",
"buildNumber": 1
"buildNumber": 1,
"notes": "사용자가 수정한 버전 정보입니다. 이 파일을 편집하여 앱 버전 정보를 변경할 수 있습니다."
}

View File

@@ -1,14 +1,20 @@
import React, { useCallback, useEffect, useState, useRef } from 'react';
import { getAppVersionInfo, isAndroidPlatform } from '@/utils/platform';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
interface AppVersionInfoProps {
className?: string;
showDevInfo?: boolean; // 개발자 정보 표시 여부
editable?: boolean; // 편집 가능 여부
}
const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
className,
showDevInfo = true
showDevInfo = true,
editable = false
}) => {
const [versionInfo, setVersionInfo] = useState<{
versionName: string;
@@ -23,8 +29,14 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
const [error, setError] = useState(false);
const [retries, setRetries] = useState(0);
// 편집 가능한 필드를 위한 상태
const [editableVersionName, setEditableVersionName] = useState('1.0.0');
const [editableBuildNumber, setEditableBuildNumber] = useState('1');
const [editableVersionCode, setEditableVersionCode] = useState('1');
// 버전 정보 가져오기
const fetchVersionInfo = useCallback(async () => {
if (!editable) {
setLoading(true);
setError(false);
@@ -51,6 +63,13 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
versionCode: info.versionCode
});
// 편집 가능한 필드도 업데이트
setEditableVersionName(info.versionName);
setEditableBuildNumber(String(info.buildNumber));
if (info.versionCode) {
setEditableVersionCode(String(info.versionCode));
}
setLoading(false);
console.log('앱 버전 정보 표시 준비 완료');
} catch (error) {
@@ -58,7 +77,8 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
setError(true);
setLoading(false);
}
}, [retries]);
}
}, [retries, editable]);
// 재시도 처리
const handleRetry = useCallback(() => {
@@ -71,6 +91,7 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
// 컴포넌트 마운트 시 즉시 실행 (IIFE)
useEffect(() => {
if (!editable) {
(async () => {
// 즉시 버전 정보 가져오기 시도
await fetchVersionInfo();
@@ -92,7 +113,59 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
return () => clearInterval(interval);
}
}, [fetchVersionInfo, error, loading]);
}
}, [fetchVersionInfo, error, loading, editable]);
if (editable) {
return (
<div className={className}>
<div className="space-y-3">
<div>
<Label htmlFor="versionName"> </Label>
<Input
id="versionName"
value={editableVersionName}
onChange={(e) => setEditableVersionName(e.target.value)}
placeholder="앱 버전 (예: 1.0.0)"
/>
</div>
<div>
<Label htmlFor="buildNumber"> </Label>
<Input
id="buildNumber"
value={editableBuildNumber}
onChange={(e) => setEditableBuildNumber(e.target.value)}
placeholder="빌드 번호 (예: 1)"
type="number"
/>
</div>
{showDevInfo && (
<div>
<Label htmlFor="versionCode"> </Label>
<Input
id="versionCode"
value={editableVersionCode}
onChange={(e) => setEditableVersionCode(e.target.value)}
placeholder="버전 코드 (예: 1)"
type="number"
/>
</div>
)}
<div>
<Label htmlFor="notes"></Label>
<Textarea
id="notes"
placeholder="추가 정보를 입력하세요"
className="h-20"
/>
</div>
</div>
</div>
);
}
return (
<div className={className}>

View File

@@ -83,7 +83,6 @@ const Settings = () => {
{/* Data Sync Settings */}
<div className="mb-8">
<SyncSettings />
</div>
@@ -97,9 +96,7 @@ const Settings = () => {
<div className="space-y-4 mb-8">
<h2 className="text-sm font-medium text-gray-500 mb-2 px-2"> </h2>
<SettingsOption icon={Lock} label="보안 및 개인정보" description="보안 및 데이터 설정"
// 로그인 상태와 관계없이 접근 가능하도록 변경
onClick={() => navigate('/security-privacy')} />
<SettingsOption icon={Lock} label="보안 및 개인정보" description="보안 및 데이터 설정" onClick={() => navigate('/security-privacy')} />
<SettingsOption icon={HelpCircle} label="도움말 및 지원" description="FAQ 및 고객 지원" onClick={() => navigate('/help-support')} />
</div>
@@ -109,7 +106,8 @@ const Settings = () => {
<div className="mt-10 border-t border-gray-200 pt-4">
<div className="neuro-flat p-3 rounded-lg">
<AppVersionInfo showDevInfo={true} />
<h2 className="text-sm font-medium text-gray-500 mb-2 px-2"> </h2>
<AppVersionInfo showDevInfo={true} editable={true} />
</div>
{/* 앱 버전 카드 아래 추가 공간 */}
@@ -120,4 +118,5 @@ const Settings = () => {
<NavBar />
</div>;
};
export default Settings;