零基础开始学习鸿蒙开发-智能家居APP离线版介绍
目录
1.我的小屋
2.查找设备
3.个人主页
前言
好久不发博文了,最近都忙于面试,忙于找工作,这段时间终于找到工作了。我对鸿蒙开发的激情依然没有减退,前几天做了一个鸿蒙的APP,现在给大家分享一下!
具体功能如下图:
1.我的小屋
1.1 锁门:对大门开关锁的控制
1.2设备状态:展示了某台设备的详细信息
1.3 控制面板:房门开关、车库门开关、窗帘开关、灯开关
1.4 添加设备:根据设备信息添加设备
我的小屋
锁门
设备状态
2.查找设备
2.1 搜索:对已经添加的设备进行搜索
2.2 搜索历史:可以查看到搜索过的信息
查找设备
3.个人主页
3.1 个人资料:展示个人的资料信息,支持修改
3.2账号与安全:包含修改密码和退出登录
注册页面代码
// 导入必要的模块
import router from '@ohos.router';
import Preferences from '@ohos.data.preferences';
import UserBean from '../common/bean/UserBean';// 注册页面
@Entry
@Component
struct RegisterPage {@State username: string = '';@State password: string = '';@State confirmPwd: string = '';@State errorMsg: string = '';private prefKey: string = 'userData'private context = getContext(this)// 保存用户数据(保持原逻辑)async saveUser() {try {let prefs = await Preferences.getPreferences(this.context, this.prefKey)const newUser: UserBean = {// @ts-ignoreusername: this.username,password: this.password}await prefs.put(this.username, JSON.stringify(newUser))await prefs.flush()router.back()} catch (e) {console.error('注册失败:', e)}}// 注册验证(保持原逻辑)handleRegister() {if (!this.username || !this.password) {this.errorMsg = '用户名和密码不能为空'return}if (this.password !== this.confirmPwd) {this.errorMsg = '两次密码不一致'return}this.saveUser()}build() {Column() {// 用户名输入框TextInput({ placeholder: '用户名' }).width('80%').height(50).margin({ bottom: 20 }).backgroundColor('#FFFFFF') // 新增白色背景.onChange(v => this.username = v)// 密码输入框// @ts-ignoreTextInput({ placeholder: '密码', type: InputType.Password }).width('80%').height(50).margin({ bottom: 20 }).backgroundColor('#FFFFFF') // 新增白色背景.onChange(v => this.password = v)// 确认密码输入框// @ts-ignoreTextInput({ placeholder: '确认密码', type: InputType.Password }).width('80%').height(50).margin({ bottom: 20 }).backgroundColor('#FFFFFF') // 新增白色背景.onChange(v => this.confirmPwd = v)// 错误提示(保持原样)if (this.errorMsg) {Text(this.errorMsg).fontColor('red').margin({ bottom: 10 })}// 注册按钮(保持原样)Button('注册', { type: ButtonType.Capsule }).width('80%').height(50).backgroundColor('#007AFF').onClick(() => this.handleRegister())// 返回按钮(保持原样)Button('返回登录', { type: ButtonType.Capsule }).width('80%').height(40).margin({ top: 20 }).backgroundColor('#34C759').onClick(() => router.back())}.width('100%').height('100%').padding(20).justifyContent(FlexAlign.Center).backgroundColor('#1A1A1A') // 新增暗黑背景色}
}
登录页面代码
// 导入必要的模块
import router from '@ohos.router';
import Preferences from '@ohos.data.preferences';
import DeviceBean from '../common/bean/DeviceBean';// 用户数据模型
class User {username: string = '';password: string = '';
}// 登录页面
@Entry
@Component
struct LoginPage {@State username: string = '';@State password: string = '';@State errorMsg: string = '';@State deviceList:Array<DeviceBean> =[new DeviceBean(0,'设备1',0,0,0,0,0,0,0,0,0,0,),new DeviceBean(1,'设备2',0,0,0,0,0,0,0,0,0,0,),new DeviceBean(3,'设备3',0,0,0,0,0,0,0,0,0,0,)];private prefKey: string = 'userData'// 获取本地存储上下文private context = getContext(this)// 获取用户数据async getUser(): Promise<User | null> {try {// @ts-ignorereturn userData ? JSON.parse(userData) : null} catch (e) {console.error('读取失败:', e)return null}}// 登录处理async handleLogin(username:string,password:string,) {if (!this.username || !this.password) {this.errorMsg = '用户名和密码不能为空'return}const user = await this.getUser()if ( username == 'admin' && password=='123456') {AppStorage.SetOrCreate("deviceList",this.deviceList);AppStorage.SetOrCreate("signature","金克斯的含义就是金克斯")AppStorage.SetOrCreate("nickName","金克斯")AppStorage.SetOrCreate("nickname","金克斯")AppStorage.SetOrCreate("login_username",this.username)// 登录成功跳转主页router.pushUrl({ url: 'pages/MainPages', params: { username: this.username } })} else {this.errorMsg = '用户名或密码错误'}}build() {Column() {// 新增欢迎语Text('欢迎登录智能家庭app').fontSize(24).margin({ bottom: 40 }).fontColor('#FFFFFF') // 白色文字TextInput({ placeholder: '用户名' }).width('80%').height(50).margin({ bottom: 20 }).onChange(v => this.username = v).fontColor(Color.White).placeholderColor(Color.White)// @ts-ignoreTextInput({ placeholder: '密码', type: InputType.Password}).fontColor(Color.White).placeholderColor(Color.White).width('80%').height(50).margin({ bottom: 20 }).onChange(v => this.password = v)if (this.errorMsg) {Text(this.errorMsg).fontColor('red').margin({ bottom: 10 })}Button('登录', { type: ButtonType.Capsule }).width('80%').height(50).backgroundColor('#007AFF').onClick(() => this.handleLogin(this.username,this.password))Button('注册', { type: ButtonType.Capsule }).width('80%').height(40).margin({ top: 20 }).backgroundColor('#34C759').onClick(() => router.pushUrl({ url: 'pages/RegisterPage' }))}.width('100%').height('100%').padding(20).justifyContent(FlexAlign.Center).backgroundColor('#1A1A1A') // 新增暗黑背景色}
}
主页代码
import prompt from '@ohos.prompt';
import { TabID, TabItemList } from '../model/TabItem'
import { DeviceSearchComponent } from '../view/DeviceSearchComponent';
import HouseStateComponent from '../view/HouseStateComponent';
import { MineComponent } from '../view/MineComponent';
import { NotLogin } from '../view/NotLogin';
@Entry
@Component
struct MainPages {@State pageIndex:number = 0;//页面索引private tabController:TabsController = new TabsController();//tab切换控制器@Builder MyTabBuilder(idx:number){Column(){Image(idx === this.pageIndex ? TabItemList[idx].icon_selected:TabItemList[idx].icon).width(32).height(32)// .margin({top:5})Text(TabItemList[idx].title).fontSize(14).fontWeight(FontWeight.Bold).fontColor(this.pageIndex === idx ? '#006eee':'#888')}}build() {Tabs({barPosition:BarPosition.End}){TabContent(){// Text('小屋状态')HouseStateComponent()}// .tabBar('小屋状态').tabBar(this.MyTabBuilder(TabID.HOUSE)) //调用自定义的TabBarTabContent(){// Text('搜索设备')DeviceSearchComponent()//调用设备搜索组件}// .tabBar('搜索设备').tabBar(this.MyTabBuilder(TabID.SEARCH_DEVICE)) //调用自定义的TabBarTabContent(){// Text('我的')MineComponent();//个人主页// NotLogin()}// .tabBar('我的').tabBar(this.MyTabBuilder(TabID.MINE)) //调用自定义的TabBar}.barWidth('100%').barMode(BarMode.Fixed).width('100%').height('100%').onChange((index)=>{//绑定onChange函数切换页签this.pageIndex = index;}).backgroundColor('#000')}
}
我的小屋代码
import router from '@ohos.router';
import { Action } from '@ohos.multimodalInput.keyEvent';
import DeviceBean from '../common/bean/DeviceBean';
import MainViewModel from '../model/MainViewModel';
import promptAction from '@ohos.promptAction';// 自定义弹窗组件
@CustomDialog
struct SimpleDialog {@State deviceList:Array<DeviceBean> =[new DeviceBean(0,'设备1',0,0,0,0,0,0,0,0,0,0,),new DeviceBean(1,'设备2',0,0,0,0,0,0,0,0,0,0,),new DeviceBean(3,'设备3',0,0,0,0,0,0,0,0,0,0,)];// @ts-ignore@State deviceId: number=1; //设备ID@State name: string=''; //设备名@State temperator: number=25.3; //室内温度@State humidity: number =20; //室内湿度@State lumination: number =10; //光照@State isRain: number =30; //下雨预警 0:正常 1:触发报警@State isSmoke: number =0; //烟雾报警 0:正常 1:触发报警@State isFire: number=0; //火灾报警 0:正常 1:触发报警@State doorStatus: number=0; //门开关状态 0:正常 1:开启@State garageStatus: number=0; //车库门开关 0:正常 1:开启@State curtainStatus: number=0; //窗帘开关 0:正常 1:开启@State lightStatus: number=0; //灯开关 0:正常 1:开启@State tempDevice: DeviceBean = new DeviceBean(0,'',0,0,0,0,0,0,0,0,0,0,);tmpMap:Map<string, string> = new Map();controller:CustomDialogController;build() {Column() {// 设备基本信息TextInput({ placeholder: '设备ID(数字)' }).onChange(v => this.tempDevice.deviceId = Number(v))TextInput({ placeholder: '设备名称' }).onChange(v => this.tempDevice.name = v)// 环境参数/* TextInput({ placeholder: '温度(0-100)' }).onChange(v => this.tempDevice.temperator = Number(v))TextInput({ placeholder: '湿度(0-100)' }).onChange(v => this.tempDevice.humidity = Number(v))TextInput({ placeholder: '光照强度' }).onChange(v => this.tempDevice.lumination = Number(v))*/Button('保存').onClick(()=>{promptAction.showToast({message:'保存成功!',duration:2000,})// 添加新设备到列表//this.deviceList = [...this.deviceList, {...this.tempDevice}];console.log(JSON.stringify(this.tempDevice))this.deviceList.push(this.tempDevice); // 关键步骤:创建新数组AppStorage.SetOrCreate("deviceList",this.deviceList);this.controller.close()})/* .onClick(() => {this.deviceList = [...this.deviceList, {// @ts-ignoreid: this.id,name: this.name,}]this.controller.close()})*/}.padding(20)}
}@Component
export default struct HouseStateComponent{private exitDialog() { }@State handlePopup: boolean = false@State devices: DeviceBean[]=[]// 确保控制器正确初始化private dialogController: CustomDialogController = new CustomDialogController({builder: SimpleDialog(), // 确认组件正确引用cancel: this.exitDialog, // 关闭回调autoCancel: true // 允许点击外部关闭})@Builder AddMenu(){Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {Column(){Text('扫一扫').fontSize(20).width('100%').height(30).align(Alignment.Center)Divider().width('80%').color('#ccc')Text('添加设备').fontSize(20).width('100%').height(30).align(Alignment.Center).onClick(()=>{this.dialogController.open()})}.padding(5).height(65)}.width(100)}build(){Column({space:8}){Row() {Text('小屋状态').fontSize(24).fontWeight(FontWeight.Bold).fontColor(Color.White).margin({ top: 10 }).textAlign(TextAlign.Start)Image($r('app.media.jiahao_0')).width(32).height(32).margin({top:10,left:160}).bindMenu(this.AddMenu())Image($r('app.media.news')).fillColor(Color.Black).width(32).height(32).margin({top:10}).onClick(() => {this.handlePopup = !this.handlePopup}).bindPopup(this.handlePopup,{message:'当前暂无未读消息',})// .onClick({//// })}.width('95%').justifyContent(FlexAlign.SpaceBetween)Divider().width('95%').color(Color.White)Flex({ wrap: FlexWrap.Wrap }){Button()Row() {Shape() {Circle({ width: 60, height: 60 }).fill('#494848').margin({left:15,top:'32%'}).opacity(0.7)Image($r('app.media.lock')).width(30).margin({ left: 30 ,top:'42%'})}.height('100%')Column() {Text('大门').fontSize(25).fontColor('#838383').fontWeight(FontWeight.Bold).margin({ left: 20, top: 0 })Text('已锁').fontSize(25).fontColor('#838383').fontWeight(FontWeight.Bold).margin({ left: 20, top: 0 })}}.borderRadius(20).backgroundColor('#1c1c1e')// .backgroundImage($r('app.media.Button_img'))// .backgroundImageSize(ImageSize.Cover)// .border({ width: 1 })// .borderColor('#b9b9b9').width('47%').height(160).onClick(()=>{router.pushUrl({url:"house/HomeGate"})})Button()Row() {Shape() {Circle({ width: 60, height: 60 }).fill('#494848').margin({left:15,top:'32%'}).opacity(0.7)Image($r('app.media.Device_icon')).width(30).margin({ left: 30 ,top:'42%'})}.height('100%')Column() {Text('设备').fontSize(25).fontColor('#838383').fontWeight(FontWeight.Bold).margin({ left: 20, top: 0 })Text('状态').fontSize(25).fontColor('#838383').fontWeight(FontWeight.Bold).margin({ left: 20, top: 0 })}}.onClick(()=>{router.pushUrl({url:"house/DeviceStatus"})}).borderRadius(20).backgroundColor('#1c1c1e').margin({left:20})// .border({ width: 1 })// .borderColor('#b9b9b9').width('47%').height(160)}.width('95%').padding(10)Flex() {Button()Row() {Shape() {Circle({ width: 60, height: 60 }).fill('#494848').margin({ left: 15, top: '32%' }).opacity(0.7)Image($r('app.media.console_1')).width(30).margin({ left: 30, top: '47%' })}.height('100%')Column() {Text('控制').fontSize(25).fontColor('#838383').fontWeight(FontWeight.Bold).margin({ left: 20, top: 0 })Text('面板').fontSize(25).fontColor('#838383').fontWeight(FontWeight.Bold).margin({ left: 20, top: 0 })}}.onClick(() => {router.pushUrl({url: "house/ControlConsole"})}).borderRadius(20).backgroundColor('#1c1c1e')// .border({ width: 1 })// .borderColor('#b9b9b9').width('47%').height(160)}.width('95%').padding(10)}.width('100%').height('100%').backgroundImage($r('app.media.index_background1')).backgroundImageSize(ImageSize.Cover)}
}
设备搜索代码
import DeviceBean from '../common/bean/DeviceBean'
@Component
export struct DeviceSearchComponent {@State submitValue: string = '' //获取历史记录数据@State allDevices:Array<DeviceBean> =[new DeviceBean(0,'设备1',0,0,0,0,0,0,0,0,0,0,),new DeviceBean(1,'设备2',0,0,0,0,0,0,0,0,0,0,)];@State all_devices:Array<DeviceBean> =AppStorage.Get("deviceList");@State filteredDevices:Array<DeviceBean>=[];controller: SearchController = new SearchController()scroll: Scroller = new Scroller()@State historyValueArr: Array<string> = [] //历史记录存放private swiperController: SwiperController = new SwiperController()build() {Column({ space: 8 }) {Row({space:1}){Search({placeholder:'搜索一下',controller: this.controller}).searchButton('搜索').margin(15).width('80%').height(40).backgroundColor('#F5F5F5').placeholderColor(Color.Grey).placeholderFont({ size: 14, weight: 400 }).textFont({ size: 14, weight: 400 }).onSubmit((value: string) => { //绑定 输入内容添加到submit中this.submitValue = valuefor (let i = 0; i < this.historyValueArr.length; i++) {if (this.historyValueArr[i] === this.submitValue) {this.historyValueArr.splice(i, 1);break;}}this.historyValueArr.unshift(this.submitValue) //将输入数据添加到历史数据// 若历史记录超过10条,则移除最后一项if (this.historyValueArr.length > 10) {this.historyValueArr.splice(this.historyValueArr.length - 1);}let devices: Array<DeviceBean> = AppStorage.Get("deviceList") as Array<DeviceBean>JSON.stringify(devices);// 增加过滤逻辑this.filteredDevices = devices.filter(item =>item.name.includes(value))})// 搜索结果列表:ml-citation{ref="7" data="citationList"}//二维码Scroll(this.scroll){Image($r('app.media.saomiao')).width(35).height(35).objectFit(ImageFit.Contain)}}.margin({top:20})// 轮播图Swiper(this.swiperController) {Image($r('app.media.lunbotu1' )).width('100%').height('100%').objectFit(ImageFit.Auto) //让图片自适应大小 刚好沾满// .backgroundImageSize(ImageSize.Cover)Image($r('app.media.lbt2' )).width('100%').height('100%').objectFit(ImageFit.Auto)Image($r('app.media.lbt3' )).width('100%').height('100%').objectFit(ImageFit.Auto)Image($r('app.media.lbt4' )).width('100%').height('100%').objectFit(ImageFit.Auto)Image($r('app.media.tips' )).width('100%').height('100%').objectFit(ImageFit.Auto)}.loop(true).autoPlay(true).interval(5000) //每隔5秒换一张.width('90%').height('25%').borderRadius(20)// 历史记录Row() {// 搜索历史标题Text('搜索历史').fontSize('31lpx').fontColor("#828385")// 清空记录按钮Text('清空记录').fontSize('27lpx').fontColor("#828385")// 清空记录按钮点击事件,清空历史记录数组.onClick(() => {this.historyValueArr.length = 0;})}.margin({top:30})// 设置Row组件的宽度、对齐方式和内外边距.width('100%').justifyContent(FlexAlign.SpaceBetween).padding({left: '37lpx',top: '11lpx',bottom: '11lpx',right: '37lpx'})Row(){// 搜索结果列表:ml-citation{ref="7" data="citationList"}List({ space: 10 }) {if (this.filteredDevices.length===0){ListItem() {Text(`暂时未找到任何设备..`).fontColor(Color.White)}}ForEach(this.filteredDevices, (item: DeviceBean) => {ListItem() {Text(`${item.deviceId} (${item.name})`).fontColor(Color.White)}}, item => item.deviceId)}/* List({ space: 10 }) {ForEach(this.filteredDevices, (item: DeviceBean) => {ListItem() {Text('模拟设备1').fontColor(Color.White)}ListItem() {Text('模拟设备2').fontColor(Color.White)}}, item => item.id)}*/}.margin({top:50,left:30})// 使用Flex布局,包裹搜索历史记录Flex({direction: FlexDirection.Row,wrap: FlexWrap.Wrap,}) {// 遍历历史记录数组,创建Text组件展示每一条历史记录ForEach(this.historyValueArr, (item: string, value: number) => {Text(item).padding({left: '15lpx',right: '15lpx',top: '7lpx',bottom: '7lpx'})// 设置背景颜色、圆角和间距.backgroundColor("#EFEFEF").borderRadius(10)// .margin('11lpx').margin({top:5,left:20})})}// 设置Flex容器的宽度和内外边距.width('100%').padding({top: '11lpx',bottom: '11lpx',right: '26lpx'})}.width('100%').height('100%')// .backgroundColor('#f1f2f3').backgroundImage($r('app.media.index_background1')).backgroundImageSize(ImageSize.Cover)}
}
// }
个人主页代码
import router from '@ohos.router';
import promptAction from '@ohos.promptAction';
import UserBean from '../common/bean/UserBean';
import { InfoItem, MineItemList } from '../model/MineItemList';
@Entry
@Component
export struct MineComponent{@State userBean:UserBean = new UserBean()@State nickname:string = this.userBean.getNickName();//昵称@State signature:string = this.userBean.getSignature();//签名build(){Column() {Image($r('app.media.user_avtar1')).width('100%').height('25%').opacity(0.5)Column() {Shape() {Circle({ width: 80, height: 80 }).fill('#3d3f46')Image($r('app.media.user_avtar1')).width(68).height(68).margin({ top: 6, left: 6 }).borderRadius(34)}Text(`${this.nickname}`).fontSize(18).fontWeight(FontWeight.Bold).fontColor(Color.White)Text(`${this.signature}`).fontSize(14).fontColor(Color.Orange)}.width('95%').margin({ top: -34 })//功能列表Shape() {Rect().width('100%').height(240).fill('#3d3f46').radius(40).opacity(0.5)Column() {List() {ForEach(MineItemList, (item: InfoItem) => {ListItem() {// Text(item.title)Row() {Row() {Image(item.icon).width(30).height(30)if (item.title == '个人资料') {Shape() {Rect().width('80%').height(30).opacity(0)Text(item.title).fontSize(22).fontColor(Color.White).margin({ left: 10 })}.onClick(() => {router.pushUrl({url:"myhomepage/PersonalData"})})}else if (item.title == '账号与安全') {Shape() {Rect().width('80%').height(30).opacity(0)Text(item.title).fontSize(22).fontColor(Color.White).margin({ left: 10 })}.onClick(() => {router.pushUrl({url:"myhomepage/AccountSecurity"})})}else if (item.title == '检查更新') {Shape() {Rect().width('80%').height(30).opacity(0)Text(item.title).fontSize(22).fontColor(Color.White).margin({ left: 10 })}.onClick(()=>{promptAction.showToast({message:"当前暂无更新",duration:2000,})})}else if (item.title == '关于') {Shape() {Rect().width('80%').height(30).opacity(0)Text(item.title).fontSize(22).fontColor(Color.White).margin({ left: 10 })}.onClick(()=>{promptAction.showToast({message:"当前版本为1.0.0",duration:2000,})})}else{Text(item.title).fontSize(22).fontColor(Color.White).margin({ left: 10 })}}Image($r('app.media.right')).width(38).height(38)}.width('100%').height(52).justifyContent(FlexAlign.SpaceBetween)}// .border({// width: { bottom: 1 },// color: Color.Orange// })}, item => JSON.stringify(item))}.margin(10).border({radius: {topLeft: 24,topRight: 24}})// .backgroundColor('#115f7691').width('95%')// .height('100%').margin({ top: '5%', left: '5%' })}}.margin({ top: 20 }).width('90%')}.width('100%').height('100%').backgroundImage($r('app.media.index_background1')).backgroundImageSize(ImageSize.Cover)}
}
感谢大家的阅读和点赞,你们的支持 是我前进的动力,我会继续保持热爱,贡献自己的微薄码力!
’
相关文章:
零基础开始学习鸿蒙开发-智能家居APP离线版介绍
目录 1.我的小屋 2.查找设备 3.个人主页 前言 好久不发博文了,最近都忙于面试,忙于找工作,这段时间终于找到工作了。我对鸿蒙开发的激情依然没有减退,前几天做了一个鸿蒙的APP,现在给大家分享一下! 具体…...
你的 Linux 服务器连不上网?10 分钟入门网络故障排查
问题现象:服务器突然失去网络连接 当你兴冲冲地打开终端,准备开始一天的开发工作时,却发现服务器无法连接网络,ifconfig命令只能看到本地环回接口(lo)。这种突如其来的网络中断可能会让很多Linux新手感到手足无措。 别担心&…...
《Vue Router实战教程》20.路由懒加载
欢迎观看《Vue Router 实战(第4版)》视频课程 路由懒加载 当打包构建应用时,JavaScript 包会变得非常大,影响页面加载。如果我们能把不同路由对应的组件分割成不同的代码块,然后当路由被访问的时候才加载对应组件&am…...
JVM 之 String 引用机制解析:常量池、堆内存与 intern 方法
案例一: String s1 new String("1"); String s2 "1"; System.out.println(s1 s2);s1: 执行 new String("1"),JVM 首先在字符串常量池中查找或添加字面量 "1",然后在堆内存中新建一个内容为 &quo…...
如何在 Mac 上安装 Python
所有最新的 MacOS(从 macOS 12.3 开始)都预装了 Python 版本(通常是 Python 2.x),但它已经过时并且不再受支持。要充分利用 Python 的功能,您需要安装最新版本的 Python。 本文提供了分步教程,展…...
无锡东亭无人机培训机构电话
无锡东亭无人机培训机构电话,随着科技的迅猛发展,无人机逐渐走入我们的生活和工作领域,成为多种行业中不可或缺的工具。而在其广泛的应用中,如何正确、熟练地操控无人机成为了关键。因此,找到一家专业的无人机培训机构…...
WPS复制粘贴错误 ,文件未找到 mathpage.wll
文章目录 1.错误提示图片2.解决方案1.找到MathType.wll文件和MathType Commands 2016.dotm文件并复制2.找到wps安装地址并拷贝上述两个文件到指定目录 3.重启WPS 1.错误提示图片 2.解决方案 1.找到MathType.wll文件和MathType Commands 2016.dotm文件并复制 MathType.wll地址如…...
蓝桥杯单片机刷题——按键设置当前采集距离为距离参数
设计要求 驱动超声波传感器,启动距离测量功能,并将其结果显示到数码管上。 按键“S5”定义为参数按键,按下S5按键,设备自动将当前采集的距离数据作为距离参数; 若测量的距离数据超过距离参数,指示灯L1点亮ÿ…...
mybaties plus 更新null值进入数据库
(数据库一定要支持字段为null值) 问题: 假设我现在数据库里有一个值是1,这个字段允许为null。 目前我使用的是的mybaties plus,我希望将这个值更新weinull,如何操作? 提示:如果直接…...
VSCode优雅的使用debug
原始用法:(这里不使用) 配置launch.json,里面传入参数然后debug,这里我们通常需要传入的参数比较多,而且经常修改参数,直接去修改launch.json会比较麻烦,所以使用sh脚本比较方便。 {// Use IntelliSense to…...
优化你的 REST Assured 测试:设置默认主机与端口、GET 请求与断言
REST Assured 是一个功能强大的 Java 库,用于测试 RESTful Web 服务。它简化了 API 测试流程,提供了一整套用于高效验证响应的工具。在本篇博客中,我们将深入探讨几个核心概念,包括如何设置默认主机和端口、如何发起 GET 请求以及…...
JVM之String创建、拼接
一、字符串创建的两种方式 1. 字面量直接赋值 String s1 "a"; 过程: JVM 检查字符串常量池中是否存在 "a"。若存在,直接返回常量池中的引用。若不存在,在常量池中创建 "a",返回其引用。 特点&a…...
UE5 模仿生存建造类游戏创建的过程
一、大概流程如下 点击界面按钮生成Actor->移动鼠标Actor的位置随着鼠标移动移动->点击鼠标左键确定Actor的位置 使用了盒体检测GetWorld()->SweepSingleByChannel()函数检测是否发生碰撞通过 FCollisionQueryParams CollisionParams;CollisionParams.AddIgnoredAc…...
大模型在慢性髓细胞白血病(CML)初治成人患者诊疗中的应用研究
目录 一、引言 1.1 研究背景与意义 1.2 国内外研究现状 1.3 研究目的与内容 二、大模型技术与 CML 相关知识 2.1 大模型技术原理与特点 2.2 CML 的病理生理与诊疗现状 三、术前风险预测与手术方案制定 3.1 术前数据收集与预处理 3.2 大模型预测术前风险 3.3 根据预测…...
汽车性能的幕后保障:慧通测控电动尾翼综合力学测试浅析
在汽车性能不断追求极致的当下,电动尾翼已成为众多高性能车型以及部分新能源汽车提升空气动力学表现与操控稳定性的关键配置。从炫酷的超跑到注重续航与驾驶体验的新能源车,电动尾翼正逐渐崭露头角。它绝非仅仅是外观上的装饰,而是能在车辆行…...
动力电池自动点焊机:新能源汽车制造的智能焊接利器
在新能源汽车产业蓬勃发展的今天,动力电池作为其核心部件,其性能与安全性直接关系到整车的续航里程和使用寿命。而动力电池的制造过程中,焊接工艺是至关重要的一环。这时,动力电池自动点焊机便以其高效、精准、智能的特点…...
arm64架构的copy_from_user分析
文章目录 前言代码实现内核c代码copy_from_user_copy_from_userraw_copy_from_user 内核汇编代码copy_from_user.Scopy_template.S 汇编代码分析汇编简介标签.req伪指令.macro伪指令tbz指令neg指令str指令 copy_template.S分析 小结 前言 一谈到内核-用户空间的数据拷贝&#…...
【远程工具】1.1 时间处理设计与实现(datetime库lib.rs)
一、设计原理与决策 时间单位选择 采用**秒(s)**作为基准单位,基于以下考虑: 国际单位制(SI)基本时间单位 整数秒(i64)方案优势: 精确无误差(相比浮点数&am…...
【STM32】解读启动文件startup_stm32f10x_md.s
栈空间 栈(Stack):栈是一种后进先出(LIFO)的数据结构,用于存储函数调用时的局部变量、返回地址和寄存器的值。启动文件会定义栈的大小,并将栈指针初始化为栈顶地址。在函数调用时,…...
Redis下载稳定版本5.0.4
https://www.redis.net.cn/download/ Redis下载 Redis 版本号采用标准惯例:主版本号.副版本号.补丁级别,一个副版本号就标记为一个标准发行版本,例如 1.2,2.0,2.2,2.4,2.6,2.8,奇数的副版本号用来表示非标准版本,例如2.9.x发行版本是Redis 3.0标准版本的非标准发行版本…...
阿里云服务迁移实战: 02-服务器迁移
ECS 迁移 最简单的方式是 ECS 过户,不过这里有一些限制,如果原账号是个人账号,那么目标账号无限制。如果原账号是企业账号,则指定过户给相同实名认证的企业账号。 具体操作步骤可以参考官方文档 ECS过户 进行操作。 本文重点介绍…...
怎么解决CentOS上Zookeeper启动失败的问题
在 CentOS 上启动 Zookeeper 失败通常是由于配置错误、端口冲突、权限问题或 Java 环境配置问题导致的。我们可以逐步排查: 一、查看错误日志 Zookeeper 的日志目录一般在: /your-zookeeper-path/logs/zookeeper.out 或者: /your-zookeeper-p…...
《Vue3学习手记》
下面进入Vue3的学习,以下代码中都有很详细的注释,代码也比较清晰易懂: Vue3 index.html是入口文件 Vue3通过createApp函数创建一个应用实例 main.ts: // Vue3中通过createApp函数创建应用实例 // 引入createApp用于创建应用 import { crea…...
【Ubutun】 在Linux Yocto的基础上去适配4G模块
1)、完整解决流程总结 一. 固定4G模块的网络接口名 usb0(基于物理路径) # 创建UDEV规则文件 sudo vi /etc/udev/rules.d/10-4g-rename.rules添加内容: SUBSYSTEM"net", ACTION"add", ATTRS{busnum}"2&…...
达梦数据库-学习-15-大内存SQL相关视图介绍
目录 一、环境信息 二、介绍 三、数据字典表 1、V$MEM_POOL 2、V$SQL_STAT 3、V$SQL_STAT_HISTORY 4、V$LARGE_MEM_SQLS 5、V$SYSTEM_LARGE_MEM_SQLS 四、总结 一、环境信息 名称值CPU12th Gen Intel(R) Core(TM) i7-12700H操作系统CentOS Linux release 7.9.2009 (Co…...
分治-归并系列一>翻转对
目录 题目:解析:策略一: 代码:策略二: 代码: 题目: 链接: link 这题和逆序对区别点就是,要找到前一个元素是后一个元素的2倍 先找到目标值再,继续堆排序 解析࿱…...
微服务面试题
五大组件 注册中心/配置中心 nacos 服务注册 服务启动时 将自己的id等信息发送给nacos 完成注册 服务发现 服务需要调用其他服务时 从nacos获取服务列表 交给负载均衡选择 服务监控 临时实例 由服务每隔一段时间注册中心发送信息 表示自己存活 若注册中心超过一定时间没有…...
高级java每日一道面试题-2025年3月31日-微服务篇[Nacos篇]-Nacos集群模式下的部署方案有哪些?
如果有遗漏,评论区告诉我进行补充 面试官: Nacos集群模式下的部署方案有哪些? 我回答: Nacos 集群模式下的部署方案详解 在 Java 高级面试中,Nacos 集群部署是考察候选人对分布式系统高可用性和扩展性理解的重要议题。以下是几种常见的 Nacos 集群部…...
3dmax的python通过普通的摄像头动捕表情
1、安装python 进入cdm,打python要能显示版本号 >>>(进入python提示符模式) import sys sys.path显示python的安装路径, 进入到python.exe的路径 在python目录中安装(ctrlz退出python交互模式) 2、pip install mediapipe…...
vue3+vite Cannot find module ‘@/XXXXXX‘ or its corresponding type declarations
在使用vue3vite 创建新的工程时会出现Connot find module /xxx错误,根本原因是vite 中没有配置跟目录别名导致的,可以在vite.config.ts 中增加如下配置 如果在tsconfig.json中增加 "compilerOptions": {"paths": {"/*": …...
vmware-exporter容器
vmware-exporter干嘛的,需要的都知道,不再赘述,如果你不了解,说明你也用不到,此文可略过。 如果你嫌自行部署比较麻烦,可移步https://download.csdn.net/download/qq_28608175/90595900下载容器打包文件&a…...
异形遮罩之QML中的 `OpacityMask` 实战
文章目录 🌧️ 传统实现的问题👉 效果图 🌈 使用 OpacityMask 的理想方案👉代码如下🎯 最终效果: ✨ 延伸应用🧠 总结 在 UI 设计中,经常希望实现一些“异形区域”拥有统一透明度或颜…...
代码随想录算法训练营Day27 | Leetcode 56. 合并区间、738.单调递增的数字、968.监控二叉树
代码随想录算法训练营Day27 | Leetcode 56.合并区间、738.单调递增的数字、968.监控二叉树 一、合并区间 相关题目:Leetcode56 文档讲解:Leetcode56 视频讲解:Leetcode56 1. Leetcode56. 合并区间 以数组 intervals 表示若干个区间的集合&am…...
【SQL】常见SQL 行列转换的方法汇总 - 精华版
【SQL】常见SQL 行列转换的方法汇总 - 精华版 一、引言二、SQL常见的行列转换对比1. 行转列 Pivoting1.1 CASE WHEN 聚合函数1.2 IF 聚合函数1.3 PIVOT操作符 2.列转行 Unpivoting2.1 UNION ALL2.2 EXPLODE函数(Hive/Spark&#…...
docx文档转为pdf文件响应前端
1、转换文件(docx~pdf) 1.引入pom依赖 <dependency><groupId>com.aspose</groupId><artifactId>aspose-words</artifactId><version>20.12.0</version> </dependency>2.读取docx文档数据-转换 // 初…...
python办公自动化------word转换pdf
需要安装包:docx2pdf 例1:将docx文件转换为pdf文件 from docx2pdf import convertconvert("./dataFile/test_doc.docx", "./dataFile/测试文件转换.pdf") 运行结果:...
cs224w课程学习笔记-第10课
cs224w课程学习笔记-第10课 异构图 前言一、异构图1、异构图定义2、异构图与同构图 二、异构图下的GNN1、GCN扩展至RGCN1.1 RGCN原理1.2 异构图的任务预测特点1.3 异构图任务预测基础案例 2、完整的异构图GCN三、异构图下的Transformer 前言 异构图的定义是节点内部存在类型不…...
leetcode每日一题:查询数组异或美丽值
引言 今天的每日一题原题是2843. 统计对称整数的数目,由于数据量很小,最大只是到10000,所以直接模拟即可,不需要复杂的数位DP,反而执行的更慢。更换成前几天遇到的更有意思的一题来写这个每日一题。 题目 2527. 查询…...
【C#】一种优雅的基于winform的串口通信管理
serialPort.DataReceived、串口优雅管理 完整《C#串口通信系统》功能清单 Part 1 — SerialPortManager.cs —— 串口核心管理类 using System; using System.IO.Ports; using System.Text; using System.Threading; using System.Windows.Forms;/// <summary> /// 专业…...
【Linux】ubuntu环境变量配置以及shell配置文件编写
一、确定配置文件类型 输入命令确定配置文件类型 echo $SHELL输出如果是 /bin/zsh,那就改 .zshrc;如果是 /bin/bash,那就改 .bashrc。 下面以 .bashrc 为例。 二、编辑 ./bashrc 文件 输入命令编辑配置文件。 vim ~/.bashrc在文件末尾添…...
.NET MAUI教程2-利用.NET CommunityToolkit.Maui框架弹Toast
在上一篇博文的基础上继续操作: .NET MAUI教程1-入门并发布apk包安装到真机-CSDN博客 本文内容参考: Toast - .NET MAUI Community Toolkit - Community Toolkits for .NET | Microsoft Learn 1 在NuGet包管理器中安装 MAUI Community Toolkit&…...
Android 16应用适配指南
Android 16版本特性介绍 https://developer.android.com/about/versions/16?hlzh-cn Android 16 所有功能和 API 概览 https://developer.android.com/about/versions/16/features?hlzh-cn#language-switching Android 16 发布时间 Android 16 适配指南 Google开发平台&…...
<C#>在 C# .NET 6 中,使用IWebHostEnvironment获取Web应用程序的运行信息。
在 C# .NET 6 中,IWebHostEnvironment 接口提供了有关应用程序运行环境的信息,例如应用程序的根目录、环境名称等。它在处理文件路径、加载配置文件以及根据不同环境提供不同服务等场景中非常有用。以下是关于 IWebHostEnvironment 的详细用法介绍&#…...
在 STM32 中实现电机测速的方法介绍
在 STM32 中实现电机测速的方法介绍 关键字:M 法测速, T 法测速,编码器 1. 电机测速方法介绍 在电机控制类应用中,经常会需要对电机转速进行检测,测速常用的方式有 M 法测速和 T法测速。 M 法测速是利用在规定时间 …...
第四十六篇 人力资源管理数据仓库架构设计与高阶实践
声明:文章内容仅供参考,需仔细甄别。文中技术名称属相关方商标,仅作技术描述;代码示例为交流学习用途;案例数据已脱敏,技术推荐保持中立;法规解读仅供参考,请以《网络安全法》《数据…...
支持iOS与Android!SciChart开源金融图表库助力高效开发交易应用
如果您想了解更多关于开源财务图表库的iOS和Android应用程序,SciChart高性能的iOS、Android图表库一定不要错过!使用SciChart创建金融、交易呵股票、外汇或加密应用程序变得很容易。 SciChart iOS & macOS是一个功能丰富和强大的OpenGL ES和Metal 2D…...
stack和queue的模拟实现
功能介绍 1.stack stack是栈,它是后进先出,如下图所示: 它是从顶部出数据,从顶部出数据。STL库中提供了几个接口来实现栈。、 它们是: empty判断栈是否为空,返回值是bool。 size是返回栈中的元素个数。…...
【QT】-define (A, B) (quint16)(((A) << 8) | (B)) 分析
不加 quint8 的写法:#define TO_SOURCE(A, B) (quint16)((A << 8) | B) 潜在问题 符号位扩展(如果 A 是负数) 如果 A 是 char 或 int8_t 且为负数(如 0xFF -1),左移 << 8 会导致 符号位扩展&…...
DISTRIBUTED PRIORITIZED EXPERIENCE REPLAY(分布式优先级体验回放)论文阅读
标题:DISTRIBUTED PRIORITIZED EXPERIENCE REPLAY(分布式优先级体验回放) 作者:John Quan, Dan Horgan,David Budden,Gabriel Barth-Maron 单位: DeepMind 发表期刊:Machine Learning 发表时…...
【Qt】QxOrm:下载、安装、使用
1、下载源码 github地址:https://github.com/QxOrm/QxOrm 稳定版本下载:https://github.com/QxOrm/QxOrm/releases/tag/1.5.0 2、编译源码 QxOrm支持cmake编译(CMakeLists.txt)、Qt pro工程编译(QxOrm.pro) 以 QxOrm.pro 为例,编译生成的库,没有在 build-QxOrm-1.5…...