WPF实战学习笔记21-自定义首页添加对话服务

news/2024/5/17 15:59:10

自定义首页添加对话服务

定义接口与实现

添加自定义添加对话框接口

添加文件:Mytodo.Dialog.IDialogHostAware.cs

using Prism.Commands;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace Mytodo.Dialog
{public interface IDialogHostAware{/// <summary>/// DialoHost名称/// </summary>string DialogHostName { get; set; }/// <summary>/// 打开过程中执行/// </summary>/// <param name="parameters"></param>void OnDialogOpend(IDialogParameters parameters);/// <summary>/// 确定/// </summary>DelegateCommand SaveCommand { get; set; }/// <summary>/// 取消/// </summary>DelegateCommand CancelCommand { get; set; }}
}

添加自定义添加对话框显示接口

注意dialogHostName应与view中dialoghost 的Identifier属性一致

using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace Mytodo.Dialog
{public interface  IDialogHostService:IDialogService{/// <summary>/// 显示Dialog方法/// </summary>/// <param name="name"></param>/// <param name="parameters"></param>/// <param name="dialogHostName"></param>/// <returns></returns>Task<IDialogResult> ShowDialog(string name, IDialogParameters parameters, string dialogHostName = "Root");}
}

实现IDialogHostService接口

添加文件:Mytodo.Dialog.DialogHostService.cs

DialogHostService实现了自定义的IDialogHostService接口,以及DialogService类.

DialogService:可参考https://www.cnblogs.com/chonglu/p/15159387.html

Prism提供了一组对话服务, 封装了常用的对话框组件的功能, 例如:

  • RegisterDialog/IDialogService (注册对话及使用对话)
  • 打开对话框传递参数/关闭对话框返回参数
  • 回调通知对话结果
using MaterialDesignThemes.Wpf;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;namespace Mytodo.Dialog
{public class DialogHostService:DialogService, IDialogHostService{private readonly IContainerExtension containerExtension;public DialogHostService(IContainerExtension containerExtension) : base(containerExtension){this.containerExtension = containerExtension;}public async Task<IDialogResult> ShowDialog(string name, IDialogParameters parameters, string dialogHostName = "Root"){if (parameters == null)parameters = new DialogParameters();//从容器当中去除弹出窗口的实例var content = containerExtension.Resolve<object>(name);//验证实例的有效性 if (!(content is FrameworkElement dialogContent))throw new NullReferenceException("A dialog's content must be a FrameworkElement");if (dialogContent is FrameworkElement view && view.DataContext is null && ViewModelLocator.GetAutoWireViewModel(view) is null)ViewModelLocator.SetAutoWireViewModel(view, true);if (!(dialogContent.DataContext is IDialogHostAware viewModel))throw new NullReferenceException("A dialog's ViewModel must implement the IDialogAware interface");viewModel.DialogHostName = dialogHostName;DialogOpenedEventHandler eventHandler = (sender, eventArgs) =>{if (viewModel is IDialogHostAware aware){aware.OnDialogOpend(parameters);}eventArgs.Session.UpdateContent(content);};return (IDialogResult)await DialogHost.Show(dialogContent, viewModel.DialogHostName, eventHandler);}}
}

添加对应的窗体

添加AddMemoView

添加文件Mytodo.Views.Dialogs.AddMemoView.xaml

<UserControlx:Class="Mytodo.Views.Dialogs.AddMemoView"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:local="clr-namespace:Mytodo.Views"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"d:DesignHeight="450"d:DesignWidth="800"mc:Ignorable="d"><Grid Width="400"><Grid.RowDefinitions><RowDefinition Height="auto" /><RowDefinition /><RowDefinition Height="auto" /></Grid.RowDefinitions><TextBlockPadding="20,10"FontSize="20"FontWeight="Bold"Text="添加备忘录" /><DockPanel Grid.Row="1" LastChildFill="False"><TextBoxMargin="20,0"md:HintAssist.Hint="请输入备忘录概要"DockPanel.Dock="Top"Text="{Binding Model.Title}" /><TextBoxMinHeight="100"Margin="20,10"md:HintAssist.Hint="请输入备忘录内容"AcceptsReturn="True"DockPanel.Dock="Top"Text="{Binding Model.Content}"TextWrapping="Wrap" /></DockPanel><StackPanelGrid.Row="2"Margin="10"HorizontalAlignment="Right"Orientation="Horizontal"><ButtonMargin="0,0,10,0"Command="{Binding CancelCommand}"Content="取消"Style="{StaticResource MaterialDesignOutlinedButton}" /><Button Command="{Binding SaveCommand}" Content="确定" /></StackPanel></Grid>
</UserControl>

添加文件:Mytodo.Views.Dialogs.AddMemoViewmodel.cs

using MaterialDesignThemes.Wpf;
using Mytodo.Dialog;
using MyToDo.Share.Models;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace Mytodo.ViewModels.Dialogs
{internal class AddMemoViewModel : BindableBase, IDialogHostAware{public AddMemoViewModel(){SaveCommand = new DelegateCommand(Save);CancelCommand = new DelegateCommand(Cancel);}private MemoDto model;public MemoDto Model{get { return model; }set { model = value; RaisePropertyChanged(); }}private void Cancel(){if (DialogHost.IsDialogOpen(DialogHostName))DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.No));}private void Save(){if (string.IsNullOrWhiteSpace(Model.Title) ||string.IsNullOrWhiteSpace(model.Content)) return;if (DialogHost.IsDialogOpen(DialogHostName)){//确定时,把编辑的实体返回并且返回OKDialogParameters param = new DialogParameters();param.Add("Value", Model);DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.OK, param));}}public string DialogHostName { get; set; }public DelegateCommand SaveCommand { get; set; }public DelegateCommand CancelCommand { get; set; }public void OnDialogOpend(IDialogParameters parameters){if (parameters.ContainsKey("Value")){Model = parameters.GetValue<MemoDto>("Value");}elseModel = new MemoDto();}}
}

添加AddTodoView

添加文件Mytodo.Views.Dialogs.AddtodoView.xaml

<UserControlx:Class="Mytodo.Views.TodoView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:cv="clr-namespace:Mytodo.Common.Converters"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:i="http://schemas.microsoft.com/xaml/behaviors"xmlns:local="clr-namespace:Mytodo.Views"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"d:DesignHeight="450"d:DesignWidth="800"mc:Ignorable="d"><UserControl.Resources><ResourceDictionary><cv:IntToVisibilityConveter x:Key="IntToVisility" /></ResourceDictionary></UserControl.Resources><md:DialogHost><md:DrawerHost IsRightDrawerOpen="{Binding IsRightOpen}"><md:DrawerHost.RightDrawerContent><DockPanelMinWidth="200"MaxWidth="240"Margin="2"LastChildFill="False"><TextBlockMargin="10"DockPanel.Dock="Top"FontFamily="微软雅黑"FontSize="20"FontWeight="Bold"Text="{Binding RightContentTitle}" /><StackPanelMargin="10"DockPanel.Dock="Top"Orientation="Horizontal"><TextBlockMargin="5"VerticalAlignment="Center"FontFamily="微软雅黑"FontSize="14"Text="状态" /><ComboBox Margin="5" SelectedIndex="{Binding CurrDto.Status}"><ComboBoxItem Content="已完成" FontSize="12" /><ComboBoxItem Content="未完成" FontSize="12" /></ComboBox></StackPanel><TextBoxMargin="10"md:HintAssist.Hint="待办事项标题"DockPanel.Dock="Top"FontFamily="微软雅黑"FontSize="12"Text="{Binding CurrDto.Title}" /><TextBoxMinHeight="50"Margin="10"md:HintAssist.Hint="待办事项内容"DockPanel.Dock="Top"FontFamily="微软雅黑"FontSize="12"Text="{Binding CurrDto.Content}"TextWrapping="Wrap" /><ButtonMargin="10,5"HorizontalAlignment="Center"Command="{Binding ExecuteCommand}"CommandParameter="保存"Content="保存"DockPanel.Dock="Top" /></DockPanel></md:DrawerHost.RightDrawerContent><Grid><Grid.RowDefinitions><RowDefinition Height="auto" /><RowDefinition /></Grid.RowDefinitions><StackPanel Margin="15,10" Orientation="Horizontal"><TextBoxWidth="200"md:HintAssist.Hint="查找待办事项"md:TextFieldAssist.HasClearButton="True"FontFamily="微软雅黑"FontSize="14"Text="{Binding SearchString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"><TextBox.InputBindings><KeyBindingKey="Enter"Command="{Binding ExecuteCommand}"CommandParameter="查询" /></TextBox.InputBindings></TextBox><TextBlockMargin="10"FontSize="14"Text="筛选" /><ComboBoxWidth="auto"MinWidth="30"FontFamily="微软雅黑"FontSize="14"SelectedIndex="{Binding SelectIndex}"><ComboBoxItem Content="全部" /><ComboBoxItem Content="已完成" /><ComboBoxItem Content="未完成" /></ComboBox></StackPanel><ButtonMargin="10,0"HorizontalAlignment="Right"Command="{Binding ExecuteCommand}"CommandParameter="添加"Content="+ 添加到待办"FontFamily="微软雅黑"FontSize="14" /><StackPanelGrid.Row="1"VerticalAlignment="Center"Visibility="{Binding TodoDtos.Count, Converter={StaticResource IntToVisility}}"><md:PackIconWidth="120"Height="120"HorizontalAlignment="Center"Kind="ClipboardText" /><TextBlockMargin="0,10"HorizontalAlignment="Center"FontSize="18"Text="尝试添加一些待办事项,以便在此处查看它们。" /></StackPanel><ItemsControlGrid.Row="1"Margin="10"ItemsSource="{Binding TodoDtos}"><ItemsControl.ItemsPanel><ItemsPanelTemplate><WrapPanel /></ItemsPanelTemplate></ItemsControl.ItemsPanel><ItemsControl.ItemTemplate><DataTemplate><Border MinWidth="200" Margin="10"><Border.Style><Style TargetType="Border"><Style.Triggers><DataTrigger Binding="{Binding Status}" Value="0"><Setter Property="Background" Value="#1E90FF" /></DataTrigger><DataTrigger Binding="{Binding Status}" Value="1"><Setter Property="Background" Value="#3CB371" /></DataTrigger></Style.Triggers></Style></Border.Style><Grid MinHeight="150"><!--  给项目添加行为  --><i:Interaction.Triggers><i:EventTrigger EventName="MouseLeftButtonUp"><i:InvokeCommandAction Command="{Binding DataContext.SelectedCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" CommandParameter="{Binding}" /></i:EventTrigger></i:Interaction.Triggers><Grid.RowDefinitions><RowDefinition Height="auto" /><RowDefinition /></Grid.RowDefinitions><DockPanel Panel.ZIndex="2" LastChildFill="False"><TextBlockMargin="10,10"FontFamily="黑体"FontSize="14"Text="{Binding Title}" /><!--<md:PackIconMargin="10,10"VerticalContentAlignment="Top"DockPanel.Dock="Right"Kind="More" />--><md:PopupBoxMargin="5"Panel.ZIndex="1"DockPanel.Dock="Right"><ButtonPanel.ZIndex="2"Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"CommandParameter="{Binding}"Content="删除" /></md:PopupBox></DockPanel><TextBlockGrid.Row="1"Margin="10,5"FontFamily="黑体"FontSize="12"Opacity="0.7"Text="{Binding Content}" /><Canvas Grid.RowSpan="2" ClipToBounds="True"><BorderCanvas.Top="10"Canvas.Right="-50"Width="120"Height="120"Background="#FFFFFF"CornerRadius="100"Opacity="0.1" /><BorderCanvas.Top="80"Canvas.Right="-30"Width="120"Height="120"Background="#FFFFFF"CornerRadius="100"Opacity="0.1" /></Canvas><BorderGrid.RowSpan="2"Background="#ffcccc"CornerRadius="5"Opacity="0.3" /></Grid></Border></DataTemplate></ItemsControl.ItemTemplate></ItemsControl></Grid></md:DrawerHost></md:DialogHost>
</UserControl>

添加文件:Mytodo.Views.Dialogs.AddTodoViewmodel.cs

using Mytodo.Common.Models;
using Mytodo.Service;
using Prism.Commands;
using Prism.Ioc;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using MyToDo.Share.Models;
using System.Threading.Tasks;
using Prism.Regions;
using System.Windows;namespace Mytodo.ViewModels
{public class TodoViewModel: NavigationViewModel{#region 命令定义/// <summary>/// 展开侧边栏/// </summary>public DelegateCommand OpenRightContentCmd { set; get; }/// <summary>/// 打开选择的项/// </summary>public DelegateCommand<ToDoDto> SelectedCommand { get; set; }/// <summary>/// 添加、编辑 项/// </summary>public DelegateCommand<string> ExecuteCommand { get; set; }/// <summary>/// 删除项/// </summary>public DelegateCommand<ToDoDto> DeleteCommand { get; set; }#endregion#region 属性定义/// <summary>/// 项目状态/// </summary>public int SelectIndex{get { return selectIndex; }set { selectIndex = value; RaisePropertyChanged(); }}/// <summary>/// 当前选中项/// </summary>public ToDoDto? CurrDto{get { return currDto; }set { currDto = value; RaisePropertyChanged(); }}/// <summary>/// 指示侧边栏是否展开/// </summary>public bool IsRightOpen{get { return isRightOpen; }set { isRightOpen = value; RaisePropertyChanged(); }}/// <summary>/// todo集合/// </summary>public ObservableCollection<ToDoDto>? TodoDtos{get { return todoDtos; }set { todoDtos = value; RaisePropertyChanged(); }}/// <summary>/// 右侧侧边栏标题/// </summary>public string RightContentTitle{get { return rightContentTitle; }set { rightContentTitle = value;RaisePropertyChanged(); }}/// <summary>/// 要搜索的字符串/// </summary>public string SearchString{get { return search; }set { search = value; RaisePropertyChanged(); }}#endregion#region 重要字段定义private readonly ITodoService service;#endregion#region 字段定义private int selectIndex;private ToDoDto currDto;private bool isRightOpen;private ObservableCollection<ToDoDto>? todoDtos;private string rightContentTitle;private string search;#endregion#region 命令方法/// <summary>/// 删除指定项/// </summary>/// <param name="dto"></param>async private void DeleteItem(ToDoDto dto){var delres = await service.DeleteAsync(dto.Id);if (delres.Status){var model = TodoDtos.FirstOrDefault(t => t.Id.Equals(dto.Id));TodoDtos.Remove(dto);}}private void ExceuteCmd(string obj){switch (obj){case "添加":Add(); break;case "查询":Query();break;case "保存":Save(); break;}}/// <summary>/// 保存消息/// </summary>private async void Save(){try{if (string.IsNullOrWhiteSpace(CurrDto.Title) || string.IsNullOrWhiteSpace(CurrDto.Content))return;UpdateLoding(true);if(CurrDto.Id>0) //编辑项{var updateres = await service.UpdateAsync(CurrDto);if (updateres.Status){UpdateDataAsync();}else{MessageBox.Show("更新失败");}}else{       //添加项var add_res =   await service.AddAsync(CurrDto);//刷新if (add_res.Status) //如果添加成功{TodoDtos.Add(add_res.Result);}else{MessageBox.Show("添加失败");}}}catch{}finally{IsRightOpen = false;//卸载数据加载窗体UpdateLoding(false);}}/// <summary>/// 打开待办事项弹窗/// </summary>void Add(){CurrDto = new ToDoDto();IsRightOpen = true;}private void Query(){GetDataAsync();}/// <summary>/// 根据条件更新数据/// </summary>async void UpdateDataAsync(){int? Status = SelectIndex == 0 ? null : SelectIndex == 2 ? 1 : 0;var todoResult = await service.GetAllFilterAsync(new MyToDo.Share.Parameters.TodoParameter { PageIndex = 0, PageSize = 100, Search = SearchString, Status = Status });if (todoResult.Status){todoDtos.Clear();foreach (var item in todoResult.Result.Items)todoDtos.Add(item);}}/// <summary>/// 获取所有数据/// </summary>async void GetDataAsync(){//调用数据加载页面UpdateLoding(true);//更新数据UpdateDataAsync();//卸载数据加载页面UpdateLoding(false);}/// <summary>/// 弹出详细信息/// </summary>/// <param name="obj"></param>private async void Selected(ToDoDto obj){var todores = await service.GetFirstOfDefaultAsync(obj.Id);if(todores.Status){CurrDto = todores.Result;IsRightOpen = true;RightContentTitle = "我的待办";}}#endregionpublic TodoViewModel(ITodoService service,IContainerProvider provider) : base(provider){//初始化对象TodoDtos = new ObservableCollection<ToDoDto>();  RightContentTitle = "添加血雨待办";//初始化命令SelectedCommand         = new DelegateCommand<ToDoDto>(Selected);OpenRightContentCmd     = new DelegateCommand(Add);ExecuteCommand          = new DelegateCommand<string>(ExceuteCmd);DeleteCommand           = new DelegateCommand<ToDoDto>(DeleteItem);this.service = service;}public override void OnNavigatedTo(NavigationContext navigationContext){base.OnNavigatedTo(navigationContext);GetDataAsync();}}
}

修改绑定

修改文件:"Mytodo.Views.IndexView.xaml

Background="{Binding Color}"
CornerRadius="5"
Opacity="0.9">
<Border.Style><ButtonWidth="30"Height="30"Margin="10"VerticalAlignment="Top"Command="{Binding ExecuteCommand}"CommandParameter="新增待办"Content="{materialDesign:PackIcon Kind=Add}"DockPanel.Dock="Right"Style="{StaticResource MaterialDesignFloatingActionAccentButton}" /><ButtonWidth="30"Height="30"Margin="10"VerticalAlignment="Top"Command="{Binding ExecuteCommand}"CommandParameter="新增备忘"Content="{materialDesign:PackIcon Kind=Add}"DockPanel.Dock="Right"Style="{StaticResource MaterialDesignFloatingActionAccentButton}" />

依赖注入

修改文件:Mytodo.App.xmal.cs

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{//注册服务containerRegistry.GetContainer().Register<HttpRestClient>(made: Parameters.Of.Type<string>(serviceKey: "webUrl"));containerRegistry.GetContainer().RegisterInstance(@"Http://localhost:19007/", serviceKey: "webUrl");containerRegistry.Register<ITodoService, TodoService>();containerRegistry.Register<IMemoService, MemoService>();containerRegistry.Register<IDialogHostService, DialogHostService>();//注册对话框containerRegistry.RegisterForNavigation<AddTodoView,AddTodoViewModel>();containerRegistry.RegisterForNavigation<AddMemoView,AddMemoViewModel>();containerRegistry.RegisterForNavigation<AboutView, AboutViewModel>();containerRegistry.RegisterForNavigation<SysSetView, SysSetViewModel>();containerRegistry.RegisterForNavigation<SkinView, SkinViewModel>();containerRegistry.RegisterForNavigation<IndexView, IndexViewModel>();containerRegistry.RegisterForNavigation<TodoView, TodoViewModel>();containerRegistry.RegisterForNavigation<MemoView, MemoViewModel>();containerRegistry.RegisterForNavigation<SettingsView, SettingsViewModel>();
}

http://www.mrgr.cn/p/85514442

相关文章

Zabbix分布式监控Web监控

目录 1 概述2 配置 Web 场景2.1 配置步骤2.2 显示 3 Web 场景步骤3.1 创建新的 Web 场景。3.2 定义场景的步骤3.3 保存配置完成的Web 监控场景。 4 Zabbix-Get的使用 1 概述 您可以使用 Zabbix 对多个网站进行可用性方面监控&#xff1a; 要使用 Web 监控&#xff0c;您需要定…

QtC++ 技术分析4 - 流、d-pointer隐式共享以及容器迭代器

目录 QT 中的流文件系统与底层文件操作文件系统类 QFile QTextStreamQDataStreamQLocale 隐式共享与 d-pointer隐式共享d-pointer 在隐式共享中的应用二进制代码兼容d-pointer 模式实现 Qt 容器及迭代器QTL 概述几种常见的迭代器及其对应类型QTL 容器对应迭代器通用算法函子&am…

超全整理,Jmeter性能测试-常用Jmeter第三方插件详解(超细)

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 Jmeter作为一个开…

批量插入数据、MVC三层分离

八、批量插入数据 1、使用Statement&#xff08;&#xff09; 2、使用PreparedStatement() 3、使用批量操作API 4、优化 九、MVC三层分离

Windows下安装HBase

Windows下安装HBase 一、HBase简介二、HBase下载安装包三、环境准备3.1、 JDK的安装3.2、 Hadoop的安装 四、HBase安装4.1、压缩包解压为文件夹4.2、配置环境变量4.3、%HBASE_HOME%目录下新建临时文件夹4.4、修改配置文件 hbase-env.cmd4.4.1、配置JAVA环境4.4.2、set HBASE_MA…

高等数学中如何求间断点

高等数学中求间断点是一项重要的技巧&#xff0c;特别适用于分析函数的性质和图像的特征。在本文中&#xff0c;我们将深入探讨如何在给定函数中找到间断点&#xff0c;并解释其数学原理和实际应用。 什么是间断点&#xff1f; 在高等数学中&#xff0c;间断点是指函数在某个点…

加利福尼亚大学|3D-LLM:将3D世界于大规模语言模型结合

来自加利福尼亚大学的3D-LLM项目团队提到&#xff1a;大型语言模型 (LLM) 和视觉语言模型 (VLM) 已被证明在多项任务上表现出色&#xff0c;例如常识推理。尽管这些模型非常强大&#xff0c;但它们并不以 3D 物理世界为基础&#xff0c;而 3D 物理世界涉及更丰富的概念&#xf…

windows下载安装FFmpeg

FFmpeg是一款强大的音视频处理软件&#xff0c;下面介绍如何在windows下下载安装FFmpeg 下载 进入官网: https://ffmpeg.org/download.html, 选择Windows, 然后选择"Windows builds from gyan.dev" 在弹出的界面中找到release builds, 然后选择一个版本&#xff0…

亚马逊云科技全新Amazon Bedrock,助力客户构建生成式AI应用

亚马逊云科技近日在纽约峰会上宣布全面扩展其全托管基础模型服务Amazon Bedrock&#xff0c;包括新增Cohere作为基础模型供应商&#xff0c;加入Anthropic和Stability AI的最新基础模型&#xff0c;并发布变革性的新功能Amazon Bedrock Agents功能。客户无需管理任何基础设施&a…

Jenkins 安装构建

一、CentOS 安装 1. 使用该存储库 sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key 2. 安装 Java yum install fontconfig java-11-openjdk配…

java实现文件下载

1.文件上传 文件上传&#xff0c;也称为upload&#xff0c;是指将本地图片、视频、音频等文件上传到服务器上&#xff0c;可以供其他用户浏览或下载的过程。文件上传在项目中应用非常广泛&#xff0c;我们经常发微博、发微信朋友圈都用到了文件上传功能。 import com.itheima.…

前端Web实战:从零打造一个类Visio的流程图拓扑图绘图工具

前言 大家好&#xff0c;本系列从Web前端实战的角度&#xff0c;给大家分享介绍如何从零打造一个自己专属的绘图工具&#xff0c;实现流程图、拓扑图、脑图等类Visio的绘图工具。 你将收获 免费好用、专属自己的绘图工具前端项目实战学习如何从0搭建一个前端项目等基础框架项…

spring6——容器

文章目录 容器&#xff1a;IocIoc容器控制反转&#xff08;Ioc&#xff09;依赖注入IoC容器在Spring的实现 基于XML管理Bean搭建环境获取bean依赖注入setter注入构造器注入特殊值处理字面量赋值null值xml实体CDATA节 特殊类型属性注入为对象类型属性赋值方式一&#xff1a;引入…

音频开发-小程序和H5

微信录音 1、引入sdk 2、录音操作 浏览器录音 参考文献&#xff1a;前端H5实现调用麦克风&#xff0c;录音功能_h5 录音_Darker丨峰神的博客-CSDN博客 function record() { window.navigator.mediaDevices.getUserMedia({ audio: { sampleRate: 44100, // 采样率 channelCount…

【软件安装】MATLAB_R2021b for mac 安装

Mac matlab_r2021b 安装 下载链接&#xff1a;百度网盘 下载链接中所有文件备用。 我所使用的电脑配置&#xff1a; Macbook Pro M1 Pro 16512 系统 macOS 13.5 安装步骤 前置准备 无此选项者&#xff0c;自行百度 “mac 任何来源”。 1 下载好「MATLAB R2021b」安装文…

Leetcode-每日一题【剑指 Offer 56 - I. 数组中数字出现的次数】

题目 一个整型数组 nums 里除两个数字之外&#xff0c;其他数字都出现了两次。请写程序找出这两个只出现一次的数字。要求时间复杂度是O(n)&#xff0c;空间复杂度是O(1)。 示例 1&#xff1a; 输入&#xff1a;nums [4,1,4,6]输出&#xff1a;[1,6] 或 [6,1] 示例 2&#x…

计算机网络——传输层

文章目录 **1 传输层提供的服务****1.1 传输层的功能****1.2 传输层的寻址与端口** **2 UDP协议****2.1 UDP数据报****2.2 UDP校验** **3 TCP协议****3.1 TCP协议的特点****3.2 TCP报文段****3.3 TCP连接管理****3.4 TCP可靠传输****3.5 TCP流量控制****3.6 TCP拥塞控制** 1 传…

Verilog语法学习——LV4_移位运算与乘法

LV4_移位运算与乘法 题目来源于牛客网 [牛客网在线编程_Verilog篇_Verilog快速入门 (nowcoder.com)](https://www.nowcoder.com/exam/oj?page1&tabVerilog篇&topicId301) 题目 题目描述&#xff1a; 已知d为一个8位数&#xff0c;请在每个时钟周期分别输出该数乘1/…

Spring Security 构建基于 JWT 的登录认证

一言以蔽之&#xff0c;JWT 可以携带非敏感信息&#xff0c;并具有不可篡改性。可以通过验证是否被篡改&#xff0c;以及读取信息内容&#xff0c;完成网络认证的三个问题&#xff1a;“你是谁”、“你有哪些权限”、“是不是冒充的”。 为了安全&#xff0c;使用它需要采用 …

HTTP、HTTPS协议详解

文章目录 HTTP是什么报文结构请求头部响应头部 工作原理用户点击一个URL链接后&#xff0c;浏览器和web服务器会执行什么http的版本持久连接和非持久连接无状态与有状态Cookie和Sessionhttp方法&#xff1a;get和post的区别 状态码 HTTPS是什么ssl如何搞到证书nginx中的部署 加…