Commit Graph

4114 Commits (4ce5d0c2cfa05b310ea4de59636c5de392692525)

Author SHA1 Message Date
Ryan Wang 6e21f559e5 fix: show publish time instead of creation time for post list (halo-dev/console#676) 2022-11-01 18:00:42 +08:00
Ryan Wang 5605759e49
perf: use the new formkit custom input for system setting forms schema (#2646)
#### What type of PR is this?

/kind improvement
/milestone 2.0
/area core

#### What this PR does / why we need it:

更新系统设置的表单定义,为 Logo / Favicon 使用新的选择附件输入框,为代码注入部分设置使用新的代码编辑器输入框。

#### Which issue(s) this PR fixes:

Ref https://github.com/halo-dev/halo/issues/2558

#### Special notes for your reviewer:

/hold

请等待以下 PR 合并:

- https://github.com/halo-dev/console/pull/674
- https://github.com/halo-dev/console/pull/672
- https://github.com/halo-dev/console/pull/675

测试方式:

1. Console 需要使用最新的 main 分支。
2. 测试系统设置中的 Logo / Favicon 和代码注入部分的设置项是否正常使用。

#### Does this PR introduce a user-facing change?

```release-note
更新系统设置的表单定义,提供更便捷的代码和附件选择输入框。
```
2022-11-01 06:36:16 +00:00
Ryan Wang 25f47bf598 feat: add preset language support for codemirror components (halo-dev/console#675)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

为 Codemirror 组件添加更多预设语言支持,以及支持从外部传入语言包。

目前预设支持:

1. yaml
2. html
3. javascript
4. css
5. json

使用方式:

1. 使用预设

```vue
<script lang="ts" setup>
import { VCodemirror } from "@halo-dev/components"
</script>

<template>
    <VCodemirror language="html" />
</template>
```

2. 外部引入

```bash
pnpm install @codemirror/lang-java
```

```vue
<script lang="ts" setup>
import { VCodemirror } from "@halo-dev/components"
import { java } from "@codemirror/lang-java"
</script>

<template>
    <VCodemirror :language="java()" />
</template>
```

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-11-01 06:18:16 +00:00
Ryan Wang 9a24604a6b feat: add formkit custom input of attachment (halo-dev/console#674)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

添加选择附件类型的 FormKit 输入框。

在 Vue 单组件中使用:

```vue
<script lang="ts" setup>
const logo = ref("")
</script>

<template>
  <FormKit
    v-model="logo"
    label="Logo"
    type="attachment"
    validation="required"
  />
</template>
```

在 FormKit Schema 中使用(插件 / 主题设置表单定义):

```yaml
- $formkit: attachment
  name: logo
  label: Logo
```


#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2558

#### Screenshots:

<img width="671" alt="image" src="https://user-images.githubusercontent.com/21301288/198980581-ba90ec32-f205-4d03-8546-3c93238298e7.png">


#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

#### Does this PR introduce a user-facing change?

```release-note
添加选择附件类型的 FormKit 输入框。
```
2022-11-01 03:06:18 +00:00
Ryan Wang f77be1ecb7 feat: add formkit custom input of codemirror (halo-dev/console#672)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

添加 Codemirror 类型的 FormKit 输入框。

在 Vue 单组件中使用:

```vue
<script lang="ts" setup>
const code = ref("")
</script>

<template>
  <FormKit
    v-model="code"
    label="页脚代码"
    type="code"
    validation="required"
  />
</template>
```

在 FormKit Schema 中使用(插件 / 主题设置表单定义):

```yaml
- $formkit: code
  name: code
  label: 页脚代码
```

#### Screenshots:

<img width="1331" alt="image" src="https://user-images.githubusercontent.com/21301288/198954003-02ce1972-8f7f-4959-a349-5650d166f3ae.png">

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

#### Does this PR introduce a user-facing change?


```release-note
添加 Codemirror 类型的 FormKit 输入框。
```
2022-11-01 02:56:16 +00:00
Ryan Wang ea3620f2c5 perf: improve the layout and style of forms (halo-dev/console#673)
Change form style from horizontal to vertical.
2022-10-31 16:01:28 +08:00
guqing b63131c36e
feat: support obtaining the previous post and next post according to post name (#2636)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.0

#### What this PR does / why we need it:
支持通过文章名称获取上一篇和下一篇文章数据

本 PR 通过实现一个固定大小的滑动窗口数据结构来通过传入的文章名称获取上一篇和下一篇文章
例如当具有一系列文章名为 [a, b, c, d, e, f, g]
查询文章名为 d 的文章的上一篇和下一篇则使用一个固定大小为 3 的滑动窗口, 示意图如下
<img width="526" alt="image" src="https://user-images.githubusercontent.com/38999863/198243133-20f77431-1107-4526-9f4f-6a11c68204e7.png">
通过窗口右移来调整当窗口圈住所需元素 D 时且 元素 D 的位置不是窗口的最后一个元素时得到一个想要的窗口
此时:
1. 如果 D 位于 window 中的第一个元素则 D 没有上一篇
2. 如果 D 位于 window 中间则 window 的第一个元素为 D 的上一篇,最后一个元素为下一篇
3. 如果 D 位于 window 的最后一个位置,则 D 没有下一篇
#### Which issue(s) this PR fixes:

Fixes #2635

#### Special notes for your reviewer:
how to test it?
1. 创建几篇文章然后发布
4. 能通过 `${postFinder.cursor(your-post-name)}` 来获取到带有上一页下一页的文章数据
5. 当文章处于第一条时没有上一页,当文章处于最后一页时没有下一页(可以通过`${postCursor.hasPrevious()}` 和 `${postCursor.hasNext()}` 判断按钮是否展示)

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
支持通过文章名称获取上一篇和下一篇文章数据
```
2022-10-31 07:44:16 +00:00
John Niang 8b038c1e0a
Update README.md due to 2.0.0-alpha.3 released (#2634)
#### What type of PR is this?

/kind documentation

#### What this PR does / why we need it:

Bump image tag in docker command.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 09:36:09 +00:00
Ryan Wang b11ca066b0 chore: release 2.0.0-alpha.3 (halo-dev/console#669)
#### What type of PR is this?

/milestone 2.0

#### What this PR does / why we need it:

发布 2.0.0-alpha.3

从此版本开始,`@halo-dev/console-shared` 包的版本与 Console 始终保持一致。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 07:48:10 +00:00
Ryan Wang 3d293a5a46 fix: logo cannot be displayed after the build (halo-dev/console#668)
#### What type of PR is this?

/kind bug
/milestone 2.0

#### What this PR does / why we need it:

修复在 `vite build` 之后无法加载 Logo 的问题。

#### Special notes for your reviewer:

测试方式:

1. `pnpm build`
2. `pnpm preview`
3. 检查登录页面的 Logo 是否正常加载。

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 07:36:10 +00:00
Ryan Wang d7159eb9d3 chore: bump dependencies (halo-dev/console#667)
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

依赖升级。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 07:32:13 +00:00
guqing 84617c3e96
refactor: ignore trailing separator for permalink router (#2632)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
#### What this PR does / why we need it:
permalink 路由匹配时自动忽略末尾分隔符
例如
/archives  匹配到 /archives
/archives/ 匹配到 /archives

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 07:24:10 +00:00
guqing fa3e0c44f4
refactor: use LinkedHashMultimap to replace MultiValueMap (#2629)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
#### What this PR does / why we need it:
ReverseProxyRouterFunctionRegistry 的注册方法之前使用了一个 LinkedMultiValueMap<String, String>,相当于是一个 Map<String, List<String>>,当插件启动后扫描到 ReverseProxy 资源保存到数据库会触发 ReverseProxyReconciler 调用`ReverseProxyRouterFunctionRegistry#register`,如果此时插件的 PluginApplicationContext 还没有被创建好,register 时会在中途因为获取不到 PluginApplicationContext 而失败然后 requeue,而 LinkedMultiValueMap 此时已经保存了一条记录 requeue后再执行 LinkedMultiValueMap(即`Map<String, List<String>>`) 这个 value 是一个 List 需要更多的判断来防止重复,需要用一个 Map<String, Set<String>>这样的结构来保证 requeue 时 ReverseProxyRouterFunctionRegistry 中集合结构之前的数据一致性这样更方便,所以将从 spring 的 LinkedMultiValueMap 切换到  guava 提供的 LinkedHashMultimap(它的结构是Map<K, Set<V>)

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 05:00:11 +00:00
Ryan Wang 6272e8e710 refactor: upload component changed from filepond to uppy (halo-dev/console#666)
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

使用 [uppy](https://github.com/transloadit/uppy) 代替原来的 [filepond](https://github.com/pqina/filepond)。

#### Screenshots:

<img width="1665" alt="image" src="https://user-images.githubusercontent.com/21301288/197812049-44dba688-673a-4636-9ec0-0acba6d9d68b.png">


#### Special notes for your reviewer:

测试方式:

1. Console 需要 `pnpm install`
2. 测试附件上传、主题/插件的安装和更新。

#### Does this PR introduce a user-facing change?

```release-note
使用 [uppy](https://github.com/transloadit/uppy) 代替原来的 [filepond](https://github.com/pqina/filepond)。
```
2022-10-26 04:40:10 +00:00
John Niang ee032f8cb9
Bump jasync-r2dbc-mysql to 2.1.7 (#2631)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:

Please refer to <https://github.com/jasync-sql/jasync-sql/releases/tag/2.1.7>.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 04:24:09 +00:00
John Niang 403f1bd7b2
Bump SpringDoc to 2.0.0-RC1 (#2628)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:

Please refer to <https://github.com/springdoc/springdoc-openapi/releases/tag/v2.0.0-RC1>.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 04:22:14 +00:00
Ryan Wang 03aeb707f6
chore: disable thymeleaf cache in dev profile (#2630)
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

在 dev 的配置文件中禁用 Thymeleaf 的模板缓存。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo 

#### Does this PR introduce a user-facing change?

```release-note
在 dev 的配置文件中禁用 Thymeleaf 的模板缓存。
```
2022-10-26 04:20:09 +00:00
John Niang d9cb6bf732
Provide an endpoint to upgrade plugin (#2624)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

#### What this PR does / why we need it:

Provide an endpoint to upgrade plugin by uploading a new jar file.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2551

#### Special notes for your reviewer:

1. Install an old plugin
2. Update the plugin and package again
3. Upgrade the plugin and see the result

#### Does this PR introduce a user-facing change?

```release-note
提供插件更新功能
```
2022-10-26 04:02:10 +00:00
Ryan Wang a23c4318cc feat: add upgrade plugin support (halo-dev/console#663)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

支持插件升级,适配 https://github.com/halo-dev/halo/pull/2624

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2551

#### Screenshots:
<img width="1663" alt="image" src="https://user-images.githubusercontent.com/21301288/197682557-7e37895e-a6b5-43d6-8d40-2a1c899b9ce1.png">
<img width="1662" alt="image" src="https://user-images.githubusercontent.com/21301288/197682572-4db39f09-efda-4928-9a6d-8593c7c0c790.png">


#### Special notes for your reviewer:

测试方式:

1. Halo 需要使用 https://github.com/halo-dev/halo/pull/2624 PR 的分支。
2. Console 需要 `pnpm install`
3. 修改已安装的插件,构建之后更新插件,检查是否更新成功。


#### Does this PR introduce a user-facing change?

```release-note
支持插件升级
```
2022-10-26 03:26:09 +00:00
guqing 3ec7e31cac
refactor: fill in the name of the rendered template as the template id to the view model (#2626)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
渲染模板页面时将被渲染的模板名称填充到试图模型中作为 templateId
为什么需要它:
1. thymeleaf 渲染模板可以使用 fragment,此时在 thymeleaf 的 IElementTagProcessor 等处理器中获取到的 template name不一定是例如 post.html这样的名称
2. 比如渲染文章模板 post.html 而 #2569 计划将要在 theme.yaml 中通过配置允许用户选择文章所渲染的模板,因为无法确定渲染模板的标志,例如有些处理器想在文章页插入 head 这样的需求就需要知道哪个模板是文章页。see also [issuecomment-1215135195](https://github.com/halo-dev/halo/issues/2322#issuecomment-1215135195)
所以目前想到的是通过在 render 时填充一个 templateId 到 view model 中标识模板身份
#### Which issue(s) this PR fixes:

Fixes #2621

#### Special notes for your reviewer:
how to test it?
见 issue #2621

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
修复设置了文章的 htmlMetas 字段但没有在页面的 head 注入标签的问题
```
2022-10-26 03:12:10 +00:00
Ryan Wang 4ca853e159 refactor: load the logo as an inline svg (halo-dev/console#664)
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

以 inline svg 的形式加载 Logo,解决因为加载 svg 文件导致的页面抖动问题。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:检查登录页面、初始化页面、侧边菜单顶部的 Logo 是否加载正常。

#### Does this PR introduce a user-facing change?

```release-note
以 inline svg 的形式加载 Logo,解决因为加载 svg 文件导致的页面抖动问题。
```
2022-10-26 03:10:14 +00:00
guqing 7c3fc3ac02
refactor: plugin reconciler to fix entry path when optimistic lock occurred (#2625)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
#### What this PR does / why we need it:
重构 PluginReconciler,避免因为每一段逻辑的执行时间太长而增加乐观锁错误的发生概率
修复判断逻辑问题导致启动时因为发生乐关锁错误造成没有填充 entry 和 stylesheet 字段的问题
#### Which issue(s) this PR fixes:
Fixes #2616

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-26 03:10:13 +00:00
guqing 160dd909cc
feat: provides the route of the post archive page for theme-side (#2598)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.0

#### What this PR does / why we need it:
提供文章归档页

#### Which issue(s) this PR fixes:

Fixes #2548

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
为主题提供文章归档页
```
2022-10-25 07:46:12 +00:00
Ryan Wang 95f0809042
fix: issue of abnormal sorting in the aggregation query interface (#2623)
#### What type of PR is this?

/kind bug
/milestone 2.0

#### What this PR does / why we need it:

修复文章、自定义页面、评论聚合查询接口排序不固定的问题。

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2622

#### Special notes for your reviewer:

测试方式:检查 Console 端的文章、自定义页面、评论、回复的排序是否正常,需要多次刷新检查。

```release-note
修复文章、自定义页面、评论聚合查询接口排序不固定的问题。
```
2022-10-25 06:24:11 +00:00
John Niang d2aa707071
Bump Spring Boot to 3.0.0-RC1 (#2620)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:

- See https://github.com/spring-projects/spring-boot/releases/tag/v3.0.0-RC1 for more.
- Due to [Default to Xor CSRF protection](https://github.com/spring-projects/spring-security/issues/11960), we have to implement a XOR algorithm in console project to generate a XORed token. Please be aware of source code of Spring Security at [here](9cb668aec2/web/src/main/java/org/springframework/security/web/server/csrf/XorServerCsrfTokenRequestAttributeHandler.java (L94-L115)), @halo-dev/sig-halo-console 

#### Special notes for reviewers

We have removed `ThemeJava8TimeDialect` due to removal of `thymeleaf-extras-java8time` module in https://github.com/thymeleaf/thymeleaf/issues/912

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-25 02:56:11 +00:00
guqing 0a46ec8123
refactor: files were not deleted when the plugin was uninstalled (#2613)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
#### What this PR does / why we need it:
修复插件卸载时没有连同删除插件 JAR 文件的问题
#### Which issue(s) this PR fixes:

Fixes #2552

#### Special notes for your reviewer:
how to test it?
1. 以 deployment 模式安装一个插件
2. 插件的名称在插件目录是以 {pluginName}-{version}.jar 的方式命名的
3. 卸载插件时会连同删除插件的 JAR 文件
4. 开发模式下不会删除插件文件

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
修复插件卸载时没有连同删除插件 JAR 文件的问题
```
2022-10-25 02:42:11 +00:00
Ryan Wang 2e60eaee00 feat: automatically refresh the list when it has data that is being deleted (halo-dev/console#661)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

优化部分数据列表的逻辑,支持在检测出有正在删除的数据时,自动定时刷新列表。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:

1. 进入任意一个数据列表,比如文章。
2. 删除一个文章,观察是否有自动刷新列表。
3. 切换路由,检查自动刷新是否停止。

#### Does this PR introduce a user-facing change?

```release-note
优化部分数据列表的逻辑,支持在检测出有正在删除的数据时,自动定时刷新列表。
```
2022-10-24 14:10:10 +00:00
Ryan Wang 9d91adc590 typo: fix some typos about attachment and editor components (halo-dev/console#662)
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

修正关于 Attachment 组件和编辑器组件的参数错别字。

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-24 13:34:10 +00:00
Ryan Wang c9d7ba7f85 feat: add preview theme support (halo-dev/console#660)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

Ref https://github.com/halo-dev/halo/pull/2280

支持在 Console 预览主题。

#### Screenshots:

<img width="1920" alt="image" src="https://user-images.githubusercontent.com/21301288/197442483-e89b8c3c-441e-4668-9840-96fe741a1f95.png">


#### Special notes for your reviewer:

测试方式:进入主题管理,打开已安装主题列表,在每一项的更多按钮即可看到预览主题的按钮。

#### Does this PR introduce a user-facing change?

```release-note
支持在 Console 预览主题。
```
2022-10-24 10:54:10 +00:00
Ryan Wang f4bb13fe8b docs: update repobeats analytics images source for readme file (halo-dev/console#659)
#### What type of PR is this?

/kind documentation

#### What this PR does / why we need it:

更新 [Repobeats analytics](https://repobeats.axiom.co/) 的图片源,之前因为修改仓库名,导致 Repobeats analytics 的统计失效。

#### Does this PR introduce a user-facing change?

```release-note
None 
```
2022-10-24 08:04:11 +00:00
guqing 7b4dd59c58
refactor: cascade delete snapshots and comments when post or page deleted (#2601)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.0

#### What this PR does / why we need it:
当删除文章或自定义页面时级联删除内容快照和评论及计数器

see also #2602
#### Which issue(s) this PR fixes:

Fixes #2599

#### Special notes for your reviewer:
how to test it?
1. 新建一篇文章并创建一些评论(需要安装评论插件 [plugin-comment-widget](https://github.com/halo-sigs/plugin-comment-widget))
2. 逻辑删除文章时评论不会被删除,真实删除则会
3. 新建一个文章,再删除它,然后查询 snaphost 模型看关联文章的数据有没有被删除
4. 自定义页面同上
5. 删除文章或自定义页面时会删除对应的 Counter 记录(`GET /apis/metrics.halo.run/v1alpha1/counters`)

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
修复删除文章或自定义页面时没有级联删除内容快照和评论的问题
```
2022-10-24 07:44:10 +00:00
Ryan Wang 33b665788a chore: remove the step to run unit tests and typecheck before git commit (halo-dev/console#658)
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

移除在 Git Commit 之前运行单元测试和类型检查的步骤。因为目前 main 分支处于保护分支,无法直接推送代码。所以仅在 PR 中的 Action 来运行这两个步骤即可。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-24 03:22:10 +00:00
Ryan Wang eaf11a65b6 refactor: load the theme and plugin logos using the avatar component (halo-dev/console#657)
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

插件和主题管理的 Logo 改为使用 `Avatar` 组件。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:检查主题和插件相关的管理页面是否正常加载 Logo。

#### Does this PR introduce a user-facing change?

```release-note
插件和主题管理的 Logo 改为使用 `Avatar` 组件。
```
2022-10-24 03:20:12 +00:00
Ryan Wang 7a5d52effe feat: add a refresh button to the data list (halo-dev/console#656)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

为部分功能数据列表添加刷新按钮。

#### Screenshots:

<img width="1664" alt="image" src="https://user-images.githubusercontent.com/21301288/197397277-353befe4-8c43-4326-9ad5-64d2888dc4a3.png">

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:

1. 需要 `pnpm build:packages`
2. 测试点击刷新按钮是否可以正常请求接口。

#### Does this PR introduce a user-facing change?

```release-note
为部分功能数据列表添加刷新按钮。
```
2022-10-24 03:18:16 +00:00
Ryan Wang 82b1f3b2ea feat: add upgrade theme support (halo-dev/console#653)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

支持升级主题。适配 https://github.com/halo-dev/halo/pull/2600

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2550

#### Screenshots:

<img width="915" alt="image" src="https://user-images.githubusercontent.com/21301288/196875056-cb0fbb7d-1cfd-47c3-ae6a-5e76c642b51d.png">
<img width="915" alt="image" src="https://user-images.githubusercontent.com/21301288/196875083-39e3778c-4925-4cb9-befc-563f40c77d06.png">

#### Special notes for your reviewer:

测试方式:

1. Halo 需要切换到 https://github.com/halo-dev/halo/pull/2600
2. 需要 `pnpm install`
3. 测试更主题功能是否正常。

#### Does this PR introduce a user-facing change?

```release-note
支持升级主题。
```
2022-10-24 03:16:20 +00:00
Ryan Wang 05bf7134ef chore: bump packages version (halo-dev/console#654)
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

发布 `@halo-dev/components` `@halo-dev/console-shared` 版本。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

#### Does this PR introduce a user-facing change?


```release-note
None
```
2022-10-24 02:26:09 +00:00
John Niang d765c2c329
Use CopyOnWriteArrayList on SchemeManager (#2612)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0

#### What this PR does / why we need it:

Use CopyOnWriteArrayList on SchemeManager to prevent concurrent modification when link plugin is installed.

#### How to test?

1. Install link plugin
2. Restart Halo
3. Delete any extensions
4. Check the result

#### Does this PR introduce a user-facing change?

```release-note
修复数据一直处于删除中的错误
```
2022-10-21 03:18:11 +00:00
John Niang e93f028a25
Provide an endpoint to upgrade theme (#2600)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

#### What this PR does / why we need it:

This PR mainly provides an endpoint to upgrade theme.

Please see the request sample as follows:

```bash
curl -X 'POST' \
  'http://localhost:8090/apis/api.console.halo.run/v1alpha1/themes/theme-default/upgrade' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@theme-default-main.zip;type=application/x-zip-compressed'
```

We also can refer to API documentation:

![image](https://user-images.githubusercontent.com/16865714/196628148-09900fc2-85d9-49e5-9508-6b7f79df0537.png)

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2550

#### How to test?

1. Install any theme you want
2. Unzip the theme and change the content of theme installed just now
3. Zip the theme and try to upgrade it by requesting theme upgrade API

#### Does this PR introduce a user-facing change?

```release-note
提供主题更新功能
```
2022-10-21 02:16:12 +00:00
guqing 969c0d56f6
feat: add site stats finder for theme-side (#2604)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.0

#### What this PR does / why we need it:
提供主题端站点统计信息查询器
#### Which issue(s) this PR fixes:

Fixes #

#### Special notes for your reviewer:
how to test it?
在任意主题页面使用如下语法
```
<p th:text="${siteStatsFinder.getStats()}"></p>
```
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
提供主题端站点统计信息查询器
```
2022-10-20 14:34:23 +00:00
guqing 6b2aea9301
refactor: content permalink routing using radix tree (#2547)
#### What type of PR is this?
/area core
/milestone 2.0
/kind improvement

#### What this PR does / why we need it:
由于之前的实现方式在某些场景下遇到瓶颈,例如 permalink 含有中文或者 /{year}/{month}/{slug} 这样的 pattern 容易出现路由冲突,所以提出此 PR 以改进之前的路由方式:

[Radix tree wiki](https://en.wikipedia.org/wiki/Radix_tree)

本 PR 通过变种的 RadixTree 来作为存储 permalink 的数据结构有以下原因:
1. 内容模块的 permalink 都具有大部分相同的前缀,例如分类是 以 /categories 前缀开头,文章的 /{year}/{month}/ 前缀等,使用 RadixTree 前缀树来存储将更节约内存
2. 具有分页规则例如根据分类查询文章列表的路由,/categories/fake-slug/page/{page},需要 Router 在匹配时能支持动态参数
3. 最坏时间复杂度为 O(n)

当插入以下几个路由
```
/categories/default
/categories/hello
/archives/test
/about
/tags/halo
```
存储结构将如下(带 * 的表示它为实际 path 节点)
```
/ [indices=act, priority=6]
├── a [indices=rb, priority=3]
│   ├── rchives/test [value=archives-test, priority=1]*
│   └── bout [value=about, priority=1]*
├── categories/ [indices=dh, priority=2]
│   ├── default [value=categories-default, priority=1]*
│   └── hello [value=categories-hello, priority=1]*
└── tags/halo [value=tags-halo, priority=1]*
```
通过在 Node 添加 indices 字段来对应 children 的首字符,当查询时便可直接判断 key 的首字符选择对应下标的 children 进行深度查找(这得益于每个 node 都是与插入 key part 取最大公共字串,所以每个 node 的 indices 都不存在重复的字符。)
例如当查询 /categories/default 时
1. 首先将 `/categories/default` 与 root node 的 key `/` 取最长公共字串为 `/`,`/categories/default` 剩下的子串为 `categories/default` 首字符为 `c`, 通过获取 root node 的 `indices` 在 `indexOf('c')` 得到该进入哪个子分支
2. 如果 index 为 -1 则直接返回 null 表示不存在
3. 得到 index 为 1,则 node.getChildren(1), 得到 key 为 `categories` 的 node
4. 重复步骤1,取公共最长字串的剩余部分得到 `default`,获取该 node 的 indices 检查`default` 的首字符 是否存在:`indexOf('d')`,得到 index=0,取 node 的 children.get(0) 得到 key 为`default` 的 node,取最长公共字串没有剩余部分且当前node的 isReal(是否是一个 path) 为 true 查询结束得到结果

使用 indices 的改进 radix tree 的思路来自于 [julienschmidt/httprouter](https://github.com/julienschmidt/httprouter/blob/master/tree.go)

- [ ] 带参数的 node 节点和带统配符的 node 节点有待优化查询效率,尽量做到一次查询得到结果
#### Which issue(s) this PR fixes:

Fixes #2539 #2473

#### Special notes for your reviewer:
how to test it?
1. 创建文章、分类、标签、自定义页面等多条数据
2. 通过反复删除和创建来测试这些资源的 permalink 是否还能被访问到
3.  该 PR 已经支持 permalink 中带有中文和特殊字符

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
使用 RadixTree 的变种数据结构改进 permalink Router
```
2022-10-20 08:12:15 +00:00
Ryan Wang 97db382832 chore: bump @halo-dev/api-client for post stats (halo-dev/console#652)
#### What type of PR is this?

/kind api-change
/kind bug

#### What this PR does / why we need it:

更新 `@halo-dev/api-client` 以修复文章访问数据不正确的问题。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

#### Does this PR introduce a user-facing change?

```release-note
更新 `@halo-dev/api-client` 以修复文章访问数据不正确的问题。
```
2022-10-20 06:30:14 +00:00
guqing ec7dc8445f
refactor: rename stats to dashboard stats (#2609)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
修改仪表盘统计返回类型的名称避类名相同时 swagger api 的 schema 被覆盖
#### Which issue(s) this PR fixes:

Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-20 03:54:13 +00:00
John Niang 0f9c73ac8e
Make field metadata.name of extension required (#2608)
#### What type of PR is this?

/kind improvement
/area core

#### What this PR does / why we need it:

Remove custom schema validation and make field metadata.name of extension required. So that the API client generated by `openapi-gen` will be more consistent than before.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-20 03:48:14 +00:00
Ryan Wang 67c4ebc782 refactor: router and menu generation (halo-dev/console#651)
#### What type of PR is this?

/kind api-change
/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

Ref https://github.com/halo-dev/halo/issues/2595

重构路由和侧边菜单生成的逻辑,**注意,此 PR 对插件的 Console 入口文件中的路由和菜单定义包含破坏性更新。**

1. 移除 `definePlugin` 方法的 `menus` 字段,改为在 route 的 meta 中定义。
2. 将 `RoutesMenu` 组件从 `@halo-dev/components` 包中移出。
3. 将 `BasicLayout` 组件从 `@halo-dev/console-shared` 包中移出。

定义路由的方式:

```ts
import { definePlugin } from "@halo-dev/console-shared";
import BasicLayout from "@/layouts/BasicLayout.vue";
import AttachmentList from "./AttachmentList.vue";
import AttachmentSelectorModal from "./components/AttachmentSelectorModal.vue";
import { IconFolder } from "@halo-dev/components";
import { markRaw } from "vue";

export default definePlugin({
  name: "attachmentModule",
  components: [AttachmentSelectorModal],
  routes: [
    {
      path: "/attachments",
      component: BasicLayout,
      children: [
        {
          path: "",
          name: "Attachments",
          component: AttachmentList,
          meta: {
            title: "附件",
            permissions: ["system:attachments:view"],
            menu: {
              name: "附件",
              group: "内容",
              icon: markRaw(IconFolder),
              priority: 4,
              mobile: true,
            },
          },
        },
      ],
    },
  ],
});
```

menu 字段类型:

```ts
interface RouteMeta {
  title?: string;
  searchable?: boolean;
  permissions?: string[];
  menu?: {
    name: string;
    group?: string;
    icon?: Component;
    priority: number;
    mobile?: true;
  };
}
```

插件适配需要做的改动:

1. 移除 `definePlugin` 中的 menus 字段。
2. 在需要添加到菜单的 route 中提供 `meta.menu` 对象,可参考上方的 menu 字段类型。

详细文档可查阅:https://github.com/ruibaby/halo-console/tree/refactor/route-map-setting/docs/routes-generation

todolist:

- [x] 完善预设的菜单分组定义。
- [x] 绑定权限,根据权限决定是否需要将路由添加到菜单。
- [x] 优化菜单排序的定义方式。

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2595

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:

1. 需要 `pnpm build:packages`
2. 测试后台的菜单及路由是否有异常。
3. 新建角色测试路由和菜单对权限的绑定。
4. 按照 https://github.com/ruibaby/halo-console/tree/refactor/route-map-setting/docs/routes-generation 文档,创建插件,测试插件添加路由和菜单是否正常。

#### Does this PR introduce a user-facing change?

```release-note
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
guqing 9f1eafddc5
fix: list as tree in category finder (#2537)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.0

#### What this PR does / why we need it:
修复分类树查询
#### Which issue(s) this PR fixes:

Fixes #2532
#### Special notes for your reviewer:
how to test it?
1. 新建分类并,并拖动构建一个树形
2. 在主题端通过 `categoryFinder.listAsTree()` 查看结果是否正确

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
修复分类树状数据查询
```
2022-10-19 02:46:12 +00:00
Ryan Wang 97f0d99538 feat: add support for displaying and installing uninstalled themes (halo-dev/console#648)
#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

支持显示和安装**未安装**的主题,以方便主题开发的时候,创建主题资源。适配 https://github.com/halo-dev/halo/pull/2586

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2554

#### Screenshots:

<img width="1663" alt="image" src="https://user-images.githubusercontent.com/21301288/196148567-f43b1bf3-e745-4c1a-950d-65899c1ae73c.png">

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:

1. 需要 `pnpm install`
2. Halo 需要切换到 https://github.com/halo-dev/halo/pull/2586 PR 的分支。
3. 在本地的 `~/halo-dev/themes` 创建新的主题,需要包含 `themes.yaml`,或者将现有的主题直接下载到 `~/halo-dev/themes`
4. 检查后台主题管理的主题列表中是否显示了未安装的主题,以及测试是否可以安装成功。

#### Does this PR introduce a user-facing change?

```release-note
支持显示和安装未安装的主题,以方便主题开发的时候,创建主题资源。
```
2022-10-18 10:12:11 +00:00
John Niang 638ceac5a3
Bump version of SpringDoc to 2.0.0-M7 (#2593)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:

See https://github.com/springdoc/springdoc-openapi/releases/tag/v2.0.0-M7 for more.

![image](https://user-images.githubusercontent.com/16865714/196356805-ce028139-4e5f-48d7-ba63-d29cefb17683.png)


#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-18 10:12:11 +00:00
guqing 9d67ce60cc
refactor: theme list data conversion (#2592)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.0

#### What this PR does / why we need it:
修复主题列表数据类型转换问题
#### Which issue(s) this PR fixes:

Fixes #

#### Special notes for your reviewer:
how to test it?
访问如下 API 不报错即可
```
curl http://localhost:8090/apis/api.console.halo.run/v1alpha1/themes?uninstalled=false
```

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-18 06:34:09 +00:00
John Niang 299634b756
Enable generating metadata name using generateName (#2563)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

#### What this PR does / why we need it:

See https://github.com/halo-dev/halo/issues/2309 for more.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2309

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
新增 generateName 字段用于自动生成自定义模型名称
```
2022-10-18 06:24:10 +00:00
guqing 58e98f0fc8
feat: add an API to list uninstalled themes (#2586)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core
/kind api-change

#### What this PR does / why we need it:
新增 API 用于查询未安装的主题

#### Which issue(s) this PR fixes:

Fixes #2554

#### Special notes for your reviewer:
how to test it?
1. 安装几个主题
2. 直接解压几个主题到 work dir 的 themes 目录
3. 使用以下 endpoint 查询未安装的主题,期望获得所有未安装主题的 themes.yaml 信息
```
/apis/api.console.halo.run/v1alpha1/themes?uninstalled=true
```

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
支持扫描主题目录下未安装的主题
```
2022-10-18 04:30:09 +00:00