Fix the problem of not being able to setup in OS without UTF-8 as default encoding (#7379)

#### What type of PR is this?

/kind bug

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

This PR manually set UTF-8 charset while loading YAML file to fix the problem "java.nio.charset.MalformedInputException: Input length = 1".

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

Fixes https://github.com/halo-dev/halo/issues/6937
Fixes https://github.com/orgs/halo-dev/discussions/7375

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

```release-note
修复 Windows 下可能无法正常初始化的问题
```
pull/7386/head
FoxInField 2025-04-23 17:23:10 +08:00 committed by GitHub
parent ed50a0224d
commit c2819f1f5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -289,7 +289,8 @@ public class SystemSetupEndpoint {
var processedContent = var processedContent =
PROPERTY_PLACEHOLDER_HELPER.replacePlaceholders(rawContent, properties); PROPERTY_PLACEHOLDER_HELPER.replacePlaceholders(rawContent, properties);
// load yaml to unstructured // load yaml to unstructured
var stringResource = new InMemoryResource(processedContent); var stringResource =
new InMemoryResource(processedContent.getBytes(StandardCharsets.UTF_8));
var loader = new YamlUnstructuredLoader(stringResource); var loader = new YamlUnstructuredLoader(stringResource);
return loader.load(); return loader.load();
}) })