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

豆包ai 生成动态tree 增、删、改以及上移下移 html+jquery

@[豆包ai 生成动态tree 增、删、改以及上移下移 html+jquery)

人工Ai 编程

推荐一Kimi https://kimi.moonshot.cn/

推荐二 豆包https://www.doubao.com/

实现效果图

在这里插入图片描述

html 代码

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale = 1.0"><title>Chapter Tree</title><style>/* 整体树容器样式 */#chapter-tree-container {padding-left: 20px;}/* 章节li样式 */li {position: relative;padding-left: 20px;margin: 5px 0;line-height: 24px;}/* 利用伪元素创建线条 */li::before {content: '';position: absolute;left: 0;top: 12px;width: 10px;border-top: 1px solid #ccc;}/* 顶级li去除顶部线条 */#chapter-tree-container ul li:first-child::before {border-top: none;}/* 有子章节的li添加垂直线条 */li:has(ul)::before {height: 100%;border-left: 1px solid #ccc;}/* 子章节ul样式 */ul {list-style-type: none;padding-left: 10px;}/* 美化 input */input.edit-input {width: 150px;padding: 8px;border: 1px solid #ccc;border-radius: 4px;font-size: 14px;color: #555;outline: none;}input.edit-input::placeholder {color: #999;}/* 美化操作按钮 */button {padding: 6px 12px;background-color: #007BFF;color: white;border: none;border-radius: 4px;font-size: 14px;cursor: pointer;transition: background-color 0.3s ease;}button:hover {background-color: #0056b3;}button.add-button {background-color: #28a745;}button.add-button:hover {background-color: #218838;}button.modify-button {background-color: #ffc107;}button.modify-button:hover {background-color: #e0a800;}button.delete-button {background-color: #dc3545;}button.delete-button:hover {background-color: #c82333;}/* 折叠按钮样式 */button[text="+"],button[text="-"] {width: 24px;height: 24px;border-radius: 50%;padding: 0;font-size: 14px;line-height: 24px;text-align: center;}</style>
</head><body><div id="chapter-tree-container"></div><script src="https://code.jquery.com/jquery-3.6.0.min.js"></script><script>// 初始数据结构,为每个章节添加唯一 idvar initialData = [{id: 1,name: "第一单元 成长的节拍",children: [{id: 2,name: "第一课 中学时代",children: [{ id: 3, name: "中学序曲" },{ id: 4, name: "珍惜青春" },{ id: 5, name: "步入中学生活" }]},{id: 6,name: "少年有梦",children: [{ id: 7, name: "梦想的含义" },{ id: 8, name: "努力的意义" },{ id: 9, name: "实现理想的途径" },{ id: 10, name: "正确对待理想与现实" }]}]}];// 渲染树形章节结构function renderTree(data) {// 清空旧的渲染内容$('#chapter-tree-container').empty();var ul = $("<ul>");function renderChildren(children, parentUl) {if (!children) return;children.forEach(function (child) {let li;li = $("<li>").data('chapter-id', child.id);var expandButton = $("<button>").text("+");expandButton.click(function () {try {var subUl = li.find("ul");if (subUl.length) {subUl.toggle();expandButton.text(subUl.is(":visible")? "-" : "+");} else {var newSubUl = $("<ul>").hide();renderChildren(child.children, newSubUl);li.append(newSubUl);newSubUl.show();expandButton.text("-");}} catch (error) {console.error('Error in expand button click:', error);}});var chapterNameSpan = $("<span>").text(child.name).addClass('chapter-name-span');// 添加增删改按钮var addButton = $("<button>").text("添加").addClass('add-button');var modifyButton = $("<button>").text("修改").addClass('modify-button');var deleteButton = $("<button>").text("删除").addClass('delete-button');var moveUpButton = $("<button>").text("上移");var moveDownButton = $("<button>").text("下移");var addSubChapterButton = $("<button>").text("添加子章节");addButton.click(function () {try {addChapter(li);} catch (error) {console.error('Error in add button click:', error);}});modifyButton.click(function () {try {var currentLi = $(this).closest('li');var chapterId = currentLi.data('chapter-id');var chapter = findChapterById(chapterId, initialData);if (!chapter) {console.error('Chapter not found for modification.');return;}var chapterNameSpan = currentLi.find('.chapter-name-span:eq(0)');var input = $("<input>").val(chapter.name).addClass('edit-input').focus();chapterNameSpan.replaceWith(input);input.on('blur', function () {try {var newName = $(this).val();var currentLi = $(this).closest('li');var chapter = getChapterFromLi(currentLi);if (chapter) {chapter.name = newName;var newChapterNameSpan = $("<span>").text(newName).addClass('chapter-name-span');$(this).replaceWith(newChapterNameSpan);if (chapter.children && chapter.children.length > 0) {var subUl = currentLi.find('ul');if (!subUl.length) {subUl = $("<ul>");renderChildren(chapter.children, subUl);currentLi.append(subUl);}}}} catch (error) {console.error('Error in blur event of edit input:', error);}});} catch (error) {console.error('Error in modify button click:', error);}});deleteButton.click(function () {try {var chapterId = li.data('chapter-id');var chapter = findChapterById(chapterId, initialData);if (chapter) {deleteChapter(chapter);}} catch (error) {console.error('Error in delete button click:', error);}});moveUpButton.click(function () {try {moveChapterUp(li);} catch (error) {console.error('Error in move up button click:', error);}});moveDownButton.click(function () {try {moveChapterDown(li);} catch (error) {console.error('Error in move down button click:', error);}});addSubChapterButton.click(function () {try {var chapterId = li.data('chapter-id');var chapter = findChapterById(chapterId, initialData);if (chapter) {addSubChapter(chapter);}} catch (error) {console.error('Error in add sub-chapter button click:', error);}});li.append(expandButton, chapterNameSpan, addButton, modifyButton, deleteButton, moveUpButton, moveDownButton, addSubChapterButton);if (child.children && child.children.length > 0) {var subUl = $("<ul>");renderChildren(child.children, subUl);li.append(subUl);}parentUl.append(li);});}renderChildren(data, ul);$("#chapter-tree-container").append(ul);}// 添加章节function addChapter(clickedLi) {try {var newChapter = { id: Date.now(), name: "默认章节", children: [] };var parentUl = clickedLi.parent('ul');var parentChapter;if (parentUl.length) {var parentLi = parentUl.parent('li');if (parentLi.length) {parentChapter = getChapterFromLi(parentLi);} else {// 顶级 ul 的情况parentChapter = { children: initialData };}} else {// 顶级 li 的情况parentChapter = { children: initialData };}if (!parentChapter.children) {parentChapter.children = [];}parentChapter.children.push(newChapter);renderTree(initialData);} catch (error) {console.error('Error in addChapter function:', error);}}// 添加子章节function addSubChapter(parentNode) {try {var newChapter = { id: Date.now(), name: "默认子章节", children: [] };if (!parentNode.children) {parentNode.children = [];}parentNode.children.push(newChapter);renderTree(initialData);} catch (error) {console.error('Error in addSubChapter function:', error);}}// 删除章节function deleteChapter(node) {try {if (node.parent) {var index = node.parent.children.indexOf(node);if (index >-1) {node.parent.children.splice(index, 1);}} else {var index = initialData.indexOf(node);if (index >-1) {initialData.splice(index, 1);}}renderTree(initialData);} catch (error) {console.error('Error in deleteChapter function:', error);}}// 章节上移function moveChapterUp(li) {try {var prevLi = li.prev("li");if (prevLi.length) {var prevIndex = li.parent().children().index(prevLi);var currentIndex = li.parent().children().index(li);var parent = getParentOfLi(li);if (parent && Array.isArray(parent.children)) {var chapter = getChapterFromLi(li);if (chapter) {parent.children.splice(currentIndex, 1);parent.children.splice(prevIndex, 0, chapter);}} else if (!parent && Array.isArray(initialData)) {var chapter = getChapterFromLi(li);if (chapter) {initialData.splice(currentIndex, 1);initialData.splice(prevIndex, 0, chapter);}}li.insertBefore(prevLi);}} catch (error) {console.error('Error in moveChapterUp function:', error);}}// 章节下移function moveChapterDown(li) {try {var nextLi = li.next("li");if (nextLi.length) {var nextIndex = li.parent().children().index(nextLi);var currentIndex = li.parent().children().index(li);var parent = getParentOfLi(li);if (parent && Array.isArray(parent.children)) {var chapter = getChapterFromLi(li);if (chapter) {parent.children.splice(currentIndex, 1);parent.children.splice(nextIndex + 1, 0, chapter);}} else if (!parent && Array.isArray(initialData)) {var chapter = getChapterFromLi(li);if (chapter) {initialData.splice(currentIndex, 1);initialData.splice(nextIndex + 1, 0, chapter);}}li.insertAfter(nextLi);}} catch (error) {console.error('Error in moveChapterDown function:', error);}}function getParentOfLi(li) {try {var parentLi = li.parent('li');if (parentLi.length) {var parentChapterId = parentLi.data('chapter-id');return findChapterById(parentChapterId, initialData);}return null;} catch (error) {console.error('Error in getParentOfLi function:', error);}}function getChapterFromLi(li) {try {var chapterId = li.data('chapter-id');return findChapterById(chapterId, initialData);} catch (error) {console.error('Error in getChapterFromLi function:', error);}}function findChapterById(id, data) {try {for (var i = 0; i < data.length; i++) {if (data[i].id === id) {return data[i];}if (data[i].children && data[i].children.length > 0) {var found = findChapterById(id, data[i].children);if (found) {return found;}}}return null;} catch (error) {console.error('Error in findChapterById function:', error);}}// 初始化渲染$(document).ready(function () {renderTree(initialData);});</script>
</body></html>

