首页 文章 精选 留言 我的

精选列表

搜索[快速],共10000篇文章
优秀的个人博客,低调大师

快速入门 TinyVue 组件库一键换肤!get“多主题适配”技能

本文由体验技术团队 TinyVue 项目成员岑灌铭创作,欢迎大家实操体验,本实操内容通过实现 TinyVue 中 Button 组件和 Alert 的类 element 主题适配,让开发者感受到 TinyVue 跨设计规范的亮点特性,同时对 TinyVue 组件库多主题的实现原理有个初步的了解。 知识背景 1. TinyVue 组件库简介 OpenTiny 是一套企业级前端开发解决方案,其中包含了组件库、低代码、中后台模板、CLI 命令行等丰富的效率提升工具。其中 TinyVue 是其中一款支持跨端、跨框架以及跨设计规范的组件库。 本次实操内容通过实现 TinyVue 中 Button 组件和 Alert 的类 element 主题适配,让开发者感受到 TinyVue 跨设计规范的亮点特性,同时对 TinyVue 组件库多主题的实现原理有个初步的了解。 代码托管 GitHub:https://github.com/opentiny/tiny-vue (欢迎大家 Star 和 提Issue、PR 进行反馈) TinyVue 官网:https://opentiny.design/tiny-vue/zh-CN/smb-theme/overview 2.环境基本要求 node.js v16+ npm v8+ 代码编辑器 VsCode 以及 Chrome/Edge 浏览器 代码实战 1.使用Vite创建一个Vue3项目 1.1 打开 VSCode 软件,使用 Ctrl+~快捷键打开终端。执行以下命令安装Vite npm install -g vite 1.2 使用 Vite 创建一个 Vue3 工程 npm create vite[@latest](https://my.oschina.net/u/4418429) tinyvue-multi-theme -- --template vue 命令行提示是否安装 create-vite@latest,输入y后回车,安装并创建 cd tinyvue-multi-theme npm install npm run dev 创建工程完毕后,依次输入以上命名 进入工程文件夹 安装依赖 执行命令启动项目 出现以下界面,则说明项目启动成功,Ctrl+鼠标左边单击 http://127.0.0.1:5173/ 从浏览器启动项目 浏览器打开会出现以上界面,说明一切正常,到此为止,Vue3项目已经完成创建。 2.安装 TinyVue,使用 button 以及 alert 组件 安装@opentiny/vue,在 vscode 终端下执行以下命名,安装 TinyVue 组件库 npm install @opentiny/vue@3.16.0 打开 OpenTiny 官网 https://opentiny.design/tiny-vue/zh-CN/overview 找到 Button 组件和 Alert 组件,可以参考官网 demo 的写法新增本次实验所需代码。 在 components 文件夹下,新建ButtonDemo.vue文件, 使用 Button 组件,新增6个类型的朴素按钮。 <template> <tiny-button plain> 朴素按钮 </tiny-button> <tiny-button type="primary" plain> 主要按钮 </tiny-button> <tiny-button type="success" plain> 成功按钮 </tiny-button> <tiny-button type="info" plain> 信息按钮 </tiny-button> <tiny-button type="warning" plain> 警告按钮 </tiny-button> <tiny-button type="danger" plain> 危险按钮 </tiny-button> </template> <script> import { Button } from "@opentiny/vue"; export default { components: { TinyButton: Button, }, }; </script> 在 components 文件夹下,新建AlertDemo.vue文件, 使用 Alert 组件,新增4个类型 alert。 <template> <div> <tiny-alert type="success" description="type 为 success"></tiny-alert> <tiny-alert type="simple" description="type 为默认值 info"></tiny-alert> <tiny-alert type="warning" description="type 为 warning"></tiny-alert> <tiny-alert type="error" description="type 为 error"></tiny-alert> </div> </template> <script> import { Alert } from "@opentiny/vue"; export default { components: { TinyAlert: Alert, }, }; </script> 删除无关文件HelloWorld.vue ,修改App.vue文件,引入ButtonDemo.vue和AlertDemo.vue组件。 import ButtonDemo from "./components/ButtonDemo.vue"; import AlertDemo from "./components/AlertDemo.vue"; 修改模板代码,删除 vite 初始 demo 代码,使用引入的 Button 和 Alert。 <template> <div class="theme-app"> <div class="container"> <button-demo></button-demo> </div> <div class="container"> <alert-demo></alert-demo> </div> </div> </template> 删除原本 vite 初始 demo 代码样式代码,新增本次实验所需的样式代码,使其看起来更美观一些。 <style scoped> .container { width: 650px; padding: 20px 24px; border-radius: 5px; border: 1px solid #ddd; margin-top: 24px; } </style> 完成以上步骤,就已经掌握了 TinyVue 组件的基本用法了,打开页面查看,如果显示以下页面,那么准备工作就完毕了~ 3.实现样式切换 下面来准备第三步,实现样式上的切换,开始实现之前,首先简单介绍一下 TinyVue 主题适配的原理。 原理: 在页面打开控制台,查看 button 的样式,可以看到样式属性值都是使用的 css var 变量。这些变量都以 ti-button 开头,这些可以称之为组件级变量。 通常情况下,相同类型(成功类型)的背景色、文本色等在不同组件中属性值相同,因此组件库定义了这部分常用到公共变量。而绝大多数组件级变量也都是使用的公共变量。 本次实验中 Button 和 Alert 的组件级变量的背景色正是使用的同一个公共变量ti-common-color-success-bg 主题适配的原理就是覆盖这些 css var 变量的值,去达到改变样式的效果。了解了原理后,就可以开始实现样式切换了。 实战: 在 components 文件夹下,新建ChangeTheme.vue文件, 编写切换样式逻辑。 这里使用 TinyVue 内置的 theme-tool 切换主题工具,只需要定义好相应主题变量的值即可,工具就会自动完成覆盖变量值的操作。 然后引入 Radio 组件,选中不同值时切换不同的主题,引入 theme-tool 工具,尝试修改上文提到的公共变量ti-common-color-success-bg,这里先设置为测试值 green 查看效果。 <script setup> import { Radio as TinyRadio, RadioGroup as TinyRadioGroup, } from "@opentiny/vue"; import TinyThemeTool from "@opentiny/vue-theme/theme-tool"; import { ref } from "vue"; const theme = ref("tiny-vue"); const themeTool = new TinyThemeTool(); const elementTheme = { id: "element-theme", name: "elementTheme", cnName: "饿了么主题", data: { "ti-common-color-success-bg": "green", }, }; const emit = defineEmits(["change-theme"]); const changeTheme = (theme) => { themeTool.changeTheme(theme === "element" ? elementTheme : null); emit("change-theme", theme); }; </script> <template> <tiny-radio-group v-model="theme" @change="changeTheme"> <tiny-radio label="tiny-vue"></tiny-radio> <tiny-radio label="element"></tiny-radio> </tiny-radio-group> </template> 在App.vue中引入并使用ChangeTheme组件 // script下新增 import ChangeTheme from "./components/ChangeTheme.vue"; // template下新增 <change-theme></change-theme> 接着打开页面查看效果,切换主题时,成功按钮和成功类型的 alert 背景颜色都变为 green 了~ 然后可以对比 element 组件样式差异:https://element-plus.org/zh-CN/component/button.html 将背景色、文字色等 css 属性修改为与 element 一致,当然也可以自己发挥,DIY 自己的主题。以下是一份参考配置: const elementTheme = { id: "element-theme", name: "elementTheme", cnName: "饿了么主题", data: { // 设置公共变量 "ti-common-color-primary-bg": "#409eff", "ti-common-color-primary-normal": "#409eff", "ti-common-color-success-bg": "#f0f9eb", "ti-common-color-success-normal": "#67c23a", "ti-common-color-info-bg": "#f4f4f5", "ti-common-color-info-normal": "#909399", "ti-common-color-warn-bg": "#fdf6ec", "ti-common-color-warn-normal": "#e6a23c", "ti-common-color-danger-bg": "#fef0f0", "ti-common-color-danger-normal": "#f56c6c", // 设置button相关样式属性 "ti-button-size-normal-height": "32px", "ti-button-border-radius": "4px", "ti-button-font-size": "14px", // 设置alert相关样式属性 "ti-alert-border-radius": "6px", "ti-alert-close-font-size": "14px", "ti-alert-description-font-size": "14px", "ti-alert-success-close-icon-color": "#a8abb2", "ti-alert-simple-close-icon-color": "#a8abb2", "ti-alert-error-close-icon-color": "#a8abb2", "ti-alert-warning-close-icon-color": "#a8abb2", "ti-alert-success-title-text-color": "#67c23a", "ti-alert-simple-title-text-color": "#909399", "ti-alert-warning-title-text-color": "#e6a23c", "ti-alert-error-title-text-color": "#f56c6c", "ti-alert-border-weight": "0px", }, }; 4.图标的适配 完成以上三步,此时 css 样式部分已经适配完毕。但是和 element 主题还是会有差别,仔细对比发现,element 主题是没有图标的。 而对于图标的隐藏,其实也可以通过 css var 变量的方式去实现,但是只能控制图标的显示和隐藏,无法实现不同主题下展示不同的图标,因此对于图标的适配,组件库采用配置的方式去实现。 以下是组件库代码截图,组件库对于图标,预留了配置项,组件库提供 ConfigProvider 组件来实现适配不同设计规范之间的图标和逻辑。 在App.vue文件下,引入 ConfigProvider,定义 designConfig,因为 element 是没有图标,因此配置为返回 null。定义切换方法 changeDesign,在切换样式的同时切换主题配置。 import { ConfigProvider } from "@opentiny/vue"; import { ref } from "vue"; const elementConfig = { name: "elementConfig", // 自定义规范名称 components: { Alert: { icons: { warning: () => null, success: () => null, error: () => null, }, }, }, }; const designConfig = ref({}); const changeDesign = (val) => { console.log(val === "element"); designConfig.value = val === "element" ? elementConfig : {}; }; 在模板中使用 ConfigProvider,传入主题配置。因为主题配置为非响应式更新,因此需要配置一下 key,切换配置后重新加载一下。 <template> <change-theme @change-theme="changeDesign"></change-theme> <config-provider :design="designConfig" :key="designConfig.name"> <div class="theme-app"> <div class="container"> <button-demo></button-demo> </div> <div class="container"> <alert-demo></alert-demo> </div> </div> </config-provider> </template> 配置完 designConfig 后,图标问题也解决了~ 5.交互的适配 完成以上4点,已经完成了 Button 组件和 Alert 组件的类 element 主题适配了,第5点属于拓展内容,试想一下,如果 element 主题在关闭 alert 前,需要弹出确认框确认,应该如何适配? 得益于 TinyVue 的 renderless 架构,可以很轻易地实现逻辑的替换,从而适配不同交互规范。对原理感兴趣的话,可以查看往期文章《手把手教你实现 miniTinyVue 版组件库》 这里直接贴实现方式,在 elementConfig 中新增替换 handleClose 的配置。 const elementConfig = { name: "elementConfig", // 自定义规范名称 components: { Alert: { icons: { warning: () => null, success: () => null, error: () => null, }, // 可以通过renderless重写某个方法,自定义交互逻辑 renderless: (props, hooks, { emit }, api) => { const state = api.state; return { handleClose() { const isClose = confirm("是否确认关闭?"); if (isClose) { state.show = false; } }, }; }, }, }, }; 打开页面,尝试关闭其中一个 alert,发现关闭前会弹出确认框。至此,样式、图标以及交互的适配都完成了~ 总结 至此,本次实操体验已全部完成。相信通过本次实操体验,你已经对 TinyVue 跨设计规范的原理以及相关工具有一个初步了解了~ 如果你感兴趣,完全通过theme-tool和config-provider打造一套属于自己的主题 ~ 关于OpenTiny OpenTiny 是一套企业级 Web 前端开发解决方案,提供跨端、跨框架、跨版本的 TinyVue 组件库,包含基于 Angular+TypeScript 的 TinyNG 组件库,拥有灵活扩展的低代码引擎 TinyEngine,具备主题配置系统TinyTheme / 中后台模板 TinyPro/ TinyCLI 命令行等丰富的效率提升工具,可帮助开发者高效开发 Web 应用。 欢迎加入 OpenTiny 开源社区。添加微信小助手:opentiny-official 一起参与交流前端技术~ OpenTiny 官网:https://opentiny.design/ OpenTiny 代码仓库:https://github.com/opentiny/ TinyVue 源码:https://github.com/opentiny/tiny-vue TinyEngine 源码: https://github.com/opentiny/tiny-engine 欢迎进入代码仓库 Star?*TinyEngine、TinyVue、TinyNG、TinyCLI~ 如果你也想要共建,可以进入代码仓库,找到 good first issue标签,一起参与开源贡献~

