Tailwind CSS 实战:社交媒体信息流开发
在社交媒体的世界里,信息流就像是一条永不停歇的河流,承载着用户的分享与互动。记得在一个社交平台项目中,我们通过重新设计信息流的展示方式,让用户的平均浏览时长提升了 45%。今天,我想和大家分享如何使用 Tailwind CSS 打造一个引人入胜的社交媒体信息流。
设计理念
设计社交媒体信息流就像是在策划一场永不落幕的展览。每一条动态都是一件展品,需要精心布置,让观众(用户)能够轻松浏览,并产生互动的欲望。在这个展览中,我们不仅要关注单个展品的呈现,更要考虑整体的节奏和韵律。
想象一下,当用户打开应用时,他们就像是走进了一个充满故事的长廊。有趣的图文内容是装点墙面的画作,短视频是播放的影像,而评论区则是观众的留言板。这种沉浸式的体验,需要我们在设计时特别注意以下几点:
- 内容呈现要像是精心策划的展位,让每条信息都有自己的舞台
- 交互设计要像是无声的导览,引导用户自然地浏览和参与
- 性能优化要像是通风系统,在用户无感知的情况下保持体验的流畅
信息流卡片开发
信息流卡片是整个展览中最基础的展示单元,需要像艺术品展架一样,既要突出内容,又要保持整体的协调:
<div class="max-w-2xl mx-auto"><!-- 信息流卡片 --><article class="bg-white rounded-lg shadow-sm mb-6 overflow-hidden"><!-- 用户信息区 --><div class="flex items-center px-4 py-3"><div class="flex items-center"><!-- 头像 --><img class="h-10 w-10 rounded-full object-cover border-2 border-white shadow-sm"src="/avatars/user-1.jpg" alt="用户头像"><!-- 用户名和发布时间 --><div class="ml-3"><h3 class="text-sm font-semibold text-gray-900"><a href="#" class="hover:underline">摄影师小王</a></h3><span class="text-xs text-gray-500">2小时前 · 上海</span></div></div><!-- 更多操作按钮 --><button class="ml-auto p-2 hover:bg-gray-100 rounded-full"><svg class="h-5 w-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20"><path d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" /></svg></button></div><!-- 内容区域 --><div class="px-4 py-2"><p class="text-gray-900 text-sm">今天在外滩拍到的日落,光线真的太美了!分享给大家 ✨<a href="#" class="text-blue-600 hover:underline">#上海风光</a><a href="#" class="text-blue-600 hover:underline">#摄影日常</a></p></div><!-- 图片区域 --><div class="mt-2"><div class="grid grid-cols-2 gap-1"><div class="relative aspect-w-1 aspect-h-1"><img src="/photos/sunset-1.jpg" alt="日落照片" class="w-full h-full object-cover cursor-pointer hover:opacity-95 transition-opacity"οnclick="openLightbox(this.src)"></div><div class="relative aspect-w-1 aspect-h-1"><img src="/photos/sunset-2.jpg" alt="日落照片" class="w-full h-full object-cover cursor-pointer hover:opacity-95 transition-opacity"οnclick="openLightbox(this.src)"></div></div></div><!-- 互动区域 --><div class="px-4 py-3"><!-- 点赞、评论、分享按钮 --><div class="flex items-center space-x-4"><button class="flex items-center space-x-2 text-gray-600 hover:text-red-500 transition-colors"><svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" /></svg><span class="text-sm">1,234</span></button><button class="flex items-center space-x-2 text-gray-600 hover:text-blue-500 transition-colors"><svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" /></svg><span class="text-sm">89</span></button><button class="flex items-center space-x-2 text-gray-600 hover:text-green-500 transition-colors"><svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z" /></svg><span class="text-sm">46</span></button></div><!-- 评论预览 --><div class="mt-3 space-y-3"><div class="flex space-x-2"><a href="#" class="text-sm font-medium text-gray-900 hover:underline">摄影师老李</a><p class="text-sm text-gray-600">构图很赞,光线把握得恰到好处!</p></div><div class="flex space-x-2"><a href="#" class="text-sm font-medium text-gray-900 hover:underline">设计师小张</a><p class="text-sm text-gray-600">色彩层次感很强,期待更多作品!</p></div><!-- 查看更多评论 --><button class="text-sm text-gray-500 hover:text-gray-700">查看全部 89 条评论</button></div><!-- 评论输入框 --><div class="mt-3 flex items-center"><img class="h-8 w-8 rounded-full object-cover"src="/avatars/current-user.jpg" alt="当前用户头像"><div class="flex-1 ml-3"><input type="text" placeholder="添加评论..." class="w-full text-sm border-0 focus:ring-0 outline-none bg-transparent"></div><button class="ml-2 text-sm font-medium text-blue-500 hover:text-blue-600">发布</button></div></div></article>
</div><!-- 图片预览弹窗 -->
<div id="lightbox" class="fixed inset-0 bg-black bg-opacity-90 hidden z-50"><button class="absolute top-4 right-4 text-white" οnclick="closeLightbox()"><svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg></button><img id="lightbox-image" class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 max-w-[90vw] max-h-[90vh]"src="" alt="预览图片">
</div><script>
function openLightbox(src) {const lightbox = document.getElementById('lightbox');const lightboxImage = document.getElementById('lightbox-image');lightboxImage.src = src;lightbox.classList.remove('hidden');document.body.style.overflow = 'hidden';
}function closeLightbox() {const lightbox = document.getElementById('lightbox');lightbox.classList.add('hidden');document.body.style.overflow = '';
}
</script>
无限滚动实现
无限滚动就像是展览的自动导览系统,需要在适当的时机加载新的内容:
<div id="feed-container" class="max-w-2xl mx-auto"><!-- 信息流内容 --><div id="feed-content"><!-- 动态卡片将在这里动态插入 --></div><!-- 加载状态 --><div id="loading-indicator" class="py-4 text-center hidden"><div class="inline-flex items-center px-4 py-2 font-semibold leading-6 text-sm shadow rounded-md text-white bg-indigo-500 transition ease-in-out duration-150 cursor-not-allowed"><svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>正在加载更多...</div></div>
</div><script>
// 使用 Intersection Observer 实现无限滚动
let page = 1;
let loading = false;const loadMorePosts = async () => {if (loading) return;loading = true;document.getElementById('loading-indicator').classList.remove('hidden');try {const response = await fetch(`/api/posts?page=${page}`);const posts = await response.json();if (posts.length > 0) {// 渲染新的帖子posts.forEach(post => {const postElement = createPostElement(post);document.getElementById('feed-content').appendChild(postElement);});page++;}} catch (error) {console.error('加载失败:', error);} finally {loading = false;document.getElementById('loading-indicator').classList.add('hidden');}
};// 创建观察器
const observer = new IntersectionObserver((entries) => {const lastEntry = entries[0];if (lastEntry.isIntersecting) {loadMorePosts();}
}, {rootMargin: '100px'
});// 监听加载指示器
observer.observe(document.getElementById('loading-indicator'));// 创建帖子元素的辅助函数
function createPostElement(post) {const template = document.createElement('template');template.innerHTML = `<article class="bg-white rounded-lg shadow-sm mb-6 overflow-hidden"><!-- 帖子内容模板 --></article>`;return template.content.firstElementChild;
}
</script>
故事流实现
故事流就像是展览中的特别展区,需要吸引眼球并鼓励互动:
<div class="max-w-2xl mx-auto mb-6"><div class="relative"><!-- 故事列表 --><div class="flex space-x-4 overflow-x-auto pb-4 scrollbar-hide"><!-- 添加故事按钮 --><div class="flex-shrink-0 w-20"><div class="relative group cursor-pointer"><div class="w-16 h-16 rounded-full overflow-hidden border-2 border-dashed border-gray-300 flex items-center justify-center bg-gray-50 group-hover:bg-gray-100"><svg class="h-8 w-8 text-gray-400 group-hover:text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" /></svg></div><p class="mt-1 text-xs text-center text-gray-500">添加故事</p></div></div><!-- 故事项目 --><div class="flex-shrink-0 w-20"><div class="relative group cursor-pointer" οnclick="openStory(1)"><div class="w-16 h-16 rounded-full overflow-hidden border-2 border-gradient-to-r from-pink-500 via-red-500 to-yellow-500"><img src="/stories/story-1.jpg" alt="故事封面" class="w-full h-full object-cover"></div><p class="mt-1 text-xs text-center text-gray-900 truncate">旅行日记</p></div></div><!-- 更多故事... --></div><!-- 左右滚动按钮 --><button class="absolute left-0 top-1/2 transform -translate-y-1/2 bg-white rounded-full shadow-lg p-2 hover:bg-gray-50 focus:outline-none hidden md:block"><svg class="h-5 w-5 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" /></svg></button><button class="absolute right-0 top-1/2 transform -translate-y-1/2 bg-white rounded-full shadow-lg p-2 hover:bg-gray-50 focus:outline-none hidden md:block"><svg class="h-5 w-5 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" /></svg></button></div>
</div><!-- 故事查看器 -->
<div id="story-viewer" class="fixed inset-0 bg-black hidden z-50"><div class="relative h-full"><!-- 故事内容 --><div class="absolute inset-0"><img id="story-image" class="w-full h-full object-contain"src="" alt="故事内容"></div><!-- 进度条 --><div class="absolute top-0 left-0 right-0 flex space-x-1 p-2"><div class="flex-1 h-0.5 bg-white bg-opacity-30"><div class="h-full bg-white w-0" style="animation: progress 5s linear forwards;"></div></div></div><!-- 用户信息 --><div class="absolute top-4 left-4 flex items-center"><img class="h-8 w-8 rounded-full border-2 border-white"src="/avatars/story-user.jpg" alt="用户头像"><div class="ml-2 text-white"><h4 class="text-sm font-semibold">用户昵称</h4><p class="text-xs opacity-75">2小时前</p></div></div><!-- 关闭按钮 --><button class="absolute top-4 right-4 text-white" οnclick="closeStory()"><svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg></button></div>
</div><style>
@keyframes progress {from { width: 0; }to { width: 100%; }
}.scrollbar-hide {-ms-overflow-style: none;scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {display: none;
}
</style><script>
function openStory(id) {const viewer = document.getElementById('story-viewer');const image = document.getElementById('story-image');image.src = `/stories/story-${id}-full.jpg`;viewer.classList.remove('hidden');document.body.style.overflow = 'hidden';
}function closeStory() {const viewer = document.getElementById('story-viewer');viewer.classList.add('hidden');document.body.style.overflow = '';
}
</script>
动态更新效果
动态更新就像是展览的实时互动,需要平滑而自然:
<script>
// 点赞动画
function animateLike(button) {// 创建心形图标const heart = document.createElement('div');heart.innerHTML = `<svg class="h-16 w-16 text-red-500 transform scale-0 opacity-0 transition-all duration-500" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clip-rule="evenodd" /></svg>`;// 定位动画heart.style.position = 'absolute';heart.style.top = '50%';heart.style.left = '50%';heart.style.transform = 'translate(-50%, -50%)';button.appendChild(heart);// 播放动画requestAnimationFrame(() => {const svg = heart.querySelector('svg');svg.classList.remove('scale-0', 'opacity-0');svg.classList.add('scale-100', 'opacity-100');setTimeout(() => {svg.classList.add('scale-0', 'opacity-0');setTimeout(() => heart.remove(), 500);}, 1000);});
}// 评论实时更新
function addComment(postId, comment) {const commentsList = document.querySelector(`#post-${postId} .comments-list`);const newComment = document.createElement('div');newComment.classList.add('flex', 'space-x-2', 'animate-fade-in');newComment.innerHTML = `<a href="#" class="text-sm font-medium text-gray-900 hover:underline">${comment.userName}</a><p class="text-sm text-gray-600">${comment.content}</p>`;commentsList.insertBefore(newComment, commentsList.firstChild);
}// 动态加载动画
class LoadingAnimation {constructor(element) {this.element = element;this.dots = 0;this.interval = null;}start() {this.interval = setInterval(() => {this.dots = (this.dots + 1) % 4;this.element.textContent = '加载中' + '.'.repeat(this.dots);}, 300);}stop() {clearInterval(this.interval);this.element.textContent = '';}
}
</script><style>
@keyframes fade-in {from { opacity: 0; transform: translateY(10px); }to { opacity: 1; transform: translateY(0); }
}.animate-fade-in {animation: fade-in 0.3s ease-out forwards;
}
</style>
性能优化
在社交媒体信息流中,性能优化就像是展览的后勤保障,需要在用户无感知的情况下保持流畅:
<script>
// 虚拟列表实现
class VirtualList {constructor(container, items, rowHeight) {this.container = container;this.items = items;this.rowHeight = rowHeight;this.visibleItems = Math.ceil(container.clientHeight / rowHeight) + 2;this.scrollTop = 0;this.startIndex = 0;this.init();}init() {// 设置容器高度this.container.style.height = `${this.items.length * this.rowHeight}px`;// 创建视口this.viewport = document.createElement('div');this.viewport.style.position = 'relative';this.viewport.style.overflow = 'hidden';this.container.appendChild(this.viewport);// 监听滚动this.container.addEventListener('scroll', this.onScroll.bind(this));// 初始渲染this.render();}onScroll() {this.scrollTop = this.container.scrollTop;this.render();}render() {// 计算可见区域的起始索引this.startIndex = Math.floor(this.scrollTop / this.rowHeight);const endIndex = Math.min(this.startIndex + this.visibleItems,this.items.length);// 清空视口this.viewport.innerHTML = '';// 渲染可见项for (let i = this.startIndex; i < endIndex; i++) {const item = this.items[i];const element = this.createItemElement(item);element.style.position = 'absolute';element.style.top = `${i * this.rowHeight}px`;this.viewport.appendChild(element);}}createItemElement(item) {// 创建列表项元素const element = document.createElement('div');element.style.height = `${this.rowHeight}px`;element.innerHTML = item.content;return element;}
}// 图片懒加载优化
const imageObserver = new IntersectionObserver((entries) => {entries.forEach(entry => {if (entry.isIntersecting) {const img = entry.target;img.src = img.dataset.src;img.classList.remove('lazy');imageObserver.unobserve(img);}});
}, {rootMargin: '50px 0px'
});document.querySelectorAll('img.lazy').forEach(img => {imageObserver.observe(img);
});// 防抖动优化
function debounce(func, wait) {let timeout;return function executedFunction(...args) {const later = () => {clearTimeout(timeout);func(...args);};clearTimeout(timeout);timeout = setTimeout(later, wait);};
}// 应用防抖
const debouncedScroll = debounce(() => {// 滚动处理逻辑
}, 150);window.addEventListener('scroll', debouncedScroll);// 预加载优化
const preloadImages = () => {const images = document.querySelectorAll('[data-preload]');const imageUrls = Array.from(images).map(img => img.dataset.src);imageUrls.forEach(url => {const img = new Image();img.src = url;});
};// DOM 回收优化
class DOMRecycler {constructor(container, template) {this.container = container;this.template = template;this.pool = [];}acquire() {return this.pool.pop() || this.template.cloneNode(true);}release(element) {element.remove();this.pool.push(element);}clear() {this.pool = [];}
}
</script>
写在最后
通过这篇文章,我们详细探讨了如何使用 Tailwind CSS 构建一个现代化的社交媒体信息流。从信息流卡片到故事流展示,从无限滚动到性能优化,我们不仅关注了视觉效果,更注重了用户体验和交互设计。
记住,一个优秀的社交媒体信息流就像是一场精心策划的展览,需要在内容呈现、交互体验和性能优化之间找到完美的平衡。在实际开发中,我们要始终以用户需求为中心,打造一个能够吸引用户驻足的数字展览。
如果觉得这篇文章对你有帮助,别忘了点个赞 👍
相关文章:
Tailwind CSS 实战:社交媒体信息流开发
在社交媒体的世界里,信息流就像是一条永不停歇的河流,承载着用户的分享与互动。记得在一个社交平台项目中,我们通过重新设计信息流的展示方式,让用户的平均浏览时长提升了 45%。今天,我想和大家分享如何使用 Tailwind …...
深入解析:谱分解、SVD与PCA在算法中的应用与实现
特征值分解(EVD)、奇异值分解(SVD)和主成分分析(PCA)是矩阵分解技术的三种重要形式,它们在人工智能中扮演了关键角色。随着数据维度的快速增长和信息复杂度的提升,这些技术为处理高维…...
C#编写的金鱼趣味小应用 - 开源研究系列文章
今天逛网,在GitHub中文网上发现一个源码,里面有这个金鱼小应用,于是就下载下来,根据自己的C#架构模板进行了更改,最终形成了这个例子。 1、 项目目录; 2、 源码介绍; 1) 初始化; 将样…...
Android 系统 AlarmManager 系统层深度定制
Android 系统 AlarmManager 系统层深度定制 目录 引言AlarmManager 概述AlarmManager 系统架构AlarmManager 核心代码解读AlarmManager 深度定制方法 修改 AlarmManagerService 修改定时任务调度策略增加定时任务类型定制内核层 修改定时触发精度增加定时触发类型优化定时任务…...
uniapp-vue3(下)
关联链接:uniapp-vue3(上) 文章目录 七、咸虾米壁纸项目实战7.1.咸虾米壁纸项目概述7.2.项目初始化公共目录和设计稿尺寸测量工具7.3.banner海报swiper轮播器7.4.使用swiper的纵向轮播做公告区域7.5.每日推荐滑动scroll-view布局7.6.组件具名…...
Debian-linux运维-docker安装和配置
腾讯云搭建docker官方文档:https://cloud.tencent.com/document/product/213/46000 阿里云安装Docker官方文档:https://help.aliyun.com/zh/ecs/use-cases/install-and-use-docker-on-a-linux-ecs-instance 天翼云常见docker源配置指导:htt…...
【每日学点鸿蒙知识】tensorflowlite编译、音频编码线程、沉浸式状态栏、TextArea最大字节数限制等
1、如何编译Tensorflow lite库? 之前项目基于tflite推理引擎做人脸识别的功能,鸿蒙侧如何复用tflite模型? tflite对Android和iOS本身支配了GPU支持,但是鸿蒙侧目前并没有,鸿蒙提供了自己的推理引擎,而且支…...
Windows上Git LFS的安装和使用
到Git LFS官网下载 传送门 初始化GitHub LFS和Git仓库 在仓库目录中运行: git lfs install再运行: git init跟踪大文件 git lfs track "*.zip"添加并提交文件 git add . git commit -m "Add large files"上传到我的github 配…...
嵌入式入门Day37
作业 驱动机械臂 #include <myhead.h>#define IP "192.168.124.16" #define SERPORT 8888int main(int argc, const char *argv[]) {//创建套接字int oldfd socket(AF_INET, SOCK_STREAM, 0);if (oldfd -1){perror("socket");return -1;}//连接服…...
MySQL 的事务与多版本并发控制(MVCC)的那些事
什么是事务原子性:一致性隔离性 问题1: 为什么MySQL要使用mvcc实现隔离性而不使用 锁 解决并发问题?持久性 问题2: MySQL 不是磁盘数据库吗,持久化为什么是 redo log 保证的?问题 3: redo log 储存了什么东西,持久化(崩溃恢复是怎么做的?)问题 4 : MySQL 的 bing log (二进制…...
二层交换机和三层交换机
一、交换机简述 交换机的主要功能包括物理编址、网络拓扑结构、错误校验、帧序列以及流控。交换机还具备了一些新的功能,如对VLAN(虚拟局域网)的支持、对链路汇聚的支持,甚至有的还具有防火墙的功能。 交换机除了能够连接同种类型…...
Win32汇编学习笔记01.环境配置
Win32汇编学习笔记01.环境配置-C/C基础-断点社区-专业的老牌游戏安全技术交流社区 - BpSend.net 环境配置 masm32下载 官网:http://www.masm32.com/安装 成功标志 环境配置: 将masm32下的bin目录添加到path新建include,将masm32目录下的in…...
[创业之路-232]:《华为闭环战略管理》-5-组织架构、业务架构、产品架构、技术架构、项目架构各自设计的原则是什么?
目录 一、组织架构设计原则 二、业务架构设计原则 三、产品架构设计原则 四、技术架构设计原则 五、项目架构设计原则 一、各自的组成元素 组织架构、业务架构、产品架构、技术架构、项目架构各自的组成元素具体如下: 组织架构 - 组织企业相似资源的方式&…...
数组方法 | vue修改数组
数组方法 修改原数组 push() 方法(在数组结尾处)向数组添加一个新的元素 var list["数学","历史"]; list.push("英语"); ["数学","历史","英语"]unshift() 方法(在开头&…...
tcp_rcv_synsent_state_process函数
tcp_rcv_synsent_state_process 是 Linux Kernel 中用于处理 TCP 连接在 SYN-SENT 状态下接收到报文的函数。这个函数在 TCP 三次握手阶段起到了至关重要的作用,处理了在客户端发送 SYN 请求之后收到服务器响应报文的各种情况。 以下是这个函数的解读和剖析: int tcp_rcv_sy…...
【Qt】信号和槽机制
目录 1.信号和槽的理解 Qt内置类的继承关系 2.connect方法 参数 使用示例 2.1 disconnect断开信号槽 2.2 查看内置类型的信号和槽 3.自定义槽函数 3.1 代码方式自定义槽函数 3.2 图形化方式自定义槽函数 4.自定义信号 5.带参数的信号和槽 6.信号和槽的关联关系 7…...
【Pytorch实用教程】循环神经网络中使用dropout需要注意的问题
文章目录 问题解答警告的具体含义解决方案示例代码总结问题 UserWarning: dropout option adds dropout after all but last recurrent layer, so non-zero dropout expects num_layers greater than 1, but got dropout=0.3 and num_layers=1 warnings.warn("dropout op…...
展望2025:在创新与协作中创造价值、奉献佳作
2025,就像远方闪耀着希望之光的灯塔,正逐步靠近我们的视野。在这个充满无限潜力的年份里,我们满怀壮志,立志创造更多价值,为大家呈上更多出类拔萃的作品。 往昔岁月,犹如一幅徐徐展开的长卷,上…...
秒鲨后端之MyBatis【3】自定义映射resultMap、动态SQL、MyBatis的缓存、MyBatis的逆向工程、分页插件(30000字)
这里我分享一下尚硅谷的pdf100页笔记和代码,大家可以参考学习。 笔记: 通过网盘分享的文件:MyBatis.pdf 链接: https://pan.baidu.com/s/14Iu1Zs-_5vZoRjBEjmagag?pwdyjh6 提取码: yjh6 --来自百度网盘超级会员v1的分享代码: …...
springboot之集成Elasticsearch
目录 二、Elasticsearch 是什么?三、Elasticsearch 安装四、Springboot 集成 Elasticsearch 的方式五、创建项目集成 Elasticsearch 2.创建 Spring Initializr 项目 es (3).新建实体类 User(4).新建 dao 接口类 UserRe…...
CLIP (Contrastive Language-Image Pre-training)用途及使用方法
CLIP (Contrastive Language-Image Pre-training) 是由 OpenAI 开发的多模态模型,可以同时处理图像和文本。在 Hugging Face 中使用 CLIP 模型主要有以下几个步骤和用途: 安装必要的库: pip install transformers pip install torch pip install Pillow导入所需模…...
2018年西部数学奥林匹克几何试题
2018G1 未完待续… 2018 G2 在 △ A B C \triangle ABC △ABC 中, E E E, F F F 分别在 A B AB AB, A C AC AC 上, 且 B F C E B C BFCEBC BFCEBC. I B I_B IB, I C I_C IC 分别为 ∠ A B C \angle ABC ∠ABC 和 ∠ A C B \angle ACB ∠ACB 所对的旁心, K K…...
华为配置 之 链路聚合
简介: 链路聚合(Link Aggregation)是一种计算机网络技术,通过将多个物理端口汇聚在一起,形成一个逻辑端口,以实现出/入流量吞吐量在各成员端口的负荷分担。当交换机检测到其中一个成员端口的链路发生故障时…...
MIT线性代数教材:Linear Algebra and Its Applications
这本教材是MIT线性代数课程所使用的教材,上课的老师是Gilbert Strang,而教材的作者也是Gilbert Strang。这本书内容比较直观,配图不少,叙述风格比较几何风格。习题也丰富,但并不怎么对我的胃口,因此我也怎么…...
SpringBoot 集成 Activiti 7 工作流引擎
一. 版本信息 IntelliJ IDEA 2023.3.6JDK 17Activiti 7 二. IDEA依赖插件安装 安装BPM流程图插件,如果IDEA的版本超过2020,则不支持actiBPM插件。我的IDEA是2023版本我装的是 Activiti BPMN visualizer 插件。 在Plugins 搜索 Activiti BPMN visualizer 安装 创…...
【数据结构】数据结构简要介绍
数据结构是计算机科学中用于组织、管理和存储数据的方式,以便于高效地访问和修改数据。 数据结构的分类: 数据结构可以大致分为两类:线性结构和非线性结构。 1. 线性结构 线性结构中的数据按顺序排列,每个元素有唯一的前驱和后…...
SQL Server导出和导入可选的数据库表和数据,以sql脚本形式
一、导出 1. 打开SQL Server Management Studio,在需要导出表的数据库上单击右键 → 任务 → 生成脚本 2. 在生成脚本的窗口中单击进入下一步 3. 如果只需要导出部分表,则选择第二项**“选择具体的数据库对象(Select specific database objects)”**&am…...
蓝桥杯JAVA刷题--001
文章目录 题目需求2.代码3.总结 题目需求 2.代码 class Solution {public String convertDateToBinary(String date) {if (date null || date.length() ! 10 || date.charAt(4) ! - || date.charAt(7) ! -) {throw new IllegalArgumentException("输入的日期格式不正确&…...
2025-01-01 NO2. XRHands 介绍
文章目录 软件配置1 XR Hands 简介2 XRHand2.1 Pose2.2 Handedness 3 XRHandJoint3.1 XRHandJointID3.2 XRHandJointTrackingState 4 XRHandSubsystem4.1 数据属性4.1.1 UpdateSuccessFlags4.1.2 UpdateType 4.2 处理器管理:注册和注销4.3 更新手部数据:…...
SQL 实战:复杂数据去重与唯一值提取
在实际开发中,数据重复是常见问题,例如用户多次登录记录、订单状态重复更新等。如何高效提取符合业务需求的唯一值或最新记录,对系统性能和数据准确性至关重要。 本文将探讨如何使用 SQL 的 窗口函数、分组查询 以及 DISTINCT 实现复杂场景下…...
基于BiLSTM和随机森林回归模型的序列数据预测
本文以新冠疫情相关数据集为案例,进行新冠数量预测。(源码请留言或评论) 首先介绍相关理论概念: 序列数据特点 序列数据是人工智能和机器学习领域的重要研究对象,在多个应用领域展现出独特的特征。这种数据类型的核心特点是 元素之间的顺序至关重要 ,反映了数据内在的时…...
基于 SensitiveWordBs 实现敏感词过滤功能
在现代的互联网应用中,敏感词过滤已成为一个必不可少的功能,尤其是在社交媒体、评论审核等需要保证内容健康的场景下。本文将基于开源库https://github.com/houbb/sensitive-word,详细讲解如何通过自定义敏感词库和工具类实现高效的敏感词过滤…...
计算机的错误计算(一百九十八)
摘要 用两个大模型计算 arctan(54.321). 结果保留 16位有效数字。第一个大模型化简有误差;第二个大模型 Python代码几乎完全正确。无论如何,它们的结果均只有 4位数字正确。 例1. 计算 arctan(54.321). 结果保留 16位有效数字。 下面是一个大模型的回…...
递归算法.
本节我们先来了解一下递归算法. 递归算法的基本原理: 说到递归算法,就不得不提到栈.当程序执行到递归函数的时候,将函数进行入栈操作,在入栈之前,通常需要完成3件事. 1.将所有实参,返回地址等信息传递给被调函数储存 2.为被调函数的局部变量分配储存区 3.将控制转移到被调函…...
我的Java-Web进阶--SpringMVC
1.三层架构与MVC模式 三层架构 MVC模式 2.SpringMVC执行流程 3.SpringMVC的基本使用方法 1. 配置 1.1 Maven依赖 首先,在pom.xml文件中添加Spring MVC的依赖: <dependencies><!-- Spring MVC --><dependency><groupId>org.…...
【复刻】ESG表现对企业价值的影响机制研究(2009-2021年)
一、数据来源:ESG数据采用华证ESG评价体系提供的评级结果,控制变量主要来自上市公司年报,内含原始数据、处理代码和基准回归 二、数据指标:资产收益率 净利润 / 平均总资产销售净利率 净利润 / 营业收入托宾Q值 …...
GSM PDU解码在Linux下的C语言实现
GSM PDU解码在Linux下的C语言实现 一、引言二、GSM PDU格式概述三、Linux环境下的C语言实现(一)头文件包含(二)数据结构定义(三)解码函数实现(四)主函数示例四、编译与运行五、注意事项与优化六、结论一、引言 GSM(全球移动通信系统)PDU(协议数据单元)是用于在GSM…...
Vue 3.0 中 template 多个根元素警告问题
在 Vue 2.0 中,template 只允许存在一个根元素,但是这种情况在 Vue 3.0 里发生了一些变化。 在 Vue 3.0 中开始支持 template 存在多个根元素了。但是因为 VSCode 中的一些插件没有及时更新,所以当你在 template 中写入多个根元素时…...
STM32F103RCT6学习之三:串口
1.串口基础 2.串口发送 1)基本配置 注意:实现串口通信功能需在keil中设置打开Use Micro LIB,才能通过串口助手观察到串口信息 2)编辑代码 int main(void) {/* USER CODE BEGIN 1 *//* USER CODE END 1 *//* MCU Configuration-------------…...
07-计算机网络面试实战
07-计算机网络面试实战 计算机网络面试实战 为什么要学习网络相关知识? 对于好一些的公司,计算机基础的内容是肯定要面的,尤其是 30k 以内的工程师,因为目前处于的这个级别肯定是要去写项目的,还没上升到去设计架构的高…...
Kafka的acks机制和ISR列表
Kafka 是一个流行的分布式流处理平台,用于构建实时数据流管道和应用程序。在 Kafka 中,acks 机制和 ISR(In-Sync Replicas)列表是两个重要的概念,它们共同确保消息的持久性和可靠性。 acks 机制 acks 机制是 Kafka 生…...
c++Qt登录页面设计
使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数 将登录按钮使用qt5版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为…...
数字图像处理 四 图像统计
1.直方图 记录每一种像素值出现的次数 各种直方图的类型 暗图像:分布靠低值区域 亮图像:分布靠高值区域 高对比度图像,直方图分布均匀,更容易人眼观察 2.直方图的均衡化 将低对比度图像转换为高对比度图像 视觉良好的直方图…...
UE蓝图类调用关卡蓝图中的函数
蓝图类调用关卡蓝图中函数 需要用到Execute Console Command函数节点 ce空格【函数名】 在关卡蓝图中创建一个函数sayhello 在第三人称蓝图类中调用 成功输出 注:用此方法只能从蓝图类中调用关卡蓝图中的函数,从关卡蓝图调用蓝图类是无效的。 另外Exec…...
JAVA: 状态模式(State Pattern)的技术指南
1、简述 状态模式是一种行为型设计模式,允许对象在其内部状态改变时改变其行为。它将状态相关的行为抽取到独立的状态类中,使得增加新状态变得简单,且不影响其他状态。 设计模式样例:https://gitee.com/lhdxhl/design-pattern-example.git 本文将详细介绍状态模式的概念…...
C语言:位段
位段的内存分配: 1. 位段的成员可以是 int unsigned int signed int 或者是char (属于整形家族)类型 2. 位段的空间上是按照需要以4个字节( 类型 int )或者1个字节( char )的方式来开辟的。 3. 位段涉及…...
数字图像处理 三 空间滤波
空间滤波是一种图像处理技术,它通过对图像像素及其邻域进行运算,利用均值,高斯,梯度,拉普拉斯等线性滤波和中值,最大最小,双边滤波等非线性滤波改变像素值,实现图像的平滑࿰…...
创建线程的8种方法
创建线程的8种方法 目录 继承Thread类实现Runnable接口实现Callable接口使用线程池使用ScheduledExecutorService使用Fork/Join框架使用CompletableFuture使用Guava的ListenableFuture总结 1. 继承Thread类 最直接的方式是创建一个继承自Thread类的子类,并重写其r…...
[项目管理] 不求甚解
前两天总结了一个例子:https://mzhan017.blog.csdn.net/article/details/144768130; 在上一篇里末尾处,说有一个情况是openstack的问题,接着这个事情来继续说。产品安装的时候需要一个对外的IP/网络,是测试/设备人员通…...
JetBrains《2024 开发者生态系统现状报告》总结
JetBrains 公布了 2024 年《开发者生态系统状况报告》,基于全球 23262 名开发者的反馈。编程语言趋势: JavaScript 的使用率: 尽管 JavaScript 仍是最常用的编程语言,61% 的开发者用于网页开发,但其作为主要语言的用户…...