Skip to content

refactor(core): 重构配置服务中的配置获取逻辑 #2421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions apps/core/src/modules/configs/configs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ export class ConfigsService {
return await this.getConfig()
}

const maxCount = 10
let curCount = 0
do {
let retryCount = 0
while (true) {
if (this.configInitd) {
return await this.getConfig()
}
await sleep(100)
curCount += 1
} while (curCount < maxCount)

throw `重试 ${curCount} 次获取配置失败, 请检查数据库连接`
retryCount++
if (retryCount % 10 === 0) {
throw `重试 ${retryCount} 次获取配置失败, 即将进行下一轮尝试`
}
await sleep(1500)
}
}

public get defaultConfig() {
Expand Down Expand Up @@ -191,7 +191,6 @@ export class ConfigsService {
if (!dto) {
throw new BadRequestException('设置不存在')
}

// 如果是评论设置,并且尝试启用 AI 审核,就检查 AI 配置
if (key === 'commentOptions' && (value as any).aiReview === true) {
const aiConfig = await this.get('ai')
Expand All @@ -202,7 +201,6 @@ export class ConfigsService {
)
}
}

const instanceValue = this.validWithDto(dto, value)

encryptObject(instanceValue)
Expand Down
14 changes: 7 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { sxzz } from '@sxzz/eslint-config'

export default sxzz(
{
prettier: true,
markdown: true,
vue: false, // auto detection
unocss: false, // auto detection
},
[
{
ignores: [
Expand Down Expand Up @@ -81,10 +87,4 @@ export default sxzz(
},
},
],
{
prettier: true,
markdown: true,
vue: false, // auto detection
unocss: false, // auto detection
},
)
)
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
},
"devDependencies": {
"@innei/prettier": "0.15.0",
"@sxzz/eslint-config": "6.1.1",
"@sxzz/eslint-config": "6.2.0",
"@types/node": "22.14.0",
"cross-env": "7.0.3",
"eslint": "^9.24.0",
"eslint": "^9.25.1",
"lint-staged": "15.5.0",
"prettier": "3.5.3",
"rimraf": "6.0.1",
"simple-git-hooks": "2.12.1",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0",
"tsup": "8.4.0",
"typescript": "5.8.3",
"typescript": "5.7.3",
"vite-tsconfig-paths": "5.1.4"
},
"simple-git-hooks": {
Expand Down
Loading
Loading