当前位置: 首页 > news >正文

在WPF中实现多语言切换的四种方式

在WPF中有多种方式可以实现多语言,这里提供几种常用的方式。

一、使用XML实现多语言切换

使用XML实现多语言的思路就是使用XML作为绑定的数据源。主要用到XmlDataProvider类.

使用XmlDataProvider.Source属性指定XML文件的路径或通过XmlDataProvider.Document指定XML文档对象,XmlDataProvider.XPath属性指定绑定的路径。

新建一个WPF工程,在debug目录下创建两个StrResource.xml文件,分别置于en-US和zh-CN文件夹

debug\en-US\StrResource.xml

1 <?xml version="1.0" encoding="utf-8"?>
2 <Language>
3     <Main_Title>Login Form</Main_Title>
4     <Main_UserName>UserName</Main_UserName>
5     <Main_Password>Password</Main_Password>
6     <Main_Button>Login</Main_Button>
7     <Window1_Title>Main Form</Window1_Title>
8     <Window1_Label>Welcome</Window1_Label>
9 </Language>

debug\zh-CN\StrResource.xml

1 <?xml version="1.0" encoding="utf-8"?>
2 <Language>
3     <Main_Title>登陆窗体</Main_Title>
4     <Main_UserName>用户名</Main_UserName>
5     <Main_Password>密码</Main_Password>
6     <Main_Button>登陆</Main_Button>
7     <Window1_Title>主界面</Window1_Title>
8     <Window1_Label>欢迎</Window1_Label>
9 </Language>

主窗体XAML

 1  <StackPanel>2         <Label Content="{Binding XPath=Main_UserName}"></Label>3         <TextBox></TextBox>4         <Label Name="Password" Content="{Binding XPath=Main_Password}"></Label>5         <TextBox></TextBox>6         <Button Height="20" Margin="10,5" Background="LightSkyBlue" Name="Login" Content="{Binding XPath=Main_Button}" Click="Login_Click"></Button>7         <ComboBox Name="combox" SelectedIndex="0" SelectionChanged="combox_SelectionChanged">8             <ComboBoxItem>中文</ComboBoxItem>9             <ComboBoxItem>English</ComboBoxItem>
10         </ComboBox>
11     </StackPanel>

后台代码中,将XmlDataProvider对象绑定到界面即可

1 XmlDocument doc = new XmlDocument();
2 XmlDataProvider xdp = new XmlDataProvider();
3 doc.Load("./zh-CN/language.xml");  //在切换语言时,重新加载xml文档,并重新绑定到界面即可
4 xdp.Document = doc;
5 xdp.XPath = @"/Language";
6 this.DataContext = xdp;

运行效果如下:

二、使用资源字典实现多语言切换

资源字典的实现方式也比较简单,这是最常用的一种方式。

主要实现步骤是:将要显示的字符绑定到资源文件,然后在切换语言时用代码更改当前使用的资源文件即可。

创建一个WPF工程,添加一个language目录,再添加en-US和zh-CN目录。再分别在目录下创建资源字典文件,内容如下:

language\en-US.xaml

 1 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"2                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"3                     xmlns:s="clr-namespace:System;assembly=mscorlib">4     <s:String x:Key="Main.Title">Main Form</s:String>5     <s:String x:Key="Main.RibbonTab.Setting">Setting</s:String>6     <s:String x:Key="Main.RibbonGroup.Setting">All Setting</s:String>7     <s:String x:Key="Main.RibbonButton.Setting">Setting</s:String>8     <s:String x:Key="Main.RibbonButton.Setting.Title">Setting</s:String>9     <s:String x:Key="Main.RibbonButton.Setting.Description">All Setting Include Language</s:String>
10     <s:String x:Key="Setting.Title">Setting</s:String>
11     <s:String x:Key="Setting.Tab.Language">Language Setting</s:String>
12     <s:String x:Key="Setting.Tab.Label.ChooseLanguage">Please choose a language</s:String>
13 </ResourceDictionary>

