diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 579d0a9..860bec7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,65 +1,31 @@ { "image": "ghcr.io/yanhao98/h-devcontainer:main", - "runArgs": ["--name=${localWorkspaceFolderBasename}-devcontainer"], - "forwardPorts": [4730, 4731], // vscode://settings/remote.localPortHost -> 默认只监听 localhost + "runArgs": [ + "--hostname=devcontainer-host", + "--name=${localWorkspaceFolderBasename}-devcontainer" + ], + "forwardPorts": [4730, 4731, 5901], "portsAttributes": { "4730": { "label": "开发服务器端口", "onAutoForward": "notify" }, "4731": { "label": "预览服务器端口", "onAutoForward": "notify" } }, - "remoteEnv": { - "ANTHROPIC_AUTH_TOKEN": "${localEnv:ANTHROPIC_AUTH_TOKEN}", - "ANTHROPIC_BASE_URL": "${localEnv:ANTHROPIC_BASE_URL}", - "GEMINI_API_KEY": "${localEnv:GEMINI_API_KEY}", - "GOOGLE_GEMINI_BASE_URL": "${localEnv:GOOGLE_GEMINI_BASE_URL}" - }, "containerEnv": { - "NODE_OPTIONS": "--max-old-space-size=4096", "TZ": "${localEnv:TZ:Asia/Shanghai}" }, "customizations": { "vscode": { - "extensions": [ - // AI - "github.copilot-chat", - "anthropic.claude-code", - "google.gemini-cli-vscode-ide-companion", - "vicanent.gcmp", - // >>>>> - // "eamodio.gitlens", - "tu6ge.naive-ui-intelligence", - "gruntfuggly.todo-tree", - "lokalise.i18n-ally", - "vitest.explorer", - "antfu.unocss", - "vue.volar", - // <<<<< - // 代码质量 / 格式化 / Lint - "dbaeumer.vscode-eslint", - "stylelint.vscode-stylelint", - "oxc.oxc-vscode", - "esbenp.prettier-vscode" - ], + "extensions": ["prettier.prettier-vscode", "vue.volar"], "settings": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" - }, - "chat.extensionUnification.enabled": true, - "chat.tools.terminal.autoApprove": { - "/.*/": true, - "git push": false - }, - // * 尽管使用了“/.*/”,但有些还是会失败,因为有几个错误的默认值: - // * https://github.com/microsoft/vscode/issues/266651#issuecomment-3292581459 - "chat.tools.terminal.ignoreDefaultAutoApproveRules": true, - "tasks": { "version": "2.0.0", "tasks": [] }, - "terminal.integrated.defaultProfile.linux": "zsh" + // "tasks": { "version": "2.0.0", "tasks": [] }, + "github.copilot.chat.codeGeneration.instructions": [ + { + "text": "This dev container includes a lightweight Fluxbox based desktop that can be accessed using a VNC viewer or the web. GUI-based commands executed from the built-in VS Code terminal will open on the desktop automatically." + } + ] } } }, "mounts": [ - // 不挂载还可能会遇到:`Cannot run macOS (Mach-O) executable in Docker: Exec format error` "source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume", "source=${localWorkspaceFolder}/.devcontainer/lifecycle-scripts.d,target=/usr/local/etc/lifecycle-scripts.d,type=bind,consistency=delegated" ], @@ -69,7 +35,5 @@ "updateContentCommand": "/usr/local/bin/run-lifecycle-scripts.sh updateContentCommand", "postCreateCommand": "/usr/local/bin/run-lifecycle-scripts.sh postCreateCommand", "postStartCommand": "/usr/local/bin/run-lifecycle-scripts.sh postStartCommand", - "postAttachCommand": "/usr/local/bin/run-lifecycle-scripts.sh postAttachCommand", - "waitFor": "updateContentCommand", - "remoteUser": "usr_vscode" + "postAttachCommand": "/usr/local/bin/run-lifecycle-scripts.sh postAttachCommand" } diff --git a/.devcontainer/lifecycle-scripts.d/.gitkeep b/.devcontainer/lifecycle-scripts.d/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.devcontainer/lifecycle-scripts.d/01-onCreateCommand.d/00-setup-container b/.devcontainer/lifecycle-scripts.d/01-onCreateCommand.d/00-setup-container deleted file mode 100755 index fda2ac8..0000000 --- a/.devcontainer/lifecycle-scripts.d/01-onCreateCommand.d/00-setup-container +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/zsh -eu -# 打印带有颜色的欢迎信息 -echo -e "\033[1;32m↘️ 容器首次创建!\033[0m" - -# 修复权限问题(比如 node_modules 目录) -sudo chown -R $(whoami):$(whoami) /workspaces || true - -# 调用内置命令 (这些命令在 _build-context/builtin-scripts 目录中的脚本中定义) -h-setup-locale -h-setup-zsh - -h-setup-bun-bin -h-setup-pnpm-bin diff --git a/.devcontainer/lifecycle-scripts.d/02-updateContentCommand.d/00-pnpm-install b/.devcontainer/lifecycle-scripts.d/02-updateContentCommand.d/00-pnpm-install deleted file mode 100755 index 39fcefb..0000000 --- a/.devcontainer/lifecycle-scripts.d/02-updateContentCommand.d/00-pnpm-install +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -eu -# 容器内容更新时的消息和依赖安装 - -echo '↘️ 容器内容已更新!' - -# 安装依赖 -if command -v pnpm >/dev/null 2>&1; then - # 跳过: The modules directory at "/workspaces/h-devcontainers/node_modules" will be removed and reinstalled from scratch. Proceed? (Y/n) · - time pnpm install --config.confirmModulesPurge=false -else - echo '❌错误: pnpm 未安装' - exit 0 -fi diff --git a/.devcontainer/lifecycle-scripts.d/04-postStartCommand.d/- b/.devcontainer/lifecycle-scripts.d/04-postStartCommand.d/- new file mode 100755 index 0000000..04313a2 --- /dev/null +++ b/.devcontainer/lifecycle-scripts.d/04-postStartCommand.d/- @@ -0,0 +1,17 @@ +#!/bin/zsh -eu +h-setup-zh-locale + +h-setup-bun-bin +h-setup-pnpm-bin + +h-setup-ai-claude-code --config +h-setup-ai-gemini-cli --config + +h-setup-chromium +h-setup-desktop-lite + +h-install-node-modules + +echo "-----------------------------" +echo "开发容器已启动并配置完成!" +echo "-----------------------------" \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 8a32071..01c6887 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,7 +5,7 @@ "dbaeumer.vscode-eslint", "EditorConfig.EditorConfig", "oxc.oxc-vscode", - "esbenp.prettier-vscode", + "prettier.prettier-vscode", "stylelint.vscode-stylelint", "lokalise.i18n-ally" ] diff --git a/.vscode/settings.json b/.vscode/settings.json index 87d5e71..53139b1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,18 +32,18 @@ "scss.lint.unknownAtRules": "ignore", "css.lint.unknownAtRules": "ignore", "less.lint.unknownAtRules": "ignore", - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "prettier.prettier-vscode", "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "prettier.prettier-vscode" }, "[vue]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "prettier.prettier-vscode" }, "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "prettier.prettier-vscode" }, "[jsonc]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "prettier.prettier-vscode" }, // ============================================================