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

鸿蒙next 自定义日历组件

效果图预览

20250124-113957

使用说明

1.选择日期左右箭头,实现每月日历切换,示例中超出当前月份,禁止进入下一月,可在代码更改

2.日历中显示当前选择的日期,选中的日期颜色可自定义

3.日历中可展示历史记录作为数据存储标志

4.当前页面选择的日期可在本页面保存状态

可根据自己需求,对日历组件进行更改,将代码拷贝到DevEco Studio 可直接运行使用

日历组件使用代码

@Entry
@Component
struct TEST {@State currentSelectDate: string = calendarUtils.getCurrentDay(); // 当前读取数据日期,用户数据获取private historyDateArray: string[] =[calendarUtils.getPreviousDay(calendarUtils.getCurrentDay()), calendarUtils.getCurrentDay()];private calendarController: CustomDialogController | null = new CustomDialogController({builder: CustomCalendar({currentSelectDate: this.currentSelectDate,defaultSelectDates: this.historyDateArray,colors: ["#fed2cf", "#ed553c", "#f74d33", "#fcfaff"],cancel: () => {this.calendarController?.close();},confirm: (date: Date) => {this.selectCalendarConfirm(date)}}),autoCancel: true,alignment: DialogAlignment.BottomEnd,offset: { dx: -8, dy: -20 },gridCount: 4,showInSubWindow: true,width: 359,isModal: true,customStyle: false,cornerRadius: 16,})// 选择日历确认框selectCalendarConfirm(date: Date) {let dateTime = new Date(date);let year = dateTime.getFullYear();let month = dateTime.getMonth() + 1;let day = dateTime.getDate();let strDate = `${year}-${month}-${day}`;this.currentSelectDate = strDate;let selectIndex = calendarUtils.getDaysFromDate(strDate);this.calendarController?.close();}build() {Column() {Button("日历组件").onClick(() => {this.calendarController?.open();})}.width('100%').height('100%')}
}

日历组件代码

