From 67c1bf32ecd587dc4edfec260ed5d213531dba4d Mon Sep 17 00:00:00 2001 From: taoye Date: Fri, 22 Jul 2022 17:29:23 +0800 Subject: [PATCH] =?UTF-8?q?180=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Model/UserManager.cs | 3 +- FryPot_DosingSystem/App.xaml.cs | 8 +- .../FryPot_DosingSystem.csproj | 3 +- .../Resources/fonts/demo_index.html | 391 ++++++++++++++++++ .../Resources/fonts/iconfont.ttf | Bin 0 -> 3676 bytes FryPot_DosingSystem/View/UserManageView.xaml | 376 +++++++++++++++++ .../View/UserManageView.xaml.cs | 28 ++ .../ViewModel/UserManageViewModel.cs | 80 ++++ 8 files changed, 886 insertions(+), 3 deletions(-) create mode 100644 FryPot_DosingSystem/Resources/fonts/demo_index.html create mode 100644 FryPot_DosingSystem/Resources/fonts/iconfont.ttf create mode 100644 FryPot_DosingSystem/View/UserManageView.xaml create mode 100644 FryPot_DosingSystem/View/UserManageView.xaml.cs create mode 100644 FryPot_DosingSystem/ViewModel/UserManageViewModel.cs diff --git a/BPASmartClient.CustomResource/Pages/Model/UserManager.cs b/BPASmartClient.CustomResource/Pages/Model/UserManager.cs index 258199e9..1baf3908 100644 --- a/BPASmartClient.CustomResource/Pages/Model/UserManager.cs +++ b/BPASmartClient.CustomResource/Pages/Model/UserManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -8,6 +9,6 @@ namespace BPASmartClient.CustomResource.Pages.Model { public class UserManager { - public List userInfos { get; set; } = new List(); + public ObservableCollection userInfos { get; set; } = new ObservableCollection(); } } diff --git a/FryPot_DosingSystem/App.xaml.cs b/FryPot_DosingSystem/App.xaml.cs index 3cf71e3d..3d322339 100644 --- a/FryPot_DosingSystem/App.xaml.cs +++ b/FryPot_DosingSystem/App.xaml.cs @@ -184,7 +184,13 @@ namespace FryPot_DosingSystem AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.PasswordChangeView" }); - + UserManager.Add(new SubMenumodel() + { + SubMenuName = "账号管理", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "FryPot_DosingSystem", + ToggleWindowPath = "View.UserManageView" + }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { diff --git a/FryPot_DosingSystem/FryPot_DosingSystem.csproj b/FryPot_DosingSystem/FryPot_DosingSystem.csproj index e56b6575..7ed8e5b5 100644 --- a/FryPot_DosingSystem/FryPot_DosingSystem.csproj +++ b/FryPot_DosingSystem/FryPot_DosingSystem.csproj @@ -10,6 +10,7 @@ + @@ -32,7 +33,7 @@ - + diff --git a/FryPot_DosingSystem/Resources/fonts/demo_index.html b/FryPot_DosingSystem/Resources/fonts/demo_index.html new file mode 100644 index 00000000..040a67f5 --- /dev/null +++ b/FryPot_DosingSystem/Resources/fonts/demo_index.html @@ -0,0 +1,391 @@ + + + + + iconfont Demo + + + + + + + + + + + + + +
+

+ + +

+ +
+
+
    + +
  • + +
    账号信息
    +
    
    +
  • + +
  • + +
    窗口-最大化_line
    +
    
    +
  • + +
  • + +
    密码
    +
    
    +
  • + +
  • + +
    权限配置
    +
    
    +
  • + +
  • + +
    close
    +
    
    +
  • + +
  • + +
    minus
    +
    
    +
  • + +
  • + +
    账号中心 账号管理
    +
    
    +
  • + +
  • + +
    齿轮,设置,设定
    +
    
    +
  • + +
  • + +
    面性密码锁
    +
    
    +
  • + +
+
+

Unicode 引用

+
+ +

Unicode 是字体在网页端最原始的应用方式,特点是:

+
    +
  • 支持按字体的方式去动态调整图标大小,颜色等等。
  • +
  • 默认情况下不支持多色,直接添加多色图标会自动去色。
  • +
+
+

注意:新版 iconfont 支持两种方式引用多色图标:SVG symbol 引用方式和彩色字体图标模式。(使用彩色字体图标需要在「编辑项目」中开启「彩色」选项后并重新生成。)

+
+

Unicode 使用步骤如下:

+

第一步:拷贝项目下面生成的 @font-face

+
@font-face {
+  font-family: 'iconfont';
+  src: url('iconfont.ttf?t=1658305362348') format('truetype');
+}
+
+

第二步:定义使用 iconfont 的样式

+
.iconfont {
+  font-family: "iconfont" !important;
+  font-size: 16px;
+  font-style: normal;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+}
+
+

