代码拉取完成,页面将自动刷新
同步操作将从 jianghong/wnmp PHP集成环境 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using Microsoft.Win32;
using System;
using System.Windows;
using System.Windows.Input;
using wnmp.tools;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.IO;
namespace wnmp
{
/// <summary>
/// webSite.xaml 的交互逻辑
/// </summary>
public partial class WebSite : Window
{
private SiteConf conf;//站点配置
private Site site;
private AppConf appConf;
private MainWindow fWindow;//父窗口
public WebSite(SiteConf sc, MainWindow app,AppConf ac)
{
InitializeComponent();
appConf = ac;
site = new Site(appConf);
conf = sc;
fWindow = app;
if (conf != null)
{
loadConf();
}
if (sc.IsNew)
{
removeWebSite.Visibility = Visibility.Hidden;
site_conf_btn.Visibility = Visibility.Hidden;
}
else
{
removeWebSite.Visibility = Visibility.Visible;
site_conf_btn.Visibility = Visibility.Visible;
}
//Site.EditHost("www.test.xyz", null,false);
}
/*
* 添加新网站
*/
private void Label_MouseDown(object sender, MouseButtonEventArgs e)
{
if (domainNameInput.Text.Trim() != "")
{
try
{
site.AddSite(GetSiteConfFromForm());
fWindow.LoadList();
Close();
}
catch
{
System.Windows.MessageBox.Show("添加失败", "错误");
}
}
else
{
System.Windows.MessageBox.Show("网站域名必须填写","错误");
}
}
/// <summary>
/// 从表单读取配置
/// </summary>
/// <returns></returns>
private SiteConf GetSiteConfFromForm()
{
SiteConf conf = new SiteConf();
//域名
if (!conf.checkDomain(domainNameInput.Text))
{
conf.domainName = "";
}
else
{
conf.domainName = domainNameInput.Text;
}
//处理多个域名
//端口
conf.sitePort = sitePortInput.Text;
//站点目录
conf.siteRoot = siteRootInput.Text;
//默认文件
conf.siteFile = siteFileInput.Text;
//是否开启为静态
conf.staticStatus = (bool)staticBox.IsChecked;
//伪静态路径
conf.staticRoot = staticInput.Text;
//压缩
conf.gzip = (bool)gzipBox.IsChecked;
//跨域
conf.cross = (bool)crossBox.IsChecked;
//同步host
conf.host = (bool)hostBox.IsChecked;
return conf;
}
/// <summary>
/// 渲染表单
/// </summary>
private void loadConf()
{
domainNameInput.Text = conf.domainName;
sitePortInput.Text = conf.sitePort;
siteRootInput.Text = conf.siteRoot;
siteFileInput.Text = conf.siteFile;
staticBox.IsChecked = conf.staticStatus;
staticInput.Text = conf.staticRoot;
gzipBox.IsChecked = conf.gzip;
crossBox.IsChecked = conf.cross;
hostBox.IsChecked = conf.host;
}
private void removeWebSite_MouseDown(object sender, MouseButtonEventArgs e)
{
//删除网站
site.RemoveSite(conf);
fWindow.LoadList();
Close();
}
private void Label_MouseDown_1(object sender, MouseButtonEventArgs e)
{
//选择目录
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.ShowDialog();
string path = fbd.SelectedPath;
if (path.Trim() == "")
{
//System.Windows.MessageBox.Show("必须选择目录", "错误");
return;
}
siteRootInput.Text = path.Replace(@"\",@"\\");
}
private void staticInput_LostFocus(object sender, RoutedEventArgs e)
{
//伪静态路径检测
string s = staticInput.Text.Trim();
if (s == "")
{
staticInput.Text = "/";
}
}
private void siteFileInput_LostFocus(object sender, RoutedEventArgs e)
{
//默认文件检测
string s = siteFileInput.Text.Trim();
if (s == "")
{
siteFileInput.Text = "index.html";
}
}
private void sitePortInput_LostFocus(object sender, RoutedEventArgs e)
{
//默认文件检测
string s = sitePortInput.Text.Trim();
if(!Regex.IsMatch(s, @"^[0-9]{2,4}$"))
{
sitePortInput.Text = "80";
System.Windows.MessageBox.Show("网站端口必须为整数");
}
}
private void Label_MouseUp(object sender, MouseButtonEventArgs e)
{
//查看Host配置
(new Tools(appConf)).OpenConf("hosts");
}
private void Label_MouseUp_1(object sender, MouseButtonEventArgs e)
{
string conf_name = conf.domainName.Split(" ")[0];
string confPath = Site.GetRootPath() + appConf.NginxRoot + "conf/vhosts/" + conf_name + ".conf";
if (File.Exists(confPath))
{
Tools t = new Tools(appConf);
t.OpenText(confPath);
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。