import { calendarUtils } from "../../utlis/calendarUtils";interface monthType {defaultData: boolean,value: number
}// 日历
@CustomDialog
export struct CustomCalendar {controller?: CustomDialogController@State selectedDate: Date = new Date();@State isDateSelected: boolean = false;@State currentMonth: number = new Date().getMonth(); // 当前选择的月数@State defaultMonth: number = new Date().getMonth(); // 默认月数@State currentYear: number = new Date().getFullYear();@Prop defaultSelectDates: string[] = []; // 默认历史数据@State defaultYear: number = new Date().getFullYear();@Prop currentSelectDate: string = calendarUtils.getCurrentDay();@Prop colors: string[] = ["#fed2cf", "#ed553c", "#f74d33", "#fcfaff"]; // 0 默认背景 1 背景默认字体颜色 2 选中背景 3 选中字体颜色@State monthDays: monthType[] = []; // 月份天数cancel: () => void = () => {}confirm: (date: Date) => void = () => {}aboutToAppear() {console.log("currentSelectDate===>", this.currentSelectDate)this.onDefaultDataSelect(this.currentSelectDate);let days = this.getDaysInMonth();console.log("days===>", JSON.stringify(days))this.monthDays = [...days]}build() {Column() {Row({ space: 30 }) {Image($r('app.media.rightArrow')).width('24vp').height('24vp').padding({left: 8,right: 8,top: 4,bottom: 4}).rotate({x: 0,y: 0,z: 90,centerX: '50%',centerY: '50%',angle: 180}).onClick(() => this.onMonthChange(-1))Text(`${this.currentYear}年${this.currentMonth + 1 >= 10 ? this.currentMonth + 1 :'0' + (this.currentMonth + 1)}月`).fontSize(20).fontWeight(FontWeight.Bold).margin({ left: 15, right: 15 })if (this.defaultYear != this.currentYear || this.currentMonth != this.defaultMonth) {Image($r('app.media.rightArrow')).width('24vp').height('24vp').padding({left: 8,right: 8,top: 4,bottom: 4}).onClick(() => this.onMonthChange(1))} else {Image($r('app.media.rightArrowGray')).width('24vp').height('24vp').padding({left: 8,right: 8,top: 4,bottom: 4})}}.width('100%').justifyContent(FlexAlign.Center).margin({ top: 20, bottom: 30 })// 星期标题Row() {ForEach(['日', '一', '二', '三', '四', '五', '六'], (day: string) => {Text(day).textAlign(TextAlign.Center).fontSize(18).fontColor('#999999')}, (day: string) => day)}.width('93%').margin({ bottom: 10 }).justifyContent(FlexAlign.SpaceBetween)Grid() {ForEach(this.monthDays, (item: monthType, index: number) => {GridItem() {Column() {Text(item.value.toString()).fontSize(18).fontWeight(this.isSelectedDate(item.value) ? FontWeight.Bold : FontWeight.Normal).fontColor(this.isSelectedDate(item.value) ? this.colors[3] :item.defaultData ? this.colors[1] : this.getDateColor(item.value))}.width('100%').height('100%').borderRadius(25).backgroundColor(this.isSelectedDate(item.value) ? this.colors[2] :(item.defaultData ? this.colors[0] : Color.Transparent)).justifyContent(FlexAlign.Center)}.aspectRatio(1).onClick(() => this.onDateSelected(item.value))})}.width('100%').columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr').rowsGap(8).columnsGap(8).height('260vp')// 按钮Row() {Button('取消', { type: ButtonType.Normal }).width('140vp').height('50vp').backgroundColor("#f6f6f6").fontColor("#171d29").borderRadius(12).onClick(() => {this.cancel();})Button('确定', { type: ButtonType.Normal }).width('140vp').height('50vp').backgroundColor("#171d29").borderRadius(12).onClick(() => {console.log("this.selectedDate==>", this.selectedDate);this.confirm(this.selectedDate)console.log("this.monthDays=>", JSON.stringify(this.monthDays))})}.width('100%').height('50vp').justifyContent(FlexAlign.SpaceBetween).padding({ left: 18, right: 18 }).margin({ bottom: 10 });}.width('100%').padding({left: 16,right: 16,top: 16,bottom: 16}).backgroundColor('#ffffff')}private onMonthChange(increment: number) {let newMonth = this.currentMonth + incrementlet newYear = this.currentYearif (newMonth > 11) {newMonth = 0newYear++} else if (newMonth < 0) {newMonth = 11newYear--}this.currentMonth = newMonth;this.currentYear = newYear;let result = this.getDaysInMonth();this.monthDays = [...result];}private onDateSelected(day: number) {const newSelectedDate = new Date(this.currentYear, this.currentMonth, day);const currentDate = new Date(this.currentYear, this.currentMonth, day)const today = new Date()// 如果点击的值大于今天值,不选中if (currentDate > today) {return}if (this.isDateSelected &&this.selectedDate.getDate() === day &&this.selectedDate.getMonth() === this.currentMonth &&this.selectedDate.getFullYear() === this.currentYear) {// 如果点击的是已选中的日期,取消选中// this.isDateSelected = falsethis.isDateSelected = true} else {// 否则,选中新的日期this.selectedDate = newSelectedDatethis.isDateSelected = true}}// 默认选中private onDefaultDataSelect(value: string) {let date = value.split("-");let year = Number(date[0]); // 获取当前年let month = Number(date[1]) - 1; // 获取当前月,如果需要渲染到页面,需要+1,不渲染默认进行计算let day = Number(date[2]); // 获取当前天数this.selectedDate = new Date(year, month, day);this.isDateSelected = true;}private isSelectedDate(day: number): boolean {return this.isDateSelected &&this.selectedDate.getDate() === day &&this.selectedDate.getMonth() === this.currentMonth &&this.selectedDate.getFullYear() === this.currentYear}private getDaysInMonth(): monthType[] {const daysInMonth = new Date(this.currentYear, this.currentMonth + 1, 0).getDate();const selectMonth = new Date(this.currentYear, this.currentMonth + 1, 0).getMonth() + 1;const selectYear = new Date(this.currentYear, this.currentMonth + 1, 0).getFullYear();let array = Array.from<number, number>({ length: daysInMonth }, (_, i) => i + 1);let result: monthType[] = [];for (let i = 0; i < array.length; i++) {let obj: monthType = {value: array[i],defaultData: false,}let selectData = this.defaultSelectDates.find((item: string) => {let date = item.split("-");let year = date[0];let month = date[1];let day = date[2];if (selectYear == Number(year) && selectMonth == Number(month) && Number(day) == array[i]) {return item} else {return undefined}});if (selectData) {obj.defaultData = true;} else {obj.defaultData = false;}result.push(obj);}return result;}private getDateColor(day: number): string {const currentDate = new Date(this.currentYear, this.currentMonth, day)const today = new Date()today.setHours(0, 0, 0, 0)if (currentDate > today) {return '#CCCCCC' // 灰色显示过去的日期} else if (this.isSelectedDate(day)) {return '#ffffff' // 选中日期的文字颜色} else {return '#000000' // 未选中日期的文字颜色}}private getLunarDate(day: number): string {return LunarDate.solarToLunar(this.currentYear, this.currentMonth + 1, day);}
}class LunarDate {private static lunarInfo: number[] = [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0,0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6,0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0];private static Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"];private static Zhi = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"];private static Animals = ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"];private static lunarMonths = ["正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊"];private static lunarDays = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十","十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十","廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"];static solarToLunar(year: number, month: number, day: number): string {if (year < 1900 || year > 2100) {return "无效年份";}const baseDate = new Date(1900, 0, 31);const objDate = new Date(year, month - 1, day);let offset = Math.floor((objDate.getTime() - baseDate.getTime()) / 86400000);let i: number, leap = 0, temp = 0;for (i = 1900; i < 2101 && offset > 0; i++) {temp = LunarDate.getLunarYearDays(i);offset -= temp;}if (offset < 0) {offset += temp;i--;}const lunarYear = i;leap = LunarDate.getLeapMonth(i);let isLeap = false;for (i = 1; i < 13 && offset > 0; i++) {if (leap > 0 && i === (leap + 1) && isLeap === false) {--i;isLeap = true;temp = LunarDate.getLeapDays(lunarYear);} else {temp = LunarDate.getLunarMonthDays(lunarYear, i);}if (isLeap === true && i === (leap + 1)) {isLeap = false;}offset -= temp;}if (offset === 0 && leap > 0 && i === leap + 1) {if (isLeap) {isLeap = false;} else {isLeap = true;--i;}}if (offset < 0) {offset += temp;--i;}const lunarMonth = i;const lunarDay = offset + 1;const monthStr = (isLeap ? "闰" : "") + LunarDate.lunarMonths[lunarMonth - 1];const dayStr = LunarDate.lunarDays[lunarDay - 1];return dayStr === '初一' ? monthStr + "月" : dayStr;}private static getLunarYearDays(year: number): number {let i = 0, sum = 348;for (i = 0x8000; i > 0x8; i >>= 1) {sum += (LunarDate.lunarInfo[year - 1900] & i) ? 1 : 0;}return sum + LunarDate.getLeapDays(year);}private static getLeapMonth(year: number): number {return LunarDate.lunarInfo[year - 1900] & 0xf;}private static getLeapDays(year: number): number {if (LunarDate.getLeapMonth(year)) {return (LunarDate.lunarInfo[year - 1900] & 0x10000) ? 30 : 29;}return 0;}private static getLunarMonthDays(year: number, month: number): number {return (LunarDate.lunarInfo[year - 1900] & (0x10000 >> month)) ? 30 : 29;}
}

