鸿蒙ArkTS---登录逻辑,数据持久化,ArkUI,网络请求等基础内容记录

该内容是在【博学谷】学习过程中的代码记录,如有任何问题请与作者联系。
也欢迎同在学习鸿蒙开发的小伙伴的留言,一同学习,一同进步。
在这里插入图片描述
在这里插入图片描述

功能实现(只记录代码,没有相关配置,跑不起来):

图一的代码:

import { router } from '@kit.ArkUI'@Entry
@Component
struct Index {// 计数器ID,保证计数器关闭时一对一的关系@State Id: number = -1// 页面打开时自动运行的代码(生命周期)onPageShow(): void {// 开启计数器this.Id = setInterval(() => {//页面跳转(需要引入router)router.replaceUrl({url: 'pages/SplashPage'})// 关闭计数器clearInterval(this.Id)}, 500)}build() {// 层叠显示Stack() {Image($r('app.media.todoBg')).width('100%').height('100%')Image($r('app.media.todoLog')).width('10%').height('10%')}.width('100%').height('100%')}
}

图二的代码:

import { common } from '@kit.AbilityKit'
import { router } from '@kit.ArkUI';@Entry
@Component
struct SplashPage {// 计数器ID,保证计数器关闭时一对一的关系@State Id: number = -1// 设置倒计时时间@State time: number = 5// 动画移动的距离(偏移量)@State animationOffset: number = -100;// 获得系统参数(用于国际化)getString(name: Resource) {let context = this.getUIContext().getHostContext() as common.UIAbilityContextlet resMgr = context.resourceManagerlet resId = name.id//获取符合当前系统语言地区、颜色模式、分辨率等配置的资源let currentLanguageString = resMgr.getStringSync(resId)return currentLanguageString}build() {Stack() {// 背景图Image($r('app.media.todoBg')).width('100%').height('100%')Column() {Text(`剩余 ${this.time} 秒`).onAppear(() => {// 开启计时器this.Id = setInterval(() => {// 倒计时this.time--// 倒计时结束if (this.time <= 0) {// 页面跳转router.replaceUrl({url: 'pages/LoginPage'})// 关闭计时器clearInterval(this.Id)}}, 1000)})// 控件展示时候调用(生命周期).onClick(() => {// 页面跳转router.replaceUrl({url: 'pages/LoginPage'})// 关闭计时器clearInterval(this.Id)})// 控件点击时调用.width(80).backgroundColor($r('app.color.start_window_background')).fontSize(15).fontColor($r('app.color.text_color_02')).borderRadius(15).padding(8).position({top: 20,right: -100}) //偏移量(不占原位置)Text(this.getString($r('app.string.splash_content1'))).fontSize(30).fontColor($r('app.color.start_window_background')).onAppear(() => {this.animationOffset = 0}).offset({top: 300,left: this.animationOffset})//偏移量(占原位置).animation({duration: 1000, // 动画播放时长iterations: 1 // 动画播放次数})Text(this.getString($r('app.string.splash_content2'))).fontSize(30).fontColor($r('app.color.start_window_background')).onAppear(() => {this.animationOffset = 0}).offset({top: 300,right: this.animationOffset})//偏移量(占原位置).animation({duration: 1000, // 动画播放时长iterations: 1 // 动画播放次数})Text(this.getString($r('app.string.splash_tips'))).fontColor($r('app.color.start_window_background')).fontSize(15).position({bottom: 10})}.height('100%')}.width('100%').height('100%')}
}

图三图四的代码:

