微信小程序使用canvas制作海报并保存到本地相册(超级详细)

news2025/3/19 13:15:50

案例图 在这里插入图片描述

分析案例图都有哪些元素 1.渐变背景 2.圆形头像 3.文字 4.文字超出换行 5.图片居中 6.文字居中 7.单位适配 8.弹窗保存图片。因为一个个绘制图形太麻烦所以这里都采用了方法封装。
canvas api介绍 最后有全部代码,复制即用。
data数据

        data() {
          return {
				myObj: {
					headImg: 'https://img.cncentre.cn/bf29eabe47edba2e6ae7249d76759247.png',
					name: '张三', //微信昵称
					introduce: '我叫张三今年18岁',
					introduction: '计算UI设计稿和你手机的屏幕宽度比例(例如UI设计稿是750宽度 你手机是3',
					bgImg: 'https://img.cncentre.cn/bf29eabe47edba2e6ae7249d76759247.png', //背景图
					rwmImg: 'https://img.cncentre.cn/bf29eabe47edba2e6ae7249d76759247.png',
					smText: '二维码介绍' //个性签名
				},
				canvasWidth: 375, //画布宽度
				canvasHeight: 800, //画布高度
				ratio: 0, //计算UI设计稿和你手机的屏幕宽度比例(例如UI设计稿是750宽度 你手机是350宽度 比例就是2  那么你画布画图时候 所有的尺寸大小、宽高、位置、定位左右上下都需要除以 / 比例2 )
				widths: '',
				heights: '',
				imgs:'' //最后生成的图片
          }
        }

1.单位适配

		onLoad() {
			let that = this
			uni.getSystemInfo({
				success: res => {
					console.log(res);
					// res.screenWidth 设备宽度
					that.canvasWidth = res.screenWidth + 'px'
					that.widths = res.screenWidth
					that.ratio = 750 / res.screenWidth
					that.canvasHeight = (that.widths / 375) * 800 + 'px'
					that.heights = (that.widths / 375) * 800
				}
			})
			uni.showLoading({
				title: '海报生成中...'
			});
			that.downImgUrl()
		},

拿到当前设备宽度用来做整个canvas的单位适配。这里根据要求高度是不变的,因为高度适配的话不同设备下最后生成的canvas 图片会被压缩

2.渐变背景

				let _this = this
				// 生成画布
				const ctx = uni.createCanvasContext('myCanvas')
				// 绘制背景
				const bcg = ctx.createLinearGradient(0, 0, 0, _this.heights)
				bcg.addColorStop(0.4, '#D9EBE6')
				bcg.addColorStop(1, '#fff')
				_this.ctxRectangle(ctx, 0, 0, (_this.widths), (_this.heights), 0, bcg)

			//画一个矩形也就是整个海报的背景
			ctxRectangle(ctx, x, y, width, height, r, gnt) {
				ctx.beginPath() //开始绘制
				ctx.save() //保存状态
				ctx.moveTo(x + r, y)
				ctx.lineTo(x + width - r, y)
				ctx.arc(x + width - r, y + r, r, Math.PI * 1.5, Math.PI * 2)
				ctx.lineTo(x + width, y + height - r)
				ctx.arc(x + width - r, y + height - r, r, 0, Math.PI * 0.5)
				ctx.lineTo(x + r, y + height)
				ctx.arc(x + r, y + height - r, r, Math.PI * 0.5, Math.PI)
				ctx.lineTo(x, y + r)
				ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5)
				ctx.fillStyle = gnt
				ctx.fill() //对当前路径中的内容进行填充
				ctx.closePath()
			},

