mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 09:36:08 +08:00
setting: 优化默认值插入
This commit is contained in:
1 parent
06ff754af3
commit
f3be3fc787
3 files changed
+8
-9
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.13.26",
|
||||
"version": "2.13.27",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -55,4 +55,4 @@
|
||||
"build": "tsc",
|
||||
"build:watch": "tsc --watch"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,9 +128,9 @@ SystemSetting(
|
||||
Setting('setting_smtp', 'smtp.secure', null, false, 'boolean', 'SSL'),
|
||||
Setting('setting_server', 'server.name', null, 'Hydro', 'text', 'Server Name'),
|
||||
Setting('setting_server', 'server.worker', null, 1, 'number', 'Server Workers Number'),
|
||||
Setting('setting_server', 'server.hostname', null, null, 'text', 'Server Hostname'),
|
||||
Setting('setting_server', 'server.host', null, null, 'text', 'Server Host'),
|
||||
Setting('setting_server', 'server.url', null, null, 'text', 'Server BaseURL'),
|
||||
Setting('setting_server', 'server.hostname', null, 'oj.undefined.moe', 'text', 'Server Hostname'),
|
||||
Setting('setting_server', 'server.host', null, 'oj.undefined.moe', 'text', 'Server Host'),
|
||||
Setting('setting_server', 'server.url', null, '/', 'text', 'Server BaseURL'),
|
||||
Setting('setting_server', 'server.cdn', null, '/', 'text', 'CDN Prefix', 'Ends with /'),
|
||||
Setting('setting_server', 'server.port', null, 8888, 'number', 'Server Port'),
|
||||
Setting('setting_server', 'server.xff', null, null, 'text', 'IP Header', 'e.g. x-forwarded-for (lowercase)'),
|
||||
@@ -146,9 +146,8 @@ bus.once('app/started', async () => {
|
||||
logger.debug('Ensuring settings');
|
||||
for (const setting of SYSTEM_SETTINGS) {
|
||||
if (setting.value) {
|
||||
// @ts-ignore
|
||||
const current = await global.Hydro.model.system.get(setting.key);
|
||||
if (current === null || current === '') {
|
||||
const current = await global.Hydro.service.db.collection('system').findOne({ _id: setting.key });
|
||||
if (!current || current.value == null || current.value === '') {
|
||||
// @ts-ignore
|
||||
await global.Hydro.model.system.set(setting.key, setting.value);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ export async function inc(_id: number, field: string, n = 1) {
|
||||
|
||||
export async function create(
|
||||
mail: string, uname: string, password: string,
|
||||
uid?: number, regip = '127.0.0.1', priv = PRIV.PRIV_DEFAULT,
|
||||
uid = 0, regip = '127.0.0.1', priv = PRIV.PRIV_DEFAULT,
|
||||
) {
|
||||
const salt = String.random();
|
||||
if (!uid) uid = await system.inc('user');
|
||||
|
||||
Reference in new issue
Block a user