import { common } from '@kit.AbilityKit'
import { http } from "@kit.NetworkKit"
import { router } from '@kit.ArkUI'const req = http.createHttp()interface UserResponse {code: numbermessage: stringdata: User
}interface User {id: numberaccount: stringusername: string
}export let userNameID: string = '' // 导出,其它页面需要userNameID@Entry
@Component
struct LoginPage {//注册用办模态@State isShow: boolean = false//登录用,用户名和密码@State username: string = ''@State password: string = ''@State passwordverification: string = ''getString(name: Resource) {let context = this.getUIContext().getHostContext() as common.UIAbilityContextlet resMgr = context.resourceManagerlet resId = name.id//获取符合当前系统语言地区、颜色模式、分辨率等配置的资源let currentLanguageString = resMgr.getStringSync(resId)return currentLanguageString}// 注册用半模态@BuilderRegisterModal() {Stack() {// 背景图Image($r('app.media.LongBack')).opacity(0.3) //透明度Column() {//输入框TextInput({placeholder: '请输入用户名', // 默认提示text: $$this.username  // 双向绑定username}).type(InputType.Normal)// 控制输入类型 基础.placeholderColor($r('app.color.start_window_background'))// 默认提示文字颜色.fontColor($r('app.color.start_window_background')).showUnderline(true)// 是否显示下横线.border({width: { bottom: 3 },color: $r('app.color.start_window_background')}).padding(10)//输入框TextInput({placeholder: '请输入密码', // 默认提示text: $$this.password // 双向绑定password}).height(48).backgroundColor(Color.Transparent)// 颜色透明.borderRadius(0).type(InputType.Password)// 控制输入类型 密码.placeholderColor($r('app.color.start_window_background')).fontColor($r('app.color.start_window_background')).border({width: { bottom: 3 },color: $r('app.color.start_window_background')}).padding(10)//输入框TextInput({placeholder: this.getString($r('app.string.repeat_password')),text: $$this.passwordverification}).height(48).backgroundColor(Color.Transparent).borderRadius(0).type(InputType.Password).placeholderColor($r('app.color.start_window_background')).fontColor($r('app.color.start_window_background')).border({width: { bottom: 3 },color: $r('app.color.start_window_background')}).padding(10)Text(this.getString($r('app.string.register_button'))).width('100%').fontSize(25).fontColor($r('app.color.start_window_background')).backgroundColor($r('app.color.primary')).textAlign(TextAlign.Center)// 文字居中.padding(10).margin({top: 50}).borderRadius(50).onClick(async () => {if (this.username.length < 8) {AlertDialog.show({message: '用户名最少8位'})return}if (this.password.length < 6) {AlertDialog.show({message: '密码最少6位'})return}if (this.password == this.passwordverification) {// 发送网络请求const res = await req.request('https://hmajax.itheima.net/api/register', {method: http.RequestMethod.POST,header: {contentType: 'application/json'},extraData: {username: this.username,password: this.password}})const userRes = JSON.parse(res.result.toString()) as UserResponse// 默认不会失败(实际应该判断一下失败,通过返回的code)AlertDialog.show({message: userRes.message})this.isShow = false} else {AlertDialog.show({message: '密码输入不一致,请重新输入'})}})}.height('100%').padding(10).justifyContent(FlexAlign.Start) // 整体从上开始排列}}build() {Stack() {Image($r('app.media.LongBack')).opacity(0.7)Column() {// logoImage($r('app.media.startIcon')).width(50).height(50).borderRadius(25).margin({ top: 50 })Row() {Text(this.getString($r('app.string.splash_content1'))).fontColor($r('app.color.start_window_background')).fontSize(15)Text(' ')Text(this.getString($r('app.string.splash_content2'))).fontColor($r('app.color.start_window_background')).fontSize(15)}.margin({ top: 10 })Text(this.getString($r('app.string.account'))).fontColor($r('app.color.start_window_background')).fontSize(30).margin({ top: 30 })Text(this.getString($r('app.string.account_description'))).fontColor($r('app.color.start_window_background')).fontSize(20)//输入框TextInput({placeholder: '请输入用户名',text: $$this.username}).type(InputType.Normal)// 控制输入类型 基础.placeholderColor($r('app.color.start_window_background'))// 默认提示文字颜色.fontColor($r('app.color.start_window_background')).showUnderline(true)// 是否显示下横线.border({width: { bottom: 3 },color: $r('app.color.start_window_background')}).padding(10).margin({ top: 50, left: 10, right: 10 })TextInput({placeholder: '请输入密码',text: $$this.password}).height(48).backgroundColor(Color.Transparent)// 颜色透明.borderRadius(0).type(InputType.Password)// 控制输入类型 密码.placeholderColor($r('app.color.start_window_background')).fontColor($r('app.color.start_window_background')).border({width: { bottom: 3 },color: $r('app.color.start_window_background')}).padding(10).margin({ left: 10, right: 10 })Text(this.getString($r('app.string.login_button'))).width('100%').fontSize(25).fontColor($r('app.color.start_window_background')).backgroundColor($r('app.color.bg_1')).textAlign(TextAlign.Center).padding(10).margin({ top: 50 }).borderRadius(50).onClick(async () => {// 登录逻辑if (this.username.length < 8) {AlertDialog.show({message: '用户名最少8位'})return}if (this.password.length < 6) {AlertDialog.show({message: '密码最少6位'})return}// 发送网络请求const res = await req.request('https://hmajax.itheima.net/api/login', {method: http.RequestMethod.POST,header: {contentType: 'application/json'},extraData: {username: this.username,password: this.password}})const userRes = JSON.parse(res.result.toString()) as UserResponseif (userRes.code == 10000) {this.isShow = false// 同步导出的数据userNameID = userRes.data.usernamerouter.replaceUrl({url: 'pages/MainPage'})} else {AlertDialog.show({message: userRes.message})}})Text(this.getString($r('app.string.register_button'))).width('100%').fontSize(25).fontColor($r('app.color.start_window_background')).backgroundColor($r('app.color.primary')).textAlign(TextAlign.Center).padding(10).margin({ top: 10 }).borderRadius(50).onClick(() => {this.isShow = true}).bindSheet($$this.isShow, this.RegisterModal(), {height: SheetSize.MEDIUM  // 半模态弹出的距离(也就是半模态的大小)}) //半模态Row() {Text(this.getString($r('app.string.privacy_statement'))).fontColor($r('app.color.start_window_background')).fontSize(15)Text('                     ') // 用空格来代替中间的间距(方法不唯一:justifyContent也能实现)Text(this.getString($r('app.string.verification_code_login'))).fontColor($r('app.color.start_window_background')).fontSize(15)}.width('100%').justifyContent(FlexAlign.Center).position({bottom: 50})}.height('100%')}.width('100%').height('100%')}
}