language\zh-CN.xaml

 1 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"2                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"3                     xmlns:s="clr-namespace:System;assembly=mscorlib">4     <s:String x:Key="Main.Title">主界面</s:String>5     <s:String x:Key="Main.RibbonTab.Setting">设置</s:String>6     <s:String x:Key="Main.RibbonGroup.Setting">全部设置</s:String>7     <s:String x:Key="Main.RibbonButton.Setting">设置</s:String>8     <s:String x:Key="Main.RibbonButton.Setting.Title">设置</s:String>9     <s:String x:Key="Main.RibbonButton.Setting.Description">包括语言在内的全部设置</s:String>
10     <s:String x:Key="Setting.Title">设置</s:String>
11     <s:String x:Key="Setting.Tab.Language">语言设置</s:String>
12     <s:String x:Key="Setting.Tab.Label.ChooseLanguage">请选择一种语言</s:String>
13 </ResourceDictionary>

主窗体XAML

 1 <TabControl>2         <TabItem Header="{DynamicResource Setting.Tab.Language}">3             <StackPanel>4                 <TextBlock VerticalAlignment="Top" Margin="5,5,5,0" HorizontalAlignment="Left" Text="{DynamicResource Setting.Tab.Label.ChooseLanguage}">5                 </TextBlock>6                 <ComboBox Height="20"  VerticalAlignment="Top" Margin="5,10" Width="200" HorizontalAlignment="Left" Name="combox_Language" SelectionChanged="combox_Language_SelectionChanged">7                     <ComboBoxItem>中文</ComboBoxItem>8                     <ComboBoxItem>English</ComboBoxItem>9                 </ComboBox>
10             </StackPanel>
11         </TabItem>
12     </TabControl>

后台代码

 private void combox_Language_SelectionChanged(object sender, SelectionChangedEventArgs e){ChangeLanguage(this.combox_Language.SelectedIndex);}/// <summary>/// 切换 语言/// </summary>/// <param name="index"></param>public void ChangeLanguage(int index){ResourceDictionary rd = new ResourceDictionary();switch(index){case 0:rd.Source = new Uri("Language/zh-CN.xaml", UriKind.Relative);break;case 1:rd.Source = new Uri("Language/en-US.xaml", UriKind.Relative);break;default:break;}            Application.Current.Resources.MergedDictionaries[0] = rd;}

运行效果如下:

三、使用资源文件实现多语言切换

这种方式的实现也比较简单,也是将字符绑定到资源文件(.resx)

但需要注意的是,这种方式是静态的,不能实现动态切换。只能在启动时更改。

创建一个WPF工程,添加一个字符资源文件StrResources.resx作为默认的字符资源文件,再添加一个StrResources.zh-CN.resx做为中文字符资源(因为我用于演示的这台电脑系统是英文的)

注意:需要将访问修饰符改为public,否则运行会报错

主界面XAML

 1  <Grid>2         <Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="{x:Static local:StrResources.ChangeLanguage}"></Label>3         <ComboBox HorizontalAlignment="Left" VerticalAlignment="Top" Margin="120,5,0,0" Width="200" Name="combox_Culture">4             <ComboBoxItem Content="{x:Static local:StrResources.zh_CN}"></ComboBoxItem>5             <ComboBoxItem Content="{x:Static local:StrResources.en_US}"></ComboBoxItem>6         </ComboBox>7 8         <Button Content="{x:Static local:StrResources.OK}" Width="88" Height="28" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,120,0"/>9         <Button Content="{x:Static local:StrResources.Cancel}" Width="88" Height="28" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,0"/>
10     </Grid>

主界面后台逻辑

 1  public partial class MainWindow : Window2     {3         public MainWindow()4         {5             InitializeComponent();6 7             LoadCulture();8         }9 
10         public void LoadCulture()
11         {
12             if(CultureInfo.CurrentCulture.Name== "zh-CN")
13             {
14                 combox_Culture.SelectedIndex = 0;
15             }
16             else
17             {
18                 combox_Culture.SelectedIndex = 1;
19             }
20         }   
21     }