上一版本有问题,下面是最新版本的。

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale = 1.0"><title>Chapter Tree</title><style>/* 整体树容器样式 */#chapter-tree-container {padding-left: 20px;}/* 章节li样式 */li {position: relative;padding-left: 20px;margin: 5px 0;line-height: 24px;}/* 利用伪元素创建线条 */li::before {content: '';position: absolute;left: 0;top: 12px;width: 10px;border-top: 1px solid #ccc;}/* 顶级li去除顶部线条 */#chapter-tree-container ul li:first-child::before {border-top: none;}/* 有子章节的li添加垂直线条 */li:has(ul)::before {height: 100%;border-left: 1px solid #ccc;}/* 子章节ul样式 */ul {list-style-type: none;padding-left: 10px;}/* 美化 input */input.edit-input {width: 150px;padding: 8px;border: 1px solid #ccc;border-radius: 4px;font-size: 14px;color: #555;outline: none;}input.edit-input::placeholder {color: #999;}/* 美化操作按钮 */button {padding: 6px 12px;background-color: #007BFF;color: white;border: none;border-radius: 4px;font-size: 14px;cursor: pointer;transition: background-color 0.3s ease;}button:hover {background-color: #0056b3;}button.add-button {background-color: #28a745;}button.add-button:hover {background-color: #218838;}button.modify-button {background-color: #ffc107;}button.modify-button:hover {background-color: #e0a800;}button.delete-button {background-color: #dc3545;}button.delete-button:hover {background-color: #c82333;}/* 折叠按钮样式 */button[text="+"],button[text="-"] {width: 24px;height: 24px;border-radius: 50%;padding: 0;font-size: 14px;line-height: 24px;text-align: center;}</style>
</head><body><div id="chapter-tree-container"></div><script src="https://code.jquery.com/jquery-3.6.0.min.js"></script><script>// 初始数据结构,为每个章节添加唯一 idvar initialData = [{id: 1,name: "第一单元 成长的节拍",children: [{id: 2,name: "第一课 中学时代",children: [{ id: 3, name: "中学序曲" },{ id: 4, name: "珍惜青春" },{ id: 5, name: "步入中学生活" }]},{id: 6,name: "少年有梦",children: [{ id: 7, name: "梦想的含义" },{ id: 8, name: "努力的意义" },{ id: 9, name: "实现理想的途径" },{ id: 10, name: "正确对待理想与现实" }]}]}];// 记录展开状态的对象var expandedStates = {};// 渲染树形章节结构function renderTree(data) {// 清空旧的渲染内容$('#chapter-tree-container').empty();var ul = $("<ul>");function renderChildren(children, parentUl) {if (!children) return;children.forEach(function (child) {let li;li = $("<li>").data('chapter-id', child.id);var expandButton = $("<button>").text(expandedStates[child.id]? "-" : "+");expandButton.click(function () {try {var subUl = li.find("ul");if (subUl.length) {subUl.toggle();expandButton.text(subUl.is(":visible")? "-" : "+");expandedStates[child.id] = subUl.is(":visible");} else {var newSubUl = $("<ul>").hide();renderChildren(child.children, newSubUl);li.append(newSubUl);newSubUl.show();expandButton.text("-");expandedStates[child.id] = true;}} catch (error) {console.error('Error in expand button click:', error);}});var chapterNameSpan = $("<span>").text(child.name).addClass('chapter-name-span');// 添加增删改按钮var addButton = $("<button>").text("添加").addClass('add-button');var modifyButton = $("<button>").text("修改").addClass('modify-button');var deleteButton = $("<button>").text("删除").addClass('delete-button');var moveUpButton = $("<button>").text("上移");var moveDownButton = $("<button>").text("下移");var addSubChapterButton = $("<button>").text("添加子章节");addButton.click(function () {try {addChapter(li);} catch (error) {console.error('Error in add button click:', error);}});modifyButton.click(function () {try {var currentLi = $(this).closest('li');var chapterId = currentLi.data('chapter-id');var chapter = findChapterById(chapterId, initialData);if (!chapter) {console.error('Chapter not found for modification.');return;}var chapterNameSpan = currentLi.find('.chapter-name-span:eq(0)');var input = $("<input>").val(chapter.name).addClass('edit-input').focus();chapterNameSpan.replaceWith(input);input.on('blur', function () {try {var newName = $(this).val();var currentLi = $(this).closest('li');var chapter = getChapterFromLi(currentLi);if (chapter) {chapter.name = newName;var newChapterNameSpan = $("<span>").text(newName).addClass('chapter-name-span');$(this).replaceWith(newChapterNameSpan);if (chapter.children && chapter.children.length > 0) {var subUl = currentLi.find('ul');if (!subUl.length) {subUl = $("<ul>");renderChildren(chapter.children, subUl);currentLi.append(subUl);}}}} catch (error) {console.error('Error in blur event of edit input:', error);}});} catch (error) {console.error('Error in modify button click:', error);}});deleteButton.click(function () {try {var chapterId = li.data('chapter-id');var chapter = findChapterById(chapterId, initialData);if (chapter && (!chapter.children || (chapter.children && chapter.children.length === 0))) {deleteChapter(chapter);}} catch (error) {console.error('Error in delete button click:', error);}});moveUpButton.click(function () {try {moveChapterUp(li);} catch (error) {console.error('Error in move up button click:', error);}});moveDownButton.click(function () {try {moveChapterDown(li);} catch (error) {console.error('Error in move down button click:', error);}});addSubChapterButton.click(function () {try {var chapterId = li.data('chapter-id');var chapter = findChapterById(chapterId, initialData);if (chapter) {addSubChapter(chapter);}} catch (error) {console.error('Error in add sub - chapter button click:', error);}});li.append(expandButton, chapterNameSpan, addButton, modifyButton, deleteButton, moveUpButton, moveDownButton, addSubChapterButton);if (child.children && child.children.length > 0) {var subUl = $("<ul>");renderChildren(child.children, subUl);li.append(subUl);if (expandedStates[child.id]) {subUl.show();expandButton.text("-");} else {subUl.hide();expandButton.text("+");}}parentUl.append(li);});}renderChildren(data, ul);$("#chapter-tree-container").append(ul);}// 添加章节function addChapter(clickedLi) {try {var newChapter = { id: Date.now(), name: "默认章节", children: [] };var parentUl = clickedLi.parent('ul');var parentChapter;if (parentUl.length) {var parentLi = parentUl.parent('li');if (parentLi.length) {parentChapter = getChapterFromLi(parentLi);} else {// 顶级 ul 的情况parentChapter = { children: initialData };}} else {// 顶级 li 的情况parentChapter = { children: initialData };}if (!parentChapter.children) {parentChapter.children = [];}parentChapter.children.push(newChapter);renderTree(initialData);} catch (error) {console.error('Error in addChapter function:', error);}}// 添加子章节function addSubChapter(parentNode) {try {var newChapter = { id: Date.now(), name: "默认子章节", children: [] };if (!parentNode.children) {parentNode.children = [];}parentNode.children.push(newChapter);renderTree(initialData);} catch (error) {console.error('Error in addSubChapter function:', error);}}// 删除章节function deleteChapter(node) {try {let parent;let parentArray;if (node.id === initialData[0].id) {initialData = [];} else {const findParent = (data) => {for (let i = 0; i < data.length; i++) {if (data[i].children) {for (let j = 0; j < data[i].children.length; j++) {if (data[i].children[j].id === node.id) {return { parent: data[i], index: j };}}const result = findParent(data[i].children);if (result) {return result;}}}return null;};const parentInfo = findParent(initialData);if (parentInfo) {parent = parentInfo.parent;parentArray = parent.children;parentArray.splice(parentInfo.index, 1);}}renderTree(initialData);} catch (error) {console.error('Error in deleteChapter function:', error);}}// 章节上移function moveChapterUp(li) {try {var chapter = getChapterFromLi(li);if (!chapter) {return;}var parentArray = findContainingArray(chapter, initialData);if (!parentArray) {return;}var currentIndex = parentArray.indexOf(chapter);if (currentIndex > 0) {var temp = parentArray[currentIndex - 1];parentArray[currentIndex - 1] = chapter;parentArray[currentIndex] = temp;renderTree(initialData);}} catch (error) {console.error('Error in moveChapterUp function:', error);}}// 章节下移function moveChapterDown(li) {try {var chapter = getChapterFromLi(li);if (!chapter) {return;}var parentArray = findContainingArray(chapter, initialData);if (!parentArray) {return;}var currentIndex = parentArray.indexOf(chapter);if (currentIndex < parentArray.length - 1) {var temp = parentArray[currentIndex + 1];parentArray[currentIndex + 1] = chapter;parentArray[currentIndex] = temp;renderTree(initialData);}} catch (error) {console.error('Error in moveChapterDown function:', error);}}function findContainingArray(target, data) {for (let i = 0; i < data.length; i++) {if (data[i].id === target.id) {return data;}if (data[i].children) {const subArray = findContainingArray(target, data[i].children);if (subArray) {return subArray;}}}return null;}function getChapterFromLi(li) {const chapterId = li.data('chapter-id');return findChapterById(chapterId, initialData);}function findChapterById(id, data) {for (let i = 0; i < data.length; i++) {if (data[i].id === id) {return data[i];}if (data[i].children) {const found = findChapterById(id, data[i].children);if (found) {return found;}}}return null;}// 初始化渲染$(document).ready(function () {renderTree(initialData);});</script>
</body></html>

