ui: change to ts & tsx

This commit is contained in:
undefined committed 2021-10-11 23:33:54 +08:00
1 parent 36cce6d1bd
commit d10fec361c
29 files changed
+165 -221

No files matched your search

-30
View File
@@ -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);