在Application类的Startup事件中可以切换语言,但在程序运行后无法再切换

 1    public partial class App : Application2     {3         private void Application_Startup(object sender, StartupEventArgs e)4         {5             //在这里可以更改语言6             ChangeCulture(0);7         }8 9         public void ChangeCulture(int index)
10         {
11             string cultureName = "";
12 
13             switch (index)
14             {
15                 case 0:
16                     cultureName = "zh-CN";
17                     break;
18                 case 1:
19                     cultureName = "en-US";
20                     break;
21                 default:
22                     cultureName = "en-US";
23                     break;
24             }
25 
26             Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureName);
27             Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);
28         }
29     }

运行效果:

四、使用json文件实现多语言切换

这种方式实现多语言切换有点麻烦,但可以使用json作为语言文件(其它格式文件其实也可以.txt .xml .csv)。

这种方式的实现原理是使用索引器方法查找每个字段值,然后绑定到界面上。支持动态切换

debug目录下创建

zh-CN.json

1 {
2   "OK": "确定",
3   "Cancel": "取消",
4   "ChangeLanguage": "更改语言",
5   "zh_CN": "中文",
6   "en_US": "English"
7 }

en-US.json

1 {
2   "OK": "OK",
3   "Cancel": "Cancel",
4   "ChangeLanguage": "Change language",
5   "zh_CN": "中文",
6   "en_US": "English"
7 }

封装一个绑定通知类,这个类用于切换语言时,绑定的通知更新。

 1 /// <summary>2     /// 绑定通知类3     /// </summary>4     public class NotifyPropertyChanged : INotifyPropertyChanged5     {6         public event PropertyChangedEventHandler PropertyChanged;7 8         protected void RaisePropertyChanged(string PropertyName)9         {
10             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName));
11         }
12 
13         protected void OnPropertyChanged([CallerMemberName] string PropertyName = null)
14         {
15             RaisePropertyChanged(PropertyName);
16         }
17 
18         protected void RaiseAllChanged()
19         {
20             RaisePropertyChanged("");
21         }
22     }

创建一个语言字段类,这个类用于封装所有的语言字段。这一步确实就比较麻烦了,每个字段都得封装一个属性。

 1  /// <summary>2     /// 语言字段类3     /// </summary>4     public class LanguageFields : NotifyPropertyChanged5     {6         /// <summary>7         /// 需要被重写的方法 用于获取语言字段值8         /// </summary>9         /// <param name="key"></param>
10         /// <returns></returns>
11         protected virtual string GetValue(string key) => "";
12 
13         protected virtual void SetValue(string Key, string value) { }
14 
15         /// <summary>
16         /// 使用CallerMemberName特性传递当前属性名
17         /// </summary>
18         /// <param name="propertyName"></param>
19         /// <returns></returns>
20         string Get([CallerMemberName] string propertyName = null)
21         {
22             return GetValue(propertyName);
23         }
24 
25         void Set(string value, [CallerMemberName] string propertyName = null)
26         {
27             SetValue(propertyName, value);
28         }
29 
30         public string OK { get => Get(); set => Set(value); }
31         public string Cancel { get => Get(); set => Set(value); }
32         public string ChangeLanguage { get => Get(); set => Set(value); }
33         public string zh_CN { get => Get(); set => Set(value); }
34         public string en_US { get => Get(); set => Set(value); }
35     }