日期处理utils代码

class CalendarUtils {private totalDays: number = 0;// 获取日历全部时间列表值public getCalendarListCount() {let list: number[] = []for (let i = 1; i <= this.getDaysInLastTenYears(); i++) {list.push(i);}return list;}// 获取前10年的总共天数public getDaysInLastTenYears(): number {const now = new Date();const tenYearsAgo = new Date(now.getFullYear() - 10, now.getMonth(), now.getDate());const millisecondsInDay = 1000 * 60 * 60 * 24;const diffInMilliseconds = now.getTime() - tenYearsAgo.getTime();this.totalDays = Math.ceil(diffInMilliseconds / millisecondsInDay);return Math.ceil(diffInMilliseconds / millisecondsInDay);}// 根据当前天数获取年月日public getDateFromDaysAgo(days: number): string {const now = new Date();let dayCount = this.totalDays - days;const millisecondsPerDay = 1000 * 60 * 60 * 24;const targetDate = new Date(now.getTime() - dayCount * millisecondsPerDay);const year = targetDate.getFullYear();const month = String(targetDate.getMonth() + 1).padStart(2, '0'); // Months are zero-basedconst day = String(targetDate.getDate()).padStart(2, '0');return `${year}-${month}-${day}`;}// 根据年月日获取天数下标 反值public getDaysFromDate(dateString: string): number {const dateParts = dateString.split('-');const targetDate = new Date(Number(dateParts[0]), Number(dateParts[1]) - 1, Number(dateParts[2]));const now = new Date();const diffInMilliseconds = now.getTime() - targetDate.getTime();const millisecondsPerDay = 1000 * 60 * 60 * 24;let days = Math.floor(Math.abs(diffInMilliseconds) / millisecondsPerDay);return (this.totalDays - 1) - days;}// 获取上一天年月日public getPreviousDay(value: string | Date): string {const now = new Date(value);now.setDate(now.getDate() - 1); // 获取前一天const year = now.getFullYear();const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以需要+1,并补0const day = String(now.getDate()).padStart(2, '0'); // 补0return `${year}-${month}-${day}`;}// 获取下一天年月日public getNextDay(value: string | Date): string {const now = new Date(value);now.setDate(now.getDate() + 1); // 获取后一天const year = now.getFullYear();const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以需要+1,并补0const day = String(now.getDate()).padStart(2, '0'); // 补0return `${year}-${month}-${day}`;}// 获取当前年月日public getCurrentDay() {const now = new Date();const year = now.getFullYear();const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,加一,补0const day = String(now.getDate()).padStart(2, '0'); // 补0return `${year}-${month}-${day}`;}// 获取前10年的年月茹public getTheFirstYearsDate(value: number) {const currentDate = new Date();const currentYear = currentDate.getFullYear();// 获取前10年的日期const previousTenYearsDate = new Date(currentDate.setFullYear(currentYear - value));const Year = previousTenYearsDate.getFullYear();const Month = String(previousTenYearsDate.getMonth() + 1).padStart(2, '0');const Day = String(previousTenYearsDate.getDate()).padStart(2, '0');return `${Year}-${Month}-${Day}`;}
}// 获取数据预加载
export class MyDataSource implements IDataSource {private list: number[] = []constructor(list: number[]) {this.list = list}totalCount(): number {return this.list.length}getData(index: number): number {return this.list[index]}registerDataChangeListener(listener: DataChangeListener): void {}unregisterDataChangeListener() {}
}export const calendarUtils = new CalendarUtils();