3.圆形头像

             //绘制头像
		    _this.ctxCircular(ctx, _this.myObj.headImg, (40 / _this.ratio), (100 / _this.ratio), (160 / _this.ratio), (160 / _this.ratio), 80 / _this.ratio, 1)
			//画一个带圆角矩形
			//ctx 创建的canvas img填充的图片路径 x轴距离 y轴距离 width宽度 height高度 r圆角大小 shadow是否增加阴影
			ctxCircular(ctx, img, x, y, width, height, r, shadow) {
				ctx.beginPath() //开始绘制
				ctx.save() //保存(canvas)状态
				ctx.moveTo(x + r, y)
				ctx.lineTo(x + width - r, y)
				ctx.arc(x + width - r, y + r, r, Math.PI * 1.5, Math.PI * 2)
				ctx.lineTo(x + width, y + height - r)
				ctx.arc(x + width - r, y + height - r, r, 0, Math.PI * 0.5)
				ctx.lineTo(x + r, y + height)
				ctx.arc(x + r, y + height - r, r, Math.PI * 0.5, Math.PI)
				ctx.lineTo(x, y + r)
				ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5)
				if (shadow == 1) {
					ctx.shadowBlur = 20; // 阴影模糊程度
					ctx.shadowColor = '#fff'; // 阴影颜色
				}
				ctx.fill() //对当前路径中的内容进行填充
				ctx.clip() //从原始画布中剪切任意形状和尺寸
				ctx.closePath() //关闭一个路径
				ctx.drawImage(img, x, y, width, height);
				ctx.restore() //恢复(canvas)状态
			},	

增加了阴影的效果在这里插入图片描述

4.绘制文字

				//名字
				_this.ctxText(ctx,'normal bold 18px Arial,PingFang SC','left','#00663A',_this.myObj.name, 220 / _this.ratio, 128 / _this.ratio)
				//文字方法
				// textFont 字体样式大小 
				ctxText(ctx, textFont, textAlign, textFillStyle, textName, x, y) {
				ctx.beginPath()
				ctx.save() //保存状态
				//字体样式大小
				ctx.font = textFont,
				//文字对齐方式
				ctx.textAlign = textAlign
				//字体颜色
				ctx.fillStyle = textFillStyle
				//填充字体  x轴 y轴
				ctx.fillText(textName, x, y)
			},

5.文字超出换行

             //介绍
			_this.ctxTextWrap(ctx, _this.myObj.introduction, 220 / _this.ratio, 170 / _this.ratio, 460 / _this.ratio)
			//文字超出换行方法
			ctxTextWrap(ctx, text, x, y, w) {
				//自动换行介绍
				var temp = ""
				var row = []
				let gxqm = ''
				if (text) {
					gxqm = text
				} else {
					gxqm = '未设置个性签名'
				}
				let gexingqianming = gxqm.split("")
				for (var a = 0; a < gexingqianming.length; a++) {
					if (ctx.measureText(temp).width < w) {} else {
						row.push(temp)
						temp = ""
					}
					temp += gexingqianming[a]
				}
				row.push(temp)
				ctx.font = "13px arail"
				ctx.textAlign = 'left';
				ctx.fillStyle = "#000000"
				for (var b = 0; b < row.length; b++) {
					ctx.fillText(row[b], x, y + (b + 1) * 20)
				}
			},

6.图片居中

这里是中间的背景图比较简单就没有封装方法

	            // 背景图
				ctx.drawImage(_this.myObj.bgImg, //图像资源
					(48 / _this.ratio),//图像的左上角在目标canvas上 X 轴的位置
					(290 / _this.ratio),//图像的左上角在目标canvas上 Y 轴的位置
					(654 / _this.ratio),//在目标画布上绘制图像的宽度
					(1064 / _this.ratio)//在目标画布上绘制图像的高度
				)

7.文字居中

                // 文字居中
				_this.ctxText(ctx,
					'13px Arial,PingFang SC',
					'center',
					'#242424',
					_this.myObj.smText, 375 / _this.ratio, 1562 / _this.ratio)
			//封装方法 textAlign传入 center就可以
			ctxText(ctx, textFont, textAlign, textFillStyle, textName, x, y) {
				ctx.beginPath()
				ctx.save() //保存状态
				//字体
				ctx.font = textFont,
				//字体样式
				ctx.textAlign = textAlign
				//字体颜色
				ctx.fillStyle = textFillStyle
				//填充字体
				ctx.fillText(textName, x, y)
			},

8.渲染画布,保存图片

8.1 渲染画布

				// 渲染画布
				ctx.draw(false, (() => {
					setTimeout(() => {
						uni.canvasToTempFilePath({
							canvasId: 'myCanvas',
							destWidth: _this.canvasWidth * 2, //展示图片尺寸=画布尺寸1*像素比2
							destHeight: _this.canvasHeight * 2,
							quality: 1,
							fileType: 'jpg',
							success: (res) => {
								uni.hideLoading()
								console.log('通过画布绘制出的图片--保存的就是这个图', res.tempFilePath)
								_this.imgs = res.tempFilePath
								//点击保存方法 打开弹窗
								_this.$refs.popup.open()
							},
							fail: function(error) {
								uni.hideLoading()
								uni.showToast({
									icon: 'none',
									position: 'bottom',
									title: "绘制图片失败", // res.tempFilePath
								})
							}
						}, _this)

					}, 100)
				})())