创建一个语言切换帮助类,这个类可以对当前使用的语言以及字段值进行操作

 1  public class LanguageHelper : LanguageFields2     {   3         private JObject currentLanguage;           //当前语言的JObject对象 4         private static readonly string dir = Environment.CurrentDirectory;  //语言文件夹5         private CultureInfo currentCulture;   //当前语言6 7         public static LanguageHelper Instance { get; } = new LanguageHelper();8 9         LanguageHelper()
10         {
11             CurrentCulture = CultureInfo.CurrentCulture;
12         }
13 
14         /// <summary>
15         /// 当前语言属性 当值更新时,加载语言并更新绑定
16         /// </summary>
17         public CultureInfo CurrentCulture
18         {
19             get => currentCulture;
20             set
21             {
22                 currentCulture = value;
23                 CultureInfo.CurrentUICulture = value;
24                 currentLanguage = LoadLang(value.Name); 
25                 LanguageChanged?.Invoke(value);
26                 RaiseAllChanged();
27             }
28         }
29 
30         /// <summary>
31         /// 加载语言文件 
32         /// </summary>
33         /// <param name="LanguageId"></param>
34         /// <returns></returns>
35         JObject LoadLang(string LanguageId)
36         {
37             try
38             {
39                 var filePath = System.IO.Path.Combine(dir, $"{LanguageId}.json");
40                 return JObject.Parse(File.ReadAllText(filePath));
41             }
42             catch
43             {
44                 return new JObject();
45             }
46         }
47 
48         /// <summary>
49         /// 索引器方法 用于查找语言字段值
50         /// </summary>
51         /// <param name="Key"></param>
52         /// <returns></returns>
53         public string this[string Key]
54         {
55             get
56             {
57                 if (Key == null)
58                     return "";
59 
60                 if (currentLanguage != null && currentLanguage.TryGetValue(Key, out var value) && value.ToString() is string s && !string.IsNullOrWhiteSpace(s))
61                     return s;
62 
63                 return Key;
64             }
65         }
66 
67         /// <summary>
68         /// 重写 GetValue方法,调用索引器方法 
69         /// </summary>
70         /// <param name="PropertyName"></param>
71         /// <returns></returns>
72         protected override string GetValue(string PropertyName) => this[PropertyName];
73 
74         /// <summary>
75         /// 语言更改事件
76         /// </summary>
77         public event Action<CultureInfo> LanguageChanged;
78     }

主窗体XAML

 1  <Grid>2         <Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="{Binding ChangeLanguage, Source={StaticResource LangManger}, Mode=OneWay}"></Label>3         <ComboBox HorizontalAlignment="Left" VerticalAlignment="Top" Margin="120,5,0,0" Width="200" Name="combox_Culture" SelectionChanged="combox_Culture_SelectionChanged">4             <ComboBoxItem Content="{Binding zh_CN, Source={StaticResource LangManger}, Mode=OneWay}"></ComboBoxItem>5             <ComboBoxItem Content="{Binding en_US, Source={StaticResource LangManger}, Mode=OneWay}"></ComboBoxItem>6         </ComboBox>7 8         <Button Content="{Binding OK, Source={StaticResource LangManger}, Mode=OneWay}" Width="88" Height="28" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,120,0"/>9         <Button Content="{Binding Cancel, Source={StaticResource LangManger}, Mode=OneWay}" Width="88" Height="28" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,0"/>
10     </Grid>

主窗体后台逻辑

软件启动时,加载当前语言。当下位框切换时,切换语言。

 1 public partial class MainWindow : Window2     {3         public MainWindow()4         {5             InitializeComponent();6 7             LanguageHelper.Instance.LanguageChanged += Instance_LanguageChanged;8             LoadCulture(LanguageHelper.Instance.CurrentCulture);9         }
10 
11         private void Instance_LanguageChanged(System.Globalization.CultureInfo obj)
12         {
13             //这里可以对语言更改进行处理
14             switch(obj.Name)
15             {
16                 case "zh-CN":
17                     break;
18                 case "en-US":
19                     break;
20             }
21         }
22 
23         private void LoadCulture(System.Globalization.CultureInfo culture)
24         {
25             switch(culture.Name)
26             {
27                 case "zh-CN":
28                     combox_Culture.SelectedIndex = 0;
29                     break;
30                 case "en-US":
31                     combox_Culture.SelectedIndex = 1;
32                     break;
33             }
34         }
35 
36         private void combox_Culture_SelectionChanged(object sender, SelectionChangedEventArgs e)
37         {
38             var culture = "zh-CN";
39 
40             switch(combox_Culture.SelectedIndex)
41             {
42                 case 0:
43                     culture = "zh-CN";
44                     break;
45                 case 1:
46                     culture = "en-US";
47                     break;
48             }
49 
50             if (culture == null)
51                 return;
52 
53             LanguageHelper.Instance.CurrentCulture = new System.Globalization.CultureInfo(culture.ToString().Replace("_", "-"));   //变量命名不支持 '-' ,所以这里需要替换一下
54         }
55     }

