Skip to content

Commit

Permalink
feat: Added the ability to show hidden passwords
Browse files Browse the repository at this point in the history
chore

chore
  • Loading branch information
ZGGSONG committed Jan 17, 2024
1 parent 70a0e76 commit ffc98e1
Show file tree
Hide file tree
Showing 20 changed files with 409 additions and 36 deletions.
75 changes: 72 additions & 3 deletions Attachments/iconfont/demo_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ <h1 class="logo"><a href="https://www.iconfont.cn/" title="iconfont 首页" targ
<div class="content unicode" style="display: block;">
<ul class="icon_lists dib-box">

<li class="dib">
<span class="icon iconfont">&#xe725;</span>
<div class="name">密码显示隐藏-02</div>
<div class="code-name">&amp;#xe725;</div>
</li>

<li class="dib">
<span class="icon iconfont">&#xe641;</span>
<div class="name">隐藏</div>
<div class="code-name">&amp;#xe641;</div>
</li>

<li class="dib">
<span class="icon iconfont">&#xe608;</span>
<div class="name">密码显示隐藏-01</div>
<div class="code-name">&amp;#xe608;</div>
</li>

<li class="dib">
<span class="icon iconfont">&#xe607;</span>
<div class="name">二维码</div>
Expand Down Expand Up @@ -360,9 +378,9 @@ <h3 id="-font-face">第一步:拷贝项目下面生成的 <code>@font-face</co
<pre><code class="language-css"
>@font-face {
font-family: 'iconfont';
src: url('iconfont.woff2?t=1704174060960') format('woff2'),
url('iconfont.woff?t=1704174060960') format('woff'),
url('iconfont.ttf?t=1704174060960') format('truetype');
src: url('iconfont.woff2?t=1705480740490') format('woff2'),
url('iconfont.woff?t=1705480740490') format('woff'),
url('iconfont.ttf?t=1705480740490') format('truetype');
}
</code></pre>
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
Expand All @@ -388,6 +406,33 @@ <h3 id="-">第三步:挑选相应图标并获取字体编码,应用于页面
<div class="content font-class">
<ul class="icon_lists dib-box">

<li class="dib">
<span class="icon iconfont icon-mimaxianshiyincang-"></span>
<div class="name">
密码显示隐藏-02
</div>
<div class="code-name">.icon-mimaxianshiyincang-
</div>
</li>

<li class="dib">
<span class="icon iconfont icon-yincang"></span>
<div class="name">
隐藏
</div>
<div class="code-name">.icon-yincang
</div>
</li>

<li class="dib">
<span class="icon iconfont icon-pasw-show"></span>
<div class="name">
密码显示隐藏-01
</div>
<div class="code-name">.icon-pasw-show
</div>
</li>

<li class="dib">
<span class="icon iconfont icon-erweima"></span>
<div class="name">
Expand Down Expand Up @@ -847,6 +892,30 @@ <h3 id="-">第二步:挑选相应图标并获取类名,应用于页面:</h
<div class="content symbol">
<ul class="icon_lists dib-box">

<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-mimaxianshiyincang-"></use>
</svg>
<div class="name">密码显示隐藏-02</div>
<div class="code-name">#icon-mimaxianshiyincang-</div>
</li>

<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-yincang"></use>
</svg>
<div class="name">隐藏</div>
<div class="code-name">#icon-yincang</div>
</li>

<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-pasw-show"></use>
</svg>
<div class="name">密码显示隐藏-01</div>
<div class="code-name">#icon-pasw-show</div>
</li>

<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-erweima"></use>
Expand Down
18 changes: 15 additions & 3 deletions Attachments/iconfont/iconfont.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 4294789 */
src: url('iconfont.woff2?t=1704174060960') format('woff2'),
url('iconfont.woff?t=1704174060960') format('woff'),
url('iconfont.ttf?t=1704174060960') format('truetype');
src: url('iconfont.woff2?t=1705480740490') format('woff2'),
url('iconfont.woff?t=1705480740490') format('woff'),
url('iconfont.ttf?t=1705480740490') format('truetype');
}

.iconfont {
Expand All @@ -13,6 +13,18 @@
-moz-osx-font-smoothing: grayscale;
}

.icon-mimaxianshiyincang-:before {
content: "\e725";
}

.icon-yincang:before {
content: "\e641";
}

.icon-pasw-show:before {
content: "\e608";
}