相关文章:

鸿蒙next 自定义日历组件

效果图预览 20250124-113957 使用说明 1.选择日期左右箭头&#xff0c;实现每月日历切换&#xff0c;示例中超出当前月份&#xff0c;禁止进入下一月&#xff0c;可在代码更改 2.日历中显示当前选择的日期&#xff0c;选中的日期颜色可自定义 3.日历中可展示历史记录作为数据…...

【express-generator】08-路由重定向

前言 通过前面两篇文章的讲解&#xff0c;我们已经介绍完第二阶段的前两点&#xff0c;本篇介绍第三点&#xff1a;路由重定向。 1. 路由重定向概述 路由重定向是指在服务器端将客户端的请求从一个 URL 重定向到另一个 URL 的过程。这通常通过 HTTP 状态码&#xff08;如 30…...

搭建Spring Boot开发环境

JDK&#xff08;1.8及以上版本&#xff09; Apache Maven 3.6.0 修改settings.xml 设置本地仓库位置 <localRepository>D:/repository</localRepository> 设置远程仓库镜像 <mirror><id>alimaven</id><name>aliyun maven</name&…...

Spatial Group-wise Enhance (SGE) module

来源&#xff1a; [1905.09646] Spatial Group-wise Enhance: Improving Semantic Feature Learning in Convolutional Networks 相关工作&#xff1a; #GroupedFeatures #AttentionModels 创新点&#xff1a; 贡献&#xff1a; 提出了一种轻量级的SGE模块&#xff0c;能够…...