示例代码

https://github.com/zhaotianff/DotNetCoreWPF/tree/master/其它、实现多语言切换的几种方式/MultiLanguageDemo

相关文章:

在WPF中实现多语言切换的四种方式

在WPF中有多种方式可以实现多语言&#xff0c;这里提供几种常用的方式。 一、使用XML实现多语言切换 使用XML实现多语言的思路就是使用XML作为绑定的数据源。主要用到XmlDataProvider类. 使用XmlDataProvider.Source属性指定XML文件的路径或通过XmlDataProvider.Document指定…...

30min 的OpenCV learning Note

1.安装python和pycharm与环境搭配 打开Windows终端&#xff1a;&#xff08;winR&#xff09;&#xff08;一般使用清华镜像网站安装库比较快&#xff09; pip install opencv-contrib-python -i https://pypi.mirrors.ustc.edu.cn/simple 或者 python -m pip install open…...

C--编译和链接见解

欢迎各位看官&#xff01;如果您觉得这篇文章对您有帮助的话 欢迎您分享给更多人哦 感谢大家的点赞收藏评论 感谢各位看官的支持&#xff01;&#xff01;&#xff01; 一&#xff1a;翻译环境和运行环境 在ANSIIC的任何一种实现中&#xff0c;存在两个不同的环境1&#xff0c;…...

【QT Quick】基础语法:基础类与控件

QML 的基础类和控件中&#xff0c;我们可以看到主要的几个分类&#xff1a;基础控件类、窗口类以及组件类。以下是对这些控件及其属性、继承关系等的详细讲解&#xff1a; 控件关系总结 QtObject 是所有 QML 对象的基类。它定义了基础属性&#xff0c;主要用于逻辑和数据封装…...

使用 SSH 连接 Docker 服务器:IntelliJ IDEA 高效配置与操作指南

使用 SSH 连接 Docker 服务器&#xff1a;IntelliJ IDEA 高效配置与操作指南 本文详细介绍了如何在 2375 端口未开放的情况下&#xff0c;通过 SSH 连接 Docker 服务器并在 Idea 中进行开发。通过修改用户权限、生成密钥对以及配置 SSH 访问&#xff0c;用户可以安全地远程操作…...

Gas费用是什么?

Gas费用是什么? 每5个Byte 需要1个GasGasLimit 用来限制合约最多执行多少次运算GasPrice 每次计算需要支付的费用在Web3的语境中,尤其是在以太坊(Ethereum)这样的区块链平台上,Gas费是一个核心概念。以下是关于Gas费的详细解释: 1. 定义 Gas是以太坊网络上的计算单位,…...

大语言模型(LLM)的子模块拆拆分进行联邦学习;大语言模型按照多头(Multi-Head)拆分进行联邦学习

目录 大语言模型(LLM)的子模块拆拆分进行联邦学习 方式概述 简单示例 大语言模型按照多头(Multi-Head)拆分进行联邦学习 场景设定 多头拆分与联邦学习 示例说明 大语言模型(LLM)的子模块拆拆分进行联邦学习 大语言模型(LLM)的子模块拆分进行联邦学习,主要涉及…...

Qt 概述

1. Qlabel HelloWorld 程序 使用纯代码实现 // widget.cpp Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this);// 给当前这个lable对象&#xff0c;指定一个父对象QLabel* label new QLabel(this);// C语言风格的字符串可以直接…...

移动应用的界面配置-手机银行APP

设置登录界面为线性布局&#xff0c;组件垂直居中排列设置主页为滚动模式&#xff0c;包括布局、添加背景图片设置按钮样式&#xff0c;包括形状、边框线的宽度和颜色 设置登录界面 设置界面为线性布局&#xff0c;组件垂直居中排列 --android:gravity"center_vertical…...

微服务nginx解析部署使用全流程

目录 1、nginx介绍 1、简介 2、反向代理 3、负载均衡 2、安装nginx 1、下载nginx 2、解压nginx安装包 3、安装nginx​编辑 1、执行configure命令 2、执行make命令 4、启动nginx 1、查找nginx位置并启动 2、常用命令 3、反向代理 1、介绍反向代理配置 1、基础配置…...

