diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0c68fc9932..fe9243c077 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 2307ee0c71..0d60467621 100644 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9570913c43..3b24dcf79d 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ pnpm-lock.yaml tsconfig.json tsconfig.*.json .idea/ +.vscode/* # Project Rules ## Core diff --git a/.vscode/settings.json b/.vscode/settings.json index e3bb0585c6..4b230f31de 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,6 +10,5 @@ }, "files.associations": { "*.html": "nunjucks" - }, - "peacock.remoteColor": "#215732" + } } diff --git a/packages/codemate-plugin/plugins/invite-code/index.ts b/packages/codemate-plugin/plugins/invite-code/index.ts index 615faaf37d..f5cd0b8020 100644 --- a/packages/codemate-plugin/plugins/invite-code/index.ts +++ b/packages/codemate-plugin/plugins/invite-code/index.ts @@ -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,