Skip to content

Commit

Permalink
i18n: init i18n config for auth
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jun 13, 2023
1 parent 81798a2 commit 392eb6b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
18 changes: 10 additions & 8 deletions plugins/auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ namespace AuthService {

export const Admin: Schema<Admin> = Schema.intersect([
Schema.object({
enabled: Schema.boolean().default(true).description('启用管理员账号。'),
enabled: Schema.boolean().default(true),
}),
Schema.union([
Schema.object({
enabled: Schema.const(true),
username: Schema.string().default('admin').description('管理员用户名。'),
password: Schema.string().role('secret').required().description('管理员密码。'),
username: Schema.string().default('admin'),
password: Schema.string().role('secret').required(),
}),
Schema.object({}),
]),
Expand All @@ -300,12 +300,14 @@ namespace AuthService {
export const Config: Schema<Config> = Schema.intersect([
Schema.object({
admin: Admin,
}).description('管理员设置'),
}),
Schema.object({
authTokenExpire: Schema.natural().role('ms').default(Time.week).min(Time.hour).description('用户令牌有效期。'),
loginTokenExpire: Schema.natural().role('ms').default(Time.minute * 10).min(Time.minute).description('登录令牌有效期。'),
}).description('高级设置'),
])
authTokenExpire: Schema.natural().role('ms').default(Time.week).min(Time.hour),
loginTokenExpire: Schema.natural().role('ms').default(Time.minute * 10).min(Time.minute),
}),
]).i18n({
'zh-CN': require('./locales/zh-CN'),
})
}

export default AuthService
8 changes: 8 additions & 0 deletions plugins/auth/src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- $description: 管理员设置
admin:
enabled: 启用管理员账号。
username: 管理员用户名。
password: 管理员密码。
- $description: 高级设置
authTokenExpire: 用户令牌有效期。
loginTokenExpire: 登录令牌有效期。

0 comments on commit 392eb6b

Please sign in to comment.