华硕天选笔记本外接音箱没有声音

系列文章目录 文章目录 系列文章目录一.前言二.解决方法第一种方法第二种方法 一.前言 华硕天选笔记本外接音箱没有声音&#xff0c;在插上外接音箱时&#xff0c;系统会自动弹出下图窗口 二.解决方法 第一种方法 在我的电脑上选择 Headphone Speaker Out Headset 这三个选项…...

Unity中Socket_TCP异步连接,加入断线检测以及重连功能

1、服务端 using System; using System.Collections.Generic; using System.Text; #region 命名空间 using System.Net; using System.Net.Sockets; using System.Threading; using UnityEngine; #endregionnamespace AsynServerConsole {/// <summary>/// Tcp协议异步通…...

Android build子系统(01)Ninja构建系统解读

说明&#xff1a;本文将解读Ninja构建系统&#xff0c;这是当前Android Framework中广泛使用的构建工具。我们将从Ninja的起源和背景信息开始&#xff0c;逐步解读Ninja的优势和核心原理&#xff0c;并探讨其一般使用场景。然后介绍其在Android Framework中的应用及相关工具&am…...

徐老师的吉祥数

题目背景 文件读写 输入文件avoid.in 输出文件avoid.out 限制 1000ms 512MB 题目描述 众所周知&#xff0c; 3这个数字在有些时候不是很吉利&#xff0c;因为它谐音为 “散” 所以徐老师认为只要是 3的整数次幂的数字就不吉利 现在徐老师想知道&#xff0c;在某个范围[l,r] …...

使用html写一个能发起请求的登录界面

目录 head部分 内联样式部分 body部分 login-form类的div myModal类的div id script部分 总的代码 界面与操作演示 <!DOCTYPE html> <html lang"en"> <!DOCTYPE html> 这是文档类型声明&#xff0c;告诉浏览器这是一个 HTML文档。 <…...

五子棋双人对战项目(2)——登录模块

目录 一、数据库模块 1、创建数据库 2、使用MyBatis连接并操作数据库 编写后端数据库代码 二、约定前后端交互接口 三、后端代码编写 文件路径如下&#xff1a; UserAPI&#xff1a; UserMapper&#xff1a; 四、前端代码 登录页面 login.html&#xff1a; 注册页面…...

几种操作系统和几种cpu

常见的操作系统&#xff1a;windows&#xff0c;linux&#xff0c;macOS&#xff0c;统信&#xff0c;deepin&#xff0c;raspberry&#xff0c;andriod&#xff0c;iOS&#xff0c;鸿蒙&#xff0c;等等。 常见的cpu&#xff1a;intel&#xff0c;amd&#xff0c;龙芯&#x…...

[Cocoa]_[初级]_[使用NSNotificationCenter作为目标观察者实现时需要注意的事项]

场景 在开发Cocoa程序时&#xff0c;由于界面是用Objective-C写的。无法使用C的目标观察者[1]类。如果是使用第二种方案2[2],那么也需要增加一个代理类。那么有没有更省事的办法&#xff1f; 说明 开发界面的时候&#xff0c;经常是需要在子界面里传递数据给主界面&#xff0…...

彩虹易支付最新版源码及安装教程(修复BUG+新增加订单投诉功能)

该源码当前版本为较新的版本&#xff0c;新增了订单投诉功能和一套精美的二次元模板。 此版本为全开源版本&#xff0c;所有文件均未加密。系统默认安装完成后无法直接打开&#xff0c;需要进一步配置。 本站特别针对BUG文件进行了修复&#xff0c;且在PHP7.4环境下表现良好。…...

ping香港服务器超时的原因通常有哪些?

Ping命令用于测试计算机与目标服务器之间的网络连接。当您在尝试使用ping命令检测服务器时遇到超时的情况&#xff0c;通常可能是由以下原因造成的&#xff1a; 1. 网络连接问题&#xff1a; - 本地网络故障&#xff1a;如网线损坏、路由器故障或配置不当。 - ISP(互联网服务提…...

wordpress后台更新后 前端没变化的解决方法