再次实现,两个tree 左右对比,左边的章节,选中关联的在右边tree2 默认出来
在这里插入图片描述
增加搜索按钮,动态折叠展示搜索的内容
在这里插入图片描述

学习Ai 大模型 第一步学会使用这些工具助手

相关文章:

豆包ai 生成动态tree 增、删、改以及上移下移 html+jquery

[豆包ai 生成动态tree 增、删、改以及上移下移 htmljquery) 人工Ai 编程 推荐一Kimi https://kimi.moonshot.cn/ 推荐二 豆包https://www.doubao.com/ 实现效果图 html 代码 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF…...

【网络协议】IPv4 地址分配 - 第二部分

前言 在第 1 部分中&#xff0c;我们学习了 IPv4 地址的分配方式&#xff0c;了解了各种类型的 IPv4 地址&#xff0c;并进行了基础的子网划分&#xff08;Subnetting&#xff09;。在第 2 部分中&#xff0c;我们将继续学习子网划分&#xff0c;并引入一些新的概念。 【网络…...

攻防世界 bug

发现有Register界面&#xff0c;先去注册 登录以后发现以下界面&#xff0c;点击Manage显示you are not admin&#xff0c;并且在注册界面用admin为注册名时显示用户名已存在。初步推测是设法改变admin的密码取得权限。 在主界面一通操作并没有什么发现&#xff0c;去findpw…...

