Skip to content

Commit

Permalink
Merge pull request #679 from wu-yafeng/main
Browse files Browse the repository at this point in the history
fix #678
  • Loading branch information
MliKiowa authored Dec 31, 2024
2 parents 15cae6b + 42cee0d commit 6be6023
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/webui/src/helper/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class WebUiConfigWrapper {
try {
const configPath = resolve(webUiPathWrapper.configPath, './webui.json');

if (!await fs.access(configPath, constants.R_OK).then(() => true).catch(() => false)) {
if (!await fs.access(configPath, constants.F_OK).then(() => true).catch(() => false)) {
await fs.writeFile(configPath, JSON.stringify(defaultconfig, null, 4));
}

Expand All @@ -101,7 +101,12 @@ export class WebUiConfigWrapper {
if (!parsedConfig.prefix.startsWith('/')) parsedConfig.prefix = '/' + parsedConfig.prefix;
if (parsedConfig.prefix.endsWith('/')) parsedConfig.prefix = parsedConfig.prefix.slice(0, -1);
// 配置已经被操作过了,还是回写一下吧,不然新配置不会出现在配置文件里
await fs.writeFile(configPath, JSON.stringify(parsedConfig, null, 4));
if (await fs.access(configPath, constants.W_OK).then(() => true).catch(() => false)) {
await fs.writeFile(configPath, JSON.stringify(parsedConfig, null, 4));
}
else {
console.warn(`文件: ${configPath} 没有写入权限, 配置的更改部分可能会在重启后还原.`);
}
// 不希望回写的配置放后面

// 查询主机地址是否可用
Expand Down

0 comments on commit 6be6023

Please sign in to comment.