优秀的个人博客,低调大师

企业级快速开发框架 nbsaas-boot 1.1.8-2024 发布了

<parent> <groupId>com.nbsaas.boot</groupId> <artifactId>nbsaas-boot</artifactId> <version>1.1.8-2024</version> </parent> ​ 本次更新内容 1. 重构代码生成器,采用类提取和字段提取两种方式,提取功能接口,方便后期扩展 2. 对数据字典注解增加字符串类型 3. 修改mybatis list大小不能处理各种数据库的问题 4. 重新编写项目代码结构规范,支持单应用和saas系统,saas采用域名和请求头租户识别。 5. 代码生成器增加feign类生成 6. 修改字段映射类生成方式 nbsaas-boot 具有以下特点: 自动建表:nbsaas-boot 提供了自动建表功能,根据用户定义的数据模型自动生成数据库表结构,减少手动操作,提高开发效率。 支持 jpa,mybatis-plus 等数据库 orm。内置一套访问数据的注解 DSL 开发规范:nbsaas-boot 提供一套开发规范,包括代码风格、命名规范、注释规范等,使团队开发更加规范化和高效化。 代码生成器:nbsaas-boot 提供代码生成器,根据数据模型自动生成前端和后端代码,提高开发效率和代码质量。 多租户支持:nbsaas-boot 支持多租户,为不同客户提供独立的数据存储空间和访问权限,保证数据安全性和隔离性 通过 Command 处理复杂的业务 InputRequestObject context = new InputRequestObject(); context.setConfig(config); context.setFormBean(formBean); new DomainCommand() .after(new ApiCommand()) .after(new ConvertCommand()) .after(new ControllerFrontCommand()) .after(new RestCommand()) .after(new ExtApiCommand()) .after(new RepositoryCommand()) .after(new FieldCommand()) .after(new FinishCommand()).execute(context); 模型构建 @CatalogClass @FormAnnotation(title = "组织架构管理", model = "组织架构") @Data @Entity @Table(name = "sys_structure") public class Structure extends CatalogEntity { @FormField(title = "父分类名称") @Comment("父分id") @FieldName @FieldConvert(classType = "Integer") @ManyToOne(fetch = FetchType.LAZY) private Structure parent; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") private List<Structure> children; } 搜索模型 @Data public class ArticleSearch extends PageRequest implements Serializable { /** * 主键id ==查询 **/ @Search(name = "id", operator = Operator.eq) private Long id; /** * 文章标题 模糊查询 **/ @Search(name = "title", operator = Operator.like) private String title; } 通过模型数据提取,然后通过代码生成器生成后端代码 + vue3 后端管理代码 项目最佳实践:https://gitee.com/quhaodian/nbsaas-mall2 基础功能项目 https://gitee.com/cng1985/nbsaas-boot-starter 项目脚手架 https://gitee.com/cng1985/nbsaas-admin vue3 后台管理脚手架 https://gitee.com/cng1985/nbsaas-admin-vue3

优秀的个人博客,低调大师

企业级快速开发框架 nbsaas-boot 1.1.7-2024 发布了

<parent> <groupId>com.nbsaas.boot</groupId> <artifactId>nbsaas-boot</artifactId> <version>1.1.7-2024</version> </parent> 本次更新内容 1. 数据请求全面采用 json 格式数据提交,增加前端参数加密和后端响应加密功能。 2. 修改代码生成器,单个对象字段要是实体类,会抛出异常,需要进行相应的处理。 3. 修改后台vue3代码生成模板 4. 新增用户搜索注解 5. 新增系统判断,解决不能在mac系统代码生成的问题 6. 修改后台代码生成器模板代码 nbsaas-boot 具有以下特点: 自动建表:nbsaas-boot 提供了自动建表功能,根据用户定义的数据模型自动生成数据库表结构,减少手动操作,提高开发效率。 支持 jpa,mybatis-plus 等数据库 orm。内置一套访问数据的注解 DSL 开发规范:nbsaas-boot 提供一套开发规范,包括代码风格、命名规范、注释规范等,使团队开发更加规范化和高效化。 代码生成器:nbsaas-boot 提供代码生成器,根据数据模型自动生成前端和后端代码,提高开发效率和代码质量。 多租户支持:nbsaas-boot 支持多租户,为不同客户提供独立的数据存储空间和访问权限,保证数据安全性和隔离性 通过 Command 处理复杂的业务 InputRequestObject context = new InputRequestObject(); context.setConfig(config); context.setFormBean(formBean); new DomainCommand() .after(new ApiCommand()) .after(new ConvertCommand()) .after(new ControllerFrontCommand()) .after(new RestCommand()) .after(new ExtApiCommand()) .after(new RepositoryCommand()) .after(new FieldCommand()) .after(new FinishCommand()).execute(context); 模型构建 @CatalogClass @FormAnnotation(title = "组织架构管理", model = "组织架构", menu = "1,27,88") @Data @Entity @Table(name = "sys_structure") public class Structure extends CatalogEntity { @FormField(title = "父分类名称") @Comment("父分id") @FieldName @FieldConvert(classType = "Integer") @ManyToOne(fetch = FetchType.LAZY) private Structure parent; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") private List<Structure> children; } 搜索模型 @Data public class ArticleSearch extends PageRequest implements Serializable { /** * 主键id ==查询 **/ @Search(name = "id", operator = Operator.eq) private Long id; /** * 文章标题 模糊查询 **/ @Search(name = "title", operator = Operator.like) private String title; } 通过模型数据提取,然后通过代码生成器生成后端代码 + vue3 后端管理代码 项目最佳实践:https://gitee.com/quhaodian/nbsaas-mall2 基础功能项目 https://gitee.com/cng1985/nbsaas-boot-starter 项目脚手架 https://gitee.com/cng1985/nbsaas-admin vue3 后台管理脚手架 https://gitee.com/cng1985/nbsaas-admin-vue3

优秀的个人博客,低调大师

企业级快速开发框架 nbsaas-boot 1.1.6-2023 发布了

<parent> <groupId>com.nbsaas.boot</groupId> <artifactId>nbsaas-boot</artifactId> <version>1.1.6-2023</version> </parent> 本次更新内容 1. 数据请求全面从没用json格式数据提交,增加前端参数加密和后端响应加密功能。 2. 修改vue3代码生成模板 3. 增加@EncryptionData注解,放到参数上,后台认为请求需要加密,进行解密。放到方法头上,aes加密响应请求。 4. 增加 mybatis mapper文件夹生成Command 5. 增加数据库逻辑删除代码生成功能 6. 修改后台代码生成器模板代码 nbsaas-boot 具有以下特点: 自动建表:nbsaas-boot 提供了自动建表功能,根据用户定义的数据模型自动生成数据库表结构,减少手动操作,提高开发效率。 支持jpa,mybatis-plus等数据库orm。内置一套访问数据的注解DSL 开发规范:nbsaas-boot 提供一套开发规范,包括代码风格、命名规范、注释规范等,使团队开发更加规范化和高效化。 代码生成器:nbsaas-boot 提供代码生成器,根据数据模型自动生成前端和后端代码,提高开发效率和代码质量。 多租户支持:nbsaas-boot 支持多租户,为不同客户提供独立的数据存储空间和访问权限,保证数据安全性和隔离性 通过 Command 处理复杂的业务 InputRequestObject context = new InputRequestObject(); context.setConfig(config); context.setFormBean(formBean); new DomainCommand() .after(new ApiCommand()) .after(new ConvertCommand()) .after(new ControllerFrontCommand()) .after(new RestCommand()) .after(new ExtApiCommand()) .after(new RepositoryCommand()) .after(new FieldCommand()) .after(new FinishCommand()).execute(context); 模型构建 @CatalogClass @FormAnnotation(title = "组织架构管理", model = "组织架构", menu = "1,27,88") @Data @Entity @Table(name = "sys_structure") public class Structure extends CatalogEntity { @FormField(title = "父分类名称") @Comment("父分id") @FieldName @FieldConvert(classType = "Integer") @ManyToOne(fetch = FetchType.LAZY) private Structure parent; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") private List<Structure> children; } 搜索模型 @Data public class ArticleSearch extends PageRequest implements Serializable { /** * 主键id ==查询 **/ @Search(name = "id", operator = Operator.eq) private Long id; /** * 文章标题 模糊查询 **/ @Search(name = "title", operator = Operator.like) private String title; } 通过模型数据提取,然后通过代码生成器生成后端代码 + vue3 后端管理代码 项目最佳实践:https://gitee.com/quhaodian/nbsaas-mall2 基础功能项目 https://gitee.com/cng1985/nbsaas-boot-starter 项目脚手架 https://gitee.com/cng1985/nbsaas-admin vue3 后台管理脚手架 https://gitee.com/cng1985/nbsaas-admin-vue3

优秀的个人博客,低调大师

企业级快速开发框架 nbsaas-boot 1.1.4-2023 发布了

<parent> <groupId>com.nbsaas.boot</groupId> <artifactId>nbsaas-boot</artifactId> <version>1.1.4-2023</version> </parent> 本次更新内容 1. 增加@Dict@DictItem注解,方便字典类型数据显示 2. DataRequest对象重构成Request对象,SearchRequest对象重构成Search对象 3. 修改代码生成模块Request对象,SearchRequest对象相关模块 4. 增加PageExtResponse对象,方便列表数据增加其他属性。 5. 增加NeStrategy,支持ne查询。 6. 调整FilterGroup等类型,这样兼容dubbo3 nbsaas-boot 具有以下特点: 自动建表:nbsaas-boot 提供了自动建表功能,根据用户定义的数据模型自动生成数据库表结构,减少手动操作,提高开发效率。 开发规范:nbsaas-boot 提供一套开发规范,包括代码风格、命名规范、注释规范等,使团队开发更加规范化和高效化。 代码生成器:nbsaas-boot 提供代码生成器,根据数据模型自动生成前端和后端代码,提高开发效率和代码质量。 多租户支持:nbsaas-boot 支持多租户,为不同客户提供独立的数据存储空间和访问权限,保证数据安全性和隔离性 通过 Command 处理复杂的业务 InputRequestObject context = new InputRequestObject(); context.setConfig(config); context.setFormBean(formBean); new DomainCommand() .after(new ApiCommand()) .after(new ConvertCommand()) .after(new ControllerFrontCommand()) .after(new RestCommand()) .after(new ExtApiCommand()) .after(new RepositoryCommand()) .after(new FieldCommand()) .after(new FinishCommand()).execute(context); 模型构建 @CatalogClass @FormAnnotation(title = "组织架构管理", model = "组织架构", menu = "1,27,88") @Data @Entity @Table(name = "sys_structure") public class Structure extends CatalogEntity { @FormField(title = "父分类名称") @Comment("父分id") @FieldName @FieldConvert(classType = "Integer") @ManyToOne(fetch = FetchType.LAZY) private Structure parent; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") private List<Structure> children; } 搜索模型 @Data public class ArticleSearch extends PageRequest implements Serializable { /** * 主键id ==查询 **/ @Search(name = "id", operator = Operator.eq) private Long id; /** * 文章标题 模糊查询 **/ @Search(name = "title", operator = Operator.like) private String title; } 通过模型数据提取,然后通过代码生成器生成后端代码 + vue3 后端管理代码 基础功能项目 https://gitee.com/cng1985/nbsaas-boot-starter 项目脚手架 https://gitee.com/cng1985/nbsaas-admin vue3 后台管理脚手架 https://gitee.com/cng1985/nbsaas-admin-vue3

优秀的个人博客,低调大师

企业级快速开发框架 nbsaas-boot 1.1.3-2023 发布了

<parent> <groupId>com.nbsaas.boot</groupId> <artifactId>nbsaas-boot</artifactId> <version>1.1.3-2023</version> </parent> 本次更新内容 1. 升级 spring-boot 版本,升级shiro版本1.13.0 2. 增加SearchData注解,方便在搜索的适合通过aop进行数据拦截 3. 增加控制操作区域是否显示属性 4. 新增ExtResourceCommand ,处理生成代码的时候生成扩展模块文件夹。 5. 搜索模块支持or条件搜索。 6. 修改通过注解提取模型数据。 nbsaas-boot 具有以下特点: 自动建表:nbsaas-boot 提供了自动建表功能,根据用户定义的数据模型自动生成数据库表结构,减少手动操作,提高开发效率。 开发规范:nbsaas-boot 提供一套开发规范,包括代码风格、命名规范、注释规范等,使团队开发更加规范化和高效化。 代码生成器:nbsaas-boot 提供代码生成器,根据数据模型自动生成前端和后端代码,提高开发效率和代码质量。 多租户支持:nbsaas-boot 支持多租户,为不同客户提供独立的数据存储空间和访问权限,保证数据安全性和隔离性 通过 Command 处理复杂的业务 InputRequestObject context = new InputRequestObject(); context.setConfig(config); context.setFormBean(formBean); new DomainCommand() .after(new ApiCommand()) .after(new ConvertCommand()) .after(new ControllerFrontCommand()) .after(new RestCommand()) .after(new ExtApiCommand()) .after(new RepositoryCommand()) .after(new FieldCommand()) .after(new FinishCommand()).execute(context); 模型构建 @CatalogClass @FormAnnotation(title = "组织架构管理", model = "组织架构", menu = "1,27,88") @Data @Entity @Table(name = "sys_structure") public class Structure extends CatalogEntity { @FormField(title = "父分类名称") @Comment("父分id") @FieldName @FieldConvert(classType = "Integer") @ManyToOne(fetch = FetchType.LAZY) private Structure parent; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") private List<Structure> children; } 通过模型数据提取,然后通过代码生成器生成后端代码 + vue3 后端管理代码 基础功能项目 https://gitee.com/cng1985/nbsaas-boot-starter 项目脚手架 https://gitee.com/cng1985/nbsaas-admin vue3 后台管理脚手架 https://gitee.com/cng1985/nbsaas-admin-vue3

优秀的个人博客,低调大师

企业级快速开发框架 nbsaas-boot 1.1.2-2023 发布了

<parent> <groupId>com.nbsaas.boot</groupId> <artifactId>nbsaas-boot</artifactId> <version>1.1.2-2023</version> </parent> 本次更新内容 1. 升级spring-boot版本 2. 增加统一异常处理类,方便在业务系统中统一处理异常返回结果 3. 增加租户统一请求对象基类 4. java8 兼容 caffeine cache 5. 修复el-select对象代码中数据请求url错误的问题。 6.修改java版本兼容问题,最低要求java8 nbsaas-boot 具有以下特点: 自动建表:nbsaas-boot 提供了自动建表功能,根据用户定义的数据模型自动生成数据库表结构,减少手动操作,提高开发效率。 开发规范:nbsaas-boot 提供一套开发规范,包括代码风格、命名规范、注释规范等,使团队开发更加规范化和高效化。 代码生成器:nbsaas-boot 提供代码生成器,根据数据模型自动生成前端和后端代码,提高开发效率和代码质量。 多租户支持:nbsaas-boot 支持多租户,为不同客户提供独立的数据存储空间和访问权限,保证数据安全性和隔离性 通过 Command 处理复杂的业务 InputRequestObject context = new InputRequestObject(); context.setConfig(config); context.setFormBean(formBean); new DomainCommand() .after(new ApiCommand()) .after(new ConvertCommand()) .after(new ControllerFrontCommand()) .after(new RestCommand()) .after(new ExtApiCommand()) .after(new RepositoryCommand()) .after(new FieldCommand()) .after(new FinishCommand()).execute(context); 模型构建 @CatalogClass @FormAnnotation(title = "组织架构管理", model = "组织架构", menu = "1,27,88") @Data @Entity @Table(name = "sys_structure") public class Structure extends CatalogEntity { @FormField(title = "父分类名称") @Comment("父分id") @FieldName @FieldConvert(classType = "Integer") @ManyToOne(fetch = FetchType.LAZY) private Structure parent; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") private List<Structure> children; } 通过模型数据提取,然后通过代码生成器生成后端代码 + vue3 后端管理代码 基础功能项目 https://gitee.com/cng1985/nbsaas-boot-starter 项目脚手架 https://gitee.com/cng1985/nbsaas-admin vue3 后台管理脚手架 https://gitee.com/cng1985/nbsaas-admin-vue3

优秀的个人博客,低调大师

高效数据传输:Java通过绑定快速将数据导出至Excel

摘要:本文由葡萄城技术团队原创并首发。转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具、解决方案和服务,赋能开发者。 前言 把数据导出至 Excel 是很常见的需求,而数据的持久化,往往又放在数据库中。因此把数据库中的数据导出到 Excel中,成了非常普遍的一个需求。 以关系型数据库为例,数据表是一个二维矩阵,但是为了易于操作和维护,在数据读取中,都会定义类,并且以对象的形式在内存中存放数据。但是Excel的工作表又是另一个二维矩阵,这就意味着,从数据库读取出的对象数据,又需要循环写入另一个表格中,这使得代码难以维护。 为了解决数据不易维护的问题,可以给工作表,单元格或者表格设置对象及单元格的绑定关系,这样在保存时便可以根据数据源的绑定关系,自动填充数据。 具体实现方法 现有数据类如下: public static class SalesRecord { public int sales; public String productType; public String product; public String salesman; public String area; } public static class SalesData { public ArrayList records; } 样本数据如下: private SalesData getDataSource() { // 创建数据源 SalesData datasource = new SalesData(); datasource.records = new ArrayList(); // 添加数据 SalesRecord record1 = new SalesRecord(); record1.area = "NorthChina"; record1.salesman = "Hellen"; record1.product = "Apple"; record1.productType = "Fruit"; record1.sales = 120; datasource.records.add(record1); SalesRecord record2 = new SalesRecord(); record2.area = "NorthChina"; record2.salesman = "Hellen"; record2.product = "Banana"; record2.productType = "Fruit"; record2.sales = 143; datasource.records.add(record2); SalesRecord record3 = new SalesRecord(); record3.area = "NorthChina"; record3.salesman = "Hellen"; record3.product = "Kiwi"; record3.productType = "Fruit"; record3.sales = 322; datasource.records.add(record3); return datasource; } 1.数据源绑定至工作表 下面是给工作表设置数据源绑定的代码,其中setAutoGenerateColumns设置为false,当setAutoGenerateColumns为true 时,工作表会根据数据源自动生成列。 public void SheetBinding() { // 创建一个新的workbook Workbook workbook = new Workbook(); // 获取默认sheet IWorksheet worksheet = workbook.getWorksheets().get(0); SalesData datasource = getDataSource(); // 自动生成列设置为false worksheet.setAutoGenerateColumns(false); // 给工作表中的每一列绑定数据源 worksheet.getRange("A:A").getEntireColumn().setBindingPath("area"); worksheet.getRange("B:B").getEntireColumn().setBindingPath("salesman"); worksheet.getRange("C:C").getEntireColumn().setBindingPath("product"); worksheet.getRange("D:D").getEntireColumn().setBindingPath("productType"); worksheet.getRange("E:E").getEntireColumn().setBindingPath("sales"); // 设置数据源 worksheet.setDataSource(datasource.records); // 保存为Excel文件 workbook.save("output/SheetBinding.xlsx"); } 实现效果如下: 2.数据源绑定至单元格 // 创建workbook Workbook workbook = new Workbook(); // 获取默认的sheet IWorksheet worksheet = workbook.getActiveSheet(); // 添加数据 SalesRecord record = new SalesRecord(); record.area = "北方"; record.salesman = "李强"; record.product = "苹果"; record.productType = "水果"; record.sales = 120; // 给单元格设置绑定 worksheet.getRange("A1").setBindingPath("area"); worksheet.getRange("B2").setBindingPath("salesman"); worksheet.getRange("C2").setBindingPath("product"); worksheet.getRange("D3").setBindingPath("productType"); // 设置数据源 worksheet.setDataSource(record); // 保存为Excel workbook.save("output/CellBinding.xlsx"); 实现效果如下: 3.数据源绑定至表格 下面的代码使用了setExpandBoundRows ,ITable.setExpandBoundRows方法用来处理一个绑定的表格对数据源的更改该如何响应。当属性设置为true时,该绑定表格会使用整行操作自动调整行数以适应数据源更改。 // 创建workbook Workbook workbook = new Workbook(); // 获取默认的sheet IWorksheet worksheet = workbook.getActiveSheet(); SalesData datasource = getDataSource(); // 添加一个表格 ITable table = worksheet.getTables().add(worksheet.getRange("B2:F5"), true); // 设置表格,不自动生成列 table.setAutoGenerateColumns(false); // 给表格设置绑定path table.setBindingPath("records"); // 设置setExpandBoundRows为true, table.setExpandBoundRows(true); // 设置表格列的数据字段 table.getColumns().get(0).setDataField("area"); table.getColumns().get(1).setDataField("salesman"); table.getColumns().get(2).setDataField("product"); table.getColumns().get(3).setDataField("productType"); table.getColumns().get(4).setDataField("sales"); // 设置数据源 worksheet.setDataSource(datasource); // 保存为excel workbook.save("output/TableBinding.xlsx"); 实现效果如下: 总结 通过给工作表、单元格或表格设置数据源绑定关系,可以实现将数据库中的数据导出到Excel的功能。这种方法使用对象和属性的绑定关系,将内存中的数据源与Excel中的工作表、单元格或表格进行连接。这样,在保存数据时,只需要根据数据源的绑定关系自动填充数据,而无需手动循环写入。这种实现方式简化了代码,提高了代码的可维护性和可扩展性。同时,通过设置自动生成列、设置绑定路径以及处理数据源变化等操作,还可以进一步增强导出功能的灵活性和适应性。总的来说,这种数据源绑定的方法为数据导出提供了一种优雅而高效的解决方案。 扩展链接: 从表单驱动到模型驱动,解读低代码开发平台的发展趋势 低代码开发平台是什么? 基于分支的版本管理,帮助低代码从项目交付走向定制化产品开发

优秀的个人博客,低调大师

企业级快速开发框架 nbsaas-boot 1.0.18-2023 发布了

<parent> <groupId>com.nbsaas.boot</groupId> <artifactId>nbsaas-boot</artifactId> <version>1.0.18-2023</version> </parent> 本次更新内容 1. 修复部分操作不支持多层搜索功能,例如: @SearchBean(items = {@SearchItem(label = "文章分类", name = "categoryName", key = "article.catalog.name", operator = Operator.like)}) 2.优化了vue代码生成模板,支持element-plus中的tree选择,移除了以前的无效主题。 3. 修改了公共组件中的字典功能 4. 优化了 nbsaas-admin 中用户管理模块 5. 修改了vue3中的状态管理,解决页面跳转返回以后重置页面条件的问题 6. 增加数据权限控制相关注解 boot-nbsaas 具有以下特点: 自动建表:boot-nbsaas 提供了自动建表功能,根据用户定义的数据模型自动生成数据库表结构,减少手动操作,提高开发效率。 开发规范:boot-nbsaas 提供一套开发规范,包括代码风格、命名规范、注释规范等,使团队开发更加规范化和高效化。 代码生成器:boot-nbsaas 提供代码生成器,根据数据模型自动生成前端和后端代码,提高开发效率和代码质量。 多租户支持:boot-nbsaas 支持多租户,为不同客户提供独立的数据存储空间和访问权限,保证数据安全性和隔离性 通过 Command 处理复杂的业务 InputRequestObject context = new InputRequestObject(); context.setConfig(config); context.setFormBean(formBean); new DomainCommand() .after(new ApiCommand()) .after(new ConvertCommand()) .after(new ControllerFrontCommand()) .after(new RestCommand()) .after(new ExtApiCommand()) .after(new RepositoryCommand()) .after(new FieldCommand()) .after(new FinishCommand()).execute(context); 模型构建 @CatalogClass @FormAnnotation(title = "组织架构管理", model = "组织架构", menu = "1,27,88") @Data @Entity @Table(name = "sys_structure") public class Structure extends CatalogEntity { @FormField(title = "父分类名称") @Comment("父分id") @FieldName @FieldConvert(classType = "Integer") @ManyToOne(fetch = FetchType.LAZY) private Structure parent; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") private List<Structure> children; } 通过模型数据提取,然后通过代码生成器生成后端代码 + vue3 后端管理代码 基础功能项目 https://gitee.com/cng1985/nbsaas-boot-starter 项目脚手架 https://gitee.com/cng1985/nbsaas-admin vue3 后台管理脚手架 https://gitee.com/cng1985/nbsaas-admin-vue3

优秀的个人博客,低调大师

JeeSite V5.5.0 发布,升级 Antd v4.0,Java 快速开发平台

升级内容 升级 spring boot 2.7.14、justauth 1.16.5、antdv 4.0.0 调整 语法 html 和 js 编写不同的占位符,减少IDE标红提示 新增 支持数据源独立设置XA开关,如 jdbc.数据源名.xa: false 新增 当前用户展示子系统列表过滤,进入角色管理中配置包含系统 新增 js ajax 下载 clearParams 参数,可清理掉不需要添加的请求参数 优化 子系统,角色增加包含系统参数,切换系统时只需展示当前用户包含的子系统 优化 fileupload 增加缩略图生成设置,前端组件可使用 imageThumbName 使用缩略图 优化 fileupload 使用 returnPath 时的下载还原原始文件名 优化 翰高数据库有原来的 oracle 语法换为原生 postgresql 语法 优化 导出,查询后默认不添加 pageNo 参数 优化 界面,默认隐藏表单右上角按钮 修正 jquery migrate 版本,处理ie9下的一些兼容问题 修正 GBase 数据库,多余的 remarksReporting 属性问题,支持设置为空 修正 SqlServer2012 驱动下初始化库报 OFFSET 错误问题 修正 树表更新子节点状态,字段名错误问题(所有版本) 修正 初始化库的时候 area 表没有插入数据问题 优化 用户头像获取接口,排除 http 的地址,不增加 ctxPath 其它细节更多改进... Vue分离端 升级 antdv4.0.0、vite4.4.9 等等 新增 ListSelect 组件 queryParams 参数 新增 Upload 组件 图片最大宽高的压缩参数 新增 Upload 组件 缩略图生成预览参数支持 新增 对话框弹窗、路由页签的弹窗表单例子 新增 downloadByUrl post 带参数下载文件 新增 iframe 支持 query 参数接受 新增 BpmButton initialize 事件 优化 国际化语言包完善(用户组织公司岗位个人中心) 优化 在线用户列表查询换 Switch 组件 优化 权限类型的菜单也可以设置组件名称 优化 升级 antdv4 后的整体配色、布局等细节 简化 视图组件名称,直接通过 name 统一设置 修正 解决 Radio 组件 onChange 调用 2 次的问题 升级方法 修改pom.xml文件中的jeesite-parent版本号为5.5.0-SNAPSHOT 如果你修改了parent、common、core项目源码,请与git上的代码进行同步 如果你是跨版本升级,请注意每一个版本的升级方法,业务上有调整的地方进行修改 关于 Beetl 语法 html 和 js 编写不同的占位符,查找替换方法(使用正则表达式、全字匹配): \$\{@DictUtils\.getDictListJson\(\'(.+?)\'\)\}替换为"#\{@DictUtils\.getDictListJson\(\'$1\'\)\}" \$\{toJson\((.+?)\)\}替换为"#\{toJson\($1\)\}" \/\/\<\% (.+?) \%\>替换为//# $1 执行root/package.bat(sh)打包脚本,强制更新依赖。 Vue分离端升级 请与jeesite-vue代码仓库源码进行同步,合并代码,手动解决冲突代码。 Antdv 4.0 相比 3.2 改动还是比较大的,遗弃和修改了很多内容,但是您也无需担心升级的问题 由于 JeeSite 封装了各种业务组件,所以业务代码上变化不是很大,您对 JeeSite 改动越少,升级越容易 请先了解 Ant Design Vue 4.0 的升级指南:https://antdv.com/docs/vue/migration-v4-cn(opens new window) 全局替换,匹配文件*.vue,*.ts,*.tsx(区分大小写、全字匹配,注意排除掉 css、sys.ts 文件): dropdownClassName替换为popupClassName visible替换为open 关于 antdv4 样式 less 替换 CSS-in-JS 实现动态主题 为了方便升级 jeesite 保留了 less,减少升级难度 同时支持 CSS-in-JS 提供更好的动态主题支持 业务中的样式可通过 css and 选择器,可覆盖 antdv 中的样式 匹配后端版本为JeeSite v5.5.0 了解更多 JeeSite 官网地址:http://jeesite.com JeeSite 在线文档:http://docs.jeesite.com JeeSite 演示地址:http://demo.jeesite.com JeeSite Vue 演示地址:http://vue.jeesite.com JeeSite 源码仓库:https://gitee.com/thinkgem/jeesite4 JeeSite Vue 前端源码:https://gitee.com/thinkgem/jeesite-vue JeeSite 跨平台手机端:https://gitee.com/thinkgem/jeesite4-uniapp JeeSite Cloud 微服务:https://gitee.com/thinkgem/jeesite4-cloud JeeSite 客户端安装程序:https://gitee.com/thinkgem/jeesite-client

优秀的个人博客,低调大师

企业级快速开发框架 nbsaas-boot 1.0.15-2023 发布了

<parent> <groupId>com.nbsaas.boot</groupId> <artifactId>nbsaas-boot</artifactId> <version>1.0.15-2023</version> </parent> 本次更新内容 1.后台模块增加shiro权限注解,前台添加菜单的时候需要配置权限标签,不然会报406错误 2.vue代码模板增加添加数据加载动画功能 3.修改了vue代码生成模板和jpa代码生成模板 4.优化了nbsaas-admin模块部分功能 5.增加基础功能模块 nbsaas-boot-starter,微信支付模块。基础功能引入pom就好了。 6.优化了nbsaas-admin-vue3视图页面 boot-nbsaas 具有以下特点: 自动建表:boot-nbsaas 提供了自动建表功能,根据用户定义的数据模型自动生成数据库表结构,减少手动操作,提高开发效率。 开发规范:boot-nbsaas 提供一套开发规范,包括代码风格、命名规范、注释规范等,使团队开发更加规范化和高效化。 代码生成器:boot-nbsaas 提供代码生成器,根据数据模型自动生成前端和后端代码,提高开发效率和代码质量。 多租户支持:boot-nbsaas 支持多租户,为不同客户提供独立的数据存储空间和访问权限,保证数据安全性和隔离性 通过 Command 处理复杂的业务 InputRequestObject context = new InputRequestObject(); context.setConfig(config); context.setFormBean(formBean); new DomainCommand() .after(new ApiCommand()) .after(new ConvertCommand()) .after(new ControllerFrontCommand()) .after(new RestCommand()) .after(new ExtApiCommand()) .after(new RepositoryCommand()) .after(new FieldCommand()) .after(new FinishCommand()).execute(context); 模型构建 @CatalogClass @FormAnnotation(title = "组织架构管理", model = "组织架构", menu = "1,27,88") @Data @Entity @Table(name = "sys_structure") public class Structure extends CatalogEntity { @FormField(title = "父分类名称") @Comment("父分id") @FieldName @FieldConvert(classType = "Integer") @ManyToOne(fetch = FetchType.LAZY) private Structure parent; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") private List<Structure> children; } 通过模型数据提取,然后通过代码生成器生成后端代码 + vue3 后端管理代码 基础功能项目 https://gitee.com/cng1985/nbsaas-boot-starter 项目脚手架 https://gitee.com/cng1985/nbsaas-admin vue3 后台管理脚手架 https://gitee.com/cng1985/nbsaas-admin-vue3

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册