二叉搜索树中的搜索(力扣700)

首先介绍一下什么是二叉搜索树。 二叉搜索树是一个有序树&#xff1a; 若它的左子树不空&#xff0c;则左子树上所有结点的值均小于它的根结点的值&#xff1b;若它的右子树不空&#xff0c;则右子树上所有结点的值均大于它的根结点的值&#xff1b;它的左、右子树也分别为二叉…...

记录让cursor帮我给ruoyi-vue后台管理项目整合mybatis-plus

自己整合过程中会出现 work.web.exception.GlobalExceptionHandler :100 | 请求地址/admin/device/install/detail/1,发生未知异常. org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.fire.mapper.DeviceInstallMapper.selectById at o…...

【可实战】Linux 系统扫盲、 Shell扫盲(如何写一个简单的shell脚本)

一、Linux系统扫盲 1.Linux 能运行主要的 UNIX 工具软件、应用程序和网络协议 2.Linux 的发行版说简单点就是将 Linux 内核与应用软件做一个打包。 目前市面上较知名的发行版有&#xff1a;Ubuntu、RedHat、CentOS、Debian、Fedora、SuSE、OpenSUSE、Arch Linux、SolusOS 等…...

sqlzoo答案4:SELECT within SELECT Tutorial

sql练习&#xff1a;SELECT within SELECT Tutorial - SQLZoo world表&#xff1a; namecontinentareapopulationgdpAfghanistanAsia6522302550010020343000000AlbaniaEurope28748283174112960000000AlgeriaAfrica238174137100000188681000000AndorraEurope46878115371200000…...

【fly-iot飞凡物联】(20):2025年总体规划,把物联网整套技术方案和实现并落地,完成项目开发和课程录制。

前言 fly-iot飞凡物联专栏&#xff1a; https://blog.csdn.net/freewebsys/category_12219758.html 1&#xff0c;开源项目地址进行项目开发 https://gitee.com/fly-iot/fly-iot-platform 完成项目开发&#xff0c;接口开发。 把相关内容总结成文档&#xff0c;并录制课程。…...

Lucene常用的字段类型lucene检索打分原理

在 Apache Lucene 中&#xff0c;Field 类是文档中存储数据的基础。不同类型的 Field 用于存储不同类型的数据&#xff08;如文本、数字、二进制数据等&#xff09;。以下是一些常用的 Field 类型及其底层存储结构&#xff1a; TextField&#xff1a; 用途&#xff1a;用于存储…...

适用于IntelliJ IDEA 2024.1.2部署Tomcat的完整方法,以及笔者踩的坑,避免高血压,保姆级教程