.icon-erweima:before {
content: "\e607";
}
Expand Down
2 changes: 1 addition & 1 deletion Attachments/iconfont/iconfont.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions Attachments/iconfont/iconfont.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@
"css_prefix_text": "icon-",
"description": "基于.Net 6 开发的新款翻译工具",
"glyphs": [
{
"icon_id": "6250252",
"name": "密码显示隐藏-02",
"font_class": "mimaxianshiyincang-",
"unicode": "e725",
"unicode_decimal": 59173
},
{
"icon_id": "19449551",
"name": "隐藏",
"font_class": "yincang",
"unicode": "e641",
"unicode_decimal": 58945
},
{
"icon_id": "29421598",
"name": "密码显示隐藏-01",
"font_class": "pasw-show",
"unicode": "e608",
"unicode_decimal": 58888
},
{
"icon_id": "77191",
"name": "二维码",
Expand Down
Binary file modified Attachments/iconfont/iconfont.ttf
Binary file not shown.
Binary file modified Attachments/iconfont/iconfont.woff
Binary file not shown.
Binary file modified Attachments/iconfont/iconfont.woff2
Binary file not shown.
3 changes: 3 additions & 0 deletions STranslate.Model/ConstStr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public static class ConstStr
public const string MAXIMIZECONTENT = "\xe651";
public const string MAXIMIZEBACKCONTENT = "\xe693";

public const string SHOWICON = "\xe608";
public const string HIDEICON = "\xe725";

public const string DEFAULTINPUTHOTKEY = "Alt + A";
public const string DEFAULTCROSSWORDHOTKEY = "Alt + D";
public const string DEFAULTSCREENSHOTHOTKEY = "Alt + S";
Expand Down
2 changes: 1 addition & 1 deletion STranslate.Style/Commons/PlaceholderTextBox .cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public PlaceholderTextBox()
var binding = new Binding { Source = this, Path = new PropertyPath("Placeholder") };
_placeholderTextBlock.SetBinding(TextProperty, binding);
//_placeholderTextBlock.FontStyle = FontStyles.Italic;
_placeholderTextBlock.Padding = new Thickness(5, 2, 5, 2);
_placeholderTextBlock.Padding = new Thickness(3,0,3,0);
_placeholderTextBlock.BorderThickness = new Thickness(0);
_placeholderTextBlock.Foreground = Brushes.Gray;

Expand Down
33 changes: 33 additions & 0 deletions STranslate.Style/Converters/BooleanToContentConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using System.Windows.Data;
using STranslate.Model;

namespace STranslate.Style.Converters
{
public class BooleanToContentConverter : IValueConverter
{
/// <summary>
/// True False 控制图标
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool bValue)
{
return bValue ? ConstStr.HIDEICON : ConstStr.SHOWICON;
}

return ConstStr.HIDEICON;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
35 changes: 35 additions & 0 deletions STranslate.Style/Converters/BooleanToVisibilityReverseConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace STranslate.Style.Converters
{
public sealed class BooleanToVisibilityReverseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool bValue = false;
if (value is bool v)
{
bValue = v;
}
else if (value is bool?)
{
bool? tmp = (bool?)value;
bValue = tmp ?? false;
}
return (bValue) ? Visibility.Collapsed : Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Visibility visi)
{
return visi == Visibility.Collapsed;
}

return true;
}
}
}
Binary file modified STranslate.Style/Fonts/iconfont.ttf
Binary file not shown.
2 changes: 2 additions & 0 deletions STranslate.Style/Styles/CommonStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
<converter:String2IsEnableConverter x:Key="String2IsEnableConverter" />
<converter:BooleanReverseConverter x:Key="BooleanReverseConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converter:BooleanToVisibilityReverseConverter x:Key="BooleanToVisibilityReverseConverter" />
<converter:BooleanToContentConverter x:Key="BooleanToContentConverter" />
</ResourceDictionary>
1 change: 1 addition & 0 deletions STranslate.Style/Styles/TextBoxStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Style TargetType="TextBox">
<Setter Property="Padding" Value="5,2" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Foreground" Value="{DynamicResource TextForeground}" />
<Setter Property="CaretBrush" Value="{DynamicResource TextForeground}" />
<Setter Property="SelectionBrush" Value="{DynamicResource TextForeground}" />
Expand Down
54 changes: 54 additions & 0 deletions STranslate/ViewModels/Preference/Services/TranslatorBaidu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Newtonsoft.Json;
using STranslate.Model;
using STranslate.Util;
Expand Down Expand Up @@ -88,6 +89,59 @@ public object Data
[JsonIgnore]
public List<IconType> Icons { get; private set; } = Enum.GetValues(typeof(IconType)).OfType<IconType>().ToList();

#region Show/Hide Encrypt Info

[JsonIgnore]
private bool _idHide = true;

[JsonIgnore]
public bool IdHide
{
get => _idHide;
set
{
if (_idHide != value)
{
OnPropertyChanging(nameof(IdHide));
_idHide = value;
OnPropertyChanged(nameof(IdHide));
}
}
}

[JsonIgnore]
private bool _keyHide = true;

[JsonIgnore]
public bool KeyHide
{
get => _keyHide;
set
{
if (_keyHide != value)
{
OnPropertyChanging(nameof(KeyHide));
_keyHide = value;
OnPropertyChanged(nameof(KeyHide));
}
}
}

[RelayCommand]
private void ShowEncryptInfo(string obj)
{
if (obj.Equals(nameof(AppID)))
{
IdHide = !IdHide;
}
else if (obj.Equals(nameof(AppKey)))
{
KeyHide = !KeyHide;
}
}

#endregion Show/Hide Encrypt Info

public async Task<object> TranslateAsync(object request, CancellationToken token)
{
if (request is RequestBaidu rb)
Expand Down
Loading

0 comments on commit ffc98e1

Please sign in to comment.