mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
支持彩色编译信息输出
This commit is contained in:
1 parent
f293e1f59e
commit
d040b153a1
18 files changed
+130
-59
No files matched your search
+38
-15
@@ -10,6 +10,13 @@ for (const country of countries) {
|
||||
}
|
||||
const timezones = Array.from(tzs).sort().map((tz) => [tz, tz]);
|
||||
|
||||
const PREFERENCE_SETTINGS = [];
|
||||
const ACCOUNT_SETTINGS = [];
|
||||
const SYSTEM_SETTINGS = [];
|
||||
const SETTINGS = [];
|
||||
const SETTINGS_BY_KEY = {};
|
||||
const SYSTEM_SETTINGS_BY_KEY = {};
|
||||
|
||||
const Setting = (
|
||||
family, key, range = null,
|
||||
value = null, ui = 'text', name = '',
|
||||
@@ -18,7 +25,28 @@ const Setting = (
|
||||
family, key, range, value, ui, name, desc,
|
||||
});
|
||||
|
||||
const PREFERENCE_SETTINGS = [
|
||||
const PreferenceSetting = (...settings) => {
|
||||
for (const setting of settings) {
|
||||
PREFERENCE_SETTINGS.push(setting);
|
||||
SETTINGS.push(setting);
|
||||
SETTINGS_BY_KEY[setting.key] = setting;
|
||||
}
|
||||
};
|
||||
const AccountSetting = (...settings) => {
|
||||
for (const setting of settings) {
|
||||
ACCOUNT_SETTINGS.push(setting);
|
||||
SETTINGS.push(setting);
|
||||
SETTINGS_BY_KEY[setting.key] = setting;
|
||||
}
|
||||
};
|
||||
const SystemSetting = (...settings) => {
|
||||
for (const setting of settings) {
|
||||
SYSTEM_SETTINGS.push(setting);
|
||||
SYSTEM_SETTINGS_BY_KEY[setting.key] = setting;
|
||||
}
|
||||
};
|
||||
|
||||
PreferenceSetting(
|
||||
Setting('setting_display', 'viewLang', builtin.VIEW_LANGS.map((i) => [i.code, i.name]),
|
||||
options.default_locale, 'select', 'UI Language'),
|
||||
Setting('setting_display', 'timezone', timezones,
|
||||
@@ -28,9 +56,9 @@ const PREFERENCE_SETTINGS = [
|
||||
Setting('setting_usage', 'codeTemplate', null,
|
||||
null, 'textarea', 'Default Code Template',
|
||||
'If left blank, the built-in template of the corresponding language will be used.'),
|
||||
];
|
||||
);
|
||||
|
||||
const ACCOUNT_SETTINGS = [
|
||||
AccountSetting(
|
||||
Setting('setting_info', 'gravatar', null,
|
||||
null, 'text', 'Gravatar Email',
|
||||
'We use <a href="https://en.gravatar.com/" target="_blank">Gravatar</a> to present your avatar icon.'),
|
||||
@@ -43,14 +71,9 @@ const ACCOUNT_SETTINGS = [
|
||||
Setting('setting_customize', 'backgroundImage', null,
|
||||
'/components/background/profile/backgrounds/1.jpg', 'text', 'Profile Background Image',
|
||||
'Choose the background image in your profile page.'),
|
||||
];
|
||||
);
|
||||
|
||||
const SETTINGS = [...PREFERENCE_SETTINGS, ...ACCOUNT_SETTINGS];
|
||||
const SETTINGS_BY_KEY = {};
|
||||
|
||||
for (const setting of SETTINGS) SETTINGS_BY_KEY[setting.key] = setting;
|
||||
|
||||
const SYSTEM_SETTINGS = [
|
||||
SystemSetting(
|
||||
Setting('setting_basic', 'user.register', null, false, 'checkbox', 'Allow register'),
|
||||
Setting('setting_basic', 'user.create_domain', null, true, 'checkbox', 'Allow domain creation'),
|
||||
Setting('setting_smtp', 'smtp.user', null, null, 'text', 'SMTP Username'),
|
||||
@@ -59,6 +82,7 @@ const SYSTEM_SETTINGS = [
|
||||
Setting('setting_smtp', 'smtp.port', null, 465, 'number', 'SMTP Server Port'),
|
||||
Setting('setting_smtp', 'smtp.from', null, null, 'text', 'Mail From'),
|
||||
Setting('setting_smtp', 'smtp.secure', null, false, 'checkbox', 'SSL'),
|
||||
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'),
|
||||
@@ -70,14 +94,13 @@ const SYSTEM_SETTINGS = [
|
||||
Setting('setting_constant', 'SOLUTION_PER_PAGE', null, 20, 'number', 'Solutions per Page'),
|
||||
Setting('setting_constant', 'TRAINING_PER_PAGE', null, 10, 'number', 'Training per Page'),
|
||||
Setting('setting_constant', 'REPLY_PER_PAGE', null, 50, 'number', 'Reply per Page'),
|
||||
];
|
||||
|
||||
const SYSTEM_SETTINGS_BY_KEY = {};
|
||||
|
||||
for (const setting of SYSTEM_SETTINGS) SYSTEM_SETTINGS_BY_KEY[setting.key] = setting;
|
||||
);
|
||||
|
||||
global.Hydro.model.setting = module.exports = {
|
||||
Setting,
|
||||
PreferenceSetting,
|
||||
AccountSetting,
|
||||
SystemSetting,
|
||||
PREFERENCE_SETTINGS,
|
||||
ACCOUNT_SETTINGS,
|
||||
SETTINGS,
|
||||
|
||||
@@ -42,7 +42,6 @@ class USER {
|
||||
checkPassword(password) {
|
||||
const h = global.Hydro.lib[`hash.${this.hashType || 'hydro'}`];
|
||||
if (!h) throw new Error('Unknown hash method');
|
||||
console.log(h(password, this.salt(), this), this.hash());
|
||||
if (!(h(password, this.salt(), this) === this.hash())) {
|
||||
throw new LoginError(this.uname);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user