第三步:挑选相应图标并获取字体编码,应用于页面

+
+<span class="iconfont">&#x33;</span>
+
+
+

"iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。

+
+
+
+
+
    + +
  • + +
    + 账号信息 +
    +
    .icon-zhanghaoxinxi +
    +
  • + +
  • + +
    + 窗口-最大化_line +
    +
    .icon-window-max_line +
    +
  • + +
  • + +
    + 密码 +
    +
    .icon-mima +
    +
  • + +
  • + +
    + 权限配置 +
    +
    .icon-quanxianpeizhi +
    +
  • + +
  • + +
    + close +
    +
    .icon-close +
    +
  • + +
  • + +
    + minus +
    +
    .icon-minus +
    +
  • + +
  • + +
    + 账号中心 账号管理 +
    +
    .icon-zhanghaozhongxinzhanghaoguanli +
    +
  • + +
  • + +
    + 齿轮,设置,设定 +
    +
    .icon-set +
    +
  • + +
  • + +
    + 面性密码锁 +
    +
    .icon-mianxingmima +
    +
  • + +
+
+

font-class 引用

+
+ +

font-class 是 Unicode 使用方式的一种变种,主要是解决 Unicode 书写不直观,语意不明确的问题。

+

与 Unicode 使用方式相比,具有如下特点:

+
    +
  • 相比于 Unicode 语意明确,书写更直观。可以很容易分辨这个 icon 是什么。
  • +
  • 因为使用 class 来定义图标,所以当要替换图标时,只需要修改 class 里面的 Unicode 引用。
  • +
+

使用步骤如下:

+

第一步:引入项目下面生成的 fontclass 代码:

+
<link rel="stylesheet" href="./iconfont.css">
+
+

第二步:挑选相应图标并获取类名,应用于页面:

+
<span class="iconfont icon-xxx"></span>
+
+
+

" + iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。

+
+
+
+
+
    + +
  • + +
    账号信息
    +
    #icon-zhanghaoxinxi
    +
  • + +
  • + +
    窗口-最大化_line
    +
    #icon-window-max_line
    +
  • + +
  • + +
    密码
    +
    #icon-mima
    +
  • + +
  • + +
    权限配置
    +
    #icon-quanxianpeizhi
    +
  • + +
  • + +
    close
    +
    #icon-close
    +
  • + +
  • + +
    minus
    +
    #icon-minus
    +
  • + +
  • + +
    账号中心 账号管理
    +
    #icon-zhanghaozhongxinzhanghaoguanli
    +
  • + +
  • + +
    齿轮,设置,设定
    +
    #icon-set
    +
  • + +
  • + +
    面性密码锁
    +
    #icon-mianxingmima
    +
  • + +
+
+

Symbol 引用

+
+ +

这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇文章 + 这种用法其实是做了一个 SVG 的集合,与另外两种相比具有如下特点:

+
    +
  • 支持多色图标了,不再受单色限制。
  • +
  • 通过一些技巧,支持像字体那样,通过 font-size, color 来调整样式。
  • +
  • 兼容性较差,支持 IE9+,及现代浏览器。
  • +
  • 浏览器渲染 SVG 的性能一般,还不如 png。
  • +
+

使用步骤如下:

+

第一步:引入项目下面生成的 symbol 代码:

+
<script src="./iconfont.js"></script>
+
+

第二步:加入通用 CSS 代码(引入一次就行):

+
<style>
+.icon {
+  width: 1em;
+  height: 1em;
+  vertical-align: -0.15em;
+  fill: currentColor;
+  overflow: hidden;
+}
+</style>
+
+

第三步:挑选相应图标并获取类名,应用于页面:

+
<svg class="icon" aria-hidden="true">
+  <use xlink:href="#icon-xxx"></use>
+</svg>
+
+
+
+ +
+
+ + + diff --git a/FryPot_DosingSystem/Resources/fonts/iconfont.ttf b/FryPot_DosingSystem/Resources/fonts/iconfont.ttf new file mode 100644 index 0000000000000000000000000000000000000000..7bc40e7980fcd02db71a2289a79e3090c893b966 GIT binary patch literal 3676 zcmd^C-E&jN6+e5gboFIRw)HI`b1fmsmSvg9_7xZ-%O)!?k5& zdpgveGBgc^WG1DZAuqI@Nk8&J2WB#9^S~rbJJXMc_N9|fCuRB|$`IbtzF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kZpwPk0 zdW%zEepG&>cUtt!Tz;r;YSu9`GwYh0^lStDke44ZtKRI=mmhLHGy2PqbY>^NCn{&J zxWayd+Z8e34OBPPB8jhUPS%^v^}?@Evp38xGv3OHyY;2`Td|H>kx7GelulzD0)s<| zqydzGSpuYpP##crL~oVhhy&Ydlp&t|U06c^SteN}o85=y*$yx+(mX{AcBOwHx3Spb z>+k7Lx!n$*6FJq_`?AC5aJy3(f+~R2CLn8x6xuZf=304 zP0HuuiQK?I&%O)iWc%y!M6%K8Y#dq{@_AQ=DrEn`sY9?f(%wD-lfSU-w%SZa`>=ht z)xOJdjW-@UFjL_seh)Ws8n=RnGV~D;h&Brrqkt2oJ1)c!Q%D%33qXl+1n_FGMi4d& zatg2ACUHXY;f(QC8lVGhCBR_{bn}=+Fa{J(DEwTC;uHeHMy}@Lnfa6z%g#9fY)s+v zc13sE>E_0t%p#E78*w-yy@_fgADrv!n_K7Aq)O!-aY`!DH8`QG7xa3eUN=9O z#H$ufx_y^odXq}@eU*|v#+9srdjF`uK47ggw4d5-HfS6DF;`GqSEmiSV*W<0!Myua zd!6BhYOR``Y6d}m;x6|(QS%p0-(}j6Q`4k9w$v!p>3ripU7gTSJf>}uTp=wp^!FQ} z;F4aTpmB1Ac-)X^G_|pisZrE-$>tts&!9o=cZJenr(bOt1aFqR^dfZHcB(krpHZoP zz>qj1I+0ga^5Zl@cHul15GYo4S0!C=^6-p%e2_L;B)^y6H%gS>L6Y$I@@PwZ?Buby zT>kYJvXW3_wo<0%wzg)0*X4iNWjP|tEXW+;v3Lt~!?$nCij22xY4b3rClvCO|J~en zMz-&VF0T;3gm0P8tC^RF6rjTRyI)@T*zP>oh&ZP6MnL4L4C>#3cF zYP10s7jOeJ74B*Z(06Mz|DyV3jTXp=9IEPwkpI3$t3dy)Mytt2_iMBS`DTsQ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FryPot_DosingSystem/View/UserManageView.xaml.cs b/FryPot_DosingSystem/View/UserManageView.xaml.cs new file mode 100644 index 00000000..0045dfb5 --- /dev/null +++ b/FryPot_DosingSystem/View/UserManageView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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.Navigation; +using System.Windows.Shapes; + +namespace FryPot_DosingSystem.View +{ + /// + /// UserManageView.xaml 的交互逻辑 + /// + public partial class UserManageView : UserControl + { + public UserManageView() + { + InitializeComponent(); + } + } +} diff --git a/FryPot_DosingSystem/ViewModel/UserManageViewModel.cs b/FryPot_DosingSystem/ViewModel/UserManageViewModel.cs new file mode 100644 index 00000000..3cf75e0f --- /dev/null +++ b/FryPot_DosingSystem/ViewModel/UserManageViewModel.cs @@ -0,0 +1,80 @@ +using BPA.Message; +using BPASmartClient.CustomResource.Pages.Enums; +using BPASmartClient.CustomResource.Pages.Model; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace FryPot_DosingSystem.ViewModel +{ + internal class UserManageViewModel:ObservableObject + { + public ObservableCollection usersInfo { get; set; } = new ObservableCollection(); + + public List Authorities { get; set; } = new List(); + + public RelayCommand SaveCommand { get; set; } + public RelayCommand UpdateCommand { get; set; } + public RelayCommand DeleteCommand { get; set; } + public UserManageViewModel() + { + var userManager = JsonConvert.DeserializeObject(File.ReadAllText("up.hbl").AESDecrypt()); + usersInfo = userManager.userInfos; + AddAuthorities(); + SaveCommand = new RelayCommand((str) => + { + if (str != string.Empty && str != null) + { + int num = usersInfo.Where(p => p.UserName == str).Count(); + if (num > 0 && num >= 2) + { + MessageBox.Show("用户名重复", "提示", MessageBoxButton.OK, MessageBoxImage.Information); + } + else + { + Global.userManager.userInfos = usersInfo; + File.WriteAllText("UserInfo.jz", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); + MessageBox.Show("保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information); + } + + } + }); + DeleteCommand = new RelayCommand((str) => + { + if (str != string.Empty && str != null) + { + var userInfo = usersInfo.FirstOrDefault(p => p.UserName == str); + if (userInfo != null) + { + if (usersInfo.Remove(userInfo)) + { + Global.userManager.userInfos = usersInfo; + File.WriteAllText("UserInfo.jz", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); + } + } + else + { + MessageBox.Show("未找到对应记录", "提示", MessageBoxButton.OK, MessageBoxImage.Information); + } + } + }); + } + + private void AddAuthorities() + { + foreach (Permission aut in System.Enum.GetValues(typeof(Permission))) + { + Authorities.Add(aut.ToString()); + } + + } + } +}