Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@
"forwardPorts": [8888, 2333, 8000],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash .devcontainer/setup.sh && yarn install"
"postCreateCommand": "bash .devcontainer/setup.sh",
"postStartCommand": "zsh", // 每次容器启动时自动进入 zsh

// Configure tool-specific properties.
// "customizations": {},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh"
},
"extensions": [
"ms-vscode-remote.remote-containers",
"Codeium.codeium",
"esbenp.prettier-vscode"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Expand Down
25 changes: 21 additions & 4 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
mkdir ~/.hydro
#!/bin/bash

# 创建必要的目录和配置文件
mkdir -p ~/.hydro
echo '["@hydrooj/ui-default"]' > ~/.hydro/addon.json
# the following config refers to a local mongodb instance.
# before you run this application, please ensure you have a mongo instance read at this port
echo '{"uri": "mongodb://admin:admin@localhost:27017/hydro?authSource=admin"}' > ~/.hydro/config.json
echo '{"uri": "mongodb://admin:admin@localhost:27017/hydro?authSource=admin"}' > ~/.hydro/config.json

# 安装 zsh 和 oh-my-zsh
sudo apt-get update && sudo apt-get install -y zsh curl git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 安装 zsh-autosuggestions 插件
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# 安装 zsh-syntax-highlighting 插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# 更新 .zshrc 文件以启用插件
sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/' ~/.zshrc

# 安装 yarn 依赖
yarn install
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pnpm-lock.yaml
tsconfig.json
tsconfig.*.json
.idea/
.vscode/*

# Project Rules
## Core
Expand Down
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
},
"files.associations": {
"*.html": "nunjucks"
},
"peacock.remoteColor": "#215732"
}
}
7 changes: 4 additions & 3 deletions packages/codemate-plugin/plugins/invite-code/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Context, Handler, PERM } from 'hydrooj';
import { Context, Handler, param, PERM, Types } from 'hydrooj';
import { InvitatonModel } from './model';

class InvitationCreateHandler extends Handler {
async post() {
const code = await InvitatonModel.add(this.domain._id, this.user._id);
@param('num', Types.PositiveInt, true)
async post(domainId: string, num = 1) {
const code = await Promise.all(Array.from({ length: num }, () => InvitatonModel.add(this.domain._id, this.user._id)));
this.response.body = {
success: true,
code,
Expand Down