Flink如何设置合理的并行度

一个Flink程序由多个Operator组成(source、transformation和 sink)。 一个Operator由多个并行的Task(线程)来执行, 一个Operator的并行Task(线程)数目就被称为该Operator(任务)的并行度(Parallel)。即并行度就是相对于Operator来说的。 合理设置并行度可以有效提高Flink作业…...

小兔鲜儿:生鲜区域,最新专题

生鲜区域: 生鲜区域标题部分&#xff1a; 生鲜区域内容部分&#xff1a; 分左右两个部分 右边区域是8个 li 标签区域&#xff0c;li中嵌套 a ,上部分是图片&#xff0c;下部分是内容&#xff1b;与 a 并列的是cover&#xff0c;定位在 li 之外&#xff0c;设置是溢出隐藏&…...

TypeScript语言的网络编程

基于 TypeScript 的网络编程探索 随着互联网技术的发展&#xff0c;网络编程已成为软件开发中不可或缺的一部分。尤其是在构建现代 Web 应用程序时&#xff0c;网络编程的各个方面&#xff0c;包括 HTTP 请求、WebSocket、API 交互等&#xff0c;都扮演着至关重要的角色。Type…...

复合机器人助力手机壳cnc加工向自动化升级

在当今竞争激烈的制造业领域&#xff0c;如何提高生产效率、降低成本、提升产品质量&#xff0c;成为众多企业面临的关键挑战。尤其是在手机壳 CNC 加工这一细分行业&#xff0c;随着市场需求的持续增长&#xff0c;对生产效能的要求愈发严苛。而复合机器人的出现&#xff0c;正…...

