mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add welcome page
This commit is contained in:
1 parent
b17bc16d66
commit
8e9854b1f3
5 files changed
+100
-2
No files matched your search
@@ -30,6 +30,7 @@ import db from './service/db';
|
||||
import storage from './service/storage';
|
||||
import { Progress } from './ui';
|
||||
import { streamToBuffer } from './utils';
|
||||
import welcome from './welcome';
|
||||
|
||||
const logger = new Logger('upgrade');
|
||||
type UpgradeScript = void | (() => Promise<boolean | void>);
|
||||
@@ -41,6 +42,7 @@ const scripts: UpgradeScript[] = [
|
||||
async function _1_2() {
|
||||
const ddoc = await domain.get('system');
|
||||
if (!ddoc) await domain.add('system', 1, 'Hydro', 'Welcome to Hydro!');
|
||||
await welcome();
|
||||
// TODO discussion node?
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import DomainModel from './model/domain';
|
||||
import ProblemModel from './model/problem';
|
||||
import RecordModel from './model/record';
|
||||
|
||||
const bulletin = `\
|
||||
### 欢迎来到 Hydro !
|
||||
|
||||
当你看到这行字时,说明 Hydro 的基础功能已经正常运行。
|
||||
下一步您应该:
|
||||
|
||||
- 在右上角注册一个账号。
|
||||
- 回到刚刚的终端,使用 \`hydrooj cli user setSuperAdmin 2\` 将 UID 为 2 的用户设置为超级管理员。
|
||||
- 使用 \`pm2 restart hydrooj\` 重启以使管理员更改立刻生效。
|
||||
- 前往 “题库” 面板,查看创建的示例题目是否正常工作。
|
||||
- 使用超级管理员账号登录,通读 [控制面板 -> 系统设置](/manage/setting) 页面,按需配置。
|
||||
|
||||
如果您需要可以直接导入的题目,可以 [加入 Hydro 用户群](https://jq.qq.com/?_wv=1027&k=pKYrk4yp) 或是 [从 Hydro 题库下载](https://hydro.ac/d/tk/p) 。
|
||||
如果您需要题目配置指南,可以 [查看文档](https://hydro.js.org) 或是 [查看配置示例](https://hydro.ac/d/system_test/) 。
|
||||
|
||||
这条消息可以在 [管理域 > 编辑域资料](/domain/edit) 页面修改。
|
||||
|
||||
### Welcome to Hydro !
|
||||
|
||||
If you see this line, it means Hydro is running normally.
|
||||
Next step you should:
|
||||
|
||||
- Register a new account.
|
||||
- Go back to the terminal, use \`hydrooj cli user setSuperAdmin 2\` to set user with UID 2 as super admin.
|
||||
- Use \`pm2 restart hydrooj\` to make the change take effect.
|
||||
- Go to “Problems” panel, check whether the example problem is working properly.
|
||||
- Use super admin account to login, read the [Control panel -> System settings](/manage/setting) page, configure as needed.
|
||||
|
||||
If you need to import a problem, you can join [Hydro user group](https://jq.qq.com/?_wv=1027&k=pKYrk4yp)
|
||||
or download [Hydro problem library](https://hydro.ac/d/tk/p) .
|
||||
If you need problem configuration guide, you can [view the document](https://hydro.js.org) or
|
||||
[view examples](https://hydro.ac/d/system_test/) .
|
||||
|
||||
This message can be modified in [Domain > Edit information](/domain/edit) page.
|
||||
`;
|
||||
|
||||
const defaultProblem = JSON.stringify({
|
||||
en: `\
|
||||
This is the example A+B problem.
|
||||
If you didn't see 'No testdata at current' message, it means file storage is working properly.
|
||||
|
||||
Just write a program that reads two integers from standard input, and prints their sum to standard output.
|
||||
Feel free to delete this problem in 'Edit' panel if you don't need this.
|
||||
|
||||
Click 'Enter Online Programming Mode' to open the built-in Hydro IDE.
|
||||
`,
|
||||
zh: `\
|
||||
这是一道简单的 A+B 题目。
|
||||
如果您没有看到“当前没有测试数据”的消息,说明文件存储功能正常运行。
|
||||
|
||||
编写一个程序,从标准输入读取两个整数,并将它们的和输出到标准输出。
|
||||
如果您不需要这道题目,可以在右侧“编辑”面板中删除它。
|
||||
|
||||
点击右侧 “进入在线编程模式” 打开内置的 Hydro IDE。
|
||||
`,
|
||||
});
|
||||
|
||||
const testdatas = {
|
||||
'config.yaml': 'time: 1s\nmemory: 64m\n',
|
||||
'1.in': '1 2\n',
|
||||
'1.out': '3\n',
|
||||
'2.in': '1 1\n',
|
||||
'2.out': '2\n',
|
||||
};
|
||||
|
||||
const std = `\
|
||||
// 这是由 Hydro 自动提交的测试代码,用于测试系统是否正常运行。
|
||||
// 如果这个提交返回了 Accepted ,则说明一切正常。
|
||||
// This is a submission by Hydro system, used to test if judge is working properly.
|
||||
// If this submission returns 'Accepted', it means everything is fine.
|
||||
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main() {
|
||||
int a, b;
|
||||
cin >> a >> b;
|
||||
cout << a + b << endl;
|
||||
return 0;
|
||||
}
|
||||
`;
|
||||
|
||||
export default async function apply() {
|
||||
await DomainModel.edit('system', { bulletin });
|
||||
const docId = await ProblemModel.add('system', 'P1000', 'A+B Problem', defaultProblem, 1, ['系统测试']);
|
||||
// This might fail so we are doing it asynchronously.
|
||||
Promise.all(
|
||||
Object.keys(testdatas).map(
|
||||
(i) => ProblemModel.addTestdata('system', docId, i, Buffer.from(testdatas[i])),
|
||||
),
|
||||
).then(() => RecordModel.add('system', docId, 1, 'cc', std, true));
|
||||
}
|
||||
Reference in new issue
Block a user