Tips:创建部署Tomcat直接跳转到四 一、软件准备 笔者用的是IntelliJ IDEA 2024.1.2和Tomcat 8.5。之前我使用的是Tomcat 10&#xff0c;但遇到了许多问题。其中一个主要问题是需要使用高于1.8版本的JDK&#xff0c;为此我下载了新的JDK版本&#xff0c;但这又引发了更多的兼容…...

XSS靶场通关详解

前言 这里作者采用phpstudy部署的xss-lab靶场&#xff0c;配置如下&#xff1a; 第一关 进入靶场后寻找页面的传参处&#xff0c;发现url中的name参数传了test给页面&#xff0c;可以在此处进行尝试xss 成功弹窗&#xff01; payload&#xff1a; <script>alert(1)<…...

Excel 技巧15 - 在Excel中抠图头像,换背景色(★★)

本文讲了如何在Excel中抠图头像&#xff0c;换背景色。 1&#xff0c;如何在Excel中抠图头像&#xff0c;换背景色 大家都知道在PS中可以很容易抠图头像&#xff0c;换背景色&#xff0c;其实Excel中也可以抠简单的图&#xff0c;换背景色。 ※所用头像图片为百度搜索&#x…...

备忘-humanplus相关的代码解析

-1: numpy必须为1.20.0&#xff0c;否则会报错&#xff0c;版本冲突0.rlvalue-based: 如q-learning&#xff08;走迷宫&#xff09;&#xff0c;对当前状态下作出的动作进行价值计算&#xff0c;通过贪婪策略穷尽所有可能选择最佳state-action,但是对于连续的动作空间&#x…...

青少年编程与数学 02-008 Pyhon语言编程基础 01课题、语言概要

青少年编程与数学 02-008 Pyhon语言编程基础 01课题、语言概要 一、榜一大哥起源与早期发展版本演进与社区壮大应用领域的拓展编程语言排行榜的常客结语 二、当前排行三、出色表现四、易学易用五、特色显著六、资源丰富初学者资源中高级学习资源在线编程学习平台 课题摘要:本文…...

XSS (XSS)分类

XSS &#xff08;XSS&#xff09; 概要 XSS全称为Cross Site Scripting&#xff0c;为了和CSS分开简写为XSS&#xff0c;中文名为跨站脚本。该漏洞发生在用户端&#xff0c;是指在渲染过程中发生了不在预期过程中的JavaScript代码执行。XSS通常被用于获取Cookie、以受攻击者的…...

[Linux]el8安全配置faillock:登录失败达阈值自动锁定账户配置

前言 本篇文章的配置仅使用于el8版本的Linux&#xff0c;目前已在centos8、BCLinux8上验证成功&#xff0c;其他版本系统是否可行还得考查。 el8中管理用户登录失败锁定账户所用的模块是faillock.so&#xff0c;如果想要将配置应用与其他版本的Linux&#xff0c;建议确认Linux…...

最新-CentOS 7安装1 Panel Linux 服务器运维管理面板

CentOS 7安装1 Panel Linux 服务器运维管理面板 一、前言二、环境要求三、在线安装四、离线安装1.点击下面1 Panel官网链接访问下载&#xff0c;如未登录或注册&#xff0c;请登录/注册后下载2.使用将离线安装包上传至目标终端/tem目录下3.进入到/tem目录下解压离线安装包4.执行…...

selenium定位网页元素

1、概述 在使用 Selenium 进行自动化测试时&#xff0c;定位网页元素是核心功能之一。Selenium 提供了多种定位方法&#xff0c;每种方法都有其适用场景和特点。以下是通过 id、linkText、partialLinkText、name、tagName、xpath、className 和 cssSelector 定位元素的…...

積分方程與簡單的泛函分析8.具連續對稱核的非齊次第II類弗雷德霍姆積分算子方程

1)def求解具連續對稱核的非齊次第II類弗雷德霍姆積分算子方程 设 是定义在上的连续对称核函数&#xff0c; 非齐次第二类弗雷德霍姆积分算子方程的形式为&#xff1a; &#xff0c; 其中是未知函数&#xff0c;是给定的连续函数&#xff0c;是参数。 2)def其特徵值是否一致…...

