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

鸿蒙NEXT项目实战-百得知识库03

代码仓地址,大家记得点个star

IbestKnowTeach: 百得知识库基于鸿蒙NEXT稳定版实现的一款企业级开发项目案例。 本案例涉及到多个鸿蒙相关技术知识点: 1、布局 2、配置文件 3、组件的封装和使用 4、路由的使用 5、请求响应拦截器的封装 6、位置服务 7、三方库的使用和封装 8、头像上传 9、应用软件更新等https://gitee.com/xt1314520/IbestKnowTeach

Home页面开发

设计图

需求分析

Home页面一共可以分为三块部分

1、头部-最新、热门

2、搜索框

3、内容主体

搭建Home页面布局

1、头部-最新、热门

最新、热门可以用Text文本组件,下面下划线用Divider组件

// 标题栏
Row({ space: 10 }) {Column() {Text($r('app.string.article_best_new')).textStyles()// 选中标题会出现下划线if (this.newDividerShow) {Divider().dividerStyles()}}.onClick(() => {// 展示下划线this.hotDividerShow = falsethis.newDividerShow = true// 查询最新文章数据this.isShow = falsethis.page = 1this.getArticleNewDataList(true, true)})Column() {Text($r('app.string.article_best_hot')).textStyles()// 选中标题会出现下划线if (this.hotDividerShow) {Divider().dividerStyles()}}.onClick(() => {this.newDividerShow = falsethis.hotDividerShow = true// 查询最热门文章数据this.isShow = falsethis.page = 1this.getArticleHotDataList(true, true)})}.justifyContent(FlexAlign.Start).margin({ top: 10, bottom: 20 }).width(CommonConstant.WIDTH_FULL)

2、搜索框

搜索框可以使用鸿蒙原生组件Search

// 搜索
Search({ placeholder: '请输入关键字', value: $$this.keyword }).placeholderFont({ size: 14 }).textFont({ size: 14 }).onSubmit(() => {// 处理标题this.title = encodeURIComponent(this.keyword)// 分页查询文章内容this.isShow = falsethis.page = 1this.getArticleDataList(true)}).width(CommonConstant.WIDTH_FULL).height(30)
3、内容主体

内容主体相当于我们把文章单条内容封装成一个组件,然后使用List组件进行布局嵌套使用Foreach进行循环遍历文章数组对象数据

整体大家看一条文章数据,分为三行,行使用的是Row布局,整体三行布局从上到下是列所以组件整体用Column进行包裹

封装单条文章组件(在ets下面创建component目录然后创建ArticleComponent.ets文件)

import { ArticleContentData } from '../api/ArticleContentApi.type'
import { CommonConstant } from '../contants/CommonConstant'@Componentexport struct ArticleComponent {// 文章数据@Prop articleContentData: ArticleContentDatabuild() {Column() {Row({ space: 10 }) {// 头像Image(this.articleContentData.avatarUri).width($r('app.float.common_width_tiny')).aspectRatio(1).borderRadius(10)// 姓名Text(this.articleContentData.nickname).fontSize($r('app.float.common_font_size_medium')).fontColor($r('app.color.common_gray')).width('70%').maxLines(1).textOverflow({ overflow: TextOverflow.Ellipsis })}.width(CommonConstant.WIDTH_FULL)Row() {// 内容标题Text(this.articleContentData.title).fontSize($r('app.float.common_font_size_small')).width('80%').maxLines(3).textOverflow({ overflow: TextOverflow.Ellipsis })Image(this.articleContentData.coverUrl).width($r('app.float.common_width_medium')).aspectRatio(1).objectFit(ImageFit.Contain).borderRadius(5)}.width(CommonConstant.WIDTH_FULL).justifyContent(FlexAlign.SpaceBetween)// 展示阅读、点赞、收藏Row({ space: 3 }) {Text(this.articleContentData.readCount + '阅读').textStyles()Text('|').textStyles()Text(this.articleContentData.time).textStyles()Text('|').textStyles()// 文章内容标签if (this.articleContentData.contentCategory === '1') {Text('鸿蒙').textLabelStyles()} else if (this.articleContentData.contentCategory === '2') {Text('Java').textLabelStyles()} else if (this.articleContentData.contentCategory === '3') {Text('Web前端').textLabelStyles()} else if (this.articleContentData.contentCategory === '4') {Text('运维').textLabelStyles()} else {Text('未知级别').textLabelStyles()}Text('|').textStyles()// 文章难度分类标签if (this.articleContentData.difficultyCategory === '1') {Text(this.articleContentData.platformCategory === '1' ? '基础知识' : '简单面试题').textLabelStyles()} else if (this.articleContentData.difficultyCategory === '2') {Text(this.articleContentData.platformCategory === '1' ? '进阶知识' : '中等面试题').textLabelStyles()} else if (this.articleContentData.difficultyCategory === '3') {Text(this.articleContentData.platformCategory === '1' ? '高级知识' : '困难面试题').textLabelStyles()} else {Text('未知级别').textLabelStyles()}}.width(CommonConstant.WIDTH_FULL)}.padding(10).width(CommonConstant.WIDTH_FULL).height(110).margin({ top: 13 }).backgroundColor($r('app.color.common_white')).justifyContent(FlexAlign.SpaceBetween).borderRadius(10)}
}@Extend(Text)
function textStyles() {.fontColor($r('app.color.common_gray')).fontSize($r('app.float.common_font_size_tiny'))
}@Extend(Text)
function textLabelStyles() {.fontSize($r('app.float.common_font_size_tiny')).fontColor(Color.Black)
}

然后我们整体在Home页面里面展示我们的文章内容数组数据

if (this.isShow) {Refresh({ refreshing: $$this.isRefreshing }) {// 内容组件List() {ForEach(this.articleContentList, (item: ArticleContentData) => {ListItem() {ArticleComponent({ articleContentData: item }).onClick(() => {// 路由到内容详情页router.pushUrl({url: RouterConstant.VIEWS_HOME_ARTICLE_INFO, params: {"articleId": item.id}})})}})if (this.textShow) {ListItem() {Text($r('app.string.no_have_article')).fontColor($r('app.color.common_gray')).fontSize($r('app.float.common_font_size_small')).width(CommonConstant.WIDTH_FULL).textAlign(TextAlign.Center).margin({ top: 80 })}}}.width(CommonConstant.WIDTH_FULL).height(CommonConstant.HEIGHT_FULL).scrollBar(BarState.Off).onReachEnd(() => {if (!this.isLoad) {if (this.total > this.page * this.pageSize) {this.isLoad = truethis.page++if (this.newDividerShow) {// 分页查询最新文章数据this.getArticleNewDataList(false, false)}if (this.hotDividerShow) {// 分页查询最热门文章数据this.getArticleHotDataList(false, false)}} else {this.textShow = true}}})}.onRefreshing(() => {if (!this.isLoad) {this.isLoad = truethis.textShow = false// 页面恢复到1this.page = 1if (this.newDividerShow) {// 分页查询最新文章数据this.getArticleNewDataList(true, true)}if (this.hotDividerShow) {// 分页查询最热门文章数据this.getArticleHotDataList(true, true)}}})
} else {// 加载组件LoadingComponent()
}

加载组件 LoadingComponent()是我们自己进行封装的,因为我们的数据可能因为网络原因还没在服务端查询出来,界面为了不要展示长时间空白让用户误会,所以展示我们数据正在加载中

import { CommonConstant } from '../contants/CommonConstant'@Componentexport struct LoadingComponent {@State message: string = '数据正在加载中'build() {Row() {LoadingProgress().width(30).height(30).color(Color.Gray)Text(this.message).fontSize((14)).fontColor(Color.Gray)}.height("80%").width(CommonConstant.WIDTH_FULL).justifyContent(FlexAlign.Center)}}
4、整体Home页面代码

import { router } from '@kit.ArkUI'
import { RouterConstant } from '../../contants/RouterConstant'
import { CommonConstant } from '../../contants/CommonConstant'
import { ArticleComponent } from '../../components/ArticleComponent'
import articleContentApi from '../../api/ArticleContentApi'
import { LoadingComponent } from '../../components/LoadingComponent'
import { ArticleContentData } from '../../api/ArticleContentApi.type'
import { showToast } from '../../utils/Toast'@Entry@Componentexport struct Home {// 是否展示最新标题的下划线@State newDividerShow: boolean = true// 是否展示热门标题的下划线@State hotDividerShow: boolean = false// 搜索词@State keyword: string = ''// 标题@State title: string = ''// 文章数据数组@State articleContentList: ArticleContentData[] = []// 学习打卡总记录数@State total: number = 0// 当前页@State page: number = 1// 每一页大小@State pageSize: number = 7// 控制当前页面展示@State isShow: boolean = false// 定义一个状态属性,用来和Refresh组件进行双向数据绑定@State isRefreshing: boolean = false// 节流, false表示未请求, true表示正在请求isLoad: boolean = false// 是否展示文本,列表到底@State textShow: boolean = false/*** 生命周期函数*/async aboutToAppear() {// 默认获取首页最新文章内容this.getArticleNewDataList(true, false)}/*** 分页查询最新文章数据*/async getArticleNewDataList(isFlushed: boolean, isUpdate: boolean) {// 分页查询最新文章数据const articleDataList =await articleContentApi.getNewArticle({ page: this.page, pageSize: this.pageSize, title: this.title })isFlushed ? this.articleContentList = articleDataList.records :this.articleContentList.push(...articleDataList.records)this.total = articleDataList.total// 判断总数据if (this.total > this.page * this.pageSize) {this.textShow = false} else {this.textShow = true}// 页面展示this.isShow = true// 节流,防止用户重复下拉this.isLoad = falsethis.isRefreshing = false// 是否刷新if (isUpdate) {showToast("已更新")}}/*** 分页查询最热门文章数据*/async getArticleHotDataList(isFlushed: boolean, isUpdate: boolean) {// 分页查询最热门文章数据const articleDataList =await articleContentApi.getHotArticle({ page: this.page, pageSize: this.pageSize, title: this.title })isFlushed ? this.articleContentList = articleDataList.records :this.articleContentList.push(...articleDataList.records)this.total = articleDataList.total// 判断总数据if (this.total > this.page * this.pageSize) {this.textShow = false} else {this.textShow = true}// 页面展示this.isShow = true// 节流,防止用户重复下拉this.isLoad = falsethis.isRefreshing = false// 是否刷新if (isUpdate) {showToast("已更新")}}/*** 分页查询文章数据*/async getArticleDataList(isFlushed: boolean) {// 分页查询文章数据if (this.newDividerShow) {this.getArticleNewDataList(isFlushed, true)}if (this.hotDividerShow) {this.getArticleHotDataList(isFlushed, true)}}build() {Column() {// 标题栏Row({ space: 10 }) {Column() {Text($r('app.string.article_best_new')).textStyles()// 选中标题会出现下划线if (this.newDividerShow) {Divider().dividerStyles()}}.onClick(() => {// 展示下划线this.hotDividerShow = falsethis.newDividerShow = true// 查询最新文章数据this.isShow = falsethis.page = 1this.getArticleNewDataList(true, true)})Column() {Text($r('app.string.article_best_hot')).textStyles()// 选中标题会出现下划线if (this.hotDividerShow) {Divider().dividerStyles()}}.onClick(() => {this.newDividerShow = falsethis.hotDividerShow = true// 查询最热门文章数据this.isShow = falsethis.page = 1this.getArticleHotDataList(true, true)})}.justifyContent(FlexAlign.Start).margin({ top: 10, bottom: 20 }).width(CommonConstant.WIDTH_FULL)// 搜索Search({ placeholder: '请输入关键字', value: $$this.keyword }).placeholderFont({ size: 14 }).textFont({ size: 14 }).onSubmit(() => {// 处理标题this.title = encodeURIComponent(this.keyword)// 分页查询文章内容this.isShow = falsethis.page = 1this.getArticleDataList(true)}).width(CommonConstant.WIDTH_FULL).height(30)if (this.isShow) {Refresh({ refreshing: $$this.isRefreshing }) {// 内容组件List() {ForEach(this.articleContentList, (item: ArticleContentData) => {ListItem() {ArticleComponent({ articleContentData: item }).onClick(() => {// 路由到内容详情页router.pushUrl({url: RouterConstant.VIEWS_HOME_ARTICLE_INFO, params: {"articleId": item.id}})})}})if (this.textShow) {ListItem() {Text($r('app.string.no_have_article')).fontColor($r('app.color.common_gray')).fontSize($r('app.float.common_font_size_small')).width(CommonConstant.WIDTH_FULL).textAlign(TextAlign.Center).margin({ top: 80 })}}}.width(CommonConstant.WIDTH_FULL).height(CommonConstant.HEIGHT_FULL).scrollBar(BarState.Off).onReachEnd(() => {if (!this.isLoad) {if (this.total > this.page * this.pageSize) {this.isLoad = truethis.page++if (this.newDividerShow) {// 分页查询最新文章数据this.getArticleNewDataList(false, false)}if (this.hotDividerShow) {// 分页查询最热门文章数据this.getArticleHotDataList(false, false)}} else {this.textShow = true}}})}.onRefreshing(() => {if (!this.isLoad) {this.isLoad = truethis.textShow = false// 页面恢复到1this.page = 1if (this.newDividerShow) {// 分页查询最新文章数据this.getArticleNewDataList(true, true)}if (this.hotDividerShow) {// 分页查询最热门文章数据this.getArticleHotDataList(true, true)}}})} else {// 加载组件LoadingComponent()}}.padding($r('app.float.common_padding')).height(CommonConstant.HEIGHT_FULL).width(CommonConstant.WIDTH_FULL)}
}@Extend(Text)
function textStyles() {.fontSize($r('app.float.common_font_size_huge')).fontWeight(FontWeight.Medium)
}@Extend(Divider)
function dividerStyles() {.color(Color.Black).width($r('app.float.common_width_tiny')).strokeWidth(3)
}

5、数据渲染,接口封装

查询最新文章数据,这个函数里面有个 articleContentApi.getNewArticle方法,这个方法是作者封装的接口

/*** 分页查询最新文章数据*/
async getArticleNewDataList(isFlushed: boolean, isUpdate: boolean) {// 分页查询最新文章数据const articleDataList =await articleContentApi.getNewArticle({ page: this.page, pageSize: this.pageSize, title: this.title })isFlushed ? this.articleContentList = articleDataList.records :this.articleContentList.push(...articleDataList.records)this.total = articleDataList.total// 判断总数据if (this.total > this.page * this.pageSize) {this.textShow = false} else {this.textShow = true}// 页面展示this.isShow = true// 节流,防止用户重复下拉this.isLoad = falsethis.isRefreshing = false// 是否刷新if (isUpdate) {showToast("已更新")}
}

大家可以根据东林提供的接口文档,将我们的调用接口封装成方法

这是涉及到文章的所有接口

import http from '../request/Request'
import {ArticleContentData,ArticleContentHotPageParam,ArticleContentNewPageParam,ArticleContentPageParam,PageVo
} from './ArticleContentApi.type'/*** 文章接口*/
class ArticleContentApi {/*** 分页查询文章内容*/pageListArticleContent = (data: ArticleContentPageParam): Promise<PageVo<ArticleContentData>> => {return http.get('/v1/article/page?page=' + data.page + '&&pageSize=' + data.pageSize + '&&title=' + data.title +'&&contentCategory=' + data.contentCategory + '&&platformCategory=' + data.platformCategory +'&&difficultyCategory=' + data.difficultyCategory)}/*** 根据文章id查询文章详情*/getArticleContentInfo = (data: number): Promise<ArticleContentData> => {return http.get('/v1/article/info?id=' + data)}/***  用户点赞/取消点赞文章*/likeArticleContent = (data: number) => {return http.put('/v1/article/like?id=' + data)}/***  用户收藏/取消收藏文章*/collectArticleContent = (data: number) => {return http.put('/v1/article/collect?id=' + data)}/*** 查看我的点赞,最近100条*/getUserLike = (): Promise<Array<ArticleContentData>> => {return http.get('/v1/article/myLike')}/***查看我的收藏,最近100条*/getUserCollect = (): Promise<Array<ArticleContentData>> => {return http.get('/v1/article/myCollect')}/***分页查看最新文章*/getNewArticle = (data: ArticleContentNewPageParam): Promise<PageVo<ArticleContentData>> => {return http.get('/v1/article/new?page=' + data.page + '&&pageSize=' + data.pageSize + '&&title=' + data.title)}/***分页查看最热文章*/getHotArticle = (data: ArticleContentHotPageParam): Promise<PageVo<ArticleContentData>> => {return http.get('/v1/article/hot?page=' + data.page + '&&pageSize=' + data.pageSize + '&&title=' + data.title)}
}const articleContentApi = new ArticleContentApi();export default articleContentApi as ArticleContentApi;
/*** 时间*/
export interface BaseTime {/*** 创建时间*/createTime?: Date/*** 更新时间*/updateTime?: Date
}/*** 分页参数*/
export interface PageParam {/*** 当前页*/page?: number/*** 每一页展示的数据条数*/pageSize?: number
}/*** 分页响应参数*/
export interface PageVo<T> {current: number,size: number,total: number,records: Array<T>
}/*** 分页查询文章内容*/
export interface ArticleContentPageParam extends PageParam {/*** 标题*/title?: string/*** 内容分类:1鸿蒙 2 Java 3 web 4 运维*/contentCategory?: string/*** 平台分类:1学习平台 2面试题*/platformCategory?: string/*** 难度分类:1 简单 2 中等 3 困难*/difficultyCategory?: string
}/*** 分页查询最新文章内容入参*/
export interface ArticleContentNewPageParam extends PageParam {/*** 标题*/title: string}/*** 分页查询最热文章内容入参*/
export interface ArticleContentHotPageParam extends PageParam {/*** 标题*/title: string}/*** 文章内容数据*/
export interface ArticleContentData extends BaseTime {/*** 文章id*/id: number/*** 用户头像*/avatarUri: string/*** 用户昵称*/nickname: string/*** 文章标题*/title: string/*** 文章内容*/content: string/*** 阅读数*/readCount: number/*** 点赞数*/likeCount: number/*** 收藏数*/collectCount: number/*** 封面url*/coverUrl: string/*** 内容分类:1鸿蒙 2 Java 3 web 4 运维*/contentCategory: string/*** 平台分类:1学习平台 2面试题*/platformCategory: string/*** 难度分类:1 简单 2 中等 3 困难*/difficultyCategory: string/*** 用户是否点赞*/isLike: boolean/*** 用户是否收藏*/isCollect: boolean/*** 创建时间字符串格式*/time: string
}

文章详情界面布局

当我们点击文章的话会跳转到文章详情页面,携带当前点击的文章id

这边路由我们使用的是router.push()

1、新建文章详情页面

在ets/views/Home下面新建ArticleInfo.ets文件

2、设计图

3、需求分析

整个文章详情页面呈现的是使用Column布局的,里面分为多行,其他最上面标题我们可以使用Navigation组件做,鸿蒙官方推荐的,下面的文章内容按理说是渲染的html格式(富文本)的,所以我们使用RichText组件,还有点赞和收藏按理说有两种状态(未点赞、点赞,未收藏、收藏),整体文章数据也是根据路由跳转传过来的文章id进行查询的文章数据。

4、封装富文本组件

在components目录下面新建LearnRichText.ets文件

@Componentexport struct LearnRichText {// 富文本@Prop richTextContent: string = ""build() {Scroll() {RichText(`<html><body><div style="font-size:54px">${this.richTextContent}</div><body></html>`)}.layoutWeight(1)}}

5、整体代码
import { ArticleContentData } from '../../api/ArticleContentApi.type';
import { ArticleExtraInfoComponent } from '../../components/ArticleExtraInfoComponent'
import { LearnRichText } from '../../components/LearnRichText';
import { LoadingComponent } from '../../components/LoadingComponent';
import { CommonConstant } from '../../contants/CommonConstant'
import { router } from '@kit.ArkUI';
import articleContentApi from '../../api/ArticleContentApi';
import { showToast } from '../../utils/Toast';@Entry@Componentstruct ArticleInfo {// 文章数据数组@Prop articleInfo: ArticleContentData// 控制当前页面展示@State isShow: boolean = false// 文章id@State articleId: number = 1// 节流,防止用户重复点击isLoad: boolean = false/*** 生命周期函数*/async aboutToAppear() {// 获取路由传递的文章idconst param = router.getParams() as objectif (param) {this.articleId = param["articleId"] as number// 根据文章id查询文章数据this.articleInfo = await articleContentApi.getArticleContentInfo(this.articleId)// 展示数据this.isShow = true}}/*** 点赞* @param id*/async likeArticle(id: number) {// 点赞或者取消点赞if (this.articleInfo.isLike) {// 取消点赞await articleContentApi.likeArticleContent(id)this.articleInfo.isLike = falsethis.articleInfo.likeCount--this.isLoad = falseshowToast('取消点赞成功')} else {// 点赞await articleContentApi.likeArticleContent(id)this.articleInfo.isLike = truethis.articleInfo.likeCount++this.isLoad = falseshowToast('点赞成功')}}/*** 收藏* @param id*/async collectArticle(id: number) {// 收藏或者取消收藏if (this.articleInfo.isCollect) {// 取消收藏await articleContentApi.collectArticleContent(id)this.articleInfo.isCollect = falsethis.articleInfo.collectCount--this.isLoad = falseshowToast('取消收藏成功')} else {// 收藏await articleContentApi.collectArticleContent(id)this.articleInfo.isCollect = truethis.articleInfo.collectCount++this.isLoad = falseshowToast('收藏成功')}}build() {Navigation() {if (this.isShow) {Column({ space: 15 }) {Flex() {Text(this.articleInfo.title).fontSize($r('app.float.common_font_size_medium')).maxLines(3).textOverflow({ overflow: TextOverflow.Ellipsis }).fontColor(Color.Black).fontWeight(FontWeight.Medium)}Row({ space: 10 }) {// 头像Image(this.articleInfo.avatarUri).width(30).aspectRatio(1).borderRadius(20)// 昵称Text(this.articleInfo.nickname).fontSize($r('app.float.common_font_size_medium')).width('80%').maxLines(1).textOverflow({ overflow: TextOverflow.Ellipsis })}.width(CommonConstant.WIDTH_FULL)// 展示阅读、点赞、收藏数Row() {// 文章额外信息组件ArticleExtraInfoComponent({ articleInfo: this.articleInfo })Row({ space: 15 }) {// 点赞Image(this.articleInfo.isLike ? $r('app.media.icon_like_selected') : $r('app.media.icon_like_default')).width(15).onClick(() => {// 点赞if (!this.isLoad) {this.isLoad = truethis.likeArticle(this.articleInfo.id)}})// 收藏Image(this.articleInfo.isCollect ? $r('app.media.icon_collect_selected') :$r('app.media.icon_collect_default')).width(15).onClick(() => {// 收藏if (!this.isLoad) {this.isLoad = truethis.collectArticle(this.articleInfo.id)}})}}.width(CommonConstant.WIDTH_FULL).justifyContent(FlexAlign.SpaceBetween)}.padding($r('app.float.common_padding'))// 分割线Divider().strokeWidth((4)).color('#e6f2fe')// 内容正文LearnRichText({ richTextContent: this.articleInfo.content }).padding($r('app.float.common_padding'))} else {// 加载组件LoadingComponent()}}.height(CommonConstant.HEIGHT_FULL).width(CommonConstant.WIDTH_FULL).title($r('app.string.article_info_title')).titleMode(NavigationTitleMode.Mini).mode(NavigationMode.Stack).expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])}
}
6、注意事项

当前系统除了登录、分页查询文章等部分接口,其他接口功能都是需要登录之后才可以使用的,这就是系统的权限控制,当前查询文章详情、收藏、点赞功能是需要登录得,未登录状态下使用是报错的。

相关文章:

鸿蒙NEXT项目实战-百得知识库03

代码仓地址&#xff0c;大家记得点个star IbestKnowTeach: 百得知识库基于鸿蒙NEXT稳定版实现的一款企业级开发项目案例。 本案例涉及到多个鸿蒙相关技术知识点&#xff1a; 1、布局 2、配置文件 3、组件的封装和使用 4、路由的使用 5、请求响应拦截器的封装 6、位置服务 7、三…...

sql server数据迁移,springboot搭建开发环境遇到的问题及解决方案

最近搭建springboot项目开发环境&#xff0c;数据库连的是sql server&#xff0c;遇到许多问题在此记录一下。 1、sql server安装教程 参考&#xff1a;https://www.bilibili.com/opus/944736210624970769 2、sql server导出、导入数据库 参考&#xff1a;https://blog.csd…...

Sensodrive机器人力控关节模组SensoJoint在海洋垃圾清理机器人中的拓展应用

海洋污染已成为全球性的环境挑战&#xff0c;其中海底垃圾的清理尤为困难。据研究&#xff0c;海洋中约有2600万至6600万吨垃圾&#xff0c;超过90%沉积在海底。传统上&#xff0c;潜水员收集海底垃圾不仅成本高昂&#xff0c;而且充满风险。为解决这一问题&#xff0c;欧盟资助…...

matrix-breakout-2-morpheus 靶机----练习攻略 【仅获取shell】

【此练习仅做到反弹shell】 1.靶机下载地址 https://download.vulnhub.com/matrix-breakout/matrix-breakout-2-morpheus.ova 2. 打开靶机&#xff0c;kali使用nmap扫描同C段的主机 找到靶机ip 确保靶机和kali网卡均为NAT模式 先查看kali的ip nmap 192.168.182.1/24 …...

吴恩达机器学习笔记复盘(八)多元线性回归的梯度下降

简介 梯度下降是多元线性回归的主流优化方法&#xff0c;具有普适性和可扩展性&#xff0c;而标准方程法适用于特定场景。实际应用中需结合特征工程和参数调优提升模型性能。本篇不复盘参数调优。 1.多元线性回归模型 多元线性回归模型假设因变量 与多个自变量 之间存在线性…...

SAP-ABAP: 采购申请创建(PR)BAPI_PR_CREATE 技术指南-详解

BAPI_PR_CREATE 技术指南 用途&#xff1a;通过 RFC 接口创建 SAP 采购申请&#xff08;PR&#xff09;&#xff0c;支持自动化集成与批量处理。 一、功能概览 类别说明核心功能创建标准采购申请、预留转采购申请&#xff0c;支持多行项目及账户分配。集成场景与 MRP 系统、外…...

Python:单继承方法的重写

继承&#xff1a;让类和类之间转变为父子关系&#xff0c;子类默认继承父类的属性和方法 单继承&#xff1a; class Person:def eat(self):print("eat")def sing(self):print("sing") class Girl(Person):pass#占位符&#xff0c;代码里面类下面不写任何东…...

Cursor解锁Claude Max,助力AI编程新突破!

Cursor 最新推出的 Claude Max 模型&#xff0c;以其卓越的性能和创新的能力&#xff0c;正在重新定义我们对 AI 辅助编程的认知。这款搭载 Claude3.7 大脑的超级模型&#xff0c;不仅具备超强智能&#xff0c;还凭借一系列技术突破&#xff0c;向传统 AI 编程工具发起了挑战。…...

Datawhale coze-ai-assistant 笔记4

课程地址&#xff1a; ‍​‌​‬​​&#xfeff;‌​&#xfeff;​‬​​​​​⁠​​‬​‌​​​​⁠​​‍&#xfeff;​​​​​⁠​⁠​&#xfeff;​⁠​‬​第 6 章 应用 - 飞书云文档https://zxdwhda-share.feishu.cn/wiki/Gi9aw4EDTiXxcekUWebcEtmUnb4 应用 AI…...

【基于深度学习的验证码识别】---- part3数据加载、模型等API介绍(2)

四、模型 模型的定义 在机器学习和深度学习中&#xff0c;模型 可以定义为&#xff1a; 一个数学函数或算法&#xff0c;能够从输入数据中提取特征并生成输出。通过训练过程&#xff0c;模型能够学习数据中的规律&#xff08;如分类、回归、聚类等&#xff09;。训练完成后&…...

留 言 板

书单 作者&#xff1a;郦波 《五百年来王阳明》 《郦波评说曾国藩家训》《最是人间留不住》《一天一生》 作者&#xff1a;曾仕强 《论语的生活智慧》 《曾仕强详解道德经 道经》 作者&#xff1a; [何勇&#xff0c;陈晓峰著] 《Greenplum企业应用实战 》 作者 Mark G. Sobel…...

3.18练习

BUUCTF练习day2 [GXYCTF2019]Ping Ping Ping ping题有点熟悉的命令注入&#xff0c;使用 127.0.0.1;ls可以得到当前目录的文件名 cat一下flag.php&#xff0c;发现不行 过滤了空格&#xff0c;那我们有什么方法绕过呢 <(重定向符号)${IFS}$IFS$9%09(tab键) 试一试发现过…...

Redis哨兵模式-黑马学习笔记

redis哨兵模式 1.哨兵主要的作用 用于监控主节点的健康情况 如果主节点挂掉立马选择一个从节点顶上去 2.监控的机制 如何监控呢&#xff1f; sentinel基于心跳机制检测主节点的状态 每个1秒向集群发送ping &#xff08;三体中逻辑用来威胁三体人的心跳检测&#xff09; 如…...

Linkreate wordpressAI插件 24小时自动生成原创图文,新增从百度、必应搜索引擎自动获取相关下拉关键词

Linkreate wordpressAI插件核心功能亮点 文章生成与优化 自动化文章生成&#xff1a;利用 AI 技术&#xff0c;根据关键词生成高质量文章。 支持指定长度和要求&#xff0c;异步生成不阻塞操作。 且 AI 可自动生成精准的 tag 标签&#xff0c;利于 SEO 优化。 批量生成文章…...

《AI赋能云原生区块链,引领供应链溯源革新》

在数字化浪潮席卷全球的当下&#xff0c;供应链管理领域正经历着深刻变革。云原生区块链凭借其去中心化、不可篡改等特性&#xff0c;为供应链溯源带来了前所未有的透明度与可靠性。而AI的融入&#xff0c;更如虎添翼&#xff0c;以强大的智能分析和决策能力&#xff0c;为云原…...

基于单片机的多功能热水器设计(论文+源码)

1系统方案设计 基于单片机的多功能热水器系统&#xff0c;其系统框图如图2.1所示。主要采用了DS18B20温度传感器&#xff0c;HC-SR04超声波模块&#xff0c;STC89C52单片机&#xff0c;液晶&#xff0c;继电器等来构成整个系统。硬件上主要通过温度传感器进行水温的检测&am…...

Java面试黄金宝典4

1. 什么是泛型 &#xff1f;与 T 的区别 原理 泛型是 Java 编程语言中的一个强大特性&#xff0c;它提供了编译时类型安全检查机制&#xff0c;允许在定义类、接口和方法时使用类型参数。这些类型参数在使用时会被具体的类型所替代&#xff0c;从而实现代码的复用和类型安全。泛…...

vim在连续多行行首插入相同的字符

工作中经常需要用vim注释掉一段代码或者json文件中的一部分&#xff0c;需要在多行前面插入//或者#符号。在 Vim 中&#xff0c;在连续多行行首插入相同字符主要有以下两种方法&#xff1a; Visual Block 模式插入 将光标移到要插入相同内容的第一行的行首24。按下Ctrl v进入…...

路径问题(greedy):地下城游戏

题目描述&#xff1a; 恶魔们抓住了公主并将她关在了地下城 dungeon 的 右下角 。地下城是由 m x n 个房间组成的二维网格。我们英勇的骑士最初被安置在 左上角 的房间里&#xff0c;他必须穿过地下城并通过对抗恶魔来拯救公主。 骑士的初始健康点数为一个正整数。如果他的健…...

【论文阅读】CARES:医学视觉语言模型可信度的综合基准

CARES&#xff1a;医学视觉语言模型可信度的综合基准 1. 研究背景与动机2. 方法论创新3. 核心实验结果4. 贡献与意义5.总结 CARES: A Comprehensive Benchmark of Trustworthiness in Medical Vision Language Models CARES&#xff1a;医学视觉语言模型可信度的综合基准 Accep…...

Qt窗口坐标体系

坐标系&#xff1a;以左上角为原点&#xff08;0&#xff0c;0&#xff09;&#xff0c;X向右增加&#xff0c;Y向下增加 对于嵌套窗口&#xff0c;其坐标是相对于父窗口来说的 例如&#xff1a; 通过move方法实现...

英伟达消费级RTX显卡配置表

显卡型号显存大小显存频率显存位宽显存带宽CUDA核心数TDP&#xff08;功耗&#xff09;上市年份RTX 409024GB21 Gbps384-bit1,008 GB/s16,384450W2022RTX 4080 (16GB)16GB22.4 Gbps256-bit716.8 GB/s9,728320W2022RTX 4080 (12GB)12GB21 Gbps192-bit504 GB/s7,680285W2023RTX 4…...

1.5.3 掌握Scala内建控制结构 - for循环

Scala的for循环功能强大&#xff0c;支持单重和嵌套循环。单重for循环语法为for (变量 <- 集合或数组 (条件)) {语句组}&#xff0c;可选筛选条件&#xff0c;循环变量依次取集合值。支持多种任务&#xff0c;如输出指定范围整数&#xff08;使用Range、to、until&#xff0…...

10、STL中的unordered_map使用方法

一、了解 1、unordered_map(哈希) unordered_map是借用哈希表实现的关联容器。 访问键值对O&#xff08;1&#xff09;&#xff0c;最坏情况O&#xff08;n&#xff09;&#xff0c;例如哈希冲突严重时。【n是一个哈希桶的元素数量】 unordered_map特性 键值对存储&#xff…...

pycharm-python國際象棋遊戲代碼

嗯&#xff0c;用户的问题是“pycharm寫關於python國際象棋遊戲代碼”&#xff0c;也就是要用PyCharm来写一个Python的国际象棋游戏代码。我需要先整理一下用户提供的搜索结果&#xff0c;看看有什么相关的信息可以利用。 首先看搜索结果中的各个网页内容。网页1主要讲的是象棋…...

Linux下Redis哨兵集群模式搭建(1主2从+3哨兵)

Linux下Redis哨兵集群模式搭建&#xff08;1主2从3哨兵&#xff09; 一、Redis哨兵模式搭建 1.安装包下载 链接: https://pan.baidu.com/s/1_n2rCMi5MHX-mVkkyMo4LA 提取码: gbra 2.新建redis目录 mkdir -p /app/redis3.解压到/app/redis目录下 tar -zxvf redis-6.2.16.ta…...

二.使用ffmpeg对原始音频数据重采样并进行AAC编码

重采样&#xff1a;将音频三元组【采样率 采样格式 通道数】之中的任何一个或者多个值改变。 一.为什么要进行重采样&#xff1f; 1.原始音频数据和编码器的数据格式不一致 2.播放器要求的和获取的数据不一致 3.方便运算 二.本次编码流程 1.了解自己本机麦克风参数&#x…...

【初学者】请介绍一下指针分析(Pointer Analysis)?

李升伟 整理 指针分析&#xff08;Pointer Analysis&#xff09; 指针分析&#xff08;Pointer Analysis&#xff09;是一种静态程序分析技术&#xff0c;用于确定程序中指针可能指向的内存位置或对象。它是编译器优化、程序验证、漏洞检测和并行化等领域的重要基础。 1. 指…...

【程序人生】成功人生架构图(分层模型)

文章目录 ⭐前言⭐一、根基层——价值观与使命⭐二、支柱层——健康与能量⭐三、驱动层——学习与进化⭐四、网络层——关系系统⭐五、目标层——成就与财富⭐六、顶层——意义与传承⭐外层&#xff1a;调节环——平衡与抗风险⭐思维导图 标题详情作者JosieBook头衔CSDN博客专家…...

目标检测20年(一)

今天看的文献是《Object Detection in 20 Years: A Survey》&#xff0c;非常经典的一篇目标检测文献&#xff0c;希望通过这篇文章学习到目标检测的基础方法并提供一些创新思想。 论文链接&#xff1a;1905.05055 目录 一、摘要 1.1 原文 1.2 翻译 二、介绍 三、目标检测…...

SQLMesh系列教程:SQLMesh虚拟数据环境

各种工具都已将软件工程实践引入到数据工程中&#xff0c;但仍有差距存在&#xff0c;尤其是在测试和工作流等领域。SQLMesh 的目标是在这些领域开辟新的天地&#xff0c;解决像 dbt 这样的竞争产品尚未提供强大解决方案的难题。在这篇文章中&#xff0c;我将对 SQLMesh 进行简…...

【python小游戏】扫雷

扫雷小游戏代码。供消遣娱乐&#xff1a; import tkinter as tk from tkinter import messagebox import random# 游戏参数&#xff08;中等难度&#xff1a;15x15 网格&#xff0c;40 颗雷&#xff09; ROWS 15 COLS 15 MINES 40 CELL_SIZE 30 COLORS {default: #CCCCCC…...

【Linux】learning notes(4)cat、more、less、head、tail、vi、vim

文章目录 catmore 查看整个文件less 查看整个文件head 查看部分文件tail 查看部分文件vim / vi cat cat 命令在 Linux 和 Unix 系统中非常常用&#xff0c;它用于连接文件并打印到标准输出设备&#xff08;通常是屏幕&#xff09;。虽然 cat 的基本用法很简单&#xff0c;但它…...

【论文阅读】Adversarial Patch Attacks on Monocular Depth Estimation Networks

一、背景 单目深度估计是CV领域一个比较热门的研究方向&#xff0c;但是现有的方法过度依赖于非深度特征&#xff0c;使得单目深度估计的模型容易受到外界的攻击&#xff0c;针对这一问题该论文设计了一种攻击贴图的方法&#xff0c;用于攻击深度学习实现的单目深度估计模型。…...

基于Flask的自闭症患者诊断辅助系统:助力自闭症诊断

基于Flask的自闭症患者诊断辅助系统&#xff1a;助力自闭症诊断的创新方案 在当今社会&#xff0c;自闭症的早期准确诊断对于患者的治疗和康复至关重要。作为项目的第一作者&#xff0c;我致力于开发一款基于Web的自闭症诊断辅助系统&#xff0c;为这一领域贡献一份力量。 本…...

SqlServer Sql学习随笔

环境 SqlServerSSMSC# 查询 --查询来自数据库[MyTestDb]的[dbo]的表[testTable]前1000条数据--dbo 代表 数据库所有者&#xff08;Database Owner&#xff09;&#xff0c;在 SQL Server 里&#xff0c;它是一个模式&#xff08;Schema&#xff09;。 --**模式&#xff08;Sc…...

【6】组合计数学习笔记

前言 关于今天发现自己连快速幂都忘记怎么写这件事 这篇博客是组合计数基础&#xff0c;由于大部分内容都是 6 6 6 级&#xff0c;所以我就给整个提高级的组合数学评了 6 6 6 级。 组合计数基础 加法原理与乘法原理 加法原理&#xff08;分类计数原理&#xff09;&#…...

功能安全实战系列06-英飞凌Tricore系列SMU详解

本文框架 前言1.What?1.1SMU特性及架构1.1.1 SMU_core和SMU_stdby1.1.2 Flip-Flop机制1.1.3 RT Alarm (RecoveryTime)1.2 Alarm状态机1.3 FSP1.4 Alarm handing1.4.1 SMU_core Alarm handing1.4.2 SMU_Standby Alarm handing1.5 寄存器介绍2.How?2.1 如何排查SMU问题前言 在…...

Python 中的集合的中高级用法

Python 中的集合(set)是一种无序且不重复的数据结构,适用于去重、成员检测和集合运算等场景。以下是集合的中级和高级用法,涵盖从基础到高级的详细操作。 1. 集合的创建与初始化 1.1 创建集合 # 空集合 empty_set = set()# 直接初始化 my_set = {1, 2,...

opencv初步学习——图像处理2

这一部分主要讲解如何初步地创建一个图像&#xff0c;以及彩色图像我们的一些基本处理方法 一、创建一个灰度图像 1-1、zeros()函数 [NumPy库] 要用到这一个函数&#xff0c;首先我们需要调用我们的NumPy库&#xff0c;这一个函数的作用是可以帮助我们生成一个元素值都是0的二…...

传统服务部署、虚拟化部署与云原生部署资源消耗对比与优化指南

1. 三种部署方式概述 1.1 传统服务部署 定义&#xff1a;直接运行于物理服务器或基础Linux操作系统环境&#xff0c;无虚拟化层隔离 特点&#xff1a; 资源独占&#xff08;CPU/内存/磁盘&#xff09; 部署流程简单但扩展困难 典型场景&#xff1a;单一业务高负载场景&…...

使用htool工具导出和导入Excel表

htool官网 代码中用到的hool包里面的excel工具ExcelUtil 1. 引入依赖 <!-- Java的工具类 --><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.25</version></dependency>&l…...

【Linux内核】从文件层面理解socket建立的方式(优雅的C风格多态)

内核层面理解 Socket 的创建和连接 引言 众所周知&#xff0c;Linux 下一切皆文件。无论是普通文件&#xff08;如 file.txt&#xff09;&#xff0c;还是特殊文件&#xff08;包括网络套接字&#xff09;&#xff0c;我们都可以以处理文件的方式来访问它们。网络套接字&…...

WebSocket:开启实时通信的新篇章

在当今的互联网应用中&#xff0c;实时交互已经成为不可或缺的一部分。无论是实时的在线聊天、股票行情更新&#xff0c;还是多人在线游戏&#xff0c;都需要一种高效的双向通信机制。而这正是 WebSocket 的用武之地。 本文将带你深入了解 WebSocket&#xff0c;探索其工作原理…...

只是“更轻更薄”?不!遨游三防平板还选择“更强更韧”

当消费电子领域普遍追求“更轻更薄”的设计美学时&#xff0c;遨游三防平板不止于此&#xff0c;还选择了另一条道路——“更强更韧”。在智能制造的复杂场景中&#xff0c;三防平板需直面高温、油污、撞击与极端气候的考验。普通消费级平板因防护性能不足&#xff0c;常因环境…...

C++ 各种map对比

文章目录 特点比较1. std::map2. std::unordered_map3. std::multimap4. std::unordered_multimap5. hash_map&#xff08;SGI STL 扩展&#xff09; C 示例代码代码解释 特点比较 1. std::map 底层实现&#xff1a;基于红黑树&#xff08;一种自平衡的二叉搜索树&#xff09…...

《量子门与AI神经元:计算世界的奇妙碰撞》

在当今科技飞速发展的时代&#xff0c;量子计算和人工智能作为前沿领域&#xff0c;正不断颠覆我们对计算和智能的认知。量子门操作和AI中的神经元计算过程&#xff0c;分别作为这两大领域的核心机制&#xff0c;看似处于不同维度&#xff0c;却有着千丝万缕的联系&#xff0c;…...

【Linux———生产消费模型】

并不是真的路过而已&#xff0c;也不是真的不会想你.............................................................................. 文章目录 前言 一、【生产者消费者模型的介绍】 1、【概念引入】 2、【特点—321原则】 3、【优点】 二、【基于阻塞队列的生产者消费…...

876.链表的中间节点

题目 Python # Definition for singly-linked list. # class ListNode: # def __init__(self, val0, nextNone): # self.val val # self.next next class Solution:def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]:slow fa…...

蓝桥杯第13届真题2

由硬件框图可以知道我们要配置LED 和按键 一.LED 先配置LED的八个引脚为GPIO_OutPut&#xff0c;锁存器PD2也是&#xff0c;然后都设置为起始高电平&#xff0c;生成代码时还要去解决引脚冲突问题 二.按键 按键配置&#xff0c;由原理图按键所对引脚要GPIO_Input 生成代码&a…...