mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: change to ts & tsx
This commit is contained in:
1 parent
36cce6d1bd
commit
d10fec361c
29 files changed
+165
-221
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.39.18",
|
||||
"version": "2.39.19",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -47,7 +47,7 @@ export const ForbiddenError = Err('ForbiddenError', UserFacingError, 'ForbiddenE
|
||||
export const NotFoundError = Err('NotFoundError', UserFacingError, 'NotFoundError', 404);
|
||||
export const MethodNotAllowedError = Err('MethodNotAllowedError', UserFacingError, 'MethodNotAllowedError', 405);
|
||||
export const RemoteOnlineJudgeError = Err('RemoteOnlineJudgeError', UserFacingError, 'RemoteOnlineJudgeError', 500);
|
||||
export const SendMailError = Err('SendMailError', UserFacingError, 'Failed to send mail to {0}.', 500);
|
||||
export const SendMailError = Err('SendMailError', UserFacingError, 'Failed to send mail to {0}. (1)', 500);
|
||||
|
||||
export const AlreadyVotedError = Err('AlreadyVotedError', ForbiddenError, "You've already voted.");
|
||||
export const LoginError = Err('LoginError', ForbiddenError, 'Invalid password for user {0}.');
|
||||
|
||||
@@ -49,11 +49,6 @@ function set(key: string, value: any) {
|
||||
class SystemHandler extends Handler {
|
||||
async prepare() {
|
||||
this.checkPriv(PRIV.PRIV_EDIT_SYSTEM);
|
||||
this.response.body = {
|
||||
path: [
|
||||
['Hydro', 'homepage'],
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,12 +81,6 @@ class SystemCheckConnHandler extends ConnectionHandler {
|
||||
class SystemDashboardHandler extends SystemHandler {
|
||||
async get() {
|
||||
this.response.template = 'manage_dashboard.html';
|
||||
this.response.body.path.push(['manage_dashboard', null]);
|
||||
}
|
||||
|
||||
async postRestart() {
|
||||
// TODO handle restart
|
||||
this.back();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +88,6 @@ class SystemScriptHandler extends SystemHandler {
|
||||
async get() {
|
||||
this.response.template = 'manage_script.html';
|
||||
this.response.body.scripts = global.Hydro.script;
|
||||
this.response.body.path.push(['manage_script', null]);
|
||||
}
|
||||
|
||||
@param('id', Types.Name)
|
||||
@@ -147,7 +135,6 @@ class SystemScriptHandler extends SystemHandler {
|
||||
class SystemSettingHandler extends SystemHandler {
|
||||
async get() {
|
||||
this.response.template = 'manage_setting.html';
|
||||
this.response.body.path.push(['manage_setting', null]);
|
||||
this.response.body.current = {};
|
||||
this.response.body.settings = setting.SYSTEM_SETTINGS;
|
||||
for (const s of this.response.body.settings) {
|
||||
@@ -185,7 +172,6 @@ class SystemSettingHandler extends SystemHandler {
|
||||
class SystemUserImportHandler extends SystemHandler {
|
||||
async get() {
|
||||
this.response.body.users = [];
|
||||
this.response.body.path.push(['manage_user_import']);
|
||||
this.response.template = 'manage_user_import.html';
|
||||
}
|
||||
|
||||
@@ -232,7 +218,6 @@ class SystemUserImportHandler extends SystemHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.response.body.path.push(['manage_user_import']);
|
||||
this.response.body.users = udocs;
|
||||
this.response.body.messages = messages;
|
||||
}
|
||||
|
||||
@@ -13,35 +13,6 @@ import {
|
||||
} from '../service/server';
|
||||
import { sortFiles } from '../utils';
|
||||
|
||||
class CheckInHandler extends Handler {
|
||||
async prepare() {
|
||||
const { checkincnt, lastcheckin } = this.user;
|
||||
const today = new Date();
|
||||
today.setHours(0);
|
||||
today.setMinutes(0);
|
||||
today.setSeconds(0);
|
||||
today.setMilliseconds(0);
|
||||
if (lastcheckin === today.getTime()) throw new BadRequestError("You've already checked in today!");
|
||||
this.user.checkincnt++;
|
||||
this.user.lastcheckin = today.getTime();
|
||||
await Promise.all([
|
||||
user.setById(this.user._id, { checkincnt, lastcheckin }),
|
||||
user.inc(this.user._id, 'rpdelta', Math.round(Math.sqrt(checkincnt))),
|
||||
]);
|
||||
}
|
||||
|
||||
async get() {
|
||||
this.response.redirect = '/';
|
||||
}
|
||||
|
||||
async post() {
|
||||
this.response.body = {
|
||||
cnt: this.user.checkincnt,
|
||||
last: this.user.lastcheckin,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class SwitchLanguageHandler extends Handler {
|
||||
@param('lang', Types.Name)
|
||||
async get(domainId: string, lang: string) {
|
||||
@@ -132,7 +103,6 @@ export class FSDownloadHandler extends Handler {
|
||||
}
|
||||
|
||||
export async function apply() {
|
||||
Route('check_in', '/checkin', CheckInHandler, PRIV.PRIV_USER_PROFILE);
|
||||
Route('switch_language', '/language/:lang', SwitchLanguageHandler);
|
||||
Route('home_files', '/file', FilesHandler, PRIV.PRIV_CREATE_FILE);
|
||||
Route('fs_download', '/file/:uid/:filename', FSDownloadHandler);
|
||||
|
||||
@@ -677,6 +677,8 @@ declare global {
|
||||
addons: string[],
|
||||
}
|
||||
}
|
||||
var Hydro: HydroGlobal; // eslint-disable-line
|
||||
var addons: string[]; // eslint-disable-line
|
||||
}
|
||||
|
||||
declare module 'koa' {
|
||||
|
||||
@@ -33,7 +33,7 @@ export async function sendMail(to: string, subject: string, text: string, html:
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error(e);
|
||||
throw new SendMailError(to);
|
||||
throw new SendMailError(to, e.message);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -131,8 +131,6 @@ AccountSetting(
|
||||
'/components/profile/backgrounds/1.jpg', 'text', 'Profile Background Image',
|
||||
'Choose the background image in your profile page.'),
|
||||
Setting('setting_storage', 'unreadMsg', 0, 'number', 'Unread Message Count', null, FLAG_DISABLED | FLAG_HIDDEN),
|
||||
Setting('setting_storage', 'checkincnt', 0, 'number', 'Check In Counter', null, FLAG_DISABLED | FLAG_HIDDEN),
|
||||
Setting('setting_storage', 'lastcheckin', 0, 'number', 'Last checkin time', null, FLAG_DISABLED | FLAG_HIDDEN),
|
||||
Setting('setting_storage', 'badge', '', 'text', 'badge info', null, FLAG_DISABLED | FLAG_HIDDEN),
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user