diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f5b03017f..000000000 --- a/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM mhart/alpine-node:slim-10 -WORKDIR /app -COPY .build /app -EXPOSE 8888 -CMD ["node", ".build/app.js"] diff --git a/README.md b/README.md index 45a4c21e8..44c18bf2d 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,11 @@ Hydro是一个高效的信息学在线测评系统。 [中文文档](docs/deploy.md) -Hydro 的界面基于 Vijos 二次开发。 - 如果您认为本项目有价值,欢迎 star 。 ## 联系我们 -QQ [3402182471](tencent://AddContact/?uin=3402182471&subcmd=all) +QQ [3402182471](https://wpa.qq.com/msgrd?v=3&uin=3402182471&site=qq&menu=yes) Telegram [@webpack_exports_undefined](https://t.me/webpack_exports_undefined) ## 鸣谢 diff --git a/TODO b/TODO index cfcc7f00c..e0222bba6 100644 --- a/TODO +++ b/TODO @@ -10,4 +10,3 @@ model.setting.ui.name pdoc.secretConfig? 在线IDE 更换颜色主题, fix resize move to @hydrooj/core? -remove koa-router diff --git a/bin/hydrooj.js b/bin/hydrooj.js index a04c41e35..cbeedc86b 100644 --- a/bin/hydrooj.js +++ b/bin/hydrooj.js @@ -1,20 +1,45 @@ #!/usr/bin/env node +const os = require('os'); +const path = require('path'); +const fs = require('fs-extra'); const { argv } = require('yargs'); const hydro = require('../dist/loader'); -const ui = argv.ui || '@hydrooj/ui-default'; +fs.ensureDirSync(path.resolve(os.homedir(), '.hydro')); +const addonPath = path.resolve(os.homedir(), '.hydro', 'addon.json'); +if (!fs.existsSync(addonPath)) fs.writeFileSync(addonPath, '[]'); +const addons = JSON.parse(fs.readFileSync(addonPath).toString()); try { + const ui = argv.ui || '@hydrooj/ui-default'; require.resolve(ui); + addons.push(ui); } catch (e) { console.error('Please also install @hydrooj/ui-default'); - process.exit(1); } -hydro.addon(ui); - -hydro.load().catch((e) => { - console.error(e); - process.exit(1); -}); +if (argv._[0]) { + const operation = argv._[0]; + const arg1 = argv._[1]; + const arg2 = argv._[2]; + if (operation === 'addon') { + if (arg1 === 'add') addons.push(arg2); + else if (arg1 === 'remove') { + for (let i = 0; i < addons.length; i++) { + if (addons[i] === arg2) { + addons.splice(i, 1); + break; + } + } + } + console.log('Current Addons: ', addons); + fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2)); + } +} else { + for (const addon of addons) hydro.addon(addon); + hydro.load().catch((e) => { + console.error(e); + process.exit(1); + }); +} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 89a4578f6..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3' -services: - hydro: - image: hydrooj/hydro:latest - restart: always - links: - - mongo - volumes: - - ./data/config:/config - ports: - - 8888:8888 - mongo: - image: mongo:latest - restart: always - volumes: - - ./data/db:/data/db diff --git a/hydro/model/discussion.ts b/hydro/model/discussion.ts index 4e23b7cd3..320e19351 100644 --- a/hydro/model/discussion.ts +++ b/hydro/model/discussion.ts @@ -137,7 +137,7 @@ export function getStatus(domainId: string, did: ObjectID, uid: number) { return document.getStatus(domainId, document.TYPE_DISCUSSION, did, uid); } -export function addNode(domainId: string, _id: string, category: string, args: any) { +export function addNode(domainId: string, _id: string, category: string, args: any = {}) { return document.add( domainId, category, 1, document.TYPE_DISCUSSION_NODE, _id, null, null, args, diff --git a/package.json b/package.json index 943bf0739..791245a34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.9.3", + "version": "2.9.4", "main": "dist/loader.js", "bin": "bin/hydrooj.js", "repository": "https://github.com/hydro-dev/Hydro.git",