到这里绘图就结束了最后借助 uni.canvasToTempFilePath()把当前画布指定区域的内容导出生成指定大小的图片,并返回文件路径,也就是我们 data定义的imgs

8.2 点击保存图片

			saveImage() {
				uni.saveImageToPhotosAlbum({
					filePath: this.imgs,
					success: function() {
						uni.showToast({
							icon: 'none',
							position: 'bottom',
							title: "已保存到系统相册",
						})
					},
					fail: function(error) {
						uni.showModal({
							title: '提示',
							content: '若点击不授权,将无法使用保存图片功能',
							cancelText: '不授权',
							cancelColor: '#999',
							confirmText: '授权',
							confirmColor: '#f94218',
							success(res) {
								console.log(res)
								if (res.confirm) {
									// 选择弹框内授权
									uni.openSetting({
										success(res) {
											console.log(res.authSetting)
										}
									})
								} else if (res.cancel) {
									// 选择弹框内 不授权
									console.log('用户点击不授权')
								}
							}
						})
					}
				})
			},

8.3 长按保存图片

如果要实现这个功能需要用到image带的longtap方法,也就是 长按事件。还需要一个值来隐藏显示image这里用的data里面的 isshow,然后监听imgs是否为空打开弹窗。

	<view class="percard">
		<canvas v-show='isshow' canvas-id="myCanvas" :style="{ width: canvasWidth, height: canvasHeight }"></canvas>
		<image v-show='!isshow' @longtap="saveImage()" :src="imgs" mode=""
			:style="{ width: canvasWidth, height: canvasHeight }"></image>
		<uni-popup ref="popup" type="center">
			<view class="pop1">
				<view class="tit">
					//点击下面按钮下载到相册
					请长按下载到相册
				</view>
				<view class="btns" @click="closer()">知道了</view>
				<view class="btns" @click="goindex()">回到首页</view>
			</view>
		</uni-popup>
	</view>
	watch: {
		imgs(newlue) {
			if (newlue) {
				this.isshow = false
				this.$refs.popup.open()
			}
		}
	},
	//关闭弹窗
	closer() {
		this.$refs.popup.close()
	},

全部代码

需要注意点canvas的绘制时不能直接使用网络路径图片,需要使用 uni.getImageInfo 返回图片本地路径再使用。本页面使用了uni-popup组件,自己的项目记得引入。