图五图六图七的代码:

import { userNameID } from './LoginPage'
import { router } from '@kit.ArkUI'
import { http } from "@kit.NetworkKit"
import { JSON } from '@kit.ArkTS'const req = http.createHttp()// 我的页面使用
interface UserResponse {message: stringdata: User
}interface User {avatar: stringemail: stringnickname: stringgender: numberdesc: string
}// 知道页面使用
interface DatumResponse {message: stringdata: Datum[]
}interface Datum {cmtcount: number; //新闻评论总数id: number; //新闻idimg: string; //新闻图片地址source: string; //新闻来源time: string; //新闻发布时间title: string; //新闻标题
}// 去做页面使用
interface Thing {time: numberthing: stringisSelected: boolean
}// 数据持久化
let things: Thing[] = []
PersistentStorage.persistProp('things', things)// 数据按时间分组
function classifyByDate(things: Thing[]) {return things.reduce((acc, thing) => {const formattedDate =`${new Date(thing.time).toISOString().split("T")[0]} ${new Date(thing.time).toTimeString().split(":")[0]}:${new Date(thing.time).toTimeString().split(":")[1]}`if (!acc[formattedDate]) {acc[formattedDate] = []}acc[formattedDate].push(thing)return acc}, {} as Record<string, Thing[]>)
}// 修正数据格式用于第二层循环
function formatTheData(time: string, thingTemp: Thing[]) {const thingList: Thing[] = Object.values(classifyByDate(thingTemp)[time]).flat()return thingList
}@Entry
@Component
struct MainPage {// 读取持久化的数据@StorageLink('things')things: Thing[] = []// 待做事件列表同步是否勾选列表(@State实时控制页面展示)@State isSelected: boolean[] = []// 待做事件个数统计,用于我的页面展示@State agentNumber: number = 0// 具体事件@State thingString: string = ''@State user: User = {avatar: '',email: '',nickname: '',gender: 0,desc: ''}@State datums: Datum[] = [{cmtcount: 0, //新闻评论总数id: 0, //新闻idimg: '', //新闻图片地址source: '', //新闻来源time: '', //新闻发布时间title: ''//新闻标题}]// 页面构建前初始化aboutToAppear() {// 获取持久化数据,同步,勾选状态和待做事件个数this.isSelected = this.things.map(thing => thing.isSelected)this.agentNumber = this.things.filter(thing => !thing.isSelected).length}@BuilderListItemGroupHeader(time: string) {Column() {Text(time).fontSize(20).fontColor($r('app.color.text_primary')).backgroundColor($r('app.color.primary')).width('100%').padding(10)}}@BuilderDeleteButton(item: Thing) {Button('删除').width(100).type(ButtonType.Normal).fontColor($r('app.color.start_window_background')).backgroundColor($r('app.color.primary')).onClick(() => {const index = this.things.findIndex(thing => thing.time === item.time)if (index > -1) {this.things.splice(index, 1)this.isSelected.splice(index, 1)}this.agentNumber = this.things.filter(thing => !thing.isSelected).length// AlertDialog.show({//   title: '事件详情',//   message: this.events.reduce((acc, item, index) => {//     return acc +//       `#${index + 1}\n` +//       `名称: ${item.event}\n` +//       `数据: ${item.data}\n` +//       `状态: ${item.isSelected ? '已选中' : '未选中'}\n\n`;//   }, '')// })})}// 去做@BuilderquzuoBuilder() {Scroll() {Column() {Text('去做吧').fontSize(30).fontColor($r('app.color.primary'))Row({ space: 10 }) {TextArea({text: this.thingString,placeholder: '待做...',}).width(230).height(50).fontSize(16).fontColor($r('app.color.start_window_background')).backgroundColor($r('app.color.primary')).placeholderFont({ size: 16, weight: 400 }).placeholderColor($r('app.color.start_window_background')).borderRadius(15).onChange((value: string) => {this.thingString = value;})Text('提交').width(100).height(50).fontSize(16).borderRadius(15).fontColor($r('app.color.start_window_background')).backgroundColor($r('app.color.primary')).textAlign(TextAlign.Center).onClick(() => {// 添加一个带当前时间戳的对象const newThing: Thing = {time: Date.now(),thing: this.thingString,isSelected: false}this.things.push(newThing);this.isSelected.push(newThing.isSelected);this.agentNumber = this.things.filter(event => !event.isSelected).length;})}.margin({ top: 10 })Column() {List({ space: 10 }) {ForEach(Object.keys(classifyByDate(this.things)), (time: string) => {ListItemGroup({header: this.ListItemGroupHeader(time)}) {ForEach(formatTheData(time, this.things), (thingItem: Thing) => {ListItem() {Row() {Checkbox({ group: 'checkboxGroup' }).select(thingItem.isSelected).selectedColor($r('app.color.primary')).shape(CheckBoxShape.ROUNDED_SQUARE).onChange((value: boolean) => {const index = this.things.findIndex(thing => thing.time === thingItem.time);if (index !== -1) {// 安全复制 isSelected 数组const newIsSelected = this.isSelected.slice();newIsSelected[index] = value;// 安全复制 events 数组,更新 isSelected 字段const newThings = this.things.map((thing, i): Thing => ({time: thing.time,thing: thing.thing,isSelected: newIsSelected[i]}));this.things = newThings;this.isSelected = newIsSelected;this.agentNumber = newThings.filter(event => !event.isSelected).length;}})Text(thingItem.thing).width('100%').fontSize(20).fontColor(this.isSelected[this.things.findIndex(item => item.time === thingItem.time)] ?$r('app.color.text_color_03') : $r('app.color.primary')).decoration({type: this.isSelected[this.things.findIndex(item => item.time === thingItem.time)] ?TextDecorationType.LineThrough : TextDecorationType.None,color: $r('app.color.text_color_03')})}.padding(10)}.transition({ type: TransitionType.Delete, opacity: 0 }).swipeAction({end: {builder: () => {this.DeleteButton(thingItem)},actionAreaDistance: 56,}})})}})}}.padding(10)}.justifyContent(FlexAlign.Start)}.height('100%').align(Alignment.TopStart)}// 知道@BuilderzhidaoBuilder() {Scroll() {Column({ space: 15 }) {ForEach(this.datums, (datum: Datum) => {Row() {Column() {Text(datum.title).width(200).fontSize(25).textOverflow({ overflow: TextOverflow.Ellipsis })// 文字溢出.maxLines(2) // 最大行数Row() {Row() {Text(datum.source).width(50).fontSize(15).textOverflow({ overflow: TextOverflow.Ellipsis })// 文字溢出.maxLines(1) // 最大行数Text('|').width(3).fontSize(15)Text(datum.cmtcount.toString()).width(30).fontSize(15)}Text(datum.time).width(80).fontSize(15).textOverflow({ overflow: TextOverflow.Ellipsis })// 文字溢出.maxLines(1) // 最大行数}.width(200).justifyContent(FlexAlign.SpaceBetween)}.height(100).justifyContent(FlexAlign.SpaceBetween)Image(datum.img).width(100).height(100)}.width('100%').height(100).justifyContent(FlexAlign.SpaceBetween).padding(20)})}}.width('100%').height('100%')}// 我的@BuilderwodeBuilder() {Stack() {Image($r('app.media.LongBack')).opacity(0.7)Column({ space: 10 }) {Column() {Image(this.user.avatar).width(40).height(40).offset({ top: -30 })Text(this.user.nickname)Text(this.user.email)Text(`还有${this.agentNumber}条代办事项`)}.width('90%').height(200).backgroundColor($r('app.color.start_window_background')).opacity(0.7).alignItems(HorizontalAlign.Center).borderRadius(30).justifyContent(FlexAlign.SpaceAround).margin({ top: 50 })Column() {Row() {Text('用户昵称')Text(this.user.nickname)}.width('90%').justifyContent(FlexAlign.SpaceBetween)Text().width('90%').height(1).backgroundColor($r('app.color.primary'))Row() {Text('用户性别')Text(this.user.gender == 0 ? '男' : '女')}.width('90%').justifyContent(FlexAlign.SpaceBetween)Text().width('90%').height(1).backgroundColor($r('app.color.primary'))Row() {Text('用户简介')Text(this.user.desc)}.width('90%').justifyContent(FlexAlign.SpaceBetween)}.width('90%').height(150).backgroundColor($r('app.color.start_window_background')).opacity(0.7).alignItems(HorizontalAlign.Center).borderRadius(30).justifyContent(FlexAlign.SpaceAround).padding(10)Text('修改用户信息').width('90%').height(50).backgroundColor($r('app.color.start_window_background')).opacity(0.7).borderRadius(30).textAlign(TextAlign.Center).onClick(() => {// 添加跳转逻辑router.pushUrl({url: 'pages/UserPage',})})Text('退出登录').width('90%').height(50).backgroundColor($r('app.color.start_window_background')).opacity(0.7).borderRadius(30).textAlign(TextAlign.Center).onClick(() => {// 添加跳转逻辑router.replaceUrl({url: 'pages/SplashPage',})})}.width('100%').height('100%')}}async getUser() {const res = await req.request('https://hmajax.itheima.net/api/settings?creator=' + userNameID)const userRes = JSON.parse(res.result.toString()) as UserResponsethis.user = userRes.data}async getDatums() {const res = await req.request('https://hmajax.itheima.net/api/news')const datumRes = JSON.parse(res.result.toString()) as DatumResponsethis.datums = datumRes.data}onPageShow(): void {this.getDatums()this.getUser()}@BuildertabTitleBuilder(url: string, text: string) {Column() {Image($r(url)).width(40)Text(text).fontColor($r('app.color.primary'))}}build() {Tabs() {TabContent() {this.quzuoBuilder()}.tabBar(this.tabTitleBuilder('app.media.go', '去做'))TabContent() {this.zhidaoBuilder()}.tabBar(this.tabTitleBuilder('app.media.zhidao', '知道'))TabContent() {this.wodeBuilder()}.tabBar(this.tabTitleBuilder('app.media.wode', '我的'))}.barPosition(BarPosition.End).barBackgroundColor(Color.White).barHeight(80).divider({ strokeWidth: 2 })}
}