进程地址空间(比特课总结)

一、进程地址空间 1. 环境变量 1 &#xff09;⽤户级环境变量与系统级环境变量 全局属性&#xff1a;环境变量具有全局属性&#xff0c;会被⼦进程继承。例如当bash启动⼦进程时&#xff0c;环 境变量会⾃动传递给⼦进程。 本地变量限制&#xff1a;本地变量只在当前进程(ba…...

Oracle查询表空间大小

1 查询数据库中所有的表空间以及表空间所占空间的大小 SELECTtablespace_name,sum( bytes ) / 1024 / 1024 FROMdba_data_files GROUP BYtablespace_name; 2 Oracle查询表空间大小及每个表所占空间的大小 SELECTtablespace_name,file_id,file_name,round( bytes / ( 1024 …...

为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?

在建筑行业&#xff0c;项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升&#xff0c;传统的管理模式已经难以满足现代工程的需求。过去&#xff0c;许多企业依赖手工记录、口头沟通和分散的信息管理&#xff0c;导致效率低下、成本失控、风险频发。例如&#…...

dedecms 织梦自定义表单留言增加ajax验证码功能

增加ajax功能模块&#xff0c;用户不点击提交按钮&#xff0c;只要输入框失去焦点&#xff0c;就会提前提示验证码是否正确。 一&#xff0c;模板上增加验证码 <input name"vdcode"id"vdcode" placeholder"请输入验证码" type"text&quo…...

DBAPI如何优雅的获取单条数据

API如何优雅的获取单条数据 案例一 对于查询类API&#xff0c;查询的是单条数据&#xff0c;比如根据主键ID查询用户信息&#xff0c;sql如下&#xff1a; select id, name, age from user where id #{id}API默认返回的数据格式是多条的&#xff0c;如下&#xff1a; {&qu…...

unix/linux,sudo,其发展历程详细时间线、由来、历史背景

sudo 的诞生和演化,本身就是一部 Unix/Linux 系统管理哲学变迁的微缩史。来,让我们拨开时间的迷雾,一同探寻 sudo 那波澜壮阔(也颇为实用主义)的发展历程。 历史背景:su的时代与困境 ( 20 世纪 70 年代 - 80 年代初) 在 sudo 出现之前,Unix 系统管理员和需要特权操作的…...

Spring Boot+Neo4j知识图谱实战:3步搭建智能关系网络!

一、引言 在数据驱动的背景下&#xff0c;知识图谱凭借其高效的信息组织能力&#xff0c;正逐步成为各行业应用的关键技术。本文聚焦 Spring Boot与Neo4j图数据库的技术结合&#xff0c;探讨知识图谱开发的实现细节&#xff0c;帮助读者掌握该技术栈在实际项目中的落地方法。 …...

C++.OpenGL (20/64)混合(Blending)

混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...

上位机开发过程中的设计模式体会(1):工厂方法模式、单例模式和生成器模式

简介 在我的 QT/C 开发工作中&#xff0c;合理运用设计模式极大地提高了代码的可维护性和可扩展性。本文将分享我在实际项目中应用的三种创造型模式&#xff1a;工厂方法模式、单例模式和生成器模式。 1. 工厂模式 (Factory Pattern) 应用场景 在我的 QT 项目中曾经有一个需…...

Modbus RTU与Modbus TCP详解指南

目录 1. Modbus协议基础 1.1 什么是Modbus? 1.2 Modbus协议历史 1.3 Modbus协议族 1.4 Modbus通信模型 🎭 主从架构 🔄 请求响应模式 2. Modbus RTU详解 2.1 RTU是什么? 2.2 RTU物理层 🔌 连接方式 ⚡ 通信参数 2.3 RTU数据帧格式 📦 帧结构详解 🔍…...