在 C# 中显示动画 GIF 并在运行时更改它们

您可以通过将按钮、图片框、标签或其他控件的Image属性设置为 GIF 文件 来显示动画 GIF 。&#xff08;如果您在窗体的BackgroundImage属性中显示一个&#xff0c;则不会获得动画。&#xff09; 有几种方法可以在运行时更改 GIF。 首先&#xff0c;您可以将 GIF 添加为资源。…...

个人博客搭建(二)—Typora+PicGo+OSS

个人博客站—运维鹿: http://www.kervin24.top CSDN博客—做个超努力的小奚&#xff1a; 做个超努力的小奚-CSDN博客 一、前言 博客搭建完一直没有更新&#xff0c;因为WordPress自带的文档编辑器不方便&#xff0c;以前用CSDN写作的时候&#xff0c;习惯了Typora。最近对比了…...

Cloudflare IP 优选工具:轻松找到最快的 CDN 节点

Cloudflare IP 优选工具&#xff1a;轻松找到最快的 CDN 节点 在线体验地址&#xff1a;https://cf-ip.cdtools.click 功能介绍 Cloudflare IP 优选工具是一个专门用于测试和筛选 Cloudflare CDN 节点的在线服务。它能够帮助用户找到最适合自己的 Cloudflare IP 地址&#xff…...