图八的代码:

import { userNameID } from './LoginPage'
import { http } from "@kit.NetworkKit"
import { router } from '@kit.ArkUI'const req = http.createHttp()interface UserResponse {message: stringdata: User
}interface User {avatar: stringemail: stringnickname: stringgender: numberdesc: string
}@Entry
@Component
struct UserPage {@State userAvatar: string = ''@State userEmail: string = ''@State userName: string = ''@State userGender: number = 0@State userGenderString: string = ''@State userDesc: string = ''async onPageShow() {const res = await req.request('https://hmajax.itheima.net/api/settings?creator=' + userNameID) // userName唯一标识const userRes = JSON.parse(res.result.toString()) as UserResponsethis.userAvatar = userRes.data.avatarthis.userEmail = userRes.data.emailthis.userName = userRes.data.nicknamethis.userGender = userRes.data.genderthis.userGenderString = this.userGender == 0 ? "男" : '女'this.userDesc = userRes.data.desc}build() {Column() {Image($r('app.media.fanhuijiantou')).width(20)// 通过宽度自动修正高度.position({ left: 10 }).onClick(() => {// 返回上一页router.back()})// 头像Image(this.userAvatar).width(50).height(50).margin({ top: 100 })Row({ space: 10 }) {Text('用户昵称:').fontSize(20)TextInput({placeholder: this.userName,text: $$this.userName}).width(200).placeholderColor($r('app.color.base_blake')).fontColor($r('app.color.base_blake')).border({width: { bottom: 1 },color: $r('app.color.base_blake')}).showUnderline(true).padding(0)}.width('90%').margin({ top: 30 })Row({ space: 10 }) {Text('用户性别:').fontSize(20)Select([{ value: '男' },{ value: '女' }]).width(200).font({ size: 16, weight: 500 })// 设置字体大小和粗细.fontColor($r('app.color.base_blake')).backgroundColor($r('app.color.bg_primary')).value(this.userGenderString)// 选中的展示的内容.selected(this.userGender)// 下拉选择列表中选中的内容(从0开始).selectedOptionFont({ size: 16, weight: 500 })// 设置选中的字体大小和粗细.optionFont({ size: 16, weight: 500 })// 设置未选中的字体大小和粗细.optionWidth(200)// 设置下拉选项的宽度.optionHeight(300)// 设置下拉选项的高度(支持滑动).menuAlign(MenuAlignType.START, { dx: 0, dy: 0 })// 设置展示框和下拉框的位置关系(居左/居中/居右)和 偏移量.onSelect((index: number, text?: string | undefined) => {this.userGender = index;if (text) {this.userGenderString = text;}})}.width('90%').margin({ top: 30 })Text('用户简介:').fontSize(20).width('90%').margin({ top: 30 })TextArea({text: this.userDesc}).fontSize(16).fontColor($r('app.color.base_blake')).backgroundColor($r('app.color.bg_primary')).placeholderFont({ size: 16, weight: 400 }).width('90%').height(100).margin(10).onChange((value: string) => {this.userDesc = value;}) //数据实时反馈Text('确定修改').width('90%').fontSize(25).fontColor($r('app.color.start_window_background')).backgroundColor($r('app.color.primary')).textAlign(TextAlign.Center).padding(10).borderRadius(50).onClick(async () => {// 1. 非空判断if (this.userName == '' || this.userDesc == '') {AlertDialog.show({message: '信息不能为空,请检查哦~ ღ( ´・ᴗ・` )比心'})return}const res = await req.request(`https://hmajax.itheima.net/api/settings`, {method: http.RequestMethod.PUT,header: {contentType: 'application/json'},extraData: {creator: userNameID,email: this.userEmail,nickname: this.userName,gender: this.userGender,desc: this.userDesc}})const addRes = JSON.parse(res.result.toString()) as UserResponseAlertDialog.show({message: addRes.message})router.back()}).margin({ top: 10 })}.width('100%').height('100%')}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.tpcf.cn/bicheng/86218.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

没有公网ip可以实现跨网p2p互通吗?内网让公网直连访问常用工具

没有公网IP的情况下仍然可以实现P2P通信&#xff0c;但需要借助NAT穿透技术或类似nat123同端口映射等第三方工具实现内网穿透‌。‌‌‌‌ 一、什么是P2P通信&#xff1f; P2P网络&#xff08;Peer-to-Peer Network&#xff09;是一种去中心化的网络架构&#xff0c;其中每个…

云服务器安装宝塔面板(BT Panel)

安装宝塔面板&#xff08;BT Panel&#xff09;是很多服务器管理员常用的操作&#xff0c;尤其适合用于管理网站、数据库、FTP等。以下是基于 Linux 系统&#xff08;推荐 CentOS 或 Ubuntu&#xff09;的宝塔面板安装步骤。 安装前准备 云服务器一台 可以订购服务器 海外云主…

mongoose解析http字段值

最近在使用mongoose开发嵌入式web后端时&#xff0c;会遇到要解析js前端发送过来的http消息&#xff0c;比如传递用户名&#xff0c;密码过来&#xff0c;后端要解析出来并判断是否登录成功。 前端http有两种组装字段的方式。 第一种是 $.ajax({url: /upgradePackage,method: P…

高德地图地址解析获取经纬度失败原因JSAPI

高德地图地址解析获取经纬度失败原因JSAPI 地图加载的时候老是报异常码&#xff0c;地图是可以加载出来的&#xff0c;但是在地图上的操作老是有异常码&#xff0c;找了好久不知道什么问题&#xff0c;异常码会报两种&#xff0c;一种是说什么key的问题&#xff0c;但是我当时…

极速JavaScript:全面性能优化实战指南

在现代Web开发中&#xff0c;JavaScript性能直接影响用户体验。一个优化良好的应用能带来更流畅的交互、更快的加载速度和更低的资源消耗。本文将深入探讨实用的JavaScript性能优化技术&#xff0c;帮助您打造高性能Web应用。 一、性能瓶颈分析与诊断工具 性能问题的常见来源&…

【开源模型】高考数学139分!小米MiMo开源模型:7B参数突出重围

小米 MiMo&#xff1a;7 B 参数撬动推理巅峰&#xff0c;开源模型的技术突围 70 亿参数超越 320 亿对手&#xff0c;高考数学 139 分的背后是训练策略的全面革新。 2025 年 4 月 30 日&#xff0c;小米开源的首个推理大模型 Xiaomi MiMo-7 B 横空出世&#xff0c;以​​仅 7 B …

用vscode破解最新typora1.10.8

1.下载格式化插件防止打开文件一团乱 1&#xff09;下载vscode&#xff1a; Download Visual Studio Code - Mac, Linux, Windows 2&#xff09;vscode下载中文插件重启 如果没变中文&#xff0c;在vscode界面按下&#xff1a; ctrl shift p 调出命令行 再输入&#xff…

在 CI/CD 流程中使用 Jenkins 与 Docker 集成

在 CI/CD 流程中&#xff0c;Jenkins 与 Docker 的集成可以实现自动构建、测试、打包、发布容器镜像&#xff0c;并部署到测试/生产环境。下面是从概念到落地操作的完整集成方案。 一、常见的集成方式有哪些&#xff1f; 方式描述1️⃣ Jenkins 主机安装 DockerJenkins 可以直…

闲庭信步使用SV搭建图像测试平台:第十课——继续说说类

&#xff08;本系列只需要modelsim即可完成数字图像的处理&#xff0c;每个工程都搭建了全自动化的仿真环境&#xff0c;只需要双击top_tb.bat文件就可以完成整个的仿真&#xff0c;大大降低了初学者的门槛&#xff01;&#xff01;&#xff01;&#xff01;如需要该系列的工程…

如何改进复杂推理 - 从提示词设计入手

引言&#xff08;动机&#xff09; 在使用大语言模型&#xff08;如 GPT-4、Claude、DeepSeek 等&#xff09;构建智能问答、辅助决策或复杂任务代理系统时&#xff0c;可能遇到这些问题&#xff1a; 模型回答跳步骤、思路混乱同样问题&#xff0c;模型表现高度不稳定新任务一…

如何解决和各个经销商不同软件对接的问题?汤臣案例分享

一、项目背景 汤臣倍健作为健康产品行业的领军企业&#xff0c;其营销云系统与全国经销商 ERP 系统的数据无缝对接&#xff0c;对于提升业务运营效率和营销精准度至关重要。传统数据集成方法在面对经销商 ERP 系统的多样性和复杂性时&#xff0c;暴露出诸多问题&#xff0c;如…

Wordvice AI:Wordvice 推出的免费,基于先进的 AI 技术帮助用户提升英文写作质量

Wordvice AI&#xff1a;智能写作助手&#xff0c;助力高效英文写作 在当今全球化时代&#xff0c;英文写作已成为众多学生、研究人员、职场人士必备技能。然而&#xff0c;语法错误、表达不流畅、词汇匮乏等问题常困扰着大家。别担心&#xff0c;今天就来给大家介绍一款强大的…

【UE5】如何开发安卓项目的udp客户端

1关于如何打包安卓项目这里就不赘述了 2代码举例。最重要的就是这两句 #if PLATFORM_ANDROID #endif#if PLATFORM_WINDOWS #endif全部代码如下&#xff1a; Button_Sheng.h: // Fill out your copyright notice in the Description page of Project Settings.#pragma once#in…

2025年6月21和22日复习和预习(python)

一、作业内容 &#xff08;一&#xff09;知识点回顾 用户输入处理 使用input()函数获取用户输入的字符串&#xff0c;并存储到变量中。 条件判断语句 if-elif-else结构&#xff1a;根据不同条件执行相应代码块&#xff0c;适用于多分支判断。 语音合成技术 导入pyttsx3库实现…

Vue 样式穿透语法大全(涵盖 Vue2、Vue3、Less、Scss 等)

1. 什么是样式穿透&#xff1f; 样式穿透是在使用 Vue 组件时&#xff0c;为了修改子组件或第三方组件的样式而使用的一种特殊语法。当我们使用 scoped 样式时&#xff0c;由于样式被限制在当前组件内&#xff0c;要修改子组件的样式就需要使用样式穿透。 2. 为什么需要样式穿…

Python 属性查找:深入理解__getattribute__与__getattr__

目录 一、__getattribute__方法详解 1.1 基本概念 1.2 示例分析 1.3 注意事项 二、__getattr__方法详解 2.1 基本概念 2.2 示例分析 2.3 注意事项 三、__getattribute__与__getattr__的区别对比 3.1 调用时机 3.2 应用场景 3.3 性能影响 四、属性查找顺序 属性查找…

打表法从原理到实战详解

打表法结合经典案例从原理到实战详解 一、打表法基本信息1.1 打表法定义1.2 打表法适用场景1.3 打表法的优缺点 二、打表法经典案例解析2.1 快速计算斐波那契数列2.1.1 问题描述2.1.2 打表思路2.1.3 Java代码实现2.1.4 复杂度分析 2.2 快速判断质数&#xff08;埃氏筛法结合打表…

(LeetCode 面试经典 150 题 )121. 买卖股票的最佳时机 (遍历)

题目&#xff1a;121. 买卖股票的最佳时机 思路&#xff1a;遍历&#xff0c;维护已遍历过的元素中的最小值&#xff0c;时间复杂度0(n)。 C版本&#xff1a; class Solution { public:int maxProfit(vector<int>& prices) {int mnprices[0];int mx0;for(int i1;i&…

(洛谷)P4447 [AHOI2018初中组] 分组

题目描述 小可可的学校信息组总共有 n 个队员&#xff0c;每个人都有一个实力值 ai​。现在&#xff0c;一年一度的编程大赛就要到了&#xff0c;小可可的学校获得了若干个参赛名额&#xff0c;教练决定把学校信息组的 n 个队员分成若干个小组去参加这场比赛。 但是每个队员都…

PLA/PHA生物降解化妆品包装材料的稳定性与货架期契合性研究

更多案例&#xff1a;https://npmatc.niicapm.com/ 在可持续发展理念的推动下&#xff0c;化妆品行业正经历一场绿色变革。环保聚合物在包装领域的应用已成为重要趋势&#xff0c;这不仅源于消费者对生态友好产品的需求&#xff0c;更基于全球塑料污染治理的紧迫性。化妆品包装…