# Halo 1.5.0 发布

原文：<https://www.halo.run/archives/halo-150-released>

> 距离我们 2020 年 9 月 24 号发布 1.4.0 已经过去了 545 天了，期间虽然有一些版本更新，但大多数都是 patch 修复版本。终于，在今天正式发布 1.5.0 版本。其中带来了大量的优化更新，下面为大家简单介绍一些亮点功能，详细更新日志可在本文末尾查阅。

## 版本亮点

### 文章表拆分

在此版本中，新增了 `contents` 表专门用于存储文章内容。因为在以前的版本中，当站点有大量文章的时候会出现明显拖慢页面渲染速度的情况，这是因为在之前的版本中，查询文章列表会将内容字段也包含在其中，这就会导致数据越多就会越慢。所以在这个版本中，原本的 `posts` 表就不再包含 `originalContent` 和 `formatContent` 字段，在列表查询的时候也不会包含。需要注意的是，如果你是从 1.4 版本升级的话，目前我们是没有自动清空这两个字段的内容的。当然，你可以手动清空，以获得更好的效果。

性能对比：

-   版本：1.4.17 vs 1.5.0
    
-   测试数据：文章数 1000，每篇 4000 字符。
    
-   测试工具：Apache Benchmark
    
-   测试平台：MacBook Pro M1 Pro
    
-   测试参数：`ab -c 100 -n 10000 http://localhost:8090/`
    

1.4.17：

![Screen Shot 2022-03-23 at 15.55.46](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2015.55.46.png)

1.5.0：

![Screen Shot 2022-03-23 at 16.03.46](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2016.03.46.png)

> 注意：此测试可能并不是特别严谨，仅供参考。

### 文章保存逻辑修改

目前后台已经修改为直接保存编辑器渲染的 html 内容，保证编写时和最终发布结果完全一致。另外，数学公式和 mermaid 图表已经针对此特性做了优化。数学公式仅需在前台引入 katex css 即可。mermaid 图表会被渲染为 svg 并保存，所以无需再引入 mermaid 依赖。

数学公式可以在前台引入：

```html
<link rel="stylesheet" href="https://unpkg.com/katex@0.12.0/dist/katex.min.css" />
```

![Screen Shot 2022-03-23 at 14.41.51](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.41.51.png)  
![Screen Shot 2022-03-23 at 14.42.22](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.42.22.png)  
![Screen Shot 2022-03-23 at 14.44.14](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.44.14.png)  
![Screen Shot 2022-03-23 at 14.44.24](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.44.24.png)