<template>
	<view class="percard">
		<canvas v-show='isshow' canvas-id="myCanvas" :style="{ width: canvasWidth, height: canvasHeight }"></canvas>
		<image v-show='!isshow' @longtap="saveImage()" :src="imgs" mode=""
			:style="{ width: canvasWidth, height: canvasHeight }"></image>
		<uni-popup ref="popup" type="center">
			<view class="pop1">
				<view class="tit">
					<!-- 点击下面按钮下载到相册 -->
				    请长按下载图片
				</view>
				<!-- <view class="btns" @click="saveImage()">点击保存</view> -->
				<view class="btns" @click="closer()">知道了</view>
				<view class="btns" @click="goindex()">回到首页</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isshow: true,
				myObj: {
					headImg: 'https://img.cncentre.cn/bf29eabe47edba2e6ae7249d76759247.png',
					name: '张三', //微信昵称
					introduce: '我叫张三今年18岁',
					introduction: '计算UI设计稿和你手机的屏幕宽度比例(例如UI设计稿是750宽度 你手机是3',
					bgImg: 'https://img.cncentre.cn/bf29eabe47edba2e6ae7249d76759247.png', //背景图
					rwmImg: 'https://img.cncentre.cn/bf29eabe47edba2e6ae7249d76759247.png',
					smText: '二维码介绍' //个性签名
				},
				canvasWidth: 375, //画布宽度
				canvasHeight: 800, //画布高度
				ratio: 0, //计算UI设计稿和你手机的屏幕宽度比例(例如UI设计稿是750宽度 你手机是350宽度 比例就是2  那么你画布画图时候 所有的尺寸大小、宽高、位置、定位左右上下都需要除以 / 比例2 )
				widths: '',
				heights: '',
				imgs: ''

			}
		},
		watch: {
			imgs(newlue) {
				if (newlue) {
					this.isshow = false
					this.$refs.popup.open()
				}
			}
		},
		onLoad() {
			let that = this
			uni.getSystemInfo({
				success: res => {
					console.log(res);
					// res.screenWidth 设备宽度
					that.canvasWidth = res.screenWidth + 'px'
					that.widths = res.screenWidth
					that.ratio = 750 / res.screenWidth
					that.canvasHeight = (that.widths / 375) * 800 + 'px'
					that.heights = (that.widths / 375) * 800
				}
			})
			uni.showLoading({
				title: '海报生成中...'
			});
			that.downImgUrl()
		},
		methods: {
			downImgUrl() {
				let that = this
				uni.getImageInfo({
					src: that.myObj.headImg,
					success: function(res) {
						that.myObj.headImg = res.path
						uni.getImageInfo({
							src: that.myObj.bgImg,
							success: function(res) {
								that.myObj.bgImg = res.path
								uni.getImageInfo({
									src: that.myObj.rwmImg,
									success: function(res) {
										that.myObj.rwmImg = res.path
										that.drawPageImg()
									}
								});
							}
						});
					}
				});

			},
			closer() {
				this.$refs.popup.close()
			},
			goindex() {
				uni.reLaunch({
					url: '/pages/index/index'
				})
			},
			saveImage() {
				uni.saveImageToPhotosAlbum({
					filePath: this.imgs,
					success: function() {
						uni.showToast({
							icon: 'none',
							position: 'bottom',
							title: "已保存到系统相册",
						})
					},
					fail: function(error) {
						uni.showModal({
							title: '提示',
							content: '若点击不授权,将无法使用保存图片功能',
							cancelText: '不授权',
							cancelColor: '#999',
							confirmText: '授权',
							confirmColor: '#f94218',
							success(res) {
								console.log(res)
								if (res.confirm) {
									// 选择弹框内授权
									uni.openSetting({
										success(res) {
											console.log(res.authSetting)
										}
									})
								} else if (res.cancel) {
									// 选择弹框内 不授权
									console.log('用户点击不授权')
								}
							}
						})
					}
				})
			},
			//画一个带圆角矩形
			ctxCircular(ctx, img, x, y, width, height, r, shadow) {
				ctx.beginPath() //开始绘制
				ctx.save() //保存(canvas)状态
				ctx.moveTo(x + r, y)
				ctx.lineTo(x + width - r, y)
				ctx.arc(x + width - r, y + r, r, Math.PI * 1.5, Math.PI * 2)
				ctx.lineTo(x + width, y + height - r)
				ctx.arc(x + width - r, y + height - r, r, 0, Math.PI * 0.5)
				ctx.lineTo(x + r, y + height)
				ctx.arc(x + r, y + height - r, r, Math.PI * 0.5, Math.PI)
				ctx.lineTo(x, y + r)
				ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5)
				if (shadow == 1) {
					ctx.shadowBlur = 20; // 模糊效果程度的
					ctx.shadowColor = 'red'; // 阴影颜色
				}
				ctx.fill() //对当前路径中的内容进行填充
				ctx.clip() //从原始画布中剪切任意形状和尺寸
				ctx.closePath() //关闭一个路径
				ctx.drawImage(img, x, y, width, height);
				ctx.restore() //恢复(canvas)状态
			},
			//画一个矩形也就是整个海报的背景
			ctxRectangle(ctx, x, y, width, height, r, gnt) {
				ctx.beginPath()
				ctx.save() //保存状态
				ctx.moveTo(x + r, y)
				ctx.lineTo(x + width - r, y)
				ctx.arc(x + width - r, y + r, r, Math.PI * 1.5, Math.PI * 2)
				ctx.lineTo(x + width, y + height - r)
				ctx.arc(x + width - r, y + height - r, r, 0, Math.PI * 0.5)
				ctx.lineTo(x + r, y + height)
				ctx.arc(x + r, y + height - r, r, Math.PI * 0.5, Math.PI)
				ctx.lineTo(x, y + r)
				ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5)
				ctx.fillStyle = gnt
				ctx.fill() //对当前路径中的内容进行填充
				ctx.closePath() //关闭一个路径
			},
			ctxText(ctx, textFont, textAlign, textFillStyle, textName, x, y) {
				ctx.beginPath()
				ctx.save() //保存状态
				//字体
				ctx.font = textFont,
				//字体样式
				ctx.textAlign = textAlign
				//字体颜色
				ctx.fillStyle = textFillStyle
				//填充字体
				ctx.fillText(textName, x, y)
			},
			ctxTextWrap(ctx, text, x, y, w) {
				//自动换行介绍
				var temp = ""
				var row = []
				let gxqm = ''
				if (text) {
					gxqm = text
				} else {
					gxqm = '未设置个性签名'
				}
				let gexingqianming = gxqm.split("")
				for (var a = 0; a < gexingqianming.length; a++) {
					if (ctx.measureText(temp).width < w) {} else {
						row.push(temp)
						temp = ""
					}
					temp += gexingqianming[a]
				}
				row.push(temp)
				ctx.font = "13px arail"
				ctx.textAlign = 'left';
				ctx.fillStyle = "#000000"
				for (var b = 0; b < row.length; b++) {
					ctx.fillText(row[b], x, y + (b + 1) * 20)
				}
			},
			// 使用画布绘制页面
			drawPageImg() {
				let _this = this
				// 生成画布
				const ctx = uni.createCanvasContext('myCanvas')
				// 绘制背景
				const bcg = ctx.createLinearGradient(0, 0, 0, _this.heights)
				bcg.addColorStop(0.4, '#D9EBE6')
				bcg.addColorStop(1, '#fff')
				_this.ctxRectangle(ctx, 0, 0, (_this.widths), (_this.heights), 0, bcg)
				//名字
				_this.ctxText(ctx,
					'normal bold 18px Arial,PingFang SC',
					'left',
					'#00663A',
					_this.myObj.name, 220 / _this.ratio, 128 / _this.ratio)
				//名称
				_this.ctxText(ctx,
					'13px Arial,PingFang SC',
					'left',
					'#242424',
					_this.myObj.introduce, 220 / _this.ratio, 170 / _this.ratio)
				//介绍
				_this.ctxTextWrap(ctx, _this.myObj.introduction, 220 / _this.ratio, 170 / _this.ratio, 460 / _this.ratio)
				// // 背景图
				ctx.drawImage(_this.myObj.bgImg, //图像资源
					(48 / _this.ratio),//图像的左上角在目标canvas上 X 轴的位置
					(290 / _this.ratio),//图像的左上角在目标canvas上 Y 轴的位置
					(654 / _this.ratio),//在目标画布上绘制图像的宽度
					(1064 / _this.ratio)//在目标画布上绘制图像的高度
				)
				_this.ctxText(ctx,
					'13px Arial,PingFang SC',
					'center',
					'#242424',
					_this.myObj.smText, 375 / _this.ratio, 1562 / _this.ratio)
				// // 绘制头像
				_this.ctxCircular(ctx, _this.myObj.headImg, (40 / _this.ratio), (100 / _this.ratio), (160 / _this.ratio), (
					160 / _this.ratio), 80 / _this.ratio)

				//矩形二维码
				_this.ctxCircular(ctx, _this.myObj.rwmImg, (305 / _this.ratio), (1382 / _this.ratio), (140 / _this.ratio),
					(140 / _this.ratio), 6)
				// 渲染画布
				ctx.draw(false, (() => {
					setTimeout(() => {
						uni.canvasToTempFilePath({
							canvasId: 'myCanvas',
							destWidth: _this.canvasWidth * 2, //展示图片尺寸=画布尺寸1*像素比2
							destHeight: _this.canvasHeight * 2,
							quality: 1,
							fileType: 'jpg',
							success: (res) => {
								uni.hideLoading()
								console.log('通过画布绘制出的图片--保存的就是这个图', res.tempFilePath)
								_this.imgs = res.tempFilePath
								// _this.$refs.popup.open()
							},
							fail: function(error) {
								uni.hideLoading()
								uni.showToast({
									icon: 'none',
									position: 'bottom',
									title: "绘制图片失败", // res.tempFilePath
								})
							}
						}, _this)

					}, 100)
				})())
			},

		}
	}
