..
This commit is contained in:
2
Form1.Designer.cs
generated
2
Form1.Designer.cs
generated
@@ -34,7 +34,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(463, 310);
|
||||
this.ClientSize = new System.Drawing.Size(784, 561);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
44
Form1.cs
44
Form1.cs
@@ -3,6 +3,7 @@ using System.Windows.Forms;
|
||||
using Microsoft.Web.WebView2.WinForms;
|
||||
using Microsoft.Owin.Hosting;
|
||||
using VNCServerList.Web;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
|
||||
namespace VNCServerList
|
||||
{
|
||||
@@ -28,6 +29,10 @@ namespace VNCServerList
|
||||
try
|
||||
{
|
||||
await webView.EnsureCoreWebView2Async(null);
|
||||
|
||||
// JavaScript에서 C# 메서드를 호출할 수 있도록 설정
|
||||
webView.CoreWebView2.WebMessageReceived += CoreWebView2_WebMessageReceived;
|
||||
|
||||
webView.CoreWebView2.Navigate("http://localhost:8080");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -36,6 +41,45 @@ namespace VNCServerList
|
||||
}
|
||||
}
|
||||
|
||||
private async void CoreWebView2_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var message = e.TryGetWebMessageAsString();
|
||||
|
||||
if (message == "OPEN_FILE_DIALOG")
|
||||
{
|
||||
var filePath = ShowOpenFileDialog();
|
||||
if (!string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
// JavaScript로 결과 전송 (ExecuteScriptAsync 사용)
|
||||
var script = $"window.receiveFilePath('{filePath.Replace("\\", "\\\\")}');";
|
||||
await webView.CoreWebView2.ExecuteScriptAsync(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"WebView2 메시지 처리 오류: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private string ShowOpenFileDialog()
|
||||
{
|
||||
using (var openFileDialog = new OpenFileDialog())
|
||||
{
|
||||
openFileDialog.Filter = "실행 파일 (*.exe)|*.exe|모든 파일 (*.*)|*.*";
|
||||
openFileDialog.Title = "VNC Viewer 실행 파일 선택";
|
||||
openFileDialog.InitialDirectory = @"C:\Program Files";
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
return openFileDialog.FileName;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void StartWebServer()
|
||||
{
|
||||
try
|
||||
|
||||
10
Models/AppSettings.cs
Normal file
10
Models/AppSettings.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace VNCServerList.Models
|
||||
{
|
||||
public class AppSettings
|
||||
{
|
||||
public string VNCViewerPath { get; set; } = @"C:\Program Files\TightVNC\tvnviewer.exe";
|
||||
public int WebServerPort { get; set; } = 8080;
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,11 @@ namespace VNCServerList.Services
|
||||
public class DatabaseService
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly SettingsService _settingsService;
|
||||
|
||||
public DatabaseService()
|
||||
public DatabaseService(SettingsService settingsService = null)
|
||||
{
|
||||
_settingsService = settingsService ?? new SettingsService();
|
||||
_connectionString = Properties.Settings.Default.VNCServerDB;
|
||||
InitializeDatabase();
|
||||
}
|
||||
|
||||
88
Services/SettingsService.cs
Normal file
88
Services/SettingsService.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using VNCServerList.Models;
|
||||
|
||||
namespace VNCServerList.Services
|
||||
{
|
||||
public class SettingsService
|
||||
{
|
||||
private readonly string _settingsFilePath;
|
||||
private AppSettings _settings;
|
||||
|
||||
public SettingsService()
|
||||
{
|
||||
_settingsFilePath = Path.Combine(
|
||||
AppDomain.CurrentDomain.BaseDirectory,
|
||||
"VNCServerList",
|
||||
"settings.json"
|
||||
);
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
public AppSettings GetSettings()
|
||||
{
|
||||
return _settings;
|
||||
}
|
||||
|
||||
public void SaveSettings(AppSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
|
||||
// 디버깅용 로그
|
||||
System.Diagnostics.Debug.WriteLine($"설정 저장 시작: 파일 경로={_settingsFilePath}");
|
||||
System.Diagnostics.Debug.WriteLine($"저장할 설정: VNCViewerPath={settings.VNCViewerPath}, WebServerPort={settings.WebServerPort}");
|
||||
|
||||
// 디렉토리가 없으면 생성
|
||||
var directory = Path.GetDirectoryName(_settingsFilePath);
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
System.Diagnostics.Debug.WriteLine($"디렉토리 생성: {directory}");
|
||||
}
|
||||
|
||||
// JSON으로 직렬화하여 저장
|
||||
var json = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
||||
System.Diagnostics.Debug.WriteLine($"JSON 데이터: {json}");
|
||||
|
||||
File.WriteAllText(_settingsFilePath, json);
|
||||
System.Diagnostics.Debug.WriteLine("설정 파일 저장 완료");
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"설정 로드 시작: 파일 경로={_settingsFilePath}");
|
||||
|
||||
if (File.Exists(_settingsFilePath))
|
||||
{
|
||||
var json = File.ReadAllText(_settingsFilePath);
|
||||
System.Diagnostics.Debug.WriteLine($"읽은 JSON: {json}");
|
||||
_settings = JsonConvert.DeserializeObject<AppSettings>(json);
|
||||
System.Diagnostics.Debug.WriteLine($"로드된 설정: VNCViewerPath={_settings.VNCViewerPath}, WebServerPort={_settings.WebServerPort}");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("설정 파일이 없어서 기본값으로 초기화");
|
||||
_settings = new AppSettings();
|
||||
SaveSettings(_settings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 설정 파일 로드 실패 시 기본값 사용
|
||||
System.Diagnostics.Debug.WriteLine($"설정 로드 오류: {ex.Message}");
|
||||
_settings = new AppSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVNCViewerPath(string path)
|
||||
{
|
||||
_settings.VNCViewerPath = path;
|
||||
SaveSettings(_settings);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,12 @@ namespace VNCServerList.Services
|
||||
{
|
||||
public class VNCService
|
||||
{
|
||||
private readonly string _vncViewerPath;
|
||||
private readonly SettingsService _settingsService;
|
||||
private readonly DatabaseService _databaseService;
|
||||
|
||||
public VNCService(DatabaseService databaseService)
|
||||
public VNCService(DatabaseService databaseService, SettingsService settingsService = null)
|
||||
{
|
||||
_vncViewerPath = @"C:\Program Files\TightVNC\tvnviewer.exe";
|
||||
_settingsService = settingsService ?? new SettingsService();
|
||||
_databaseService = databaseService;
|
||||
}
|
||||
|
||||
@@ -20,15 +20,17 @@ namespace VNCServerList.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_vncViewerPath))
|
||||
var vncViewerPath = _settingsService.GetSettings().VNCViewerPath;
|
||||
|
||||
if (!File.Exists(vncViewerPath))
|
||||
{
|
||||
throw new FileNotFoundException($"VNC Viewer를 찾을 수 없습니다: {_vncViewerPath}");
|
||||
throw new FileNotFoundException($"VNC Viewer를 찾을 수 없습니다: {vncViewerPath}");
|
||||
}
|
||||
|
||||
// VNC Viewer 실행
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = _vncViewerPath,
|
||||
FileName = vncViewerPath,
|
||||
Arguments = $"-host={server.IP} {server.Argument}",
|
||||
UseShellExecute = true
|
||||
};
|
||||
@@ -58,12 +60,21 @@ namespace VNCServerList.Services
|
||||
|
||||
public bool IsVNCViewerInstalled()
|
||||
{
|
||||
return File.Exists(_vncViewerPath);
|
||||
var vncViewerPath = _settingsService.GetSettings().VNCViewerPath;
|
||||
System.Diagnostics.Debug.WriteLine($"VNC 설치 확인: 경로='{vncViewerPath}', 존재={File.Exists(vncViewerPath)}");
|
||||
return File.Exists(vncViewerPath);
|
||||
}
|
||||
|
||||
public string GetVNCViewerPath()
|
||||
{
|
||||
return _vncViewerPath;
|
||||
var path = _settingsService.GetSettings().VNCViewerPath;
|
||||
System.Diagnostics.Debug.WriteLine($"VNC 경로 조회: '{path}'");
|
||||
return path;
|
||||
}
|
||||
|
||||
public void SetVNCViewerPath(string path)
|
||||
{
|
||||
_settingsService.UpdateVNCViewerPath(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,8 +67,10 @@
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Models\VNCServer.cs" />
|
||||
<Compile Include="Models\AppSettings.cs" />
|
||||
<Compile Include="Services\DatabaseService.cs" />
|
||||
<Compile Include="Services\VNCService.cs" />
|
||||
<Compile Include="Services\SettingsService.cs" />
|
||||
<Compile Include="Web\Startup.cs" />
|
||||
<Compile Include="Web\Controllers\VNCServerController.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
|
||||
@@ -11,11 +11,13 @@ namespace VNCServerList.Web.Controllers
|
||||
{
|
||||
private readonly DatabaseService _databaseService;
|
||||
private readonly VNCService _vncService;
|
||||
private readonly SettingsService _settingsService;
|
||||
|
||||
public VNCServerController()
|
||||
{
|
||||
_settingsService = new SettingsService();
|
||||
_databaseService = new DatabaseService();
|
||||
_vncService = new VNCService(_databaseService);
|
||||
_vncService = new VNCService(_databaseService, _settingsService);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@@ -169,5 +171,86 @@ namespace VNCServerList.Web.Controllers
|
||||
return InternalServerError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("set-vnc-path")]
|
||||
public IHttpActionResult SetVNCPath([FromBody] dynamic data)
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = data.path;
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return BadRequest("VNC Viewer 경로가 제공되지 않았습니다.");
|
||||
}
|
||||
|
||||
_vncService.SetVNCViewerPath(path);
|
||||
return Ok(new { Message = "VNC Viewer 경로가 설정되었습니다." });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return InternalServerError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("settings")]
|
||||
public IHttpActionResult GetSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("=== 설정 조회 시작 ===");
|
||||
|
||||
var settings = _settingsService.GetSettings();
|
||||
|
||||
// 디버깅용 로그
|
||||
System.Diagnostics.Debug.WriteLine($"조회된 설정: VNCViewerPath='{settings.VNCViewerPath}', WebServerPort={settings.WebServerPort}");
|
||||
System.Diagnostics.Debug.WriteLine("=== 설정 조회 완료 ===");
|
||||
|
||||
return Ok(settings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"설정 조회 오류: {ex.Message}");
|
||||
System.Diagnostics.Debug.WriteLine($"스택 트레이스: {ex.StackTrace}");
|
||||
return InternalServerError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("settings")]
|
||||
public IHttpActionResult UpdateSettings([FromBody] AppSettings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("=== 설정 저장 요청 시작 ===");
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("설정 객체가 null입니다.");
|
||||
return BadRequest("설정 정보가 없습니다.");
|
||||
}
|
||||
|
||||
// 디버깅용 로그
|
||||
System.Diagnostics.Debug.WriteLine($"받은 설정 데이터: VNCViewerPath='{settings.VNCViewerPath}', WebServerPort={settings.WebServerPort}");
|
||||
System.Diagnostics.Debug.WriteLine($"VNCViewerPath 타입: {settings.VNCViewerPath?.GetType()}");
|
||||
System.Diagnostics.Debug.WriteLine($"WebServerPort 타입: {settings.WebServerPort.GetType()}");
|
||||
|
||||
_settingsService.SaveSettings(settings);
|
||||
|
||||
// 저장된 설정 확인
|
||||
var savedSettings = _settingsService.GetSettings();
|
||||
System.Diagnostics.Debug.WriteLine($"저장된 설정: VNCViewerPath='{savedSettings.VNCViewerPath}', WebServerPort={savedSettings.WebServerPort}");
|
||||
System.Diagnostics.Debug.WriteLine("=== 설정 저장 완료 ===");
|
||||
|
||||
return Ok(new { Message = "설정이 저장되었습니다." });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"설정 저장 오류: {ex.Message}");
|
||||
System.Diagnostics.Debug.WriteLine($"스택 트레이스: {ex.StackTrace}");
|
||||
return InternalServerError(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,14 +32,21 @@
|
||||
<!-- 상태 표시 -->
|
||||
<div id="status" class="mb-6"></div>
|
||||
|
||||
<!-- 서버 추가 버튼 -->
|
||||
<div class="mb-6">
|
||||
<!-- 버튼 그룹 -->
|
||||
<div class="mb-6 flex space-x-4">
|
||||
<button id="addServerBtn" class="bg-primary hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg transition duration-200">
|
||||
<svg class="w-5 h-5 inline mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
|
||||
</svg>
|
||||
새 서버 추가
|
||||
</button>
|
||||
<button id="settingsBtn" class="bg-secondary hover:bg-gray-600 text-white font-bold py-2 px-4 rounded-lg transition duration-200">
|
||||
<svg class="w-5 h-5 inline mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
|
||||
</svg>
|
||||
설정
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 서버 목록 -->
|
||||
@@ -94,6 +101,36 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 설정 모달 -->
|
||||
<div id="settingsModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden z-50">
|
||||
<div class="flex items-center justify-center min-h-screen p-4">
|
||||
<div class="bg-white rounded-lg shadow-xl max-w-lg w-full">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="text-lg font-semibold text-gray-800">설정</h3>
|
||||
</div>
|
||||
<form id="settingsForm" class="p-6">
|
||||
<div class="mb-4">
|
||||
<label for="vncViewerPath" class="block text-sm font-medium text-gray-700 mb-2">VNC Viewer 경로</label>
|
||||
<div class="flex space-x-2">
|
||||
<input type="text" id="vncViewerPath" class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="C:\Program Files\TightVNC\tvnviewer.exe">
|
||||
<button type="button" id="browseVncBtn" class="px-4 py-2 bg-secondary text-white rounded-md hover:bg-gray-600 transition duration-200">찾아보기</button>
|
||||
</div>
|
||||
<p class="text-sm text-gray-500 mt-1">VNC Viewer 실행 파일의 경로를 설정하세요.</p>
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label for="webServerPort" class="block text-sm font-medium text-gray-700 mb-2">웹 서버 포트</label>
|
||||
<input type="number" id="webServerPort" value="8080" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
|
||||
<p class="text-sm text-gray-500 mt-1">내장 웹 서버의 포트 번호를 설정하세요.</p>
|
||||
</div>
|
||||
<div class="flex justify-end space-x-3">
|
||||
<button type="button" id="settingsCancelBtn" class="px-4 py-2 text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300 transition duration-200">취소</button>
|
||||
<button type="submit" class="px-4 py-2 bg-primary text-white rounded-md hover:bg-blue-700 transition duration-200">저장</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 확인 모달 -->
|
||||
<div id="confirmModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden z-50">
|
||||
<div class="flex items-center justify-center min-h-screen p-4">
|
||||
|
||||
@@ -16,17 +16,37 @@ class VNCServerApp {
|
||||
this.showServerModal();
|
||||
});
|
||||
|
||||
// 설정 버튼
|
||||
document.getElementById('settingsBtn').addEventListener('click', () => {
|
||||
this.showSettingsModal();
|
||||
});
|
||||
|
||||
// 모달 취소 버튼
|
||||
document.getElementById('cancelBtn').addEventListener('click', () => {
|
||||
this.hideServerModal();
|
||||
});
|
||||
|
||||
document.getElementById('settingsCancelBtn').addEventListener('click', () => {
|
||||
this.hideSettingsModal();
|
||||
});
|
||||
|
||||
// 서버 폼 제출
|
||||
document.getElementById('serverForm').addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
this.saveServer();
|
||||
});
|
||||
|
||||
// 설정 폼 제출
|
||||
document.getElementById('settingsForm').addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
this.saveSettings();
|
||||
});
|
||||
|
||||
// VNC 경로 찾아보기 버튼
|
||||
document.getElementById('browseVncBtn').addEventListener('click', () => {
|
||||
this.browseVNCViewer();
|
||||
});
|
||||
|
||||
// 확인 모달 이벤트
|
||||
document.getElementById('confirmCancel').addEventListener('click', () => {
|
||||
this.hideConfirmModal();
|
||||
@@ -98,12 +118,15 @@ class VNCServerApp {
|
||||
|
||||
async checkVNCStatus() {
|
||||
try {
|
||||
console.log('VNC 상태 확인 시작...'); // 디버깅용
|
||||
const response = await fetch(`${this.apiBase}/vnc-status`);
|
||||
if (!response.ok) throw new Error('VNC 상태를 확인할 수 없습니다.');
|
||||
|
||||
const status = await response.json();
|
||||
console.log('VNC 상태:', status); // 디버깅용
|
||||
this.showVNCStatus(status);
|
||||
} catch (error) {
|
||||
console.error('VNC 상태 확인 오류:', error); // 디버깅용
|
||||
this.showError('VNC 상태 확인 중 오류가 발생했습니다: ' + error.message);
|
||||
}
|
||||
}
|
||||
@@ -113,22 +136,28 @@ class VNCServerApp {
|
||||
if (status.isInstalled) {
|
||||
statusDiv.innerHTML = `
|
||||
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
|
||||
<div class="flex items-center">
|
||||
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path>
|
||||
</svg>
|
||||
VNC Viewer가 설치되어 있습니다.
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path>
|
||||
</svg>
|
||||
VNC Viewer가 설치되어 있습니다.
|
||||
</div>
|
||||
<button onclick="app.showSettingsModal()" class="text-green-600 hover:text-green-800 text-sm underline">설정 변경</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
} else {
|
||||
statusDiv.innerHTML = `
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
||||
<div class="flex items-center">
|
||||
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"></path>
|
||||
</svg>
|
||||
VNC Viewer가 설치되어 있지 않습니다. 경로: ${status.path}
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"></path>
|
||||
</svg>
|
||||
VNC Viewer를 찾을 수 없습니다. 경로: ${status.path}
|
||||
</div>
|
||||
<button onclick="app.showSettingsModal()" class="text-red-600 hover:text-red-800 text-sm underline">설정</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -160,6 +189,106 @@ class VNCServerApp {
|
||||
document.getElementById('serverModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
showSettingsModal() {
|
||||
console.log('설정 모달 열기 시작'); // 디버깅용
|
||||
this.loadSettings();
|
||||
document.getElementById('settingsModal').classList.remove('hidden');
|
||||
console.log('설정 모달 열기 완료'); // 디버깅용
|
||||
}
|
||||
|
||||
hideSettingsModal() {
|
||||
document.getElementById('settingsModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
try {
|
||||
console.log('설정 로드 시작...'); // 디버깅용
|
||||
|
||||
const response = await fetch(`${this.apiBase}/settings`);
|
||||
console.log('설정 로드 응답 상태:', response.status); // 디버깅용
|
||||
|
||||
if (!response.ok) throw new Error('설정을 불러올 수 없습니다.');
|
||||
|
||||
const settings = await response.json();
|
||||
console.log('로드된 설정:', settings); // 디버깅용
|
||||
console.log('VNC 경로:', settings.vncViewerPath); // 디버깅용
|
||||
console.log('웹 포트:', settings.webServerPort); // 디버깅용
|
||||
|
||||
const vncPathElement = document.getElementById('vncViewerPath');
|
||||
const webPortElement = document.getElementById('webServerPort');
|
||||
|
||||
console.log('VNC 경로 요소:', vncPathElement); // 디버깅용
|
||||
console.log('웹 포트 요소:', webPortElement); // 디버깅용
|
||||
|
||||
vncPathElement.value = settings.vncViewerPath || '';
|
||||
webPortElement.value = settings.webServerPort || 8080;
|
||||
|
||||
console.log('설정 로드 완료'); // 디버깅용
|
||||
console.log('설정된 VNC 경로 값:', vncPathElement.value); // 디버깅용
|
||||
console.log('설정된 웹 포트 값:', webPortElement.value); // 디버깅용
|
||||
} catch (error) {
|
||||
console.error('설정 로드 오류:', error); // 디버깅용
|
||||
this.showError('설정을 불러오는 중 오류가 발생했습니다: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
const vncPath = document.getElementById('vncViewerPath').value;
|
||||
const webPort = parseInt(document.getElementById('webServerPort').value);
|
||||
|
||||
const settings = {
|
||||
vncViewerPath: vncPath,
|
||||
webServerPort: webPort
|
||||
};
|
||||
|
||||
console.log('저장할 설정:', settings); // 디버깅용
|
||||
console.log('VNC 경로 값:', vncPath); // 디버깅용
|
||||
console.log('웹 포트 값:', webPort); // 디버깅용
|
||||
|
||||
try {
|
||||
const response = await fetch(`${this.apiBase}/settings`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(settings)
|
||||
});
|
||||
|
||||
console.log('응답 상태:', response.status); // 디버깅용
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`설정 저장에 실패했습니다. 상태: ${response.status}, 응답: ${errorText}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('저장 결과:', result); // 디버깅용
|
||||
this.showSuccess(result.message);
|
||||
this.hideSettingsModal();
|
||||
this.checkVNCStatus(); // VNC 상태 다시 확인
|
||||
} catch (error) {
|
||||
console.error('설정 저장 오류:', error); // 디버깅용
|
||||
this.showError('설정 저장 중 오류가 발생했습니다: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
browseVNCViewer() {
|
||||
// C#의 OpenFileDialog 호출
|
||||
if (window.chrome && window.chrome.webview) {
|
||||
// WebView2 환경에서 C# 메서드 호출
|
||||
window.chrome.webview.postMessage('OPEN_FILE_DIALOG');
|
||||
} else {
|
||||
// 일반 브라우저에서는 수동 입력 안내
|
||||
this.showError('WebView2 환경에서만 파일 선택이 가능합니다. 경로를 수동으로 입력해주세요.');
|
||||
}
|
||||
}
|
||||
|
||||
// C#에서 호출하는 함수
|
||||
receiveFilePath(filePath) {
|
||||
document.getElementById('vncViewerPath').value = filePath;
|
||||
this.showSuccess('VNC Viewer 경로가 설정되었습니다.');
|
||||
}
|
||||
|
||||
async saveServer() {
|
||||
const serverUser = document.getElementById('serverUser').value;
|
||||
const serverIp = document.getElementById('serverIp').value;
|
||||
@@ -303,3 +432,8 @@ class VNCServerApp {
|
||||
|
||||
// 앱 초기화
|
||||
const app = new VNCServerApp();
|
||||
|
||||
// C#에서 호출할 수 있도록 전역 함수로 등록
|
||||
window.receiveFilePath = function(filePath) {
|
||||
app.receiveFilePath(filePath);
|
||||
};
|
||||
Reference in New Issue
Block a user