使用siteground主机的wordpress网站&#xff0c;会出现更新了网站内容和修改了php模板文件、js文件、css文件、图片文件后&#xff0c;网站没有变化的情况。 不熟悉siteground主机的新手&#xff0c;遇到这个问题&#xff0c;就很抓狂&#xff0c;明明是哪都没操作错误&#x…...

JavaSec-RCE

简介 RCE(Remote Code Execution)&#xff0c;可以分为:命令注入(Command Injection)、代码注入(Code Injection) 代码注入 1.漏洞场景&#xff1a;Groovy代码注入 Groovy是一种基于JVM的动态语言&#xff0c;语法简洁&#xff0c;支持闭包、动态类型和Java互操作性&#xff0c…...

【配置 YOLOX 用于按目录分类的图片数据集】

现在的图标点选越来越多&#xff0c;如何一步解决&#xff0c;采用 YOLOX 目标检测模式则可以轻松解决 要在 YOLOX 中使用按目录分类的图片数据集&#xff08;每个目录代表一个类别&#xff0c;目录下是该类别的所有图片&#xff09;&#xff0c;你需要进行以下配置步骤&#x…...

云原生安全实战:API网关Kong的鉴权与限流详解

&#x1f525;「炎码工坊」技术弹药已装填&#xff01; 点击关注 → 解锁工业级干货【工具实测|项目避坑|源码燃烧指南】 一、基础概念 1. API网关&#xff08;API Gateway&#xff09; API网关是微服务架构中的核心组件&#xff0c;负责统一管理所有API的流量入口。它像一座…...

通过 Ansible 在 Windows 2022 上安装 IIS Web 服务器

拓扑结构 这是一个用于通过 Ansible 部署 IIS Web 服务器的实验室拓扑。 前提条件&#xff1a; 在被管理的节点上安装WinRm 准备一张自签名的证书 开放防火墙入站tcp 5985 5986端口 准备自签名证书 PS C:\Users\azureuser> $cert New-SelfSignedCertificate -DnsName &…...

图解JavaScript原型:原型链及其分析 | JavaScript图解

​​ 忽略该图的细节&#xff08;如内存地址值没有用二进制&#xff09; 以下是对该图进一步的理解和总结 1. JS 对象概念的辨析 对象是什么&#xff1a;保存在堆中一块区域&#xff0c;同时在栈中有一块区域保存其在堆中的地址&#xff08;也就是我们通常说的该变量指向谁&…...

Vue3 PC端 UI组件库我更推荐Naive UI

一、Vue3生态现状与UI库选择的重要性 随着Vue3的稳定发布和Composition API的广泛采用&#xff0c;前端开发者面临着UI组件库的重新选择。一个好的UI库不仅能提升开发效率&#xff0c;还能确保项目的长期可维护性。本文将对比三大主流Vue3 UI库&#xff08;Naive UI、Element …...

Java多线程实现之Runnable接口深度解析

Java多线程实现之Runnable接口深度解析 一、Runnable接口概述1.1 接口定义1.2 与Thread类的关系1.3 使用Runnable接口的优势 二、Runnable接口的基本实现方式2.1 传统方式实现Runnable接口2.2 使用匿名内部类实现Runnable接口2.3 使用Lambda表达式实现Runnable接口 三、Runnabl…...

RabbitMQ 各类交换机

为什么要用交换机&#xff1f; 交换机用来路由消息。如果直发队列&#xff0c;这个消息就被处理消失了&#xff0c;那别的队列也需要这个消息怎么办&#xff1f;那就要用到交换机 交换机类型 1&#xff0c;fanout&#xff1a;广播 特点 广播所有消息​​&#xff1a;将消息…...

Angular中Webpack与ngx-build-plus 浅学

Webpack 在 Angular 中的概念 Webpack 是一个模块打包工具&#xff0c;用于将多个模块和资源打包成一个或多个文件。在 Angular 项目中&#xff0c;Webpack 负责将 TypeScript、HTML、CSS 等文件打包成浏览器可以理解的 JavaScript 文件。Angular CLI 默认使用 Webpack 进行项目…...