31 changed files with 505 additions and 68 deletions
@ -0,0 +1,28 @@ |
|||
<hc:GlowWindow x:Class="齐越慧眼.LoginWindow" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:local="clr-namespace:齐越慧眼" |
|||
xmlns:hc="https://handyorg.github.io/handycontrol" |
|||
mc:Ignorable="d" Background="White" |
|||
WindowStartupLocation="CenterScreen" |
|||
ActiveGlowColor="{DynamicResource PrimaryColor}" |
|||
DataContext="{x:Static local:LoginWindowViewModel.Main}" |
|||
Title="登录" Height="250" Width="350"> |
|||
<Border Padding="20"> |
|||
<StackPanel> |
|||
<DockPanel Margin="0 20 0 0" VerticalAlignment="Center"> |
|||
<TextBlock VerticalAlignment="Center" Text="账号:"></TextBlock> |
|||
<hc:TextBox VerticalAlignment="Center" hc:InfoElement.Placeholder="请输入账号" Text="{Binding UserName}"></hc:TextBox> |
|||
</DockPanel> |
|||
|
|||
<DockPanel Margin="0 20 0 20"> |
|||
<TextBlock Text="密码:" VerticalAlignment="Center"></TextBlock> |
|||
<hc:PasswordBox hc:InfoElement.Placeholder="请输入密码" VerticalAlignment="Center" PasswordBox.PasswordChanged="PasswordBox_PasswordChanged"></hc:PasswordBox> |
|||
</DockPanel> |
|||
|
|||
<Button Command="{Binding _Btn_OkClick}" Style="{StaticResource ButtonPrimary}" Content="{Binding IsLogin,Converter={StaticResource toString},ConverterParameter=true----请稍后|false----登录|null----请稍后}" Width="200" Cursor="Hand"/> |
|||
</StackPanel> |
|||
</Border> |
|||
</hc:GlowWindow> |
@ -0,0 +1,32 @@ |
|||
using HandyControl.Controls; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Data; |
|||
using System.Windows.Documents; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using System.Windows.Media.Imaging; |
|||
using System.Windows.Shapes; |
|||
|
|||
namespace 齐越慧眼 |
|||
{ |
|||
/// <summary>
|
|||
/// LoginWindow.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class LoginWindow : GlowWindow |
|||
{ |
|||
public LoginWindow() |
|||
{ |
|||
InitializeComponent(); |
|||
LoginWindowViewModel.Main.Window = this; |
|||
} |
|||
|
|||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) |
|||
{ |
|||
LoginWindowViewModel.Main.UserPwd = (sender as HandyControl.Controls.PasswordBox).Password; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,110 @@ |
|||
using GalaSoft.MvvmLight; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Windows; |
|||
|
|||
namespace 齐越慧眼 |
|||
{ |
|||
public class LoginWindowViewModel : ViewModelBase |
|||
{ |
|||
public LoginWindow Window { get; set; } |
|||
private static LoginWindowViewModel _main = new LoginWindowViewModel(); |
|||
public static LoginWindowViewModel Main |
|||
{ |
|||
get |
|||
{ |
|||
return _main; |
|||
} |
|||
} |
|||
|
|||
public LoginWindowViewModel() |
|||
{ |
|||
_Btn_OkClick = new GalaSoft.MvvmLight.Command.RelayCommand(Btn_OkClick); |
|||
} |
|||
|
|||
|
|||
private string _UserName; |
|||
/// <summary>
|
|||
/// 用戶名
|
|||
/// </summary>
|
|||
public string UserName |
|||
{ |
|||
get { return _UserName; } |
|||
set { Set(ref _UserName, value); } |
|||
} |
|||
|
|||
|
|||
private string _UserPwd; |
|||
/// <summary>
|
|||
/// 用户密码
|
|||
/// </summary>
|
|||
public string UserPwd |
|||
{ |
|||
get { return _UserPwd; } |
|||
set { Set(ref _UserPwd, value); } |
|||
} |
|||
|
|||
private bool _IsLogin; |
|||
|
|||
public bool IsLogin |
|||
{ |
|||
get { return _IsLogin; } |
|||
set { Set(ref _IsLogin, value); } |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 确定按钮被点击
|
|||
/// </summary>
|
|||
|
|||
public GalaSoft.MvvmLight.Command.RelayCommand _Btn_OkClick { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 确定按钮点击
|
|||
/// </summary>
|
|||
public void Btn_OkClick() |
|||
{ |
|||
Thread t = new Thread(() => |
|||
{ |
|||
try |
|||
{ |
|||
|
|||
if (IsLogin) |
|||
return; |
|||
IsLogin = true; |
|||
//登录
|
|||
|
|||
var res = ApiHelper.LoginUser(UserName, UserPwd); |
|||
|
|||
if (res.isOk) |
|||
{ |
|||
Application.Current.Dispatcher.Invoke(() => |
|||
{ |
|||
MainWindow mainWindow = new MainWindow(); |
|||
mainWindow.Show(); |
|||
Application.Current.MainWindow = mainWindow; |
|||
Window.Close(); |
|||
}); |
|||
} |
|||
else |
|||
{ |
|||
MessageBox.Show(res.msg, "登录失败"); |
|||
} |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
MessageBox.Show("初始化窗口异常!", "提示"); |
|||
} |
|||
finally |
|||
{ |
|||
IsLogin = false; |
|||
} |
|||
}); |
|||
t.IsBackground = true; |
|||
t.Start(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,75 @@ |
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Windows.Data; |
|||
|
|||
namespace WPF.Converters |
|||
{ |
|||
|
|||
public class ToStringConverter : IValueConverter |
|||
{ |
|||
|
|||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
if (parameter == null) |
|||
{ |
|||
return value; |
|||
} |
|||
|
|||
string key = string.Empty; |
|||
if (value == null) |
|||
{ |
|||
key = "null"; |
|||
} |
|||
else |
|||
{ |
|||
key = value.ToString().ToLower(); |
|||
} |
|||
string[] arr = parameter.ToString().Split('|'); |
|||
|
|||
Dictionary<string, string> dic = new Dictionary<string, string>(); |
|||
|
|||
foreach (var str in arr) |
|||
{ |
|||
string[] drr = str.Split(new string[] { "----" }, StringSplitOptions.None); |
|||
dic.Add(drr[0].ToLower(), drr[1]); |
|||
} |
|||
|
|||
string defa = dic.FirstOrDefault().Value.ToString(); |
|||
|
|||
if (dic.ContainsKey(key)) |
|||
{ |
|||
if (dic[key] == "Collapsed") |
|||
return System.Windows.Visibility.Collapsed; |
|||
if (dic[key] == "Visible") |
|||
return System.Windows.Visibility.Visible; |
|||
|
|||
return dic[key]; |
|||
} |
|||
else if (defa == "Visible") |
|||
{ |
|||
return System.Windows.Visibility.Collapsed; |
|||
} |
|||
else |
|||
if (defa == "Collapsed") |
|||
return System.Windows.Visibility.Visible; |
|||
else |
|||
if (defa.ToLower() == "false") |
|||
return true; |
|||
else if (defa.ToLower() == "true") |
|||
return false; |
|||
return defa; |
|||
} |
|||
|
|||
|
|||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
string strValue = value.ToString(); |
|||
return value; |
|||
} |
|||
|
|||
} |
|||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,2 +0,0 @@ |
|||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["about"],{f820:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement;t._self._c;return t._m(0)},s=[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"about"},[n("h1",[t._v("This is an about page")])])}],u=n("2877"),c={},i=Object(u["a"])(c,a,s,!1,null,null,null);e["default"]=i.exports}}]); |
|||
//# sourceMappingURL=about.js.map
|
@ -1 +0,0 @@ |
|||
{"version":3,"sources":["webpack:///./src/views/About.vue?e60c","webpack:///./src/views/About.vue"],"names":["render","_vm","this","_h","$createElement","_self","_c","_m","staticRenderFns","staticClass","_v","script","component"],"mappings":"8GAAA,IAAIA,EAAS,WAAa,IAAIC,EAAIC,KAASC,EAAGF,EAAIG,eAAsBH,EAAII,MAAMC,GAAO,OAAOL,EAAIM,GAAG,IACnGC,EAAkB,CAAC,WAAa,IAAIP,EAAIC,KAASC,EAAGF,EAAIG,eAAmBE,EAAGL,EAAII,MAAMC,IAAIH,EAAG,OAAOG,EAAG,MAAM,CAACG,YAAY,SAAS,CAACH,EAAG,KAAK,CAACL,EAAIS,GAAG,+B,YCAtJC,EAAS,GAKTC,EAAY,eACdD,EACAX,EACAQ,GACA,EACA,KACA,KACA,MAIa,aAAAI,E","file":"js/about.js","sourcesContent":["var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _vm._m(0)}\nvar staticRenderFns = [function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"about\"},[_c('h1',[_vm._v(\"This is an about page\")])])}]\n\nexport { render, staticRenderFns }","import { render, staticRenderFns } from \"./About.vue?vue&type=template&id=1ae8a7be&\"\nvar script = {}\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports"],"sourceRoot":""} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue