@@ -32,11 +32,15 @@ import { DEFAULT_ENCRYPTION_OPTIONS } from '../../shared/constants';
3232import { HistoryItem } from '../../shared/types' ;
3333import AlgorithmSelector from '../components/AlgorithmSelector' ;
3434import PageHeader from '../components/PageHeader' ;
35+ import { getPlatformServices } from '../services' ;
3536
3637const { TextArea } = Input ;
3738const { Text } = Typography ;
3839const { TabPane } = Tabs ;
3940
41+ const services = getPlatformServices ( ) ;
42+ const isWebEnvironment = services . environment === 'web' ;
43+
4044const MainPage : React . FC = ( ) => {
4145 const { keys, selectedKey, selectKey } = useKeys ( ) ;
4246 const { saveHistoryItem } = useHistory ( ) ;
@@ -55,6 +59,14 @@ const MainPage: React.FC = () => {
5559 const [ decryptionStatus , setDecryptionStatus ] = useState < 'idle' | 'success' | 'error' > ( 'idle' ) ;
5660 const [ lastError , setLastError ] = useState < string > ( '' ) ;
5761
62+ const showWebRestrictionNotice = ( ) => {
63+ notification . info ( {
64+ message : '웹 데모 제한' ,
65+ description : '웹 데모에서는 RSA 암·복호화 기능을 사용할 수 없습니다. 데스크톱 버전에서 전체 기능을 이용해주세요.' ,
66+ placement : 'topRight' ,
67+ } ) ;
68+ } ;
69+
5870 // 선택된 키가 변경될 때마다 selectedKey 업데이트 및 알고리즘 자동 설정
5971 useEffect ( ( ) => {
6072 const key = keys . find ( k => k . id === selectedKeyId ) ;
@@ -67,6 +79,11 @@ const MainPage: React.FC = () => {
6779 } , [ selectedKeyId , keys , selectKey ] ) ;
6880
6981 const handleEncrypt = async ( ) => {
82+ if ( isWebEnvironment ) {
83+ showWebRestrictionNotice ( ) ;
84+ return ;
85+ }
86+
7087 if ( ! encryptText . trim ( ) ) {
7188 message . error ( '암호화할 텍스트를 입력해주세요.' ) ;
7289 return ;
@@ -84,7 +101,7 @@ const MainPage: React.FC = () => {
84101 setLoading ( true ) ;
85102 setEncryptionStatus ( 'idle' ) ;
86103 try {
87- const result = await window . electronAPI . encryptText (
104+ const result = await services . crypto . encrypt (
88105 encryptText ,
89106 selectedKey . publicKey ,
90107 algorithm
@@ -140,6 +157,11 @@ const MainPage: React.FC = () => {
140157 } ;
141158
142159 const handleDecrypt = async ( ) => {
160+ if ( isWebEnvironment ) {
161+ showWebRestrictionNotice ( ) ;
162+ return ;
163+ }
164+
143165 if ( ! decryptText . trim ( ) ) {
144166 message . error ( '복호화할 텍스트를 입력해주세요.' ) ;
145167 return ;
@@ -188,7 +210,7 @@ const MainPage: React.FC = () => {
188210 setLoading ( true ) ;
189211 setDecryptionStatus ( 'idle' ) ;
190212 try {
191- const result = await window . electronAPI . decryptText (
213+ const result = await services . crypto . decrypt (
192214 decryptText ,
193215 selectedKey . privateKey ,
194216 algorithm
@@ -489,8 +511,8 @@ const MainPage: React.FC = () => {
489511 // 탭 오른쪽에 표시할 버튼들
490512 const renderTabBarExtraContent = ( ) => {
491513 const isEncryptTab = activeTab === 'encrypt' ;
492- const hasInputText = isEncryptTab ? encryptText . trim ( ) : decryptText . trim ( ) ;
493- const canExecute = selectedKey && hasInputText && ! loading ;
514+ const hasInputText = ( isEncryptTab ? encryptText : decryptText ) . trim ( ) ;
515+ const canExecute = ! isWebEnvironment && ! ! selectedKey && ! ! hasInputText && ! loading ;
494516
495517 return (
496518 < Space >
@@ -534,6 +556,16 @@ const MainPage: React.FC = () => {
534556 flex : 1
535557 } } >
536558
559+ { isWebEnvironment && (
560+ < Alert
561+ type = "info"
562+ showIcon
563+ message = "웹 데모 제한 안내"
564+ description = "웹 데모에서는 RSA 암·복호화 기능이 비활성화되어 있습니다. 데스크톱 앱에서 전체 기능을 사용하거나 체인 빌더, HTTP 도구 등을 체험해보세요."
565+ style = { { marginBottom : 16 } }
566+ />
567+ ) }
568+
537569 { /* 키 선택 및 알고리즘 선택 섹션 */ }
538570 < Card style = { { marginBottom : 16 , flexShrink : 0 } } >
539571 < Row gutter = { [ 16 , 16 ] } align = "top" >
@@ -938,4 +970,4 @@ const MainPage: React.FC = () => {
938970 ) ;
939971} ;
940972
941- export default MainPage ;
973+ export default MainPage ;
0 commit comments