HTB:Ransom[WriteUP]

目录 连接至HTB服务器并启动靶机 信息收集 使用rustscan对靶机TCP端口进行开放扫描 使用nmap对靶机TCP开放端口进行脚本、服务扫描 使用nmap对靶机TCP开放端口进行漏洞、系统扫描 使用nmap对靶机常用UDP端口进行开放扫描 使用ffuf对靶机80端口进行路径FUZZ 访问/regist…...

Eclipse配置Tomcat服务器(最全图文详解)

前言&#xff1a; 本章使用图文讲解如何在Eclipse开发工具中配置Tomcat服务器、如何创建和启动JavaWeb工程&#xff0c;欢迎童鞋们互相交流。觉得不错可以三连订阅喔。 目标&#xff1a; 一、配置Tomcat服务器 1. 切换Eclipse视图 2. 打开菜单 3. 找到服务选项 4. 选择…...

STM32烧写失败之Contents mismatch at: 0800005CH (Flash=FFH Required=29H) !

一&#xff09;问题&#xff1a;用ULINK2给STM32F103C8T6下载程序&#xff0c;下载方式设置如下&#xff1a; 出现下面两个问题&#xff1a; 1&#xff09;下载问题界面如下&#xff1a; 这个错误的信息大概可以理解为&#xff0c;在0x08000063地址上读取到flash存储为FF&am…...

