This commit is contained in:
xiangbing 2025-02-24 21:46:56 +08:00
parent 123add14eb
commit e178f93663
8 changed files with 178 additions and 6 deletions

8
App.config Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="userName" value=""/>
<add key="password" value=""/>
<add key="isRemind" value=""/>
</appSettings>
</configuration>

48
Common/Tools/Config.cs Normal file
View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VideoConcat.Common.Tools
{
class Config
{
/// <summary>
/// 读取客户设置
/// </summary>
/// <param name="settingName"></param>
/// <returns></returns>
public static string GetSettingString(string settingName)
{
try
{
string settingString = ConfigurationManager.AppSettings[settingName].ToString();
return settingString;
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// 更新设置
/// </summary>
/// <param name="settingName"></param>
/// <param name="valueName"></param>
public static void UpdateSettingString(string settingName, string valueName)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (ConfigurationManager.AppSettings[settingName] != null)
{
config.AppSettings.Settings.Remove(settingName);
}
config.AppSettings.Settings.Add(settingName, valueName);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
}
}

View File

@ -9,6 +9,7 @@
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>视频.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
@ -23,6 +24,12 @@
<PackageReference Include="WPFDevelopers" Version="0.0.0.1" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Update="app.manifest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
@ -30,6 +37,9 @@
</ItemGroup>
<ItemGroup>
<None Update="App.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@ -5,7 +5,7 @@ VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VideoConcat", "VideoConcat.csproj", "{2FF5691C-3184-4B68-944B-C704E64C4E4E}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "视频", "..\视频\视频.vdproj", "{6253EBA0-190A-4A7D-AC55-954172807A46}"
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "视频", "..\视频\视频.vdproj", "{F784558F-CA6F-E806-1DC3-7B0C364779F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,8 +17,8 @@ Global
{2FF5691C-3184-4B68-944B-C704E64C4E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FF5691C-3184-4B68-944B-C704E64C4E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FF5691C-3184-4B68-944B-C704E64C4E4E}.Release|Any CPU.Build.0 = Release|Any CPU
{6253EBA0-190A-4A7D-AC55-954172807A46}.Debug|Any CPU.ActiveCfg = Debug
{6253EBA0-190A-4A7D-AC55-954172807A46}.Release|Any CPU.ActiveCfg = Release
{F784558F-CA6F-E806-1DC3-7B0C364779F3}.Debug|Any CPU.ActiveCfg = Debug
{F784558F-CA6F-E806-1DC3-7B0C364779F3}.Release|Any CPU.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -8,7 +8,7 @@
xmlns:local="clr-namespace:VideoConcat"
mc:Ignorable="d"
Title="登录"
Height="300"
Height="330"
Width="500"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen">
@ -73,6 +73,10 @@
</PasswordBox>
</StackPanel>
<StackPanel Margin="10" Orientation="Horizontal">
<CheckBox HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="30" x:Name="ckbRemember" Width="30" Height="30" Margin="15,0,10,0" IsChecked="True"></CheckBox>
<TextBlock VerticalAlignment="Center" Margin="10,0">记住我</TextBlock>
</StackPanel>
<StackPanel Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button x:Name="btnLogin" Width="100" Height="40"
materialDesign:ButtonAssist.CornerRadius="2"

View File

@ -12,6 +12,16 @@ namespace VideoConcat.Views
public MainWindow()
{
InitializeComponent();
Username.Text = Config.GetSettingString("userName");
Password.Password = Config.GetSettingString("password");
if (Config.GetSettingString("isRemember") == "true")
{
ckbRemember.IsChecked = true;
}
else
{
ckbRemember.IsChecked = false;
}
}
private void BtnExit_Click(object sender, RoutedEventArgs e)
@ -23,6 +33,7 @@ namespace VideoConcat.Views
{
string _userName = Username.Text;
bool _isChecked = Convert.ToBoolean(ckbRemember.IsChecked);
string _password = Password.Password;
if (string.IsNullOrEmpty(_userName) || string.IsNullOrEmpty(_password))
@ -33,12 +44,24 @@ namespace VideoConcat.Views
return;
}
ApiResponse<UserLoginResponse> res = await SystemApi.LoginAsync<UserLoginResponse>(_userName, _password);
if (res.Code !=0)
if (res.Code != 0)
{
WPFDevelopers.Controls.MessageBox.Show(res.Msg);
}
else
{
if (_isChecked)
{
Config.UpdateSettingString("userName", _userName);
Config.UpdateSettingString("password", _password);
Config.UpdateSettingString("isRemember", "true");
}
else
{
Config.UpdateSettingString("userName", "");
Config.UpdateSettingString("password", "");
Config.UpdateSettingString("isRemember", "false");
}
new Video().Show();
Close();
}

View File

@ -7,7 +7,7 @@
xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:local="clr-namespace:VideoConcat.Views"
mc:Ignorable="d"
Title="视频拼接" Height="800" Width="780" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
Title="视频拼接" Height="800" Width="780" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

79
app.manifest Normal file
View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI无需
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>