Remove template engine after upgrading theme (#7057)

#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

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

This PR removes template engine instead of clearing cache of template engine after upgrading theme to resolve incomplete cache clear.

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

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

#### Special notes for your reviewer:

1. Try to install the theme `theme-earth 1.12.0`
2. Request index page and you will see the `上一页` which should be `下一页`
3. Try to upgrade to the theme `theme-earth 1.12.1`
4. Request index page and you should see the `下一页` directly. 

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

```release-note
修复升级主题后语言包未更新的问题
```
pull/7060/head
John Niang 2024-11-21 17:52:10 +08:00 committed by GitHub
parent 7cef55b51f
commit d75bb09267
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 7 deletions

View File

@ -5,7 +5,6 @@ import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties;
import org.springframework.stereotype.Component;
import org.springframework.util.ConcurrentLruCache;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.dialect.IDialect;
import org.thymeleaf.spring6.ISpringWebFluxTemplateEngine;
import org.thymeleaf.spring6.dialect.SpringStandardDialect;
@ -72,12 +71,7 @@ public class TemplateEngineManager {
public Mono<Void> clearCache(String themeName) {
return themeResolver.getThemeContext(themeName)
.doOnNext(themeContext -> {
CacheKey cacheKey = buildCacheKey(themeContext);
TemplateEngine templateEngine =
(TemplateEngine) engineCache.get(cacheKey);
templateEngine.clearTemplateCache();
})
.doOnNext(themeContext -> engineCache.remove(buildCacheKey(themeContext)))
.then();
}