目前，我们已经统一使用 [@halo-dev/markdown-renderer](https://github.com/halo-dev/js-sdk/tree/master/packages/markdown-renderer) 进行 Markdown 渲染。

### 编辑器重构

编辑器编辑区域修改为 Codemirror 编辑器，支持 Markdown 语法高亮，浏览文章会更加方便。

![Screen Shot 2022-03-23 at 14.53.18](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.53.18.png)

编辑器可以通过快捷键打开图片选择，目前也已经支持多选图片和选择之后直接插入文章。

![Screen Shot 2022-03-23 at 14.52.41](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.52.41.png)

预览区域支持代码块高亮。

![Screen Shot 2022-03-23 at 14.51.53](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.51.53.png)

支持更多 Markdown 标记语法。

![Screen Shot 2022-03-23 at 14.54.15](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.54.15.png)

表格编辑体验优化。众所周知，使用 Markdown 语法编写表格的体验是非常难受的，不仅编写困难，而且格式会非常难以阅读。所以我们使用了一个叫做 [mte-kernel](https://github.com/susisu/mte-kernel) 的库来解决这个问题，不仅可以让编辑体验升级，而且会自动格式化表格。

![CleanShot 2022-03-23 at 14.54.38](https://halo.run/upload/2022/03/CleanShot%202022-03-23%20at%2014.54.38.gif)

### 标签支持设置颜色

在这个版本中，我们添加了对标签设置颜色的功能，灵感来自于 GitHub Issues 的标签颜色。这样可以比较直观地区分不同的标签。

![Screen Shot 2022-03-23 at 14.13.04](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.13.04.png)  
![Screen Shot 2022-03-23 at 14.13.17](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.13.17.png)

### 文章管理重构

重构了批量操作的逻辑，目前已经不需要提前通过文章状态筛选文章之后才能批量选择。可以任意批量选择之后进行文章状态的批量操作。

![Screen Shot 2022-03-23 at 14.16.14](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.16.14.png)

文章列表不再展示回收站的文章，改为单独为回收站提供一个入口。

![Screen Shot 2022-03-23 at 14.16.00](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.16.00.png)

文章设置弹窗进行了重构，改为更直观地显示方式，并且可以在弹窗中进行上下篇的切换。可以非常快速的预览文章设置并进行对文章设置的修改。

![Screen Shot 2022-03-23 at 14.16.39](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.16.39.png)

### 附件管理重构

目前支持将鼠标放在附件项即可显示勾选图标，不再需要提前进入批量管理功能。

![Screen Shot 2022-03-23 at 14.15.17](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.15.17.png)

附件详情也和文章设置一样，修改为弹窗的形式，可以进行上下项的快速切换，方便预览以及进行修改删除等操作。

![Screen Shot 2022-03-23 at 14.15.32](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.15.32.png)

### 主题设置重构

主题设置由原来的全屏抽屉形式改为单独的页面。并优化了布局，不再显示主题缩略图，将更多的空间留给设置表单。同时在界面上也展示了主题的相关信息。

![Screen Shot 2022-03-23 at 14.17.16](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.17.16.png)

![Screen Shot 2022-03-23 at 14.18.44](https://halo.run/upload/2022/03/Screen%20Shot%202022-03-23%20at%2014.18.44.png)

## 版本日志

### 破坏性更新

-   评论表单中的邮箱地址不再作为必填项。 [#1535](https://github.com/halo-dev/halo/pull/1535) [**@jerry-shao**](https://github.com/jerry-shao)
    
-   重构文章表结构。
    
    -   提供单独的 `contents` 表存储文章内容，将不再使用 `posts` 表中的 `originalContent` 和 `formatContent` 字段。 [#1617](https://github.com/halo-dev/halo/pull/1617) [**@guqing**](https://github.com/guqing)
        
    -   `formatContent` 已经废弃，将在下一个大版本中移除。后续使用 `content` 字段代替。 [#1617](https://github.com/halo-dev/halo/pull/1617) [**@guqing**](https://github.com/guqing)
        
    -   提供 `content_patch_logs` 表用于存储变更记录。 [#1617](https://github.com/halo-dev/halo/pull/1617) [**@guqing**](https://github.com/guqing)
        
-   后台使用 @halo-dev/admin-api 进行接口请求。 [halo-dev/console#378](https://github.com/halo-dev/console/pull/378) [**@ruibaby**](https://github.com/ruibaby) [**@guqing**](https://github.com/guqing)
    
-   修改后台页面标题后缀，由 `Halo Dashboard` 改为 `Halo`。 [halo-dev/console#426](https://github.com/halo-dev/console/pull/426) [**@ruibaby**](https://github.com/ruibaby)
    
-   默认后台布局改为左侧菜单布局。 [halo-dev/console#441](https://github.com/halo-dev/console/pull/441) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构文章/自定义页面编辑逻辑，改为保存前端渲染内容，放弃后端渲染。 [halo-dev/console#439](https://github.com/halo-dev/console/pull/439) [halo-dev/console#440](https://github.com/halo-dev/console/pull/440) [halo-dev/console#449](https://github.com/halo-dev/console/pull/449) [#1668](https://github.com/halo-dev/halo/pull/1668) [**@ruibaby**](https://github.com/ruibaby) [**@guqing**](https://github.com/guqing)
    
-   Content API 的评论列表接口不再返回 `ipAddress` 和 `email` 字段。 [#1729](https://github.com/halo-dev/halo/pull/1729) [**@guqing**](https://github.com/guqing)
    

### 新特性

-   Content API 添加获取所有图库图片分组的接口（PhotoController#listTeams）。 [#1515](https://github.com/halo-dev/halo/pull/1515) [**@fuzui**](https://github.com/fuzui)
    
-   Content API 添加根据 `themeId` 获取主题详情和设置的接口。 [#1660](https://github.com/halo-dev/halo/pull/1660) [**@guqing**](https://github.com/guqing)
    
-   图库支持点赞。 [#1537](https://github.com/halo-dev/halo/pull/1537) [**@guqing**](https://github.com/guqing)
    
-   文章标签支持设置颜色。 [#1566](https://github.com/halo-dev/halo/pull/1566) [halo-dev/console#395](https://github.com/halo-dev/console/pull/395) [**@ruibaby**](https://github.com/ruibaby) [**@guqing**](https://github.com/guqing)
    
-   重构后台文章分类管理，支持排序。 [#1650](https://github.com/halo-dev/halo/pull/1650) [#1657](https://github.com/halo-dev/halo/pull/1657) [halo-dev/console#435](https://github.com/halo-dev/console/pull/435) [**@lan-yonghui**](https://github.com/lan-yonghui) [**@ruibaby**](https://github.com/ruibaby) [**@guqing**](https://github.com/guqing)
    
-   文章设置界面支持重新生成别名。 [halo-dev/console#368](https://github.com/halo-dev/console/pull/368) [**@ruibaby**](https://github.com/ruibaby)
    
-   Admin API 提供批量删除图库图片的接口。 [#1680](https://github.com/halo-dev/halo/pull/1680) [**@ruibaby**](https://github.com/ruibaby)
    
-   Admin API 提供批量更新图库图片的接口。 [#1679](https://github.com/halo-dev/halo/pull/1679) [**@ruibaby**](https://github.com/ruibaby)
    
-   后台评论管理提供日志评论管理的界面。 [halo-dev/console#480](https://github.com/halo-dev/console/pull/480) [**@ruibaby**](https://github.com/ruibaby)
    
-   后台菜单分组支持修改分组名。 [halo-dev/console#499](https://github.com/halo-dev/console/pull/499) [**@ruibaby**](https://github.com/ruibaby)
    
-   后台个人资料头像修改支持输入链接。 [halo-dev/console#505](https://github.com/halo-dev/console/pull/505) [**@ruibaby**](https://github.com/ruibaby)
    
-   后台待审核评论弹框点击评论支持进入评论管理。 [halo-dev/console#517](https://github.com/halo-dev/console/pull/517) [**@ruibaby**](https://github.com/ruibaby)
    
-   支持配置 Redis 缓存。 [#1751](https://github.com/halo-dev/halo/pull/1751) [**@luoxmc**](https://github.com/luoxmc) [**@guqing**](https://github.com/guqing)
    

### 功能优化

-   更新 Logo。 [halo-dev/console#366](https://github.com/halo-dev/console/pull/366) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构附件上传的文件命名逻辑，文件作为第一次上传的时候文件名不添加随机字符串。 [#1500](https://github.com/halo-dev/halo/pull/1500) [**@guqing**](https://github.com/guqing)
    
-   优化后台编辑文章时的预览体验，预览文章或临时保存内容不会修改已经发布的内容。 [#1617](https://github.com/halo-dev/halo/pull/1617) [halo-dev/console#439](https://github.com/halo-dev/console/pull/439) [**@guqing**](https://github.com/guqing) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构后台主题设置界面，提供单独的设置页面，支持展示主题的相关信息。 [halo-dev/console#380](https://github.com/halo-dev/console/pull/380) [**@ruibaby**](https://github.com/ruibaby)
    
-   弱化后台登录页面的动画效果。 [halo-dev/console#369](https://github.com/halo-dev/console/pull/369) [**@ruibaby**](https://github.com/ruibaby)
    
-   优化后台附件管理列表预览图片样式。 [halo-dev/console#374](https://github.com/halo-dev/console/pull/374) [halo-dev/console#382](https://github.com/halo-dev/console/pull/382) @623337308 [**@cetr**](https://github.com/cetr)
    
-   重构后台附件详情界面，取消原有抽屉的设计，改为弹窗。 [halo-dev/console#375](https://github.com/halo-dev/console/pull/375) [halo-dev/console#381](https://github.com/halo-dev/console/pull/381) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构后台文章/自定义页面设置界面，取消原有抽屉的设计，改为弹窗。 [halo-dev/console#376](https://github.com/halo-dev/console/pull/376) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构后台操作日志列表界面，取消原有抽屉的设计，提供单独的页面。 [halo-dev/console#419](https://github.com/halo-dev/console/pull/419) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构后台图片选择弹框组件，支持直接插入到编辑器，支持多选。 [halo-dev/console#420](https://github.com/halo-dev/console/pull/420) [halo-dev/console#421](https://github.com/halo-dev/console/pull/421) [**@ruibaby**](https://github.com/ruibaby)
    
-   后台文章设置选择标签列表改为根据名称排序。 [halo-dev/console#429](https://github.com/halo-dev/console/pull/429) [**@ruibaby**](https://github.com/ruibaby)
    
-   优化后台附件管理中批量操作附件的逻辑。 [halo-dev/console#431](https://github.com/halo-dev/console/pull/431) [**@ruibaby**](https://github.com/ruibaby)
    
-   后台使用重构版本的编辑器，编辑区域支持高亮语法，优化数学公式和图表等渲染，优化表格的编辑体验。 [halo-dev/console#447](https://github.com/halo-dev/console/pull/447) [**@ruibaby**](https://github.com/ruibaby)
    
-   优化文章加密和分类加密的逻辑。 [#1678](https://github.com/halo-dev/halo/pull/1678) [**@guqing**](https://github.com/guqing)
    
-   优化后台登录页面样式。 [halo-dev/console#456](https://github.com/halo-dev/console/pull/456) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构后台文章评论列表弹窗。 [halo-dev/console#463](https://github.com/halo-dev/console/pull/463) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构后台图库管理页面，支持批量操作图片以及批量从附件库添加图片。 [halo-dev/console#468](https://github.com/halo-dev/console/pull/468) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构后台文章管理页面，文章列表将不再展示回收站状态的文章，提供单独的回收站入口。 [halo-dev/console#475](https://github.com/halo-dev/console/pull/475) [**@ruibaby**](https://github.com/ruibaby)
    
-   优化后台文章/自定义页面设置的保存逻辑，提供转为发布/草稿的按钮。保存按钮不再影响到文章状态。 [halo-dev/console#476](https://github.com/halo-dev/console/pull/476) [**@ruibaby**](https://github.com/ruibaby)
    
-   优化后台折叠菜单的体验，解决折叠时 Logo 和 菜单动画不同步的问题。 [halo-dev/console#493](https://github.com/halo-dev/console/pull/493) [**@ruibaby**](https://github.com/ruibaby)
    
-   缓存后台折叠菜单的状态，刷新页面不再会恢复到初始状态。 [halo-dev/console#493](https://github.com/halo-dev/console/pull/493) [**@ruibaby**](https://github.com/ruibaby)
    
-   优化后台判断是否初始化的逻辑，修改为每次页面加载只请求一次，切换路由不再请求。 [halo-dev/console#495](https://github.com/halo-dev/console/pull/495) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构后台主题设置保存预览功能。 [halo-dev/console#502](https://github.com/halo-dev/console/pull/502) [**@ruibaby**](https://github.com/ruibaby)
    
-   重构日志发布功能，使用 Markdown 编辑器替换 textarea，并支持保存前端渲染的 Markdown 结果。 [#1739](https://github.com/halo-dev/halo/pull/1739) [halo-dev/console#506](https://github.com/halo-dev/console/pull/506) [**@guqing**](https://github.com/guqing) [**@ruibaby**](https://github.com/ruibaby)
    

### 问题修复

-   修复修改加密文章或分类时没有清除用户访问权限的问题。 [#1540](https://github.com/halo-dev/halo/pull/1540) [**@guqing**](https://github.com/guqing)
    
-   修复重置密码没有校验密码长度的问题。 [#1636](https://github.com/halo-dev/halo/pull/1636) [halo-dev/console#403](https://github.com/halo-dev/console/pull/403) [**@ruibaby**](https://github.com/ruibaby) [**@guqing**](https://github.com/guqing)
    
-   修复后台文章设置中无法仅选择父级分类的问题。 [halo-dev/console#367](https://github.com/halo-dev/console/pull/367) [**@ruibaby**](https://github.com/ruibaby)
    
-   修复后台菜单管理中移动菜单项到其他分组的时候，导致子菜单丢失的问题。 [halo-dev/console#422](https://github.com/halo-dev/console/pull/422) [**@ruibaby**](https://github.com/ruibaby)
    
-   更新默认主题的 submodule 提交，修复模板中部分因为数字中带逗号导致的渲染异常。 [#1682](https://github.com/halo-dev/halo/pull/1682) [**@ruibaby**](https://github.com/ruibaby)
    
-   修复评论默认头像因为修改了默认类型但 options 接口没有返回字段导致评论头像无法显示的问题。 [#1692](https://github.com/halo-dev/halo/pull/1692) [**@lan-yonghui**](https://github.com/lan-yonghui)
    
-   修复使用 leveldb 的情况下，解析错误而没有清空缓存导致无法正常使用系统的问题。 [#1695](https://github.com/halo-dev/halo/pull/1695) [**@guqing**](https://github.com/guqing)
    
-   修复后台在文章编辑页面切换左侧菜单收缩的时候出现的样式异常。 [halo-dev/console#465](https://github.com/halo-dev/console/pull/465) [**@ruibaby**](https://github.com/ruibaby)
    
-   修复当前版本如果为 `alpha` 版本，安装主题无法通过版本验证的问题。 [#1705](https://github.com/halo-dev/halo/pull/1705) [**@JohnNiang**](https://github.com/JohnNiang)
    
-   修复评论部分因为没有添加事务，导致批量删除评论等操作时报错的问题。 [#1716](https://github.com/halo-dev/halo/pull/1716) [**@guqing**](https://github.com/guqing)
    
-   修复后台点击后台 Halo Logo 进入开发者选项过快可能会导致计数为负的问题。 [halo-dev/console#492](https://github.com/halo-dev/console/pull/492) [**@ruibaby**](https://github.com/ruibaby)
    
-   修复后台附件列表分页之后，可能会导致无法正常更新图片 dom 导致图片显示为上一页图片的问题。 [halo-dev/console#496](https://github.com/halo-dev/console/pull/496) [**@ruibaby**](https://github.com/ruibaby)
    
-   修复后台分类/标签/友情链接修改表单切换修改对象之后没有清除表单验证的问题。 [halo-dev/console#501](https://github.com/halo-dev/console/pull/501) [halo-dev/console#503](https://github.com/halo-dev/console/pull/503) @Yorksh1re
    
-   修复当前版本如果为 `alpha` 版本，安装主题无法通过版本验证的问题。 [#1747](https://github.com/halo-dev/halo/pull/1747) [**@JohnNiang**](https://github.com/JohnNiang)
    

### 依赖更新

-   升级 Spring Boot 版本。 [#1635](https://github.com/halo-dev/halo/pull/1635) [#1677](https://github.com/halo-dev/halo/pull/1677) [**@ruibaby**](https://github.com/ruibaby) [**@JohnNiang**](https://github.com/JohnNiang)
    
-   升级 Gradle 版本到 7.4。 [#1697](https://github.com/halo-dev/halo/pull/1697) [**@guqing**](https://github.com/guqing)
    
-   `halo-dev/halo-admin` 常规依赖升级。 [halo-dev/console#453](https://github.com/halo-dev/console/pull/453) [halo-dev/console#513](https://github.com/halo-dev/console/pull/513) [**@ruibaby**](https://github.com/ruibaby)
    
-   `halo-dev/halo-admin` 修改用于切换后台样式的 less 依赖 CDN 为 unpkg。
    
-   后台更新 @halo-dev/editor 版本。 [halo-dev/console#507](https://github.com/halo-dev/console/pull/507) [**@ruibaby**](https://github.com/ruibaby)
    

* * *

[halo-dev/halo@v1.4.17…v1.5.0](https://github.com/halo-dev/halo/compare/v1.4.17...v1.5.0)

## 相关信息

-   GitHub Release：[https://github.com/halo-dev/halo/releases/tag/v1.5.0](https://github.com/halo-dev/halo/releases/tag/v1.5.0)
    
-   升级文档：[https://docs.halo.run/getting-started/upgrade](https://docs.halo.run/getting-started/upgrade)
    
-   论坛交流：[https://bbs.halo.run/d/2227-halo-150](https://bbs.halo.run/d/2227-halo-150)