</script>
<style lang="scss">
	.pop1 {
		background-color: #fff;
		width: 520rpx;
		padding: 68rpx 120rpx;
		box-sizing: border-box;
		border-radius: 20rpx;
		background: linear-gradient(#E6F5EB 45%, #FEFFFE 100%);

		.tit {
			font-size: 32rpx;
			color: #000000;
			margin: 20px 0px;
		}

		.btns {
			font-size: 32rpx;
			color: #fff;
			background-color: #00663A;
			border-radius: 14rpx;
			padding: 14rpx 30rpx;
			margin-top: 40rpx;
			text-align: center;
		}
	}
</style>

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

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

相关文章

快排可视化

文章目录 1. 结果1.1 结果图1.2 动画图 2. 代码2.1 快排代码2.2 绘图代码 1. 结果 红色为被选中的pt 1.1 结果图 1.2 动画图 1个pt排好序后就把该pt标红 2. 代码 2.1 快排代码 private Integer selPt(List<Integer> list, int left, int right) {if (left > rig…

C# WPF上位机开发(windows pad上的应用)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 大部分同学可能都认为c# wpf只能用在pc端。其实这是一种误解。c# wpf固然暂时只能运行在windows平台上面&#xff0c;但是windows平台不仅仅是电脑…

现代 NLP:详细概述,第 1 部分:transformer

阿比吉特罗伊 一、说明 近五年来&#xff0c;随着 BERT 和 GPT 等思想的引入&#xff0c;我们在自然语言处理领域取得了巨大的成就。在本文中&#xff0c;我们的目标是逐步深入研究改进的细节&#xff0c;并了解它们带来的演变。 二、关注就是你所需要的 2017 年&#xff0c;来…

Java多线程技术六——线程的状态

1 概述 线程在不同的运行时期存在不同的状态&#xff0c;状态信息在存在于State枚举类中&#xff0c;如下图。 每个状态的解释如下图 调用于线程有关的方法是造成线程状态改变的主要原因&#xff0c;因果关系如下图 从上图可知&#xff0c;在调用与线程有关的方法后&#xff0…

Upload-Labs-Linux

题目 1.打开靶机 随便上传一个图片&#xff0c;查看get请求发现/upload/XXX.jpg 2.创建一个脚本文件 命名为flag.php.jpg,并上传 脚本文件内容&#xff1a; <?php eval($_POST[1234])?> 3上传后复制文件get请求的链接并打开蚁剑 连接密码为123 双击链接 4&#xff…

ios 之 数据库、地理位置、应用内跳转、推送、制作静态库、CoreData

第一节&#xff1a;数据库 常见的API SQLite提供了一系列的API函数&#xff0c;用于执行各种数据库相关的操作。以下是一些常用的SQLite API函数及其简要说明&#xff1a;1. sqlite3_initialize:- 初始化SQLite库。通常在开始使用SQLite之前调用&#xff0c;但如果没有调用&a…

云计算:现代技术的基本要素

众所周知&#xff0c;在儿童教育的早期阶段&#xff0c;幼儿园都会传授塑造未来行为的一些基本准则。 今天&#xff0c;我们可以以类似的方式思考云计算&#xff1a;它已成为现代技术架构中的基本元素。云现在在数字交互、安全和基础设施开发中发挥着关键作用。云不仅仅是另一…

在Android中使用Flow获取网络连接信息

在Android中使用Flow获取网络连接信息 如果你是一名Android开发者&#xff0c;你可能会对这个主题感到有趣。考虑到几乎每个应用程序都需要数据交换&#xff0c;例如刷新动态或上传/下载内容。而互联网连接对此至关重要。但是&#xff0c;当用户的设备离线时&#xff0c;数据如…

Flink电商实时数仓(六)

交易域支付成功事务事实表 从topic_db业务数据中筛选支付成功的数据从dwd_trade_order_detail主题中读取订单事实数据、LookUp字典表关联三张表形成支付成功宽表写入 Kafka 支付成功主题 执行步骤 设置ttl&#xff0c;通过Interval join实现左右流的状态管理获取下单明细数据…

OGG-MySQL无法正常同步数据问题分析

问题背景: 用户通过OGG从源端一个MySQL从库将数据同步到目标端的另一个MySQL数据库里面&#xff0c;后面由于源端的从库出现了长时间的同步延时&#xff0c;由于延时差距过大最后选择通过重建从库方式进行了修复 从库重建之后&#xff0c;源端的OGG出现了报错ERROR OGG-0014…

电商数据分析-02-电商业务介绍及表结构

参考 电商业务简介 大数据项目之电商数仓、电商业务简介、电商业务流程、电商常识、业务数据介绍、电商业务表、后台管理系统 举个例子:&#x1f330; 1.1 电商业务流程 电商的业务流程可以以一个普通用户的浏览足迹为例进行说明&#xff0c;用户点开电商首页开始浏览&…

蓝桥杯备赛 day 1 —— 递归 、递归、枚举算法(C/C++,零基础,配图)

目录 &#x1f308;前言 &#x1f4c1; 枚举的概念 &#x1f4c1;递归的概念 例题&#xff1a; 1. 递归实现指数型枚举 2. 递归实现排列型枚举 3. 递归实现组合型枚举 &#x1f4c1; 递推的概念 例题&#xff1a; 斐波那契数列 &#x1f4c1;习题 1. 带分数 2. 反硬币 3. 费解的…

小程序面试题 | 18.精选小程序面试题

&#x1f90d; 前端开发工程师&#xff08;主业&#xff09;、技术博主&#xff08;副业&#xff09;、已过CET6 &#x1f368; 阿珊和她的猫_CSDN个人主页 &#x1f560; 牛客高级专题作者、在牛客打造高质量专栏《前端面试必备》 &#x1f35a; 蓝桥云课签约作者、已在蓝桥云…

大师计划1.0 - log2 CRTO笔记

CRTOⅠ笔记 log2 这个笔记是我在2023年11月23日-12月22日中&#xff0c;学习CRTO所做的一些笔记。 事实上TryHackMe的路径和htb学院包含了许多CRTO的知识并且甚至还超出了CRTO&#xff08;CS除外&#xff09;&#xff0c;所以很多东西在THM和htb学院学过&#xff0c;这次CRTO等…

RK3588平台开发系列讲解(AI 篇)RKNN rknn_query函数详细说明

文章目录 一、查询 SDK 版本二、查询输入输出 tensor 个数三、查询输入 tensor 属性(用于通用 API 接口)四、查询输出 tensor 属性(用于通用 API 接口)五、查询模型推理的逐层耗时六、查询模型推理的总耗时七、查询模型的内存占用情况八、查询模型里用户自定义字符串九、查询原…

往年面试精选题目(前50道)

常用的集合和区别&#xff0c;list和set区别 Map&#xff1a;key-value键值对&#xff0c;常见的有&#xff1a;HashMap、Hashtable、ConcurrentHashMap以及TreeMap等。Map不能包含重复的key&#xff0c;但是可以包含相同的value。 Set&#xff1a;不包含重复元素的集合&#…

第四周:机器学习知识点回顾

前言&#xff1a; 讲真&#xff0c;复习这块我是比较头大的&#xff0c;之前的线代、高数、概率论、西瓜书、樱花书、NG的系列课程、李宏毅李沐等等等等…那可是花了三年学习佳实践下来的&#xff0c;现在一想脑子里就剩下几个名词就觉得废柴一个了&#xff0c;朋友们有没有同感…

Linux操作系统基础知识点

Linux是一种计算机操作系统&#xff0c;其内核由林纳斯本纳第克特托瓦兹&#xff08;Linus Benedict Torvalds&#xff09;于1991年首次发布。Linux操作系统通常与GNU套件一起使用&#xff0c;因此也被称为GNU/Linux。它是一种类UNIX的操作系统&#xff0c;设计为多用户、多任务…

滤波器(Filter)

滤波器 常用滤波器元器件 馈通电容滤波器NFM18PC104R1C3 \SDCW2012-2-900TF \ 0603 0.1UF(104) 16V 文章目录 滤波器前言一、滤波器是什么二、两路 0805共模滤波器 阻抗90Ω@100MHz三、0603 0.1UF(104) 16V四、馈通电容滤波器NFM18PC104R1C3总结前言 滤波器在电子系统中具有…

车载网络 - BootLoader - UDS刷写闲聊

聊升级的话,我们不得不聊一下MCU升级的一些基础概念;我们今天就简单说下,如果大家有兴趣,可以评论区留言,我后续继续补充内容或者私聊都可以的。 目录 一、MCU内存说明 二、常见的2类BOOT段 三、常见的APP段