Skip to content

Commit c680725

Browse files
committed
QpTestClient improve.
1 parent ace601b commit c680725

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed

QpTestClient/QuickConnectForm.Designer.cs

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QpTestClient/QuickConnectForm.cs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
using Quick.Protocol.Utils;
22
using System;
3-
using System.Collections.Generic;
4-
using System.ComponentModel;
5-
using System.Data;
6-
using System.Drawing;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading.Tasks;
3+
using System.Security.Policy;
104
using System.Windows.Forms;
115

126
namespace QpTestClient
@@ -37,12 +31,16 @@ private void btnOk_Click(object sender, EventArgs e)
3731
txtUrl.Focus();
3832
return;
3933
}
34+
4035
var password = txtPassword.Text.Trim();
41-
if (string.IsNullOrEmpty(password))
36+
if (pnlPassword.Visible)
4237
{
43-
MessageBox.Show("请输入密码!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
44-
txtPassword.Focus();
45-
return;
38+
if (string.IsNullOrEmpty(password))
39+
{
40+
MessageBox.Show("请输入密码!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
41+
txtPassword.Focus();
42+
return;
43+
}
4644
}
4745
var uri = new Uri(url);
4846
Quick.Protocol.QpClientOptions options = null;
@@ -55,7 +53,8 @@ private void btnOk_Click(object sender, EventArgs e)
5553
MessageBox.Show("解析URL时出错,原因:" + ExceptionUtils.GetExceptionString(ex), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
5654
return;
5755
}
58-
options.Password = password;
56+
if (pnlPassword.Visible)
57+
options.Password = password;
5958
ConnectionInfo = new TestConnectionInfo()
6059
{
6160
Name = name,
@@ -76,5 +75,17 @@ private void QuickConnectForm_Load(object sender, EventArgs e)
7675
{
7776
txtName.Text = "快速添加连接_" + DateTime.Now.ToString("yyyyMMdd_HHmmss");
7877
}
78+
79+
private void txtUrl_TextChanged(object sender, EventArgs e)
80+
{
81+
var url = txtUrl.Text.Trim();
82+
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri))
83+
{
84+
pnlPassword.Visible = true;
85+
return;
86+
}
87+
var queryString = System.Web.HttpUtility.ParseQueryString(uri.Query);
88+
pnlPassword.Visible = string.IsNullOrEmpty(queryString.Get("Password"));
89+
}
7990
}
8091
}

0 commit comments

Comments
 (0)