【HarmonyOS NEXT星河版开发实战】天气查询APP

news/2024/9/18 14:45:19/ 标签: harmonyos, 华为, 学习, 星河版, 开源, gitee

目录

前言

界面效果展示

首页

添加和删除 

界面构建讲解

1. 获取所需数据

 2. 在编译器中准备数据

 3. index页面代码讲解

  3.1 导入模块:

 3.2 定义组件:

3.3 定义状态变量:

3.4  定义Tabs控制器:

3.5 定义按钮样式:

 3.6 页面显示时触发的方法:

 3.7 获取数据的方法:

3.8  初始化数据的方法:

 3.9 构建UI:

4. AddCity页面代码讲解

   4.1 导入模块:

   4.2 定义组件:

   4.3 定义状态变量:

   4.4 接受数据的载体:

   4.5 页面显示时触发的方法:

   4.6 构建UI:

 5. getWeather页面代码讲解

  5.1 导入模块:

  5.2 定义类:

  5.3 定义方法 getWeather:

  5.4 定义方法 getWeathers:

  5.5 实例化并导出类:

全套源代码展示

AddCity 

Index

getWeather

casts

cityView

forecasts

WeatherModel


 

个人主页→VON

收录专栏→鸿蒙综合案例开发​​​​​

代码及其图片资源会发布于gitee上面(已发布)

gitee地址icon-default.png?t=N7T8https://gitee.com/wang-xin-jie234/harmony-os

 

​ 

前言

基础部分如今已经学完,可能有些东西并不是太了解,在练习实战项目的过程中也是一个不断学习的过程,因为实战项目复杂代码量较大,所以写的时候要及其认真,一个小的错误可能会花费几小时的时间去寻找bug。所以在学习的过程中要十分严谨,希望大家可以跟着我的思路独自完成天气查询app这一项目。

界面效果展示

首页

 首页包括添加删除天气的功能,还有近五天天气的展示,以及温度的展示。

添加和删除 

 

添加城市列表是本地进行导入的,如果有需要可以将想要的城市自行导入进去,添加完城市点击完成会跳转到首页进行渲染展示。删除功能,点击确定的时候改城市的信息会被删除。 

界面构建讲解

1. 获取所需数据

因为天气的数据需要我们联网去获取,所以要去调用天气的API。

我这里用的是高德开放平台,没有注册过的要先进行账号的注册。

注:必须要进行账号注册,后面要用到我们个人的Key值,每个用户都不一样。 

拿到key之后在浏览器上输入服务示例+key+extensions=all 

 2. 在编译器中准备数据

​ 

 3. index页面代码讲解

  3.1 导入模块

import getweatherutil from '../util/getWeather'
import { cityView } from '../view/cityView'
import {WeatherModel} from '../view/WeatherModel'
import router from '@ohos.router'

 3.2 定义组件

@Entry
@Component
struct Index {

3.3 定义状态变量:

// 城市代码集合
@State cityCoeList: number[] = [110000, 120000]
// 城市名字集合
@State cityNameList: string[] = []
// 城市信息集合
@State cityWeatherList: Array<WeatherModel> = []
// 当前城市索引
@State cityIndex: number = 0

3.4  定义Tabs控制器:

tabController: TabsController = new TabsController()

3.5 定义按钮样式

@Builder tabBuild(index: number) {Circle({ width: 10, height: 10 }).fill(this.cityIndex === index ? Color.White : Color.Gray).opacity(0.4)
}

