udpate login.html

This commit is contained in:
backuppc
2025-07-10 14:36:05 +09:00
parent 43526a26ec
commit 26cb328f8f
31 changed files with 866 additions and 543 deletions

View File

@@ -21,7 +21,11 @@ namespace Project.Dialog
public fDashboard()
{
InitializeComponent();
#if WEB
InitializeWebView2();
#endif
}
private void InitializeWebView2()
{

View File

@@ -76,7 +76,10 @@ namespace Project.Dialog
// 시스템에 설치된 WebView2 사용
await this.webView21.EnsureCoreWebView2Async();
}
// OWIN 서버의 DashBoard 페이지로 연결
// WebView2에서 C# 메서드를 호출할 수 있도록 설정
webView21.CoreWebView2.WebMessageReceived += WebView2_WebMessageReceived;
// OWIN 서버의 Login 페이지로 연결
webView21.Source = new Uri("http://127.0.0.1:9000/Home/Login");
label1.Visible = false;
}
@@ -85,6 +88,62 @@ namespace Project.Dialog
MessageBox.Show($"WebView2 초기화 실패: {ex.Message}");
}
}
// WebView2에서 보낸 메시지를 받아서 처리
private void WebView2_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e)
{
try
{
var message = e.TryGetWebMessageAsString();
if (message == "LOGIN_SUCCESS")
{
// UI 스레드에서 실행
this.Invoke(new Action(() =>
{
// button1_Click과 동일한 로직 실행
ExecuteLoginLogic();
}));
}
}
catch (Exception ex)
{
Console.WriteLine($"WebView2 메시지 처리 오류: {ex.Message}");
}
}
// 로그인 성공 시 실행할 로직 (button1_Click과 동일)
private void ExecuteLoginLogic()
{
DateTime dt = DateTime.Now;
// 로그인 정보가 이미 설정되어 있다고 가정 (웹에서 처리됨)
if (string.IsNullOrEmpty(FCOMMON.info.Login.no))
{
MessageBox.Show("로그인 정보가 설정되지 않았습니다.");
return;
}
try
{
// 로그인정보 기록
AddLoginInfo();
//210221
MakeAutoJobReportbyLogin();
//210613
MakeAutoJobReportByAuto();
DialogResult = DialogResult.OK;
FCOMMON.info.Login.loginusetime = (DateTime.Now - dt).TotalMilliseconds;
}
catch (Exception ex)
{
Util.MsgE("로그인 처리 중 오류가 발생했습니다.\n\n" + ex.Message);
DialogResult = System.Windows.Forms.DialogResult.Cancel;
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);