用户界面的UML建模10

非正常的可视反馈可伴随着同步事件发生&#xff0c;而同步事件可由系统动作产生。但是&#xff0c;可以分别对它们进行建模。 在下节中将对这些特殊的事件依次进行论述。 6.1 异常处理建模 异常&#xff0c;由Meyer 定义[16],其作为运行时事件&#xff08;run-time events&a…...

电影动画shader解析与实现

着色器代码解析 大家好&#xff01;我是 [数擎AI]&#xff0c;一位热爱探索新技术的前端开发者&#xff0c;在这里分享前端和Web3D、AI技术的干货与实战经验。如果你对技术有热情&#xff0c;欢迎关注我的文章&#xff0c;我们一起成长、进步&#xff01; 开发领域&#xff1a;…...

蓝桥杯 第十五届 研究生组 B题 召唤数学精灵

问题描述&#xff1a; 数学家们发现了两种用于召唤强大的数学精灵的仪式&#xff0c;这两种仪式分别被称为累加法仪式 A(n) 和累乘法仪式 B(n)。累加法仪式 A(n) 是将从 1 到 n 的所有数字进行累加求和&#xff0c;即&#xff1a;A(n)12⋯n累乘法仪式 B(n) 则是将从 1 到 n 的所…...

在 Go 应用中 如何像 FastAPI 一样优雅地构建控制器

文章精选推荐 1 JetBrains Ai assistant 编程工具让你的工作效率翻倍 2 Extra Icons&#xff1a;JetBrains IDE的图标增强神器 3 IDEA插件推荐-SequenceDiagram&#xff0c;自动生成时序图 4 BashSupport Pro 这个ides插件主要是用来干嘛的 &#xff1f; 5 IDEA必装的插件&…...

用户界面的UML建模11

然而&#xff0c;在用户界面方面&#xff0c;重要的是要了解《boundary》类是如何与这个异常分层结构进行关联的。 《exception》类的对象可以作为《control》类的对象。因此&#xff0c;《exception》类能够聚合《boundary》类。 参见图12&#xff0c;《exception》Database…...

历代iPhone运行内存大小和电池容量信息

系列设备名称充电端口标配充电线PD快充无线充电 (W)标配充电器电池容量 (mAh)发布时间RAM运存iPhone 16iPhone 16 Pro MaxUSB Type-CUSB-C to USB-C支持25无47472024/9/108GB LPDDR5XiPhone 16 ProUSB Type-CUSB-C to USB-C支持25无35772024/9/108GB LPDDR5XiPhone 16 PlusUSB …...

计算机网络之---物理层设备

什么是物理层设备 物理层设备是指负责数据在物理媒介上传输的硬件设备&#xff0c;它们主要处理数据的转换、信号的传输与接收&#xff0c;而不涉及数据的内容或意义。常见的物理层设备包括网卡、集线器、光纤收发器、调制解调器等。 物理层设备有哪些 1、网卡&#xff08;N…...

FFmpeg 低延迟同屏方案

引言 在实时互动需求激增的当下&#xff0c;无论是在线教育中的师生同屏演示、远程办公的屏幕共享协作&#xff0c;还是游戏直播的画面实时传输&#xff0c;低延迟同屏已成为保障用户体验的核心指标。FFmpeg 作为一款功能强大的多媒体框架&#xff0c;凭借其灵活的编解码、数据…...

【Java学习笔记】Arrays类

Arrays 类 1. 导入包&#xff1a;import java.util.Arrays 2. 常用方法一览表 方法描述Arrays.toString()返回数组的字符串形式Arrays.sort()排序&#xff08;自然排序和定制排序&#xff09;Arrays.binarySearch()通过二分搜索法进行查找&#xff08;前提&#xff1a;数组是…...

QT: `long long` 类型转换为 `QString` 2025.6.5

在 Qt 中&#xff0c;将 long long 类型转换为 QString 可以通过以下两种常用方法实现&#xff1a; 方法 1&#xff1a;使用 QString::number() 直接调用 QString 的静态方法 number()&#xff0c;将数值转换为字符串&#xff1a; long long value 1234567890123456789LL; …...

使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台

🎯 使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台 📌 项目背景 随着大语言模型(LLM)的广泛应用,开发者常面临多个挑战: 各大模型(OpenAI、Claude、Gemini、Ollama)接口风格不统一;缺乏一个统一平台进行模型调用与测试;本地模型 Ollama 的集成与前…...

初学 pytest 记录

安装 pip install pytest用例可以是函数也可以是类中的方法 def test_func():print()class TestAdd: # def __init__(self): 在 pytest 中不可以使用__init__方法 # self.cc 12345 pytest.mark.api def test_str(self):res add(1, 2)assert res 12def test_int(self):r…...

html css js网页制作成品——HTML+CSS榴莲商城网页设计(4页)附源码

目录 一、&#x1f468;‍&#x1f393;网站题目 二、✍️网站描述 三、&#x1f4da;网站介绍 四、&#x1f310;网站效果 五、&#x1fa93; 代码实现 &#x1f9f1;HTML 六、&#x1f947; 如何让学习不再盲目 七、&#x1f381;更多干货 一、&#x1f468;‍&#x1f…...

PAN/FPN

import torch import torch.nn as nn import torch.nn.functional as F import mathclass LowResQueryHighResKVAttention(nn.Module):"""方案 1: 低分辨率特征 (Query) 查询高分辨率特征 (Key, Value).输出分辨率与低分辨率输入相同。"""def __…...

无人机侦测与反制技术的进展与应用

国家电网无人机侦测与反制技术的进展与应用 引言 随着无人机&#xff08;无人驾驶飞行器&#xff0c;UAV&#xff09;技术的快速发展&#xff0c;其在商业、娱乐和军事领域的广泛应用带来了新的安全挑战。特别是对于关键基础设施如电力系统&#xff0c;无人机的“黑飞”&…...

MFC 抛体运动模拟:常见问题解决与界面美化

在 MFC 中开发抛体运动模拟程序时,我们常遇到 轨迹残留、无效刷新、视觉单调、物理逻辑瑕疵 等问题。本文将针对这些痛点,详细解析原因并提供解决方案,同时兼顾界面美化,让模拟效果更专业、更高效。 问题一:历史轨迹与小球残影残留 现象 小球运动后,历史位置的 “残影”…...

mac 安装homebrew (nvm 及git)

mac 安装nvm 及git 万恶之源 mac 安装这些东西离不开Xcode。及homebrew 一、先说安装git步骤 通用&#xff1a; 方法一&#xff1a;使用 Homebrew 安装 Git&#xff08;推荐&#xff09; 步骤如下&#xff1a;打开终端&#xff08;Terminal.app&#xff09; 1.安装 Homebrew…...