 3.6 页面显示时触发的方法

onPageShow() {let params = router.getParams()if (params !== null) {this.cityCoeList = params['codes']// 清空所有数据this.cityWeatherList = []this.cityNameList = []this.initDate()}
}

 3.7 获取数据的方法

aboutToAppear() {this.initDate()
}

3.8  初始化数据的方法

async initDate() {let result: Array<WeatherModel> = await getweatherutil.getWeathers(this.cityCoeList)for (let i = 0; i < result.length; i++) {// 城市天气let ACityWeather = new WeatherModel()ACityWeather = result[i]this.cityWeatherList.push(ACityWeather)// 城市名称let cityname = result[i].forecasts[0].citythis.cityNameList.push(cityname)}
}

 3.9 构建UI

build() {Column() {Row() {Button('添加').fontSize(25).fontColor(Color.Gray).backgroundColor('#00ffffff').onClick(() => {router.pushUrl({url: "pages/AddCity",params: {codes: this.cityCoeList,names: this.cityNameList}})})Text(this.cityNameList[this.cityIndex]).fontSize(40).fontColor(Color.Orange)Button('删除').fontSize(25).fontColor(Color.Gray).backgroundColor('#00ffffff').onClick(() => {AlertDialog.show({title: '删除',message: `你确定要删除${this.cityNameList[this.cityIndex]}吗?`,confirm: {value: '确定',action: () => {this.cityNameList = this.cityNameList.filter(item => item !== this.cityNameList[this.cityIndex])this.cityCoeList = this.cityCoeList.filter(item => item !== this.cityCoeList[this.cityIndex])this.cityWeatherList = this.cityWeatherList.filter(item => item !== this.cityWeatherList[this.cityIndex])}}})})}.width('100%').height('10%').justifyContent(FlexAlign.SpaceBetween)Tabs({ barPosition: BarPosition.Start, controller: this.tabController }) {ForEach(this.cityWeatherList, (cityWeather: WeatherModel) => {TabContent() {cityView({ casts: cityWeather.forecasts[0].casts })}.tabBar(this.tabBuild(this.cityWeatherList.findIndex((obj => obj === cityWeather))))})}.barWidth(40).barHeight(40).onChange((index: number) => {this.cityIndex = index})}.width('100%').height('100%').backgroundImage($r('app.media.weather_background')).backgroundImageSize({ width: '100%', height: '100%' }).backgroundImagePosition({ x: 0, y: 0 })
}

4. AddCity页面代码讲解

   4.1 导入模块

import router from '@ohos.router'

   4.2 定义组件

@Entry
@Component
struct AddCity {

   4.3 定义状态变量

// 所有城市的代码列表
@State AllCityCodeList: Array<number> = [410100, 410200, 410300, 410400, 410500, 410600, 410700, 410800, 410900, 411000, 411200, 411300, 411400, 411500, 411600, 411700
]
// 所有城市的名称列表
@State AllCityNameList: Array<string> = ['郑州市', '开封市', '洛阳市', '平顶山市', '安阳市', '鹤壁市', '新乡市', '焦作市', '濮阳市', '许昌市', '三门峡市', '南阳市', '商丘市', '信阳市', '周口市', '驻马店市'
]

   4.4 接受数据的载体

@State cityCodeList: number[] = []
@State cityNameList: string[] = []

   4.5 页面显示时触发的方法

onPageShow() {let param = router.getParams()this.cityCodeList = param['codes']this.cityNameList = param['names']
}

   4.6 构建UI

build() {Column() {Row() {Text('添加城市列表').fontSize(35).fontColor(Color.White)Blank()Button('完成').fontSize(26).backgroundColor("").onClick(() => {router.back({url: 'pages/Index',params: {codes: this.cityCodeList,names: this.AllCityNameList}})})}.height('10%').width('95%')Column() {List() {ForEach(this.AllCityNameList, (name: string) => {ListItem() {if (this.cityNameList.includes(name)) {Column() {Row() {Text(name).fontSize(35).fontColor(Color.White).width('60%').margin({ top: 20, left: 30 })Blank()Text('已添加').backgroundColor('').fontSize(18).margin({ top: 5 }).opacity(0.8)}.width('100%')Blank()Divider().strokeWidth(5)}.height(90).width('100%').margin({ top: 20 }).backgroundColor('#ff4a93c6')} else {Column() {Row() {Text(name).fontSize(35).fontColor(Color.White).width('60%').margin({ top: 20, left: 30 })Blank()Button('添加').margin({ right: 5 }).backgroundColor("").onClick(() => {// 根据name来获取索引let index = this.AllCityNameList.findIndex(obj => obj === name)// 根据索引获取城市编码let cityCode: number = this.AllCityCodeList[index]// 将城市编码加入列表this.cityCodeList.push(cityCode)this.cityNameList.push(name)})}.width('100%')Blank()Divider().strokeWidth(5)}.height(90).width('100%').margin({ top: 20 })}}})}}}.width('100%').height('100%').backgroundImage($r('app.media.weather_background')).backgroundImageSize({ width: '100%', height: '100%' }).backgroundImagePosition({ x: 0, y: 0 })
}

 5. getWeather页面代码讲解

  5.1 导入模块

import { WeatherModel } from '../view/WeatherModel'
import http from '@ohos.net.http'

  5.2 定义类

class getWeatherUtil {

  5.3 定义方法 getWeather

// 发送一个url,返回对应的数据
getWeather(cityCode: number): Promise<WeatherModel> {return new Promise<WeatherModel>((resolve, reject) => {let request = http.createHttp()let url = `https://restapi.amap.com/v3/weather/weatherInfo?city=${cityCode}&key=57b5118aed53d7a188874fc44256a0b8&extensions=all`let result = request.request(url)result.then((res) => {if (res.responseCode === 200) {console.log(res.result.toString());resolve(JSON.parse(res.result.toString()))}}).catch((err) => {console.log(err)reject(err)})})
}

  5.4 定义方法 getWeathers

// 直接发送多个url结果一并返回
async getWeathers(cityCodes: Array<number>): Promise<Array<WeatherModel>> {let promises: Array<Promise<WeatherModel>> = []let weatherModels: Array<WeatherModel> = []for (let i = 0; i < cityCodes.length; i++) {promises.push(this.getWeather(cityCodes[i]))}await Promise.all(promises).then(result => {for (const element of result) {console.log(element.forecasts[0].city)}weatherModels = result}).catch((err) => {console.log(err)})return weatherModels
}

  5.5 实例化并导出类

let getweatherutil = new getWeatherUtil()
export default getweatherutil as getWeatherUtil

 getWeather  方法

  • 该方法接受一个城市代码 cityCode,并返回一个 Promise<WeatherModel>
  • 创建一个 HTTP 请求对象 request
  • 构建请求 URL,包含城市代码和 API 密钥。
  • 发送 HTTP 请求并处理响应。
  • 如果响应码为 200,解析响应结果并返回 WeatherModel 对象。
  • 如果发生错误,捕获并记录错误。

 getWeat hers 方法

  • 该方法接受一个城市代码数组 cityCodes,并返回一个 Promise<Array<WeatherModel>>
  • 创建一个空数组 promises 用于存储每个城市天气请求的 Promise。
  • 遍历 cityCodes,为每个城市代码调用 getWeather 方法,并将返回的 Promise 添加到 promises 数组中。
  • 使用 Promise.all 等待所有请求完成,并处理结果。
  • 遍历结果数组,记录每个城市的名称。
  • 将结果赋值给 weatherModels 数组并返回。
  • 如果发生错误,捕获并记录错误。

全套源代码展示

AddCity 

import router from '@ohos.router'@Entry
@Component
struct AddCity {@State AllCityCodeList:Array<number>=[410100,410200,410300,410400,410500,410600,410700,410800,410900,411000,411200,411300,411400,411500,411600,411700]@State AllCityNameList:Array<string>=['郑州市','开封市','洛阳市','平顶山市','安阳市','鹤壁市','新乡市','焦作市','濮阳市','许昌市','三门峡市','南阳市','商丘市','信阳市','周口市','驻马店市']// 接受数据的载体@State cityCodeList:number[]=[]@State cityNameList:string[]=[]onPageShow(){let param=router.getParams()this.cityCodeList=param['codes']this.cityNameList=param['names']}build() {Column(){Row(){Text('添加城市列表').fontSize(35).fontColor(Color.White)Blank()Button('完成').fontSize(26).backgroundColor("").onClick(()=>{router.back({url:'pages/Index',params:{codes:this.cityCodeList,names:this.AllCityNameList}})})}.height('10%').width('95%')Column(){List(){ForEach(this.AllCityNameList,(name:string)=>{ListItem(){if(this.cityNameList.includes(name)){Column(){Row(){Text(name).fontSize(35).fontColor(Color.White).width('60%').margin({top:20,left:30})Blank()Text('已添加').backgroundColor('').fontSize(18).margin({top:5}).opacity(0.8)}.width('100%')Blank()Divider().strokeWidth(5)}.height(90).width('100%').margin({top:20}).backgroundColor('#ff4a93c6')}else{Column(){Row(){Text(name).fontSize(35).fontColor(Color.White).width('60%').margin({top:20,left:30})Blank()Button('添加').margin({right:5}).backgroundColor("").onClick(()=>{// 根据name来获取索引let index=this.AllCityNameList.findIndex(obj=>obj===name)// 根据索引获取城市编码let cityCode:number=this.AllCityCodeList[index]// 将城市编码加入列表this.cityCodeList.push(cityCode)this.cityNameList.push(name)})}.width('100%')Blank()Divider().strokeWidth(5)}.height(90).width('100%').margin({top:20})}}})}}}.width('100%').height('100%').backgroundImage($r('app.media.weather_background')).backgroundImageSize({width:'100%',height:'100%'}).backgroundImagePosition({x:0,y:0})}
}

Index

import getweatherutil from '../util/getWeather'
import { cityView } from '../view/cityView'
import {WeatherModel} from '../view/WeatherModel'
import router from '@ohos.router'@Entry
@Component
struct Index {// 城市代码集合@State cityCoeList:number[] =[110000,120000]// 城市名字集合@State cityNameList:string[]=[]// 城市信息集合@State cityWeatherList:Array<WeatherModel>=[]// 当前城市索引@State cityIndex:number=0tabController:TabsController=new TabsController()// 按钮样式@Builder tabBuild(index:number){Circle({width:10,height:10}).fill(this.cityIndex===index?Color.White:Color.Gray).opacity(0.4)}onPageShow(){let params=router.getParams()if(params!==null){this.cityCoeList=params['codes']// 清空所有数据this.cityWeatherList=[]this.cityNameList=[]this.initDate()}}// 获取数据aboutToAppear(){this.initDate()}// 初始化方法async initDate(){let result:Array<WeatherModel> =await getweatherutil.getWeathers(this.cityCoeList)for (let i = 0; i < result.length; i++) {// 城市天气let ACityWeather=new WeatherModel()ACityWeather=result[i]this.cityWeatherList.push(ACityWeather)// 城市名称let cityname=result[i].forecasts[0].citythis.cityNameList.push(cityname)}}build() {Column(){Row(){Button('添加').fontSize(25).fontColor(Color.Gray).backgroundColor('#00ffffff').onClick(()=>{router.pushUrl({url:"pages/AddCity",params:{codes:this.cityCoeList,names:this.cityNameList}})})Text(this.cityNameList[this.cityIndex]).fontSize(40).fontColor(Color.Orange)Button('删除').fontSize(25).fontColor(Color.Gray).backgroundColor('#00ffffff').onClick(()=>{AlertDialog.show({title:'删除',message:`你确定要删除${this.cityNameList[this.cityIndex]}吗?`,confirm:{value:'确定',action:()=>{this.cityNameList=this.cityNameList.filter(item=>item!==this.cityNameList[this.cityIndex])this.cityCoeList=this.cityCoeList.filter(item=>item!==this.cityCoeList[this.cityIndex])this.cityWeatherList=this.cityWeatherList.filter(item=>item!==this.cityWeatherList[this.cityIndex])}}})})}.width('100%').height('10%').justifyContent(FlexAlign.SpaceBetween)Tabs({barPosition:BarPosition.Start,controller:this.tabController}){ForEach(this.cityWeatherList,(cityWeather:WeatherModel)=>{TabContent(){cityView({casts:cityWeather.forecasts[0].casts})}.tabBar(this.tabBuild(this.cityWeatherList.findIndex((obj=>obj===cityWeather))))})}.barWidth(40).barHeight(40).onChange((index:number)=>{this.cityIndex=index})}.width('100%').height('100%').backgroundImage($r('app.media.weather_background')).backgroundImageSize({width:'100%',height:'100%'}).backgroundImagePosition({x:0,y:0})}
}

getWeather

import {WeatherModel} from '../view/WeatherModel'
import http from '@ohos.net.http'class getWeatherUtil{// 发送一个url,返回对应的数据getWeather(cityCode:number){return new Promise<WeatherModel>((resolve,reject)=>{let request=http.createHttp()let url=`https://restapi.amap.com/v3/weather/weatherInfo?city=${cityCode}&key=57b5118aed53d7a188874fc44256a0b8&extensions=all`let result=request.request(url)result.then((res)=>{if(res.responseCode===200){console.log(res.result.toString());resolve(JSON.parse(res.result.toString()))}}).catch((err)=>{console.log(err)})})}// 直接发送多个url结果一并返回async getWeathers(cityCodes:Array<number>){let promises:Array<Promise<WeatherModel>>=[]let weatherModels:Array<WeatherModel>=[]for (let i = 0; i < cityCodes.length; i++) {promises.push(this.getWeather(cityCodes[i]))}await Promise.all(promises).then(result=>{for(const element of result){console.log(element.forecasts[0].city)}weatherModels=result})return weatherModels}
}let getweatherutil=new getWeatherUtil()
export default getweatherutil as getWeatherUtil

casts

export class casts{date:stringdayweather:stringnightweather:stringdaytemp:numbernighttemp:numberdaywind:stringdaypower:stringdaytemp_float:numbernighttemp_float:number
}

cityView

import {casts} from '../view/casts'@Component
export struct cityView {// 获取数据// 城市天气数据casts:Array<casts>=[]@Builder weartherImage(weather:string){if(weather==='晴'){Image($r('app.media.sun')).width(23)}if(weather==='阴'){Image($r('app.media.cloudy')).width(30)}if(weather==='多云'){Image($r('app.media.cloudy')).width(30)}if(weather.includes('雨')){Image($r('app.media.rain')).width(30)}}// 展示数据build() {Column(){// 当天天气数据ForEach(this.casts,(cast:casts)=>{if(this.casts[0]===cast){// 展示天气所对应图片Row(){if(cast.dayweather==='晴'){Image($r('app.media.sun')).width(250)}if(cast.dayweather==='阴'){Image($r('app.media.cloudy')).width(250)}if(cast.dayweather==='多云'){Image($r('app.media.cloudy')).width(250)}if(cast.dayweather.includes('雨')){Image($r('app.media.rain')).width(300)}}Column(){// 温度天气Row(){Text(cast.dayweather).fontSize(30).fontColor(Color.White).fontWeight(700)Text("  "+cast.nighttemp+"°~"+cast.daytemp+"°").fontSize(30).fontColor(Color.White).fontWeight(700)}Row(){Text(cast.daywind+"风").fontSize(30).fontColor(Color.White).fontWeight(700)Text(cast.daypower+"级").fontSize(30).fontColor(Color.White).fontWeight(700)}}}})// 近期天气数据Column(){Text('近期天气查询').fontSize(26).margin({top:30,bottom:15})// 天气列表Row(){ForEach(this.casts,(cast:casts)=>{Column(){Text(cast.date.substring(5))this.weartherImage(cast.dayweather)Text(cast.daytemp.toString())Line().width(20).height(80).startPoint([10,0]).endPoint([10,70]).stroke(Color.Black).strokeWidth(3).strokeDashArray([10,3])this.weartherImage(cast.nightweather)Text(cast.nighttemp.toString())}.margin(5)})}}}.width('100%').height('100%')}
}

forecasts

import {casts} from '../view/casts'export class forecasts{city:stringadcode:numbercasts:Array<casts>
}

WeatherModel

import {forecasts} from './forecasts'export class WeatherModel{status:numbercount:numberinfocode:numberforecasts:Array<forecasts>=[]
}

http://www.ppmy.cn/news/1516723.html

相关文章

Java核心API——Collection集合的工具类Collections

集合的排序 int类型的排序 * 集合的排序 * java.util.Collections是集合的工具类&#xff0c;提供了很多static方法用于操作集合 * 其中提供了一个名为sort的方法&#xff0c;可以对List集合进行自然排序(从小到大) List<Integer> list new ArrayList<>();Rand…

96页PPT集团战略解码会工具与操作流程

德勤集团在战略解码过程中通常会用到以下一些具体工具&#xff1a; 一、平衡计分卡&#xff08;Balanced Scorecard&#xff09; 财务维度&#xff1a; 明确关键财务指标&#xff0c;如营业收入、利润、投资回报率等。你可以通过分析历史财务数据和行业趋势&#xff0c;确定…

设计模式24-命令模式

设计模式24-命令模式 写在前面行为变化模式 命令模式的动机定义与结构定义结构 C 代码推导优缺点应用场景总结补充函数对象&#xff08;Functors&#xff09;定义具体例子示例&#xff1a;使用函数对象进行自定义排序代码说明输出结果具体应用 优缺点应用场景 命令模式&#xf…

鸿蒙位置服务

位置服务 1、首先申请权限 在module.json5文件下申请位置权限 "requestPermissions": [{"name": "ohos.permission.LOCATION", // 权限名称,为系统已定义的权限"reason": "$string:location_reason", // 申请权限的原因,…

windows 核心编程第五章:演示作业的使用及获取统计信息

演示作业的使用及获取统计信息 演示作业的使用及获取统计信息 文章目录 演示作业的使用及获取统计信息演示作业的使用及获取统计信息 演示作业的使用及获取统计信息 /* 演示作业的使用及获取统计信息 */#include <stdio.h> #include <Windows.h> #include <tc…

HBase原理和操作

目录 一、HBase在Zookeeper中的存储元数据信息集群状态信息 二、HBase的操作Web Console命令行操作 三、HBase中数据的保存过程 一、HBase在Zookeeper中的存储 元数据信息 HBase的元数据信息是HBase集群运行所必需的关键数据&#xff0c;它存储在Zookeeper的"/hbase&quo…

ARM32开发——(七)GD32F4串口引脚_复用功能_查询

1. GD32F4串口引脚查询 TX RX CK CTS RTS USART0 PA9,PA15,PB6 PA10,PB3,PB7 PA8 PA11 PA12 USART1 PA2,PD5 PA3,PD6 PA4,PD7 PA0,PD3 PA1,PD4 USART2 PB10,PC10,PD8 PB11,PC5,PD9 PB12,PC12,PD10 PB13,PD11 PB14,PD12 UART3 PA0,PC10 PA1,PC11 …

kafka 入门

kafka 有分区和副本的概念&#xff0c;partition 3 表示有3个分区&#xff0c;replication 2 表示有2个副本 通过 --describe --topic test命令可以知道 test这个 主题的分区和副本情况&#xff0c;途中的replicas 表示 其他副本分区的情况&#xff0c;如第一条&#xff0c;t…

【运筹学】【数据结构】【经典算法】最小生成树问题及贪心算法设计

1 知识回顾 我们已经讲过最小生成树问题的基础知识&#xff0c;我们现在想要利用贪心算法解决该问题。我们再来回顾一下最小生成树问题和贪心算法的基础知识。 最小生成树问题就是从某个图中找出总权重最小的生成树。 贪心算法是一种算法设计范式&#xff0c;每一步都选…

深度学习学习经验——全连接神经网络(FCNN)

什么是全连接神经网络&#xff1f; 全连接神经网络&#xff08;FCNN&#xff09;是最基础的神经网络结构&#xff0c;它由多个神经元组成&#xff0c;这些神经元按照层级顺序连接在一起。每一层的每个神经元都与前一层的每个神经元连接。 想象你在参加一个盛大的晚会&#xf…

Vue中的this.$emit()方法详解【父子组件传值常用】

​在Vue中&#xff0c;this.$emit()方法用于触发自定义事件。它是Vue实例的一个方法&#xff0c;可以在组件内部使用。 使用this.$emit()方法&#xff0c;你可以向父组件发送自定义事件&#xff0c;并传递数据给父组件。父组件可以通过监听这个自定义事件来执行相应的逻辑。 …

问界M7 Pro这招太狠了,直击理想L6/L7要害

文 | AUTO芯球 作者 | 雷慢 李想的理想估计要失眠了&#xff0c;为什么啊&#xff1f; 前有L6悬架薄如铁片被曝光&#xff0c;被车主们骂了个狗血淋头&#xff0c; 现在又来个问界M7 Pro版&#xff0c; 24.98万的后驱智驾版就上华为ADS主视觉智驾了&#xff0c; 两个后驱&…

TMDOG的微服务之路_07——初入微服务,NestJS微服务快速入门

TMDOG的微服务之路_07——初入微服务&#xff0c;NestJS微服务快速入门 博客地址&#xff1a;TMDOG的博客 在前几篇博客中&#xff0c;我们探讨了如何在 NestJS 中的一些基础功能&#xff0c;并可以使用NestJS实现一个简单的单体架构后端应用。本篇博客&#xff0c;我们将进入…

基于改进YOLOv8的景区行人检测算法

贵向泉, 刘世清, 李立, 秦庆松, 李唐艳. 基于改进YOLOv8的景区行人检测算法[J]. 计算机工程, 2024, 50(7): 342-351. DOI: 10.19678/j.issn.10 原文链接如下&#xff1a;基于改进YOLOv8的景区行人检测算法https://www.ecice06.com/CN/rich_html/10.19678/j.issn.1000-3428.006…

解决Element-plus中Carousel(走马灯)图片无法正常加载的bug

前言&#xff1a; 最近帮助朋友解决了一个使用Element-plus中Carousel&#xff08;走马灯&#xff09;图片无法正常加载的bug&#xff0c;经过笔者的不断努力终于实现了&#xff0c;现在跟大家分享一下&#xff1a; 朋友原来的代码是这样的&#xff1a; <template><…

【计算机网络】电路交换、报文交换、分组交换

电路交换&#xff08;Circuit Switching&#xff09;&#xff1a;通过物理线路的连接&#xff0c;动态地分配传输线路资源 ​​​​

依靠 VPN 生存——探索 VPN 后利用技术

执行摘要 在这篇博文中,Akamai 研究人员强调了被忽视的 VPN 后利用威胁;也就是说,我们讨论了威胁行为者在入侵 VPN 服务器后可以用来进一步升级入侵的技术。 我们的发现包括影响 Ivanti Connect Secure 和 FortiGate VPN 的几个漏洞。 除了漏洞之外,我们还详细介绍了一组…

SpringBoot集成kafka-获取生产者发送的消息(阻塞式和非阻塞式获取)

说明 CompletableFuture对象需要的SpringBoot版本为3.X.X以上&#xff0c;需要的kafka依赖版本为3.X.X以上&#xff0c;需要的jdk版本17以上。 1、阻塞式&#xff08;等待式&#xff09;获取生产者发送的消息 生产者&#xff1a; package com.power.producer;import org.ap…

Linux的进程详解(进程创建函数fork和vfork的区别,资源回收函数wait,进程的状态(孤儿进程,僵尸进程),加载进程函数popen)

目录 什么是进程 Linux下操作进程的相关命令 进程的状态&#xff08;生老病死&#xff09; 创建进程系统api介绍&#xff1a; fork() 父进程和子进程的区别 vfork() 进程的状态补充&#xff1a; 孤儿进程 僵尸进程 回收进程资源api介绍&#xff1a; wait() waitpid…

VastBase——全局性能调优

目录 一、系统资源调优 1.内存和CPU 2.网络 3.I/O 二、查询最耗性能的SQL 三、分析作业是否被阻塞 背景&#xff1a;影响性能的因素 系统资源 数据库性能在很大程度上依赖于磁盘的I/O和内存使用情况。为了准确设置性能指标&#xff0c;用户需要